use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class OAuth2AuthorizationServerInterceptorBase method getMockAuthRequestExchange.
public static Callable<Exchange> getMockAuthRequestExchange() throws Exception {
return new Callable<Exchange>() {
@Override
public Exchange call() throws Exception {
Exchange exc = new Request.Builder().get(mas.getLoginURL("123security", "http://localhost:2001/", "/")).buildExchange();
exc.getRequest().getHeader().add("Cookie", oasi.getSessionManager().getCookieName() + "=" + OAuth2TestUtil.sessionId);
return exc;
}
};
}
use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class OAuth2AuthorizationServerInterceptorBase method getMockEmptyEndpointRequest.
public static Callable<Exchange> getMockEmptyEndpointRequest() throws Exception {
return new Callable<Exchange>() {
@Override
public Exchange call() throws Exception {
Exchange exc = new Request.Builder().get("/").buildExchange();
exc.getRequest().getHeader().add("Cookie", oasi.getSessionManager().getCookieName() + "=" + OAuth2TestUtil.sessionId);
OAuth2TestUtil.makeExchangeValid(exc);
return exc;
}
};
}
use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class OAuth2TestUtil method makeExchangeValid.
public static void makeExchangeValid(Exchange exc) throws Exception {
exc.setOriginalRequestUri(exc.getRequest().getUri());
exc.setRule(new NullRule());
}
use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class ResolverTestTriggerTest method handleRequest.
@Override
public Outcome handleRequest(Exchange exc) {
try {
Class<?> clazz = Class.forName("com.predic8.membrane.core.resolver.ResolverTest");
clazz.getField("deployment").set(null, "J2EE");
Object value = router.getResolverMap().getFileSchemaResolver();
Object resolverMap = clazz.getField("resolverMap").get(null);
resolverMap.getClass().getMethod("addSchemaResolver", SchemaResolver.class).invoke(resolverMap, value);
Parameterized p = new Parameterized(clazz);
JUnitCore c = new JUnitCore();
Result run = c.run(Request.runner(p));
StringBuilder sb = new StringBuilder();
sb.append(MAGIC);
for (Failure f : run.getFailures()) {
sb.append(f.toString());
StringWriter stringWriter = new StringWriter();
f.getException().printStackTrace(new PrintWriter(stringWriter));
sb.append(stringWriter.toString());
sb.append("\n");
sb.append("\n");
}
exc.setResponse(Response.ok().header(Header.CONTENT_TYPE, MimeType.TEXT_PLAIN_UTF8).body(sb.toString()).build());
} catch (Throwable t) {
LOG.error(t.getMessage(), t);
}
return Outcome.RETURN;
}
use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class AbstractExchangeSnapshot method toAbstractExchange.
public AbstractExchange toAbstractExchange() {
Exchange exc = new Exchange(null);
if (getRequest() != null)
exc.setRequest(this.getRequest().toRequest());
if (getResponse() != null)
exc.setResponse(this.getResponse().toResponse());
exc.setOriginalRequestUri(getOriginalRequestUri());
exc.setTime(getTime());
exc.setErrorMessage(getErrorMessage());
exc.setStatus(getStatus());
exc.setTimeReqSent(getTimeReqSent());
exc.setTimeReqReceived(getTimeReqReceived());
exc.setTimeResSent(getTimeResSent());
exc.setTimeResReceived(getTimeResReceived());
exc.setDestinations(getDestinations().stream().collect(Collectors.toList()));
exc.setRemoteAddr(getRemoteAddr());
exc.setRemoteAddrIp(getRemoteAddrIp());
exc.setId(getId());
exc.setRule(getRule());
setServer(getServer());
return exc;
}
Aggregations