當前位置: 首頁>>代碼示例>>Java>>正文


Java TestContext.assertTrue方法代碼示例

本文整理匯總了Java中io.vertx.ext.unit.TestContext.assertTrue方法的典型用法代碼示例。如果您正苦於以下問題:Java TestContext.assertTrue方法的具體用法?Java TestContext.assertTrue怎麽用?Java TestContext.assertTrue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.ext.unit.TestContext的用法示例。


在下文中一共展示了TestContext.assertTrue方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test_vertxCallbackTest

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void test_vertxCallbackTest(TestContext context) {
	Async async = context.async();
	
	context.assertTrue(vertx.getOrCreateContext().isEventLoopContext());
	long threadId = Thread.currentThread().getId();
	
	GraphQLObjectType query = GraphQLObjectType.newObject()
	        .name("query")
	        .field(GraphQLFieldDefinition.newFieldDefinition()
	                .name("hello")
	                .type(Scalars.GraphQLString)
	                .dataFetcher(environment -> {
	                	context.assertTrue(vertx.getOrCreateContext().isEventLoopContext());
	                	context.assertEquals(threadId, Thread.currentThread().getId());
	                	return "world";
	        		}))
	        .build(); 
	
	GraphQLSchema schema = GraphQLSchema.newSchema()
			.query(query)
			.build();
	
	AsyncGraphQLExec asyncGraphQL = AsyncGraphQLExec.create(schema);
	Future<JsonObject> queryResult = asyncGraphQL.executeQuery("query { hello }", null, null, null);
	queryResult.setHandler(res -> {
		context.assertTrue(vertx.getOrCreateContext().isEventLoopContext());
       	context.assertEquals(threadId, Thread.currentThread().getId());
		async.complete();
	});
}
 
開發者ID:tibor-kocsis,項目名稱:vertx-graphql-utils,代碼行數:32,代碼來源:VertxThreadTest.java

示例2: test_vertxCallbackAsyncTest

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void test_vertxCallbackAsyncTest(TestContext context) {
	Async async = context.async();
	
	context.assertTrue(vertx.getOrCreateContext().isEventLoopContext());
	long threadId = Thread.currentThread().getId();
	
	AsyncDataFetcher<String> asyncDataFetcher = (env, handler) -> {
		context.assertTrue(vertx.getOrCreateContext().isEventLoopContext());
		context.assertEquals(threadId, Thread.currentThread().getId());
		
		vertx.<String> executeBlocking(fut -> {
			context.assertNotEquals(threadId, Thread.currentThread().getId());
			fut.complete("world");
		}, handler);
	};
	
	GraphQLObjectType query = GraphQLObjectType.newObject()
	        .name("query")
	        .field(GraphQLFieldDefinition.newFieldDefinition()
	                .name("hello")
	                .type(Scalars.GraphQLString)
	                .dataFetcher(asyncDataFetcher))
	        .build(); 
	
	GraphQLSchema schema = GraphQLSchema.newSchema()
			.query(query)
			.build();
	
	AsyncGraphQLExec asyncGraphQL = AsyncGraphQLExec.create(schema);
	Future<JsonObject> queryResult = asyncGraphQL.executeQuery("query { hello }", null, null, null);
	queryResult.setHandler(res -> {
		context.assertTrue(vertx.getOrCreateContext().isEventLoopContext());
       	context.assertEquals(threadId, Thread.currentThread().getId());
		async.complete();
	});
}
 
開發者ID:tibor-kocsis,項目名稱:vertx-graphql-utils,代碼行數:38,代碼來源:VertxThreadTest.java

示例3: testWrite

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testWrite(TestContext context) {
    String data = "Some data to write";
    int dataLength = data.length();
    response.putHeader("Content-Length", Integer.toString(dataLength));
    context.assertEquals(response, response.write("Some data"));
    response.end();
    JsonObject output = readOuput();
    context.assertTrue(output.getBoolean("isBase64Encoded"));
    context.assertEquals(200, output.getInteger("statusCode"));
    context.assertEquals(Integer.toString(dataLength), output.getJsonObject("headers").getString("Content-Length"));
    context.assertEquals("Some data", new String(output.getBinary("body")));
}
 
開發者ID:noseka1,項目名稱:vertx-aws-lambda,代碼行數:14,代碼來源:HttpServerResponseImplTest.java

示例4: testHeadWritten

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testHeadWritten(TestContext context) {
    context.assertFalse(response.headWritten());
    response.putHeader("Content-Length", "0");
    response.write("");
    context.assertTrue(response.headWritten());
}
 
開發者ID:noseka1,項目名稱:vertx-aws-lambda,代碼行數:8,代碼來源:HttpServerResponseImplTest.java

示例5: testHandleDataRequestPath

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testHandleDataRequestPath(TestContext context) {
    request = new HttpServerRequestImpl(localHost, localPort, requestPath, response);
    request.bodyHandler(buffer -> {
        context.assertEquals("request line 1\nrequest line 2\nrequest line 3", buffer.toString());
    });
    request.handleData();
    request.handleEnd();
    context.assertEquals("/path1", request.path());
    context.assertEquals("", request.query());
    context.assertTrue(request.headers().isEmpty());
    context.assertEquals("http://localhost:8888/path1", request.absoluteURI());
}
 
開發者ID:noseka1,項目名稱:vertx-aws-lambda,代碼行數:14,代碼來源:HttpServerRequestImplTest.java

示例6: testProduce1

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testProduce1(final TestContext context) throws NoSuchMethodException {
    final Method method = Media.class.getDeclaredMethod("sayH");
    final Set<MediaType> types = MediaResolver.produces(method);
    context.assertEquals(1, types.size());
    context.assertTrue(types.contains(MediaType.WILDCARD_TYPE));
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:8,代碼來源:MediaResolverTc.java

示例7: testConsumes

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testConsumes(final TestContext context) throws NoSuchMethodException {
    final Method method = Media.class.getDeclaredMethod("sayHello");
    final Set<MediaType> types = MediaResolver.consumes(method);
    context.assertEquals(1, types.size());
    context.assertTrue(types.contains(MediaType.WILDCARD_TYPE));
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:8,代碼來源:MediaResolverTc.java

示例8: testClose2

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testClose2(TestContext context) {
    Future<Void> future = Future.future();
    server.close(future);
    context.assertTrue(future.succeeded());
}
 
開發者ID:noseka1,項目名稱:vertx-aws-lambda,代碼行數:7,代碼來源:LambdaServerTest.java

示例9: testSetChunked

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testSetChunked(TestContext context) {
    context.assertEquals(response, response.setChunked(true));
    context.assertTrue(response.isChunked());
}
 
開發者ID:noseka1,項目名稱:vertx-aws-lambda,代碼行數:6,代碼來源:HttpServerResponseImplTest.java

示例10: testClose

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testClose(TestContext context) {
    context.assertFalse(response.closed());
    response.close();
    context.assertTrue(response.closed());
}
 
開發者ID:noseka1,項目名稱:vertx-aws-lambda,代碼行數:7,代碼來源:HttpServerResponseImplTest.java

示例11: testEnded

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testEnded(TestContext context) {
    context.assertFalse(response.ended());
    response.end();
    context.assertTrue(response.ended());
}
 
開發者ID:noseka1,項目名稱:vertx-aws-lambda,代碼行數:7,代碼來源:HttpServerResponseImplTest.java

示例12: testIsEnded

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testIsEnded(TestContext context) {
    context.assertFalse(request.isEnded());
    request.handleEnd();
    context.assertTrue(request.isEnded());
}
 
開發者ID:noseka1,項目名稱:vertx-aws-lambda,代碼行數:7,代碼來源:HttpServerRequestImplTest.java

示例13: testDefined

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
public void testDefined(final TestContext context) {
    final boolean isDefined = isDefine(AnnoExceAgent.class,
            ZeroHttpAgent.class);
    context.assertTrue(isDefined);
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:6,代碼來源:VertxAnnoTc.java

示例14: testReconnect

import io.vertx.ext.unit.TestContext; //導入方法依賴的package包/類
@Test
public void testReconnect(TestContext ctx) {
  PgConnectOptions options = new PgConnectOptions(PgTestBase.options);
  ProxyServer proxy = ProxyServer.create(vertx, options.getPort(), options.getHost());
  AtomicReference<ProxyServer.Connection> connRef = new AtomicReference<>();
  proxy.proxyHandler(conn -> {
    connRef.set(conn);
    conn.connect();
  });
  Async listenLatch = ctx.async();
  proxy.listen(8080, "localhost", ctx.asyncAssertSuccess(v -> {
    options.setPort(8080).setHost("localhost");
    listenLatch.complete();
  }));
  listenLatch.awaitSuccess(10000);
  subscriber = PgSubscriber.subscriber(vertx, options);
  PgChannel sub = subscriber.channel("the_channel");
  Async connect1Latch = ctx.async();
  Async connect2Latch = ctx.async();
  Async connect3Latch = ctx.async();
  AtomicInteger times = new AtomicInteger();
  sub.subscribeHandler(v -> {
    switch (times.getAndIncrement()) {
      case 0:
        connect1Latch.complete();
        break;
      case 1:
        connect2Latch.complete();
        break;
      case 2:
        connect3Latch.complete();
        break;
    }
  });
  subscriber.connect(ar -> { });
  sub.handler(notif -> { });
  connect1Latch.awaitSuccess(10000);
  AtomicInteger count = new AtomicInteger();
  subscriber.reconnectPolicy(retries -> {
    ctx.assertEquals(0, retries);
    ctx.assertFalse(subscriber.closed());
    if (count.getAndIncrement() < 2) {
      return 100L;
    } else {
      return -1L;
    }
  });
  Async closeLatch = ctx.async();
  subscriber.closeHandler(v -> closeLatch.complete());
  connRef.get().close();
  connect2Latch.awaitSuccess(10000);
  connRef.get().close();
  connect3Latch.awaitSuccess(10000);
  connRef.get().close();
  closeLatch.awaitSuccess(10000);
  ctx.assertEquals(3, count.get());
  ctx.assertTrue(subscriber.closed());
}
 
開發者ID:vietj,項目名稱:reactive-pg-client,代碼行數:59,代碼來源:PubSubTest.java


注:本文中的io.vertx.ext.unit.TestContext.assertTrue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。