use of io.vertx.core.http.impl.headers.VertxHttpHeaders in project incubator-servicecomb-java-chassis by apache.
the class ResponseHeaderItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HttpServerResponse mockResponse = Mockito.mock(HttpServerResponse.class);
VertxHttpHeaders headers = new VertxHttpHeaders();
String headerValue = "headerValue";
param.setContextData(mockContext);
headers.add(VAR_NAME, headerValue);
Mockito.when(mockContext.response()).thenReturn(mockResponse);
Mockito.when(mockResponse.headers()).thenReturn(headers);
String result = ELEMENT.getFormattedItem(param);
assertEquals(headerValue, result);
assertEquals(ELEMENT.getVarName(), VAR_NAME);
}
use of io.vertx.core.http.impl.headers.VertxHttpHeaders in project incubator-servicecomb-java-chassis by apache.
the class RequestHeaderItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
param.setContextData(mockContext);
HttpServerRequest mockRequest = Mockito.mock(HttpServerRequest.class);
VertxHttpHeaders headers = new VertxHttpHeaders();
String testValue = "testValue";
headers.add(VAR_NAME, testValue);
Mockito.when(mockContext.request()).thenReturn(mockRequest);
Mockito.when(mockRequest.headers()).thenReturn(headers);
String result = ELEMENT.getFormattedItem(param);
assertEquals(testValue, result);
assertEquals(ELEMENT.getVarName(), VAR_NAME);
}
use of io.vertx.core.http.impl.headers.VertxHttpHeaders in project incubator-servicecomb-java-chassis by apache.
the class RequestHeaderItemTest method getFormattedElementIfNotFound.
@Test
public void getFormattedElementIfNotFound() {
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
param.setContextData(mockContext);
HttpServerRequest mockRequest = Mockito.mock(HttpServerRequest.class);
VertxHttpHeaders headers = new VertxHttpHeaders();
String testValue = "testValue";
headers.add("anotherHeader", testValue);
Mockito.when(mockContext.request()).thenReturn(mockRequest);
Mockito.when(mockRequest.headers()).thenReturn(headers);
String result = ELEMENT.getFormattedItem(param);
assertEquals("-", result);
}
use of io.vertx.core.http.impl.headers.VertxHttpHeaders in project incubator-servicecomb-java-chassis by apache.
the class ResponseHeaderItemTest method getFormattedElementOnNotFound.
@Test
public void getFormattedElementOnNotFound() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HttpServerResponse mockResponse = Mockito.mock(HttpServerResponse.class);
VertxHttpHeaders headers = new VertxHttpHeaders();
String headerValue = "headerValue";
param.setContextData(mockContext);
headers.add("anotherHeader", headerValue);
Mockito.when(mockContext.response()).thenReturn(mockResponse);
Mockito.when(mockResponse.headers()).thenReturn(headers);
String result = ELEMENT.getFormattedItem(param);
assertEquals("-", result);
}
Aggregations