use of org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx in project incubator-servicecomb-java-chassis by apache.
the class TestRestServletProducerInvocation method findRestOperationCacheTrue.
@Test
public void findRestOperationCacheTrue(@Mocked HttpServletRequest request, @Mocked HttpServerFilter f1) {
HttpServletRequestEx requestEx = new StandardHttpServletRequestEx(request);
Deencapsulation.setField(restInvocation, "requestEx", requestEx);
new MockUp<RestProducerInvocation>() {
@Mock
void findRestOperation() {
Deencapsulation.setField(getMockInstance(), "restOperationMeta", restOperationMeta);
}
};
List<HttpServerFilter> httpServerFilters = Arrays.asList(f1);
new Expectations() {
{
f1.needCacheRequest(operationMeta);
result = true;
}
};
restInvocation.setHttpServerFilters(httpServerFilters);
restInvocation.findRestOperation();
Assert.assertTrue(Deencapsulation.getField(requestEx, "cacheRequest"));
}
use of org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx in project incubator-servicecomb-java-chassis by apache.
the class ServletRestDispatcher method service.
public void service(HttpServletRequest request, HttpServletResponse response) {
if (transport == null) {
transport = CseContext.getInstance().getTransportManager().findTransport(Const.RESTFUL);
}
// 异步场景
final AsyncContext asyncCtx = request.startAsync();
asyncCtx.addListener(restAsyncListener);
asyncCtx.setTimeout(ServletConfig.getServerTimeout());
HttpServletRequestEx requestEx = new StandardHttpServletRequestEx(request);
HttpServletResponseEx responseEx = new StandardHttpServletResponseEx(response);
RestServletProducerInvocation restProducerInvocation = new RestServletProducerInvocation();
restProducerInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
}
use of org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx in project java-chassis by ServiceComb.
the class ServletRestDispatcher method service.
public void service(HttpServletRequest request, HttpServletResponse response) {
if (transport == null) {
transport = SCBEngine.getInstance().getTransportManager().findTransport(Const.RESTFUL);
microserviceMeta = SCBEngine.getInstance().getProducerMicroserviceMeta();
}
// 异步场景
AsyncContext asyncCtx = request.startAsync();
asyncCtx.addListener(restAsyncListener);
asyncCtx.setTimeout(ServletConfig.getAsyncServletTimeout());
HttpServletRequestEx requestEx = new StandardHttpServletRequestEx(request);
HttpServletResponseEx responseEx = new StandardHttpServletResponseEx(response);
if (SCBEngine.getInstance().isFilterChainEnabled()) {
((StandardHttpServletRequestEx) requestEx).setCacheRequest(true);
InvocationCreator creator = new RestServletProducerInvocationCreator(microserviceMeta, transport.getEndpoint(), requestEx, responseEx);
new RestProducerInvocationFlow(creator, requestEx, responseEx).run();
return;
}
RestServletProducerInvocation restProducerInvocation = new RestServletProducerInvocation();
restProducerInvocation.invoke(transport, requestEx, responseEx, httpServerFilters);
}
use of org.apache.servicecomb.foundation.vertx.http.StandardHttpServletRequestEx in project java-chassis by ServiceComb.
the class TestRestServletProducerInvocation method findRestOperationCacheTrue.
@Test
public void findRestOperationCacheTrue(@Mocked HttpServletRequest request, @Mocked HttpServerFilter f1) {
HttpServletRequestEx requestEx = new StandardHttpServletRequestEx(request);
Deencapsulation.setField(restInvocation, "requestEx", requestEx);
new MockUp<RestProducerInvocation>() {
@Mock
void findRestOperation() {
Deencapsulation.setField(getMockInstance(), "restOperationMeta", restOperationMeta);
}
};
List<HttpServerFilter> httpServerFilters = Arrays.asList(f1);
new Expectations() {
{
f1.needCacheRequest(operationMeta);
result = true;
}
};
restInvocation.setHttpServerFilters(httpServerFilters);
restInvocation.findRestOperation();
Assert.assertTrue(Deencapsulation.getField(requestEx, "cacheRequest"));
}
Aggregations