use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class FirstLineOfRequestItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
String uri = "/test/uri";
param.setContextData(mockContext);
Mockito.when(mockContext.request()).thenReturn(request);
Mockito.when(request.method()).thenReturn(HttpMethod.DELETE);
Mockito.when(request.path()).thenReturn(uri);
Mockito.when(request.version()).thenReturn(HttpVersion.HTTP_1_1);
String result = ELEMENT.getFormattedItem(param);
assertEquals("\"DELETE " + uri + " HTTP/1.1\"", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class LocalHostItemTest method getFormattedElementOnLocalAddressIsNull.
@Test
public void getFormattedElementOnLocalAddressIsNull() {
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.localAddress()).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 getFormattedElementOnHostIsNull.
@Test
public void getFormattedElementOnHostIsNull() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
SocketAddress localAddress = Mockito.mock(SocketAddress.class);
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.localAddress()).thenReturn(localAddress);
Mockito.when(localAddress.host()).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 LocalPortItemTest 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 = new LocalPortItem().getFormattedItem(param);
assertEquals("-", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class LocalPortItemTest 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);
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.localAddress()).thenReturn(localAddress);
Mockito.when(localAddress.port()).thenReturn(8080);
String result = new LocalPortItem().getFormattedItem(param);
assertEquals("8080", result);
}
Aggregations