io.vertx.ext.unit.TestContext.fail()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中io.vertx.ext.unit.TestContext.fail()方法的一些代码示例,展示了TestContext.fail()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestContext.fail()方法的具体详情如下:
包路径:io.vertx.ext.unit.TestContext
类名称:TestContext
方法名:fail

TestContext.fail介绍

暂无

代码示例

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Throw a failure.
 */
public void fail() { 
 delegate.fail();
}

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Throw a failure with the specified failure <code>message</code>.
 * @param message the failure message
 */
public void fail(String message) { 
 delegate.fail(message);
}

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Throw a failure with the specified failure <code>cause</code>.
 * @param cause the failure cause
 */
public void fail(Throwable cause) { 
 delegate.fail(cause);
}

代码示例来源:origin: reactiverse/reactive-pg-client

@Override
public void onError(Throwable err) {
 ctx.fail(err);
}
@Override

代码示例来源:origin: io.vertx/vertx-shell

@Override
public void complete(List<String> candidates) {
 context.fail();
}
@Override

代码示例来源:origin: io.vertx/vertx-mysql-postgresql-client-jasync

protected <A> Handler<AsyncResult<A>> onSuccess(TestContext context, Handler<A> fn) {
  return ar -> {
   if (ar.succeeded()) {
    fn.handle(ar.result());
   } else {
    context.fail("Should have been a success");
   }
  };
 }
}

代码示例来源:origin: io.vertx/vertx-unit

@Test
 public void testFail(TestContext context) {
  context.fail("the_failure");
 }
}

代码示例来源:origin: io.vertx/vertx-mail-client

/**
 * Matcher assertThat, this is usually in VertxTestBase, we pass the failure to testContext
 */
protected <T> void assertThat(T actual, Matcher<T> matcher) {
 try {
  super.assertThat(actual, matcher);
 } catch (AssertionError e) {
  testContext.fail(e);
 }
}

代码示例来源:origin: apiman/apiman

@Override
  public void handle(IAsyncResult<T> result) {
    if (result.isSuccess()) {
      successHandler.handle(result.getResult());
    } else {
      System.err.println("Operation failed"); //$NON-NLS-1$
      context.fail(result.getError());
    }
  }
};

代码示例来源:origin: io.vertx/vertx-amqp-bridge

private BrokerView getBrokerAdminView(TestContext context) {
 try {
  return getBrokerService().getAdminView();
 } catch (Exception e) {
  context.fail(e);
  // Above line throws, but satisfy the compiler.
  return null;
 }
}

代码示例来源:origin: de.braintags/NetRelayController

@Test
public void testDisplayListAll(TestContext context) {
 try {
  String url = String.format("/products/%s/DISPLAY/list.html", NetRelayExt_FileBasedSettings.SIMPLEMAPPER_NAME);
  testRequest(context, HttpMethod.POST, url, null, resp -> {
   LOGGER.info("RESPONSE: " + resp.content);
   context.assertTrue(resp.content.toString().contains("success"), "Expected name not found");
  }, 200, "OK", null);
 } catch (Exception e) {
  context.fail(e);
 }
}

代码示例来源:origin: de.braintags/NetRelayController

@Test
public void testDisplayListAllAsParam(TestContext context) {
 try {
  String url = "/products/list.html?action=DISPLAY&entity=" + NetRelayExt_FileBasedSettings.SIMPLEMAPPER_NAME;
  testRequest(context, HttpMethod.POST, url, null, resp -> {
   LOGGER.info("RESPONSE: " + resp.content);
   context.assertTrue(resp.content.toString().contains("success"), "Expected name not found");
  }, 200, "OK", null);
 } catch (Exception e) {
  context.fail(e);
 }
}

代码示例来源:origin: io.vertx/vertx-mqtt

@Test
public void acceptedClientIdAutoGenerated(TestContext context) {
 this.expectedReturnCode = MqttConnectReturnCode.CONNECTION_ACCEPTED;
 try {
  MemoryPersistence persistence = new MemoryPersistence();
  MqttClient client = new MqttClient(String.format("tcp://%s:%d", MQTT_SERVER_HOST, MQTT_SERVER_PORT), "", persistence);
  client.connect();
 } catch (MqttException e) {
  context.fail(e);
 }
}

代码示例来源:origin: io.vertx/vertx-mqtt

@Test
public void accepted(TestContext context) {
 this.expectedReturnCode = MqttConnectReturnCode.CONNECTION_ACCEPTED;
 try {
  MemoryPersistence persistence = new MemoryPersistence();
  MqttClient client = new MqttClient(String.format("tcp://%s:%d", MQTT_SERVER_HOST, MQTT_SERVER_PORT), "12345", persistence);
  client.connect();
 } catch (MqttException e) {
  context.fail(e);
 }
}

代码示例来源:origin: io.vertx/vertx-unit

@org.junit.Test
public void testAssertFailure() {
 try {
  TestCase.create("my_test", context -> context.fail("the_failure")).awaitSuccess();
  fail();
 } catch (AssertionError err) {
  assertEquals("the_failure", err.getMessage());
 }
}

代码示例来源:origin: io.vertx/vertx-mqtt

@Test
public void refusedServerUnavailable(TestContext context) {
 this.expectedReturnCode = MqttConnectReturnCode.CONNECTION_REFUSED_SERVER_UNAVAILABLE;
 try {
  MemoryPersistence persistence = new MemoryPersistence();
  MqttClient client = new MqttClient(String.format("tcp://%s:%d", MQTT_SERVER_HOST, MQTT_SERVER_PORT), "12345", persistence);
  client.connect();
  context.fail();
 } catch (MqttException e) {
  context.assertTrue(e.getReasonCode() == MqttException.REASON_CODE_BROKER_UNAVAILABLE);
 }
}

代码示例来源:origin: io.vertx/vertx-unit

private void testAwaitFailed(Consumer<Completion> consumer) {
 TestSuite suite = TestSuite.create("my_suite").test("my_test", context -> {
  context.fail();
 });
 Completion completion = suite.run(Vertx.vertx());
 consumer.accept(completion);
 assertTrue(completion.isCompleted());
 assertFalse(completion.isSucceeded());
 assertTrue(completion.isFailed());
}

代码示例来源:origin: io.vertx/vertx-shell

@Test
public void testSuspendReadyProcess(TestContext context) {
 CommandBuilder builder = CommandBuilder.command("hello");
 builder.processHandler(process -> context.fail());
 Process process = builder.build(vertx).createProcess().setSession(Session.create()).setTty(Pty.create().slave());
 try {
  process.suspend();
  context.fail();
 } catch (Exception ignore) {
 }
}

代码示例来源:origin: reactiverse/reactive-pg-client

@Test
public void testRunWithExisting(TestContext ctx) {
 Async async = ctx.async();
 vertx.runOnContext(v -> {
  try {
   PgClient.pool(new PgPoolOptions());
   ctx.fail();
  } catch (IllegalStateException ignore) {
   async.complete();
  }
 });
}

代码示例来源:origin: io.vertx/vertx-rabbitmq-client

@Test
public void testBasicConsumeWithErrorHandler(TestContext ctx) throws Exception {
 int count = 3;
 Set<String> messages = createMessages(count);
 String q = setupQueue(ctx, messages, "application/json");
 Async latch = ctx.async(count);
 vertx.eventBus().consumer("my.address", msg -> ctx.fail("Getting message with malformed json"));
 Handler<Throwable> errorHandler = throwable -> latch.countDown();
 client.basicConsume(q, "my.address", true, ctx.asyncAssertSuccess(), errorHandler);
}

相关文章