use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class ResponseHeaderItemTest method getFormattedElementOnResponseIsNull.
@Test
public void getFormattedElementOnResponseIsNull() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
param.setContextData(mockContext);
Mockito.when(mockContext.response()).thenReturn(null);
String result = ELEMENT.getFormattedItem(param);
assertEquals("-", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class ResponseSizeItemTest method getFormattedElementOnResponseIsNull.
@Test
public void getFormattedElementOnResponseIsNull() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
param.setContextData(mockContext);
Mockito.when(mockContext.response()).thenReturn(null);
String result = ELEMENT.getFormattedItem(param);
assertEquals("0", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class ResponseSizeItemTest method getFormattedElementOnBytesWrittenIsZero.
@Test
public void getFormattedElementOnBytesWrittenIsZero() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HttpServerResponse mockResponse = Mockito.mock(HttpServerResponse.class);
long bytesWritten = 0L;
param.setContextData(mockContext);
Mockito.when(mockContext.response()).thenReturn(mockResponse);
Mockito.when(mockResponse.bytesWritten()).thenReturn(bytesWritten);
String result = ELEMENT.getFormattedItem(param);
assertEquals("0", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class ResponseSizeItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HttpServerResponse mockResponse = Mockito.mock(HttpServerResponse.class);
long bytesWritten = 16L;
param.setContextData(mockContext);
Mockito.when(mockContext.response()).thenReturn(mockResponse);
Mockito.when(mockResponse.bytesWritten()).thenReturn(bytesWritten);
String result = ELEMENT.getFormattedItem(param);
assertEquals(String.valueOf(bytesWritten), result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class StatusItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerResponse response = Mockito.mock(HttpServerResponse.class);
int statusCode = 200;
param.setContextData(context);
Mockito.when(context.response()).thenReturn(response);
Mockito.when(response.getStatusCode()).thenReturn(statusCode);
String result = STATUS_ELEMENT.getFormattedItem(param);
assertEquals("200", result);
}
Aggregations