本文整理汇总了Java中io.vertx.ext.unit.TestContext.assertEquals方法的典型用法代码示例。如果您正苦于以下问题:Java TestContext.assertEquals方法的具体用法?Java TestContext.assertEquals怎么用?Java TestContext.assertEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.unit.TestContext
的用法示例。
在下文中一共展示了TestContext.assertEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testParams
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testParams(TestContext context) {
MultiMap params = request.params();
context.assertEquals(2, params.size());
context.assertEquals("1", params.get("p1"));
context.assertEquals("2", params.get("p2"));
}
示例2: 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));
}
示例3: 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();
});
}
示例4: testMethod1
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testMethod1(final TestContext context)
throws NoSuchMethodException {
final Method method = RMethod1.class.getDeclaredMethod("sayHell");
final HttpMethod httpMethod = MethodResolver.resolve(method);
context.assertEquals(HttpMethod.GET, httpMethod);
}
示例5: testEnd
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testEnd(TestContext context) {
String data = "End the response";
int dataLength = data.length();
response.end(data);
JsonObject output = readOuput();
context.assertEquals(Integer.toString(dataLength), output.getJsonObject("headers").getString("Content-Length"));
context.assertEquals(data, new String(output.getBinary("body")));
}
示例6: testAnnos
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testAnnos(final TestContext context) {
final ConcurrentMap<String, Annotation> clazzes = Anno.get(AnnoOne.class);
for (final String item : clazzes.keySet()) {
System.out.println("key=" + item + ",value=" + clazzes.get(item));
}
context.assertEquals(2, clazzes.size());
}
示例7: testMd1
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testMd1(final TestContext context) {
final Set<String> pathes = parseMethod(Method1.class);
final Set<String> expected = new TreeSet<String>() {
{
add("/api/test");
}
};
context.assertEquals(expected, pathes);
}
示例8: async_behavior
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test /*(timeout=5000)*/ // <8>
public void async_behavior(TestContext context) { // <1>
Vertx vertx = Vertx.vertx(); // <2>
context.assertEquals("foo", "foo"); // <3>
Async a1 = context.async(); // <4>
Async a2 = context.async(3); // <5>
vertx.setTimer(100, n -> a1.complete()); // <6>
vertx.setPeriodic(100, n -> a2.countDown()); // <7>
}
示例9: 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());
}
示例10: testHandleDataRequestPathMultiple
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testHandleDataRequestPathMultiple(TestContext context) {
request = new HttpServerRequestImpl(localHost, localPort, requestPathMultiple, response);
request.bodyHandler(buffer -> {
context.assertEquals("", buffer.toString());
});
request.handleData();
request.handleEnd();
context.assertEquals("/path1/path2/path3", request.path());
context.assertEquals("http://localhost:8888/path1/path2/path3", request.absoluteURI());
}
示例11: testBytesWritten
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testBytesWritten(TestContext context) {
String data = "Some response data";
int dataLength = data.length();
response.end(data);
JsonObject output = readOuput();
context.assertEquals((long) dataLength, response.bytesWritten());
context.assertEquals(Integer.toString(dataLength), output.getJsonObject("headers").getString("Content-Length"));
}
示例12: testMd3
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testMd3(final TestContext context) {
final Set<String> pathes = parseMethod(Method3.class);
final Set<String> expected = new TreeSet<String>() {
{
add("/api/test/:name");
add("/api/test/:id");
}
};
context.assertEquals(expected, pathes);
}
示例13: verifyMissHandler
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
private Handler<HttpClientResponse> verifyMissHandler(TestContext context, Async f) {
return r -> {
context.assertEquals(404, r.statusCode(), "Should have received an error for incorrect type");
f.complete();
};
}
示例14: testHandler
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testHandler(TestContext context) {
context.assertEquals(request, request.handler(ar -> {
}));
}
示例15: testRt1
import io.vertx.ext.unit.TestContext; //导入方法依赖的package包/类
@Test
public void testRt1(final TestContext context) {
context.assertEquals("/api", parseRoot(Root1.class));
}