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();
}
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);
}
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();
}
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();
}
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();
}
Aggregations