當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。