use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class HttpMethodItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
RoutingContext routingContext = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
Mockito.when(routingContext.request()).thenReturn(request);
Mockito.when(request.method()).thenReturn(HttpMethod.DELETE);
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
param.setContextData(routingContext);
Assert.assertEquals("DELETE", new HttpMethodItem().getFormattedItem(param));
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class HttpMethodItemTest method getFormattedElementOnRequestIsNull.
@Test
public void getFormattedElementOnRequestIsNull() {
RoutingContext routingContext = Mockito.mock(RoutingContext.class);
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
param.setContextData(routingContext);
Mockito.when(routingContext.request()).thenReturn(null);
Assert.assertEquals("-", new HttpMethodItem().getFormattedItem(param));
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class LocalHostItemTest method getFormattedElementIsEmpty.
@Test
public void getFormattedElementIsEmpty() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress localAddress = Mockito.mock(SocketAddress.class);
String localHost = "";
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.localAddress()).thenReturn(localAddress);
Mockito.when(localAddress.host()).thenReturn(localHost);
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 LocalHostItemTest method getFormattedElementOnRequestIsNull.
@Test
public void getFormattedElementOnRequestIsNull() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
param.setContextData(context);
Mockito.when(context.request()).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 LocalHostItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress localAddress = Mockito.mock(SocketAddress.class);
String localHost = "testHost";
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.localAddress()).thenReturn(localAddress);
Mockito.when(localAddress.host()).thenReturn(localHost);
String result = ELEMENT.getFormattedItem(param);
assertEquals(localHost, result);
}
Aggregations