use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class QueryStringItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
String query = "?status=up";
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.query()).thenReturn(query);
String result = new QueryStringItem().getFormattedItem(param);
assertEquals(query, result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class QueryStringItemTest method getFormattedElementOnQueryIsNull.
@Test
public void getFormattedElementOnQueryIsNull() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.query()).thenReturn(null);
String result = new QueryStringItem().getFormattedItem(param);
assertEquals("-", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class RemoteHostItemTest method getFormattedElementOnRemoteAddressIsNull.
@Test
public void getFormattedElementOnRemoteAddressIsNull() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.remoteAddress()).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 RemoteHostItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress address = Mockito.mock(SocketAddress.class);
String remoteHost = "remoteHost";
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.remoteAddress()).thenReturn(address);
Mockito.when(address.host()).thenReturn(remoteHost);
String result = ELEMENT.getFormattedItem(param);
assertEquals(remoteHost, result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class RemoteHostItemTest 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);
}
Aggregations