Search in sources :

Example 46 with AccessLogParam

use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.

the class LocalPortItemTest 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 = new LocalPortItem().getFormattedItem(param);
    assertEquals("-", result);
}
Also used : RoutingContext(io.vertx.ext.web.RoutingContext) AccessLogParam(org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam) HttpServerRequest(io.vertx.core.http.HttpServerRequest) Test(org.junit.Test)

Example 47 with AccessLogParam

use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.

the class QueryStringItemTest 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 QueryStringItem().getFormattedItem(param);
    assertEquals("-", result);
}
Also used : RoutingContext(io.vertx.ext.web.RoutingContext) AccessLogParam(org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam) Test(org.junit.Test)

Example 48 with AccessLogParam

use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.

the class QueryStringItemTest method getFormattedElementOnQueryIsEmpty.

@Test
public void getFormattedElementOnQueryIsEmpty() {
    AccessLogParam<RoutingContext> param = new AccessLogParam<>();
    RoutingContext context = Mockito.mock(RoutingContext.class);
    HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
    String query = "";
    param.setContextData(context);
    Mockito.when(context.request()).thenReturn(request);
    Mockito.when(request.query()).thenReturn(query);
    String result = new QueryStringItem().getFormattedItem(param);
    assertEquals("-", result);
}
Also used : RoutingContext(io.vertx.ext.web.RoutingContext) AccessLogParam(org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam) HttpServerRequest(io.vertx.core.http.HttpServerRequest) Test(org.junit.Test)

Example 49 with AccessLogParam

use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.

the class RemoteHostItemTest method getFormattedElementOnHostIsEmpty.

@Test
public void getFormattedElementOnHostIsEmpty() {
    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 = "";
    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("-", result);
}
Also used : RoutingContext(io.vertx.ext.web.RoutingContext) AccessLogParam(org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam) HttpServerRequest(io.vertx.core.http.HttpServerRequest) SocketAddress(io.vertx.core.net.SocketAddress) Test(org.junit.Test)

Example 50 with AccessLogParam

use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.

the class RemoteHostItemTest method getFormattedElementOnHostIsNull.

@Test
public void getFormattedElementOnHostIsNull() {
    AccessLogParam<RoutingContext> param = new AccessLogParam<>();
    RoutingContext context = Mockito.mock(RoutingContext.class);
    HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
    SocketAddress address = Mockito.mock(SocketAddress.class);
    param.setContextData(context);
    Mockito.when(context.request()).thenReturn(request);
    Mockito.when(request.remoteAddress()).thenReturn(address);
    Mockito.when(address.host()).thenReturn(null);
    String result = ELEMENT.getFormattedItem(param);
    assertEquals("-", result);
}
Also used : RoutingContext(io.vertx.ext.web.RoutingContext) AccessLogParam(org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam) HttpServerRequest(io.vertx.core.http.HttpServerRequest) SocketAddress(io.vertx.core.net.SocketAddress) Test(org.junit.Test)

Aggregations

RoutingContext (io.vertx.ext.web.RoutingContext)51 AccessLogParam (org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam)51 Test (org.junit.Test)51 HttpServerRequest (io.vertx.core.http.HttpServerRequest)26 SocketAddress (io.vertx.core.net.SocketAddress)7 HttpServerResponse (io.vertx.core.http.HttpServerResponse)6 VertxHttpHeaders (io.vertx.core.http.impl.headers.VertxHttpHeaders)4 Cookie (io.vertx.ext.web.Cookie)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 CookieImpl (io.vertx.ext.web.impl.CookieImpl)2 RestProducerInvocation (org.apache.servicecomb.common.rest.RestProducerInvocation)2 Invocation (org.apache.servicecomb.core.Invocation)2