Collection { public static native void Scan(String name, String batchHandle, byte[] start, byte[] limit, ScanCallbacks callbacks) throws VError;  static native Permissions GetPermissions(String name, String batchHandle); static native void SetPermissions(String name, String batchHandle, Permissions permissions); static native void Create(String name, String batchHandle, Permissions permissions); static native void Destroy(String name, String batchHandle); static native boolean Exists(String name, String batchHandle); static native void DeleteRange(String name, String batchHandle, byte[] start, byte[] limit); static native void Scan(String name, String batchHandle, byte[] start, byte[] limit, ScanCallbacks callbacks);  }
@Test public void scan() throws Exception { Id dbId = new Id("idp:a:angrybirds", "scan_collection"); String dbName = dbId.encode(); Id collectionId = new Id("...", "collection"); String collectionName = Util.NamingJoin(Arrays.asList(dbName, collectionId.encode())); final String keyName = Util.NamingJoin(Arrays.asList(collectionName, "key")); final byte[] vomValue = {(byte)0x81, 0x06, 0x03, 'a', 'b', 'c'}; try { Database.Create(dbName, anyDbPermissions()); String batchHandle = Database.BeginBatch(dbId.encode(), null); Collection.Create(collectionName, batchHandle, anyCollectionPermissions()); Row.Put(keyName, batchHandle, vomValue); Database.Commit(dbName, batchHandle); batchHandle = Database.BeginBatch(dbName, null); assertTrue(Row.Exists(keyName, batchHandle)); final SettableFuture<Void> done = SettableFuture.create(); Collection.Scan(collectionName, batchHandle, new byte[]{}, new byte[]{}, new Collection.ScanCallbacks() { @Override public void onKeyValue(KeyValue keyValue) { assertEquals("key", keyValue.key); assertArrayEquals(vomValue, keyValue.value); } @Override public void onDone(VError vError) { assertEquals(null, vError); done.set(null); } }); done.get(1, TimeUnit.SECONDS); } catch (VError vError) { vError.printStackTrace(); fail(vError.toString()); } }