/** * Assert the <code>expected</code> argument is <code>null</code>. If the argument is not, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be null * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestContext assertNull(Object expected) { delegate.assertNull(expected); return this; }
/** * Assert the <code>expected</code> argument is <code>null</code>. If the argument is not, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be null * @param message the failure message * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestContext assertNull(Object expected, String message) { delegate.assertNull(expected, message); return this; }
/** * Assert the <code>expected</code> argument is <code>null</code>. If the argument is not, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be null * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestContext assertNull(Object expected) { delegate.assertNull(expected); return this; }
/** * Assert the <code>expected</code> argument is <code>null</code>. If the argument is not, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be null * @param message the failure message * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.unit.TestContext assertNull(Object expected, String message) { delegate.assertNull(expected, message); return this; }
public static io.vertx.ext.unit.TestContext assertNull(io.vertx.ext.unit.TestContext j_receiver, java.lang.Object expected, java.lang.String message) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.assertNull(io.vertx.core.impl.ConversionHelper.toObject(expected), message)); return j_receiver; } public static io.vertx.ext.unit.TestContext assertNotNull(io.vertx.ext.unit.TestContext j_receiver, java.lang.Object expected) {
public static io.vertx.ext.unit.TestContext assertNull(io.vertx.ext.unit.TestContext j_receiver, java.lang.Object expected) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.assertNull(io.vertx.core.impl.ConversionHelper.toObject(expected))); return j_receiver; } public static io.vertx.ext.unit.TestContext assertNull(io.vertx.ext.unit.TestContext j_receiver, java.lang.Object expected, java.lang.String message) {
@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)); }
/** * Write a secret and verify that it can be read containing a null value. */ @Test public void testWriteAndReadNull(TestContext tc) throws VaultException { final String path = "secret/null"; final String value = null; Async async = tc.async(); client.write(path, new JsonObject().put("value", value), x -> { tc.assertTrue(x.succeeded()); client.read(path, ar -> { tc.assertTrue(ar.succeeded()); tc.assertNull(ar.result().getData().getString("value")); async.complete(); }); }); }
/** * Verifies that the addDevice method returns not implemented. * * @param ctx The vertx unit test context. */ @Test public void testAddDevice(final TestContext ctx) { // GIVEN an empty registry final CompleteBaseRegistrationService<ServiceConfigProperties> registrationService = newCompleteRegistrationService(); registrationService.setRegistrationAssertionFactory(RegistrationAssertionHelperImpl.forSigning(vertx, props)); // WHEN trying to add a new device registrationService.addDevice(Constants.DEFAULT_TENANT, "4711", new JsonObject(), ctx.asyncAssertSuccess(result -> { // THEN the response contain a JWT token with an empty result with status code 501. ctx.assertEquals(result.getStatus(), HttpURLConnection.HTTP_NOT_IMPLEMENTED); ctx.assertNull(result.getPayload()); })); }
/** * Verifies that the updateDevice method returns not implemented. * * @param ctx The vertx unit test context. */ @Test public void testUpdateDevice(final TestContext ctx) { // GIVEN an empty registry final CompleteBaseRegistrationService<ServiceConfigProperties> registrationService = newCompleteRegistrationService(); registrationService.setRegistrationAssertionFactory(RegistrationAssertionHelperImpl.forSigning(vertx, props)); // WHEN trying to update a device registrationService.updateDevice(Constants.DEFAULT_TENANT, "4711", new JsonObject(), ctx.asyncAssertSuccess(result -> { // THEN the response contain a JWT token with an empty result with status code 501. ctx.assertEquals(result.getStatus(), HttpURLConnection.HTTP_NOT_IMPLEMENTED); ctx.assertNull(result.getPayload()); })); }
@Test public void testPreventLengthMaxIndexOutOfBoundGetColumnNameRows(TestContext ctx) { Async async = ctx.async(); PgClient.connect(vertx, options, ctx.asyncAssertSuccess(conn -> { conn.query("SELECT 2 \"foo\"", ctx.asyncAssertSuccess(result -> { Row row = result.iterator().next(); ctx.assertNull(row.getColumnName(1)); async.complete(); })); })); }
@Test public void testNegativeGetColumnNameRows(TestContext ctx) { Async async = ctx.async(); PgClient.connect(vertx, options, ctx.asyncAssertSuccess(conn -> { conn.query("SELECT 2 \"foo\"", ctx.asyncAssertSuccess(result -> { Row row = result.iterator().next(); ctx.assertNull(row.getColumnName(-1)); async.complete(); })); })); }
/** * Verifies that a disabled device's status cannot be asserted. * * @param ctx The vertx unit test context. */ @Test public void testAssertDeviceRegistrationFailsForDisabledDevice(final TestContext ctx) { // GIVEN a registry that contains a disabled device final BaseRegistrationService<ServiceConfigProperties> registrationService = newRegistrationService(); registrationService.setRegistrationAssertionFactory(RegistrationAssertionHelperImpl.forSigning(vertx, props)); // WHEN trying to assert the device's registration status registrationService.assertRegistration(Constants.DEFAULT_TENANT, "4712", ctx.asyncAssertSuccess(result -> { // THEN the response does not contain a JWT token ctx.assertEquals(result.getStatus(), HttpURLConnection.HTTP_NOT_FOUND); ctx.assertNull(result.getPayload()); })); }
/** * Verifies that the removeDevice method returns not implemented. * * @param ctx The vertx unit test context. */ @Test public void testRemoveDevice(final TestContext ctx) { // GIVEN an empty registry final CompleteBaseRegistrationService<ServiceConfigProperties> registrationService = newCompleteRegistrationService(); registrationService.setRegistrationAssertionFactory(RegistrationAssertionHelperImpl.forSigning(vertx, props)); // WHEN trying to remove a device registrationService.removeDevice(Constants.DEFAULT_TENANT, "4711", ctx.asyncAssertSuccess(result -> { // THEN the response contain a JWT token with an empty result with status code 501. ctx.assertEquals(result.getStatus(), HttpURLConnection.HTTP_NOT_IMPLEMENTED); ctx.assertNull(result.getPayload()); })); }
@Test public void testExceptionInExecuteBlock(TestContext context) { Async async = context.async(); executeBlockingComponent.executeBlocking(future -> { throw new ExampleException("Desroches"); }, result -> { context.assertFalse(result.isSuccess()); context.assertTrue(result.isError()); context.assertTrue(result.getError() instanceof ExampleException); context.assertEquals(result.getError().getMessage(), "Desroches"); context.assertNull(result.getResult()); async.complete(); }); }
@Test public void testFailedExecution(TestContext context) { Async async = context.async(); executeBlockingComponent.executeBlocking(future -> { future.fail(new ExampleException("Silhoutte")); }, result -> { context.assertFalse(result.isSuccess()); context.assertTrue(result.isError()); context.assertTrue(result.getError() instanceof ExampleException); context.assertEquals(result.getError().getMessage(), "Silhoutte"); context.assertNull(result.getResult()); async.complete(); }); }
@Test public void testSuppressIncorrectWarningHeaders(TestContext ctx) { Async latch = ctx.async(); SocketAddress backend = startHttpBackend(ctx, 8081, req -> { req.response() .putHeader("date", "Tue, 15 Nov 1994 08:12:30 GMT") .putHeader("warning", "199 Miscellaneous warning \"Tue, 15 Nov 1994 08:12:31 GMT\"") .end(); }); startProxy(backend); HttpClient client = vertx.createHttpClient(); client.getNow(8080, "localhost", "/", resp -> { ctx.assertNotNull(resp.getHeader("date")); ctx.assertNull(resp.getHeader("warning")); latch.complete(); }); }
@Test public void testThatTaskNotSubmittedOnVertxEventLoopAreExecutedOnTheEventLoop(TestContext tc) { Async async = tc.async(); final Context context = Vertx.currentContext(); tc.assertNull(context); final Promise.DefaultPromise<String> promise = new Promise.DefaultPromise<>(); promise.onComplete(ScalaUtils.toFunction1(v -> { tc.assertNotNull(Vertx.currentContext()); async.complete(); }), VertxEventLoopExecutionContext.create(vertx)); promise.complete(new Success<>("hello")); }
@Test public void testSuccessfulExecution(TestContext context) { Async async = context.async(); executeBlockingComponent.executeBlocking(future -> { future.completed("The Farquhar Islands"); }, result -> { context.assertTrue(result.isSuccess()); context.assertFalse(result.isError()); context.assertEquals(result.getResult(), "The Farquhar Islands"); context.assertNull(result.getError()); async.complete(); }); }
@Test public void testSuspendProcess(TestContext context) throws Exception { TestTtyConnection conn = new TestTtyConnection(vertx); ShellImpl shell = createShell(conn); shell.init().readline(); Async done = context.async(); Async latch2 = context.async(); commands.add(CommandBuilder.command("foo").processHandler(process -> { Job job = shell.jobController().getJob(1); process.suspendHandler(v -> { context.assertEquals(ExecStatus.STOPPED, job.status()); context.assertNull(shell.jobController().foregroundJob()); done.complete(); }); latch2.complete(); })); conn.read("foo\r"); latch2.awaitSuccess(10000); conn.sendEvent(TtyEvent.SUSP); }