当前位置: 首页>>代码示例>>Java>>正文


Java IsEqual类代码示例

本文整理汇总了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());
    }
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:23,代码来源:MVCJettyITest.java

示例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());
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:17,代码来源:MVCJettyITest.java

示例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"));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:23,代码来源:MVCJettyITest.java

示例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"));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:24,代码来源:AbstractBaseITests.java

示例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"));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:24,代码来源:AbstractBaseITests.java

示例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());
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:22,代码来源:AbstractBaseITests.java

示例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"));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:25,代码来源:AbstractBaseITests.java

示例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"));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:22,代码来源:AbstractBaseITests.java

示例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"));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:25,代码来源:AbstractBaseITests.java

示例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());
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:17,代码来源:AbstractBaseITests.java

示例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"));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:23,代码来源:AbstractBaseITests.java

示例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"));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:23,代码来源:AbstractBaseITests.java

示例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()));
}
 
开发者ID:opentracing-contrib,项目名称:java-web-servlet-filter,代码行数:26,代码来源:TracingFilterTest.java

示例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());
}
 
开发者ID:opentracing-contrib,项目名称:java-web-servlet-filter,代码行数:20,代码来源:TracingFilterTest.java

示例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()));
}
 
开发者ID:opentracing-contrib,项目名称:java-web-servlet-filter,代码行数:26,代码来源:TracingFilterTest.java


注:本文中的org.hamcrest.core.IsEqual类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。