use of com.orientechnologies.orient.core.sql.query.OSQLNonBlockingQuery in project orientdb by orientechnologies.
the class GraphNonBlockingQueryRemote method testNonBlockingClose.
@Test
public void testNonBlockingClose() throws ExecutionException, InterruptedException {
OrientGraph database = new OrientGraph("remote:localhost:3064/" + GraphNonBlockingQueryRemote.class.getSimpleName());
database.createVertexType("Prod").createProperty("something", OType.STRING);
for (int i = 0; i < 21; i++) {
OrientVertex vertex = database.addVertex("class:Prod");
vertex.setProperty("something", "value");
vertex.save();
}
database.commit();
final CountDownLatch ended = new CountDownLatch(21);
try {
OSQLNonBlockingQuery<Object> test = new OSQLNonBlockingQuery<Object>("select * from Prod ", new OCommandResultListener() {
int resultCount = 0;
@Override
public boolean result(Object iRecord) {
resultCount++;
ODocument odoc = ((ODocument) iRecord);
for (String name : odoc.fieldNames()) {
// <----------- PROBLEM
assertEquals("something", name);
}
ended.countDown();
return resultCount > 20 ? false : true;
}
@Override
public void end() {
ended.countDown();
}
@Override
public Object getResult() {
return resultCount;
}
});
database.command(test).execute();
assertTrue(ended.await(10, TimeUnit.SECONDS));
} finally {
database.shutdown();
}
}
Aggregations