use of com.predic8.wsdl.Service in project service-proxy by membrane.
the class GroovyInterceptor method logGroovyException.
private void logGroovyException(Flow flow, Exception e) {
try {
ServiceProxy sp = getRule();
log.error("Exception in Groovy script in service proxy '" + sp.getName() + "' on port " + sp.getPort() + " with path " + (sp.getPath() != null ? sp.getPath().getValue() : "*"));
if (flow != null)
log.error("Flow: " + flow.name());
else
log.error("There is possibly a syntax error in the groovy script (compilation error)");
} catch (NoSuchElementException e2) {
// ignore - logging should not break anything
} finally {
e.printStackTrace();
}
}
use of com.predic8.wsdl.Service in project service-proxy by membrane.
the class DefaultConfigTest method test.
@Test
public void test() throws IOException, InterruptedException {
File baseDir = getMembraneHome();
File proxies = new File(baseDir, "conf/proxies.xml");
File proxiesFull = new File(baseDir, "conf/proxies-full-sample.xml");
replaceInFile(proxies, "9000", "2003");
replaceInFile(proxiesFull, "9000", "2003");
Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
try {
setupHTTPAuthentication("localhost", 2003, "admin", "membrane");
assertContains("Membrane Service Proxy Administration", getAndAssert200("http://localhost:2003/admin/"));
ProxiesXmlUtil pxu = new ProxiesXmlUtil(proxies);
pxu.updateWith(FileUtils.readFileToString(proxiesFull), sl);
setupHTTPAuthentication("localhost", 2001, "admin", "membrane");
assertContains("Routing Configuration", getAndAssert200("http://localhost:2001/static/proxies.xml"));
} finally {
sl.killScript();
}
}
use of com.predic8.wsdl.Service in project service-proxy by membrane.
the class CBRTest method test.
@Test
public void test() throws IOException, InterruptedException {
File baseDir = getExampleDir("cbr");
Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
try {
String result = postAndAssert200("http://localhost:2000/shop", FileUtils.readFileToString(new File(baseDir, "order.xml")));
assertContains("Normal order received.", result);
result = postAndAssert200("http://localhost:2000/shop", FileUtils.readFileToString(new File(baseDir, "express.xml")));
assertContains("Express order received.", result);
result = postAndAssert200("http://localhost:2000/shop", FileUtils.readFileToString(new File(baseDir, "import.xml")));
assertContains("Order contains import items.", result);
} finally {
sl.killScript();
}
}
use of com.predic8.wsdl.Service in project service-proxy by membrane.
the class LoadBalancerBasic1Test method test.
@Test
public void test() throws IOException, InterruptedException {
File base = getExampleDir("loadbalancer-basic-1");
AssertUtils.replaceInFile(new File(base, "proxies.xml"), "8080", "3023");
Process2 sl = new Process2.Builder().in(base).script("service-proxy").waitForMembrane().start();
try {
assertEquals(1, LoadBalancerUtil.getRespondingNode("http://localhost:4000/"));
assertEquals(2, LoadBalancerUtil.getRespondingNode("http://localhost:4001/"));
assertEquals(3, LoadBalancerUtil.getRespondingNode("http://localhost:4002/"));
addLBNodeViaHTML("http://localhost:9000/admin/", "localhost", 4000);
addLBNodeViaHTML("http://localhost:9000/admin/", "localhost", 4001);
Thread.sleep(1000);
assertEquals(1, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(2, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(1, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(2, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
getAndAssert(204, "http://localhost:9010/clustermanager/up?host=localhost&port=4002");
AssertUtils.assertContains("localhost:4002", getAndAssert200("http://localhost:9000/admin/clusters/show?cluster=Default"));
assertEquals(3, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(1, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(2, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(3, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
} finally {
sl.killScript();
}
}
use of com.predic8.wsdl.Service in project service-proxy by membrane.
the class LoadBalancerClient2Test method test.
@Test
public void test() throws IOException, InterruptedException {
File base = getExampleDir("loadbalancer-client-2");
AssertUtils.replaceInFile(new File(base, "proxies.xml"), "8080", "3023");
AssertUtils.replaceInFile(new File(base, "lb-client-secured.proxies.xml"), "8080", "3023");
Process2 sl = new Process2.Builder().in(base).script("service-proxy").waitForMembrane().start();
try {
assertEquals(1, LoadBalancerUtil.getRespondingNode("http://localhost:4000/"));
assertEquals(2, LoadBalancerUtil.getRespondingNode("http://localhost:4001/"));
assertEquals(3, LoadBalancerUtil.getRespondingNode("http://localhost:4002/"));
addNodeViaScript(base, "localhost", 4000);
Thread.sleep(1000);
assertNodeStatus(getAndAssert200("http://localhost:9000/admin/clusters/show?cluster=Default"), "localhost", 4000, "UP");
addNodeViaScript(base, "localhost", 4001);
addNodeViaScript(base, "localhost", 4002);
Thread.sleep(100);
assertEquals(1, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(2, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(3, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
removeNodeViaScript(base, "localhost", 4000);
Thread.sleep(100);
assertEquals(2, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
assertEquals(3, LoadBalancerUtil.getRespondingNode("http://localhost:3023/service"));
} finally {
sl.killScript();
}
sl = new Process2.Builder().in(base).script("service-proxy-secured").waitForMembrane().start();
try {
// 1 indicates failure
controlNodeViaScript(1, base, "up", "localhost", 4000);
File propFile = new File(base, "client.properties");
writeStringToFile(propFile, readFileToString(propFile).replace("#", ""));
Thread.sleep(1000);
addNodeViaScript(base, "localhost", 4000);
Thread.sleep(1000);
AssertUtils.setupHTTPAuthentication("localhost", 9000, "admin", "admin");
AssertUtils.assertContains("localhost:4000", getAndAssert200("http://localhost:9000/admin/clusters/show?cluster=Default"));
} finally {
sl.killScript();
}
}
Aggregations