本文整理汇总了Java中org.hamcrest.core.IsEqual类的典型用法代码示例。如果您正苦于以下问题:Java IsEqual类的具体用法?Java IsEqual怎么用?Java IsEqual使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IsEqual类属于org.hamcrest.core包,在下文中一共展示了IsEqual类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSecuredURLUnAuthorized
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testSecuredURLUnAuthorized() throws Exception {
{
getRestTemplate().getForEntity("/secured", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("GET", span.operationName());
Assert.assertEquals(5, span.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, span.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", span.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(getUrl("/secured"), span.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(401, span.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertNotNull(span.tags().get(Tags.COMPONENT.getKey()));
// request does not hit any controller
assertLogEvents(span.logEntries(), Collections.<String>emptyList());
}
示例2: testNoURLMapping
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testNoURLMapping() {
{
getRestTemplate().getForEntity("/nouUrlMapping", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("GET", span.operationName());
Assert.assertEquals(404, span.tags().get(Tags.HTTP_STATUS.getKey()));
assertLogEvents(span.logEntries(), Collections.<String>emptyList());
}
示例3: testControllerMappedException
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testControllerMappedException() throws Exception {
{
getRestTemplate().getForEntity("/mappedException", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("mappedException", span.operationName());
Assert.assertEquals(5, span.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, span.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", span.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(getUrl("/mappedException"), span.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(409, span.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertNotNull(span.tags().get(Tags.COMPONENT.getKey()));
assertLogEvents(span.logEntries(), Arrays.asList("preHandle", "afterCompletion"));
}
示例4: testSyncWithStandardTags
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testSyncWithStandardTags() throws Exception {
{
getRestTemplate().getForEntity("/sync", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("sync", span.operationName());
Assert.assertEquals(5, span.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, span.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", span.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(getUrl("/sync"), span.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(200, span.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertNotNull(span.tags().get(Tags.COMPONENT.getKey()));
assertLogEvents(span.logEntries(), Arrays.asList("preHandle", "afterCompletion"));
}
示例5: testAsyncDeferred
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testAsyncDeferred() throws Exception {
{
getRestTemplate().getForEntity("/asyncDeferred", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("test", span.operationName());
Assert.assertEquals(5, span.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, span.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", span.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(getUrl("/asyncDeferred"), span.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(202, span.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertNotNull(span.tags().get(Tags.COMPONENT.getKey()));
assertLogEvents(span.logEntries(), Arrays.asList("preHandle", "afterConcurrentHandlingStarted",
"preHandle", "afterCompletion"));
}
示例6: testContextPropagation
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testContextPropagation() throws Exception {
{
HttpHeaders headers = new HttpHeaders();
headers.set("spanid", "1");
headers.set("traceid", "345");
HttpEntity<String> entity = new HttpEntity<>(headers);
getRestTemplate().exchange("/sync", HttpMethod.GET, entity, String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals(1, span.parentId());
Assert.assertEquals(345, span.context().traceId());
Assert.assertEquals("sync", span.operationName());
}
示例7: testNoURLMapping
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testNoURLMapping() {
{
getRestTemplate().getForEntity("/nouUrlMapping", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(2));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(2, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("GET", span.operationName());
Assert.assertEquals(404, span.tags().get(Tags.HTTP_STATUS.getKey()));
assertLogEvents(span.logEntries(), Collections.<String>emptyList());
span = mockSpans.get(1);
Assert.assertEquals(0, span.tags().size());
Assert.assertEquals(mockSpans.get(0).context().spanId(), span.parentId());
Assert.assertEquals(0, span.tags().size());
assertLogEvents(span.logEntries(), Arrays.asList("preHandle", "afterCompletion"));
Assert.assertEquals("BasicErrorController",
span.logEntries().get(0).fields().get("handler.class_simple_name"));
}
示例8: testSecuredURLAuthorized
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testSecuredURLAuthorized() throws Exception {
{
getRestTemplate().withBasicAuth("user", "password").getForEntity("/secured", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("secured", span.operationName());
Assert.assertEquals(5, span.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, span.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", span.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(getUrl("/secured"), span.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(200, span.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertNotNull(span.tags().get(Tags.COMPONENT.getKey()));
assertLogEvents(span.logEntries(), Arrays.asList("preHandle", "afterCompletion"));
}
示例9: testForward
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testForward() {
{
getRestTemplate().getForEntity("/forward", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan mockSpan = mockSpans.get(0);
Assert.assertEquals("sync", mockSpan.operationName());
assertLogEvents(mockSpan.logEntries(), Arrays.asList("preHandle", "preHandle", "afterCompletion",
"afterCompletion"));
Assert.assertEquals("forward",
mockSpan.logEntries().get(0).fields().get(HandlerInterceptorSpanDecorator.HandlerUtils.HANDLER_METHOD_NAME));
Assert.assertEquals("sync",
mockSpan.logEntries().get(1).fields().get(HandlerInterceptorSpanDecorator.HandlerUtils.HANDLER_METHOD_NAME));
Assert.assertTrue(mockSpan.logEntries().get(2).fields().get(HandlerInterceptorSpanDecorator.HandlerUtils.HANDLER)
.toString().contains("sync"));
Assert.assertTrue(mockSpan.logEntries().get(3).fields().get(HandlerInterceptorSpanDecorator.HandlerUtils.HANDLER)
.toString().contains("forward"));
}
示例10: testLocalSpan
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testLocalSpan() {
{
getRestTemplate().getForEntity("/localSpan", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(2));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(2, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan childSpan = mockSpans.get(0);
MockSpan parentSpan = mockSpans.get(1);
Assert.assertEquals("localSpan", parentSpan.operationName());
Assert.assertEquals(childSpan.context().traceId(), parentSpan.context().traceId());
Assert.assertEquals(childSpan.parentId(), parentSpan.context().spanId());
}
示例11: testView
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testView() {
{
getRestTemplate().getForEntity("/view", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("view", span.operationName());
Assert.assertEquals(5, span.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, span.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", span.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(getUrl("/view"), span.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(200, span.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertNotNull(span.tags().get(Tags.COMPONENT.getKey()));
assertLogEvents(span.logEntries(), Arrays.asList("preHandle", "afterCompletion"));
}
示例12: testControllerView
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testControllerView() {
{
getRestTemplate().getForEntity("/controllerView", String.class);
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = TracingBeansConfiguration.mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan span = mockSpans.get(0);
Assert.assertEquals("GET", span.operationName());
Assert.assertEquals(5, span.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, span.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", span.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(getUrl("/controllerView"), span.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(200, span.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertNotNull(span.tags().get(Tags.COMPONENT.getKey()));
assertLogEvents(span.logEntries(), Arrays.asList("preHandle", "afterCompletion"));
}
示例13: testHelloRequest
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testHelloRequest() throws IOException {
{
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(localRequestUrl("/hello"))
.build();
client.newCall(request).execute();
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan mockSpan = mockSpans.get(0);
Assert.assertEquals("GET", mockSpan.operationName());
Assert.assertEquals(5, mockSpan.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, mockSpan.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", mockSpan.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(localRequestUrl("/hello"), mockSpan.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(202, mockSpan.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertEquals("java-web-servlet", mockSpan.tags().get(Tags.COMPONENT.getKey()));
}
示例14: testLocalSpan
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testLocalSpan() throws IOException {
{
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(localRequestUrl("/localSpan"))
.build();
client.newCall(request).execute();
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(2));
}
List<MockSpan> mockSpans = mockTracer.finishedSpans();
Assert.assertEquals(2, mockSpans.size());
assertOnErrors(mockSpans);
Assert.assertEquals(mockSpans.get(0).context().traceId(), mockSpans.get(1).context().traceId());
Assert.assertEquals(mockSpans.get(0).parentId(), mockSpans.get(1).context().spanId());
}
示例15: testNotExistingUrl
import org.hamcrest.core.IsEqual; //导入依赖的package包/类
@Test
public void testNotExistingUrl() throws IOException {
{
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(localRequestUrl("/doesNotExist"))
.build();
client.newCall(request).execute();
Awaitility.await().until(reportedSpansSize(), IsEqual.equalTo(1));
}
List<MockSpan> mockSpans = mockTracer.finishedSpans();
Assert.assertEquals(1, mockSpans.size());
assertOnErrors(mockSpans);
MockSpan mockSpan = mockSpans.get(0);
Assert.assertEquals("GET", mockSpan.operationName());
Assert.assertEquals(5, mockSpan.tags().size());
Assert.assertEquals(Tags.SPAN_KIND_SERVER, mockSpan.tags().get(Tags.SPAN_KIND.getKey()));
Assert.assertEquals("GET", mockSpan.tags().get(Tags.HTTP_METHOD.getKey()));
Assert.assertEquals(localRequestUrl("/doesNotExist"), mockSpan.tags().get(Tags.HTTP_URL.getKey()));
Assert.assertEquals(404, mockSpan.tags().get(Tags.HTTP_STATUS.getKey()));
Assert.assertEquals("java-web-servlet", mockSpan.tags().get(Tags.COMPONENT.getKey()));
}