Search in sources :

Example 31 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class FirstLineOfRequestItemTest method initStrBuilder.

@Before
public void initStrBuilder() {
    mockContext = Mockito.mock(RoutingContext.class);
    finishEvent = Mockito.mock(InvocationFinishEvent.class);
    invocation = Mockito.mock(Invocation.class);
    restClientRequest = Mockito.mock(RestClientRequestImpl.class);
    clientRequest = Mockito.mock(HttpClientRequest.class);
    endpoint = Mockito.mock(Endpoint.class);
    urlEndpoint = Mockito.mock(URIEndpointObject.class);
    Map<String, Object> handlerMap = new HashMap<>();
    handlerMap.put(RestConst.INVOCATION_HANDLER_REQUESTCLIENT, restClientRequest);
    when(finishEvent.getInvocation()).thenReturn(invocation);
    when(invocation.getHandlerContext()).thenReturn(handlerMap);
    when(restClientRequest.getRequest()).thenReturn(clientRequest);
    when(invocation.getEndpoint()).thenReturn(endpoint);
    when(endpoint.getAddress()).thenReturn(urlEndpoint);
    accessLogEvent = new ServerAccessLogEvent();
    accessLogEvent.setRoutingContext(mockContext);
    strBuilder = new StringBuilder();
}
Also used : Invocation(org.apache.servicecomb.core.Invocation) HashMap(java.util.HashMap) RestClientRequestImpl(org.apache.servicecomb.common.rest.codec.param.RestClientRequestImpl) RoutingContext(io.vertx.ext.web.RoutingContext) HttpClientRequest(io.vertx.core.http.HttpClientRequest) InvocationFinishEvent(org.apache.servicecomb.core.event.InvocationFinishEvent) ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) Endpoint(org.apache.servicecomb.core.Endpoint) URIEndpointObject(org.apache.servicecomb.foundation.common.net.URIEndpointObject) URIEndpointObject(org.apache.servicecomb.foundation.common.net.URIEndpointObject) Before(org.junit.Before)

Example 32 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class AccessLogGeneratorTest method testServerLog.

@Test
public void testServerLog() {
    RoutingContext context = Mockito.mock(RoutingContext.class);
    HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
    long startMillisecond = 1416863450581L;
    ServerAccessLogEvent serverAccessLogEvent = new ServerAccessLogEvent();
    serverAccessLogEvent.setMilliStartTime(startMillisecond).setRoutingContext(context);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ConfigurableDatetimeAccessItem.DEFAULT_DATETIME_PATTERN, ConfigurableDatetimeAccessItem.DEFAULT_LOCALE);
    simpleDateFormat.setTimeZone(TimeZone.getDefault());
    when(context.request()).thenReturn(request);
    when(request.method()).thenReturn(HttpMethod.DELETE);
    String log = LOG_GENERATOR.generateServerLog(serverAccessLogEvent);
    Assert.assertEquals("DELETE" + " - " + simpleDateFormat.format(startMillisecond), log);
}
Also used : RoutingContext(io.vertx.ext.web.RoutingContext) ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) HttpServerRequest(io.vertx.core.http.HttpServerRequest) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 33 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class DatetimeConfigurableItemTest method initStrBuilder.

@Before
public void initStrBuilder() {
    finishEvent = Mockito.mock(InvocationFinishEvent.class);
    invocation = Mockito.mock(Invocation.class);
    invocationStageTrace = Mockito.mock(InvocationStageTrace.class);
    when(finishEvent.getInvocation()).thenReturn(invocation);
    when(invocation.getInvocationStageTrace()).thenReturn(invocationStageTrace);
    when(invocationStageTrace.getStartSend()).thenReturn(0L);
    when(invocationStageTrace.getStart()).thenReturn(0L);
    when(invocationStageTrace.getStartTimeMillis()).thenReturn(START_MILLISECOND);
    accessLogEvent = new ServerAccessLogEvent();
    accessLogEvent.setMilliStartTime(START_MILLISECOND);
    strBuilder = new StringBuilder();
}
Also used : InvocationFinishEvent(org.apache.servicecomb.core.event.InvocationFinishEvent) ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) Invocation(org.apache.servicecomb.core.Invocation) InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace) Before(org.junit.Before)

Example 34 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class DurationSecondItemTest method initStrBuilder.

@Before
public void initStrBuilder() {
    finishEvent = Mockito.mock(InvocationFinishEvent.class);
    invocation = Mockito.mock(Invocation.class);
    invocationStageTrace = Mockito.mock(InvocationStageTrace.class);
    when(finishEvent.getInvocation()).thenReturn(invocation);
    when(invocation.getInvocationStageTrace()).thenReturn(invocationStageTrace);
    when(invocationStageTrace.getStartSend()).thenReturn(1000_000L);
    accessLogEvent = new ServerAccessLogEvent();
    accessLogEvent.setMilliStartTime(1L);
    strBuilder = new StringBuilder();
}
Also used : InvocationFinishEvent(org.apache.servicecomb.core.event.InvocationFinishEvent) ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) Invocation(org.apache.servicecomb.core.Invocation) InvocationStageTrace(org.apache.servicecomb.core.invocation.InvocationStageTrace) Before(org.junit.Before)

Example 35 with ServerAccessLogEvent

use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.

the class TransportItemTest method initStrBuilder.

@Before
public void initStrBuilder() {
    finishEvent = Mockito.mock(InvocationFinishEvent.class);
    invocation = Mockito.mock(Invocation.class);
    endpoint = Mockito.mock(Endpoint.class);
    accessLogEvent = new ServerAccessLogEvent();
    strBuilder = new StringBuilder();
}
Also used : InvocationFinishEvent(org.apache.servicecomb.core.event.InvocationFinishEvent) ServerAccessLogEvent(org.apache.servicecomb.core.event.ServerAccessLogEvent) Invocation(org.apache.servicecomb.core.Invocation) Endpoint(org.apache.servicecomb.core.Endpoint) Before(org.junit.Before)

Aggregations

ServerAccessLogEvent (org.apache.servicecomb.core.event.ServerAccessLogEvent)48 Before (org.junit.Before)44 InvocationFinishEvent (org.apache.servicecomb.core.event.InvocationFinishEvent)42 RoutingContext (io.vertx.ext.web.RoutingContext)36 Invocation (org.apache.servicecomb.core.Invocation)34 HttpServerRequest (io.vertx.core.http.HttpServerRequest)20 RestClientRequestImpl (org.apache.servicecomb.common.rest.codec.param.RestClientRequestImpl)16 HttpClientRequest (io.vertx.core.http.HttpClientRequest)14 Endpoint (org.apache.servicecomb.core.Endpoint)10 HashMap (java.util.HashMap)8 URIEndpointObject (org.apache.servicecomb.foundation.common.net.URIEndpointObject)8 HttpServerResponse (io.vertx.core.http.HttpServerResponse)6 SocketAddress (io.vertx.core.net.SocketAddress)6 InvocationStageTrace (org.apache.servicecomb.core.invocation.InvocationStageTrace)6 HttpConnection (io.vertx.core.http.HttpConnection)4 Response (org.apache.servicecomb.swagger.invocation.Response)4 Swagger (io.swagger.models.Swagger)2 MultiMap (io.vertx.core.MultiMap)2 HeadersMultiMap (io.vertx.core.http.impl.headers.HeadersMultiMap)2 SimpleDateFormat (java.text.SimpleDateFormat)2