当前位置: 首页>>代码示例>>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;未经允许,请勿转载。