Java Code Examples for io.vertx.ext.unit.TestContext#assertNull()

The following examples show how to use io.vertx.ext.unit.TestContext#assertNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TracingTestBase.java    From vertx-sql-client with Apache License 2.0 6 votes vote down vote up
@Test
public void testTracingFailure(TestContext ctx) {
  Async completed = ctx.async();
  tracer = new VertxTracer<Object, Object>() {
    @Override
    public <R> Object sendRequest(Context context, R request, String operation, BiConsumer<String, String> headers, TagExtractor<R> tagExtractor) {
      return null;
    }
    @Override
    public <R> void receiveResponse(Context context, R response, Object payload, Throwable failure, TagExtractor<R> tagExtractor) {
      ctx.assertNull(response);
      ctx.assertNotNull(failure);
      completed.complete();
    }
  };
  pool.getConnection(ctx.asyncAssertSuccess(conn -> {
    conn
      .preparedQuery(statement("SELECT * FROM undefined_table WHERE id = ", ""))
      .execute(Tuple.of(0), ctx.asyncAssertFailure(err -> {
        conn.close();
      }));
  }));
}
 
Example 2
Source File: HttpModuleClient2Test.java    From raml-module-builder with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithPojo(TestContext context) throws Exception {
  HttpModuleClient2 httpModuleClient2 = new HttpModuleClient2("localhost", port1, "tenant");

  MyPojo myPojo = new MyPojo();
  myPojo.member = "abc";

  Map<String,String> headers = new HashMap<>();
  headers.put("X-Name", "x-value");

  CompletableFuture<Response> cf = httpModuleClient2.request(HttpMethod.POST, myPojo, "/test-pojo", headers);
  Response response = cf.get(5, TimeUnit.SECONDS);

  context.assertNull(response.error);
  context.assertNull(response.exception);
  context.assertEquals("/test-pojo", lastPath);
  context.assertEquals("{\"member\":\"abc\"}", lastBuffer.toString());
  context.assertEquals("x-value", lastHeaders.get("x-name"));
}
 
Example 3
Source File: ShellTest.java    From vertx-shell with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecuteProcess(TestContext context) {
  TestTtyConnection conn = new TestTtyConnection(vertx);
  ShellImpl shell = createShell(conn);
  shell.init().readline();
  context.assertNull(shell.jobController().foregroundJob());
  context.assertEquals(Collections.emptySet(), shell.jobController().jobs());
  Async async = context.async();
  commands.add(CommandBuilder.command("foo").processHandler(process -> {
    context.assertEquals(1, shell.jobController().jobs().size());
    Job job = shell.jobController().getJob(1);
    context.assertEquals(job, shell.jobController().foregroundJob());
    context.assertEquals("foo", job.line());
    context.assertEquals(ExecStatus.RUNNING, job.status());
    async.complete();
  }));
  conn.read("foo\r");
}
 
Example 4
Source File: ShellTest.java    From vertx-shell with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecuteBufferedCommand(TestContext context) throws Exception {
  TestTtyConnection conn = new TestTtyConnection(vertx);
  ShellImpl adapter = createShell(conn);
  adapter.init().readline();
  CountDownLatch latch = new CountDownLatch(1);
  Async done = context.async();
  commands.add(CommandBuilder.command("foo").processHandler(process -> {
    context.assertEquals(null, conn.checkWritten("% foo\n"));
    conn.read("bar");
    process.end();
    latch.countDown();
  }));
  commands.add(CommandBuilder.command("bar").processHandler(process -> {
    context.assertEquals(null, conn.checkWritten("\n"));
    done.complete();
  }));
  conn.read("foo\r");
  latch.await(10, TimeUnit.SECONDS);
  context.assertNull(conn.checkWritten("bar"));
  context.assertNull(conn.checkWritten("% bar"));
  conn.read("\r");
}
 
Example 5
Source File: PostgresClientIT.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
@Test
public void closeClient(TestContext context) {
  PostgresClient c = PostgresClient.getInstance(vertx);
  context.assertNotNull(PostgresClientHelper.getClient(c), "getClient()");
  c.closeClient(context.asyncAssertSuccess());
  context.assertNull(PostgresClientHelper.getClient(c), "getClient()");
}
 
Example 6
Source File: PostgresClientIT.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
@Test
public void closeClientTenant(TestContext context) {
  PostgresClient c = PostgresClient.getInstance(vertx, TENANT);
  context.assertNotNull(PostgresClientHelper.getClient(c), "getClient()");
  c.closeClient(context.asyncAssertSuccess());
  context.assertNull(PostgresClientHelper.getClient(c), "getClient()");
}
 
Example 7
Source File: PostgresClientIT.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
@Test
public void closeClientTwice(TestContext context) {
  PostgresClient c = PostgresClient.getInstance(vertx);
  context.assertNotNull(PostgresClientHelper.getClient(c), "getClient()");
  c.closeClient(context.asyncAssertSuccess());
  context.assertNull(PostgresClientHelper.getClient(c), "getClient()");
  c.closeClient(context.asyncAssertSuccess());
  context.assertNull(PostgresClientHelper.getClient(c), "getClient()");
}
 
Example 8
Source File: PostgresClientIT.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
@Test
public void closeClientTwiceTenant(TestContext context) {
  PostgresClient c = PostgresClient.getInstance(vertx, TENANT);
  context.assertNotNull(PostgresClientHelper.getClient(c), "getClient()");
  c.closeClient(context.asyncAssertSuccess());
  context.assertNull(PostgresClientHelper.getClient(c), "getClient()");
  c.closeClient(context.asyncAssertSuccess());
  context.assertNull(PostgresClientHelper.getClient(c), "getClient()");
}
 
Example 9
Source File: PostgresClientIT.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
@Test
public void closeClientGetInstance(TestContext context) {
  PostgresClient c = PostgresClient.getInstance(vertx, TENANT);
  context.assertNotNull(PostgresClientHelper.getClient(c), "getClient()");
  c.closeClient(context.asyncAssertSuccess());
  context.assertNull(PostgresClientHelper.getClient(c), "getClient()");
  c = PostgresClient.getInstance(vertx, TENANT);
  context.assertNotNull(PostgresClientHelper.getClient(c), "getClient()");
  c.closeClient(context.asyncAssertSuccess());
  context.assertNull(PostgresClientHelper.getClient(c), "getClient()");
}
 
Example 10
Source File: HttpModuleClient2Test.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithPort(TestContext context) throws Exception {
  HttpModuleClient2 httpModuleClient2 = new HttpModuleClient2("localhost", port1, "tenant");

  CompletableFuture<Response> cf = httpModuleClient2.request("/test");
  Response response = cf.get(5, TimeUnit.SECONDS);

  context.assertNull(response.error);
  context.assertNull(response.exception);
  context.assertEquals("/test", lastPath);
  context.assertEquals("", lastBuffer.toString());
  context.assertEquals("tenant", lastHeaders.get("x-okapi-tenant"));
}
 
Example 11
Source File: HttpModuleClient2Test.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithAbs(TestContext context) throws Exception {
  HttpModuleClient2 httpModuleClient2 = new HttpModuleClient2("http://localhost:" + port1, "tenant");

  CompletableFuture<Response> cf = httpModuleClient2.request("/test");
  Response response = cf.get(5, TimeUnit.SECONDS);

  context.assertNull(response.error);
  context.assertNull(response.exception);
  context.assertEquals("/test", lastPath);
  context.assertEquals("", lastBuffer.toString());
}
 
Example 12
Source File: DeployVerticleTest.java    From vertx-shell with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeployWithOptionsAsInvalidJsonString(TestContext context) {
  String cmd = "verticle-deploy io.vertx.ext.shell.command.base.DeployVerticleTest$SomeVerticle '{'";
  String result = testDeployCmd(context, cmd);
  String msg =
    "Could not deploy io.vertx.ext.shell.command.base.DeployVerticleTest$SomeVerticle with deployment options";
  context.assertNull(ctx.get());
  context.assertTrue(result.startsWith(msg));
}
 
Example 13
Source File: ProtonClientTest.java    From vertx-proton with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 20000)
public void testConnectionPropertiesSetExplicitNull(TestContext context) throws Exception {

  final ConPropValidator nullExpectedPropsHandler = (c, props) -> {
    context.assertNull(props, "expected no properties map");
  };

  doConnectionPropertiesTestImpl(context, true, null, nullExpectedPropsHandler, null, nullExpectedPropsHandler);
}