Search in sources :

Example 1 with AccessLogParam

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

the class CookieItemTest method getFormattedElementOnCookieCountIsZero.

@Test
public void getFormattedElementOnCookieCountIsZero() {
    AccessLogParam<RoutingContext> param = new AccessLogParam<>();
    RoutingContext mockContext = Mockito.mock(RoutingContext.class);
    HashSet<Cookie> cookieSet = new HashSet<>();
    Mockito.when(mockContext.cookieCount()).thenReturn(0);
    Mockito.when(mockContext.cookies()).thenReturn(cookieSet);
    param.setContextData(mockContext);
    String result = ELEMENT.getFormattedItem(param);
    Assert.assertEquals("-", result);
}
Also used : Cookie(io.vertx.ext.web.Cookie) RoutingContext(io.vertx.ext.web.RoutingContext) AccessLogParam(org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with AccessLogParam

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

the class CookieItemTest method getFormattedElementOnNotFound.

@Test
public void getFormattedElementOnNotFound() {
    AccessLogParam<RoutingContext> param = new AccessLogParam<>();
    RoutingContext mockContext = Mockito.mock(RoutingContext.class);
    HashSet<Cookie> cookieSet = new HashSet<>();
    String cookieValue = "cookieValue";
    CookieImpl cookie = new CookieImpl("anotherCookieName", cookieValue);
    cookieSet.add(cookie);
    Mockito.when(mockContext.cookieCount()).thenReturn(1);
    Mockito.when(mockContext.cookies()).thenReturn(cookieSet);
    param.setContextData(mockContext);
    String result = ELEMENT.getFormattedItem(param);
    Assert.assertEquals("-", result);
}
Also used : Cookie(io.vertx.ext.web.Cookie) RoutingContext(io.vertx.ext.web.RoutingContext) CookieImpl(io.vertx.ext.web.impl.CookieImpl) AccessLogParam(org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with AccessLogParam

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

the class CookieItemTest method getFormattedElement.

@Test
public void getFormattedElement() {
    AccessLogParam<RoutingContext> param = new AccessLogParam<>();
    RoutingContext mockContext = Mockito.mock(RoutingContext.class);
    HashSet<Cookie> cookieSet = new HashSet<>();
    String cookieValue = "cookieValue";
    CookieImpl cookie = new CookieImpl(COOKIE_NAME, cookieValue);
    cookieSet.add(cookie);
    Mockito.when(mockContext.cookieCount()).thenReturn(1);
    Mockito.when(mockContext.cookies()).thenReturn(cookieSet);
    param.setContextData(mockContext);
    String result = ELEMENT.getFormattedItem(param);
    Assert.assertEquals(cookieValue, result);
}
Also used : Cookie(io.vertx.ext.web.Cookie) RoutingContext(io.vertx.ext.web.RoutingContext) CookieImpl(io.vertx.ext.web.impl.CookieImpl) AccessLogParam(org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with AccessLogParam

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

the class RequestProtocolItemTest method getFormattedElementOnVersionIsNull.

@Test
public void getFormattedElementOnVersionIsNull() {
    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.version()).thenReturn(null);
    String result = new RequestProtocolItem().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 5 with AccessLogParam

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

the class RequestProtocolItemTest 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 RequestProtocolItem().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)

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