use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class InterceptorInvocationTest method createRouter.
private HttpRouter createRouter() throws Exception {
HttpRouter router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(createServiceProxy());
addMockInterceptors(router, regularInterceptorNames);
router.init();
return router;
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class ConnectionTest method setUp.
@Before
public void setUp() throws Exception {
Rule rule2000 = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 2000), "predic8.com", 80);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule2000);
conLocalhost = Connection.open("localhost", 2000, null, null, 30000);
con127_0_0_1 = Connection.open("127.0.0.1", 2000, null, null, 30000);
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class EmbeddingJava method main.
public static void main(String[] args) throws Exception {
String hostname = "*";
String method = "GET";
String path = ".*";
int listenPort = 4000;
ServiceProxyKey key = new ServiceProxyKey(hostname, method, path, listenPort);
String targetHost = "predic8.com";
int targetPort = 80;
ServiceProxy sp = new ServiceProxy(key, targetHost, targetPort);
sp.getInterceptors().add(new AddMyHeaderInterceptor());
HttpRouter router = new HttpRouter();
router.add(sp);
router.init();
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class EtcdBasedConfigurator method setUpModuleServiceProxy.
private ServiceProxy setUpModuleServiceProxy(String name, int port, String path) {
log.info("Creating serviceProxy for module: " + path);
ServiceProxyKey key = new ServiceProxyKey("*", "*", path, port);
key.setUsePathPattern(true);
key.setPathRegExp(false);
ServiceProxy sp = new ServiceProxy(key, null, 0);
sp.getInterceptors().add(new LoadBalancingInterceptor());
try {
sp.init(router);
router.add(sp);
runningServiceProxyForModule.put(path, sp);
} catch (Exception ignored) {
}
return sp;
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class ConfigSerializationTest method doit.
@Test
public void doit() throws Exception {
try {
String config = FileUtils.readFileToString(new File(configFile));
Object o = MCUtil.fromXML(Router.class, config);
String xml = MCUtil.toXML(o);
// prettyPrint(xml);
// System.out.println(xml);
AssertUtils.assertContainsNot("incomplete serialization", xml);
Router r2 = MCUtil.fromXML(Router.class, xml);
String xml2 = MCUtil.toXML(r2);
XMLAssert.assertXMLEqual(xml2, xml);
} catch (Exception e) {
throw new Exception("in test " + configFile, e);
}
}
Aggregations