use of jdk.incubator.sql2.RowPublisherOperation in project oracle-db-examples by oracle.
the class RowPublisherOperationTest method rowSubscriber.
@Test
public void rowSubscriber() throws Exception {
System.out.println("rowSubscriber");
System.out.println("=============");
String sql = "select id, name from forum_user";
CompletableFuture<List<String>> result = new CompletableFuture<>();
CompletionStage<List<String>> cs;
Flow.Subscriber<Result.RowColumn> subscriber = getSubscriber(result, false);
try (Session session = getSession()) {
cs = session.<List<String>>rowPublisherOperation(sql).subscribe(subscriber, result).onError(e -> fail(e.getMessage())).submit().getCompletionStage();
}
cs.toCompletableFuture().get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
List<String> names = result.get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
;
assertNotNull(names);
assertFalse(names.isEmpty());
assertEquals(14, names.size());
}
use of jdk.incubator.sql2.RowPublisherOperation in project oracle-db-examples by oracle.
the class RowPublisherOperationTest method slowRowSubscriberRequestOnThread.
@Test
public void slowRowSubscriberRequestOnThread() throws Exception {
System.out.println("slowRowSubscriberRequestOnThread");
System.out.println("================================");
String sql = "select id, name from forum_user";
CompletableFuture<List<String>> result = new CompletableFuture<>();
CompletionStage<List<String>> cs;
Flow.Subscriber<Result.RowColumn> subscriber = getSubscriber(result, true);
try (Session session = getSession()) {
cs = session.<List<String>>rowPublisherOperation(sql).subscribe(subscriber, result).onError(e -> e.printStackTrace()).timeout(getTimeout()).submit().getCompletionStage();
}
cs.toCompletableFuture().get(getTimeout().toMillis() + 7000, TimeUnit.MILLISECONDS);
List<String> names = result.get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
assertNotNull(names);
assertFalse(names.isEmpty());
assertEquals(14, names.size());
}
use of jdk.incubator.sql2.RowPublisherOperation in project oracle-db-examples by oracle-samples.
the class MultiOperationTest method multiRowPublisherOperation.
@Test
public void multiRowPublisherOperation() throws Exception {
fail("TODO: Fix this test");
String sql = "select id, name from forum_user";
CompletableFuture<List<String>> result = new CompletableFuture<>();
CompletionStage<List<String>> cs = null;
DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME);
try (DataSource ds = factory.builder().url(URL).username(USER).password(PASSWORD).build();
Session session = ds.getSession(t -> fail("ERROR: " + t.getMessage()))) {
assertNotNull(session);
MultiOperation multiOp = session.multiOperation(sql).onError(t -> {
fail(t.toString());
});
RowPublisherOperation rowPublisherOp = multiOp.rowPublisherOperation();
multiOp.submit();
Flow.Subscriber<Result.RowColumn> subscriber = getSubscriber(result, false);
cs = rowPublisherOp.subscribe(subscriber, result).onError(e -> fail(e.toString())).timeout(TestConfig.getTimeout()).submit().getCompletionStage();
} catch (Exception e) {
fail(e.getMessage());
}
List<String> names = result.get(TestConfig.getTimeout().toMillis(), TimeUnit.MILLISECONDS);
assertTrue(names != null && !names.isEmpty());
}
use of jdk.incubator.sql2.RowPublisherOperation in project oracle-db-examples by oracle-samples.
the class RowPublisherOperationTest method slowRowSubscriberRequestOnThread.
@Test
public void slowRowSubscriberRequestOnThread() throws Exception {
System.out.println("slowRowSubscriberRequestOnThread");
System.out.println("================================");
String sql = "select id, name from forum_user";
CompletableFuture<List<String>> result = new CompletableFuture<>();
CompletionStage<List<String>> cs;
Flow.Subscriber<Result.RowColumn> subscriber = getSubscriber(result, true);
try (Session session = getSession()) {
cs = session.<List<String>>rowPublisherOperation(sql).subscribe(subscriber, result).onError(e -> e.printStackTrace()).timeout(getTimeout()).submit().getCompletionStage();
}
cs.toCompletableFuture().get(getTimeout().toMillis() + 7000, TimeUnit.MILLISECONDS);
List<String> names = result.get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
assertNotNull(names);
assertFalse(names.isEmpty());
assertEquals(14, names.size());
}
use of jdk.incubator.sql2.RowPublisherOperation in project oracle-db-examples by oracle-samples.
the class RowPublisherOperationTest method rowSubscriber.
@Test
public void rowSubscriber() throws Exception {
System.out.println("rowSubscriber");
System.out.println("=============");
String sql = "select id, name from forum_user";
CompletableFuture<List<String>> result = new CompletableFuture<>();
CompletionStage<List<String>> cs;
Flow.Subscriber<Result.RowColumn> subscriber = getSubscriber(result, false);
try (Session session = getSession()) {
cs = session.<List<String>>rowPublisherOperation(sql).subscribe(subscriber, result).onError(e -> fail(e.getMessage())).submit().getCompletionStage();
}
cs.toCompletableFuture().get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
List<String> names = result.get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
;
assertNotNull(names);
assertFalse(names.isEmpty());
assertEquals(14, names.size());
}
Aggregations