Search in sources :

Example 1 with ServerRequestWrapper

use of com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper in project pinpoint by naver.

the class NameSpaceCheckFactoryTest method newNamespace_empty_namespace.

@Test
public void newNamespace_empty_namespace() {
    String myNamespace = "myNamespace";
    NameSpaceChecker<ServerRequestWrapper> myNamespaceChecker = newNameSpaceChecker(myNamespace);
    ServerRequestWrapper serverRequestWrapper = mock(ServerRequestWrapper.class);
    when(serverRequestWrapper.getHeader(anyString())).thenReturn(null);
    Assert.assertTrue(myNamespaceChecker.checkNamespace(serverRequestWrapper));
}
Also used : ServerRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 2 with ServerRequestWrapper

use of com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper in project pinpoint by naver.

the class NameSpaceCheckFactoryTest method newNamespace_empty_config.

@Test
public void newNamespace_empty_config() {
    String myNamespace = "";
    NameSpaceChecker<ServerRequestWrapper> myNamespaceChecker = newNameSpaceChecker(myNamespace);
    ServerRequestWrapper serverRequestWrapper = mock(ServerRequestWrapper.class);
    when(serverRequestWrapper.getHeader(anyString())).thenReturn("invalid_namespace");
    Assert.assertTrue(myNamespaceChecker.checkNamespace(serverRequestWrapper));
}
Also used : ServerRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with ServerRequestWrapper

use of com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper in project pinpoint by naver.

the class NameSpaceCheckFactoryTest method newNamespace_collision.

@Test
public void newNamespace_collision() {
    String myNamespace = "myNamespace";
    NameSpaceChecker<ServerRequestWrapper> myNamespaceChecker = newNameSpaceChecker(myNamespace);
    ServerRequestWrapper serverRequestWrapper = mock(ServerRequestWrapper.class);
    when(serverRequestWrapper.getHeader(anyString())).thenReturn("collision_namespace");
    Assert.assertFalse(myNamespaceChecker.checkNamespace(serverRequestWrapper));
}
Also used : ServerRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 4 with ServerRequestWrapper

use of com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper in project pinpoint by naver.

the class NameSpaceCheckFactoryTest method newNamespace_valid.

@Test
public void newNamespace_valid() {
    String myNamespace = "myNamespace";
    NameSpaceChecker<ServerRequestWrapper> myNamespaceChecker = newNameSpaceChecker(myNamespace);
    ServerRequestWrapper serverRequestWrapper = mock(ServerRequestWrapper.class);
    when(serverRequestWrapper.getHeader(anyString())).thenReturn(myNamespace);
    Assert.assertTrue(myNamespaceChecker.checkNamespace(serverRequestWrapper));
}
Also used : ServerRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 5 with ServerRequestWrapper

use of com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper in project pinpoint by naver.

the class ServerRequestRecorderFactoryTest method record.

@Test
public void record() throws Exception {
    RequestAdaptor<ServerRequestWrapper> requestAdaptor = new ServerRequestWrapperAdaptor();
    final ServerRequestRecorder<ServerRequestWrapper> recorder = new ServerRequestRecorder<>(requestAdaptor);
    // SpanRecorder
    SpanRecorder spanRecorder = mock(SpanRecorder.class);
    recorder.record(spanRecorder, new MockServerRequestWrapper());
    verify(spanRecorder).recordRpcName(RPC_NAME);
    verify(spanRecorder).recordEndPoint(END_POINT);
    verify(spanRecorder).recordRemoteAddress(REMOTE_ADDRESS);
    verify(spanRecorder).recordAcceptorHost(GET_HEADER);
}
Also used : SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) ServerRequestRecorder(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestRecorder) ServerRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper) ServerRequestWrapperAdaptor(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapperAdaptor) Test(org.junit.Test)

Aggregations

ServerRequestWrapper (com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper)5 Test (org.junit.Test)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)1 ServerRequestRecorder (com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestRecorder)1 ServerRequestWrapperAdaptor (com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapperAdaptor)1