use of com.predic8.membrane.examples.Process2 in project service-proxy by membrane.
the class REST2SOAPJSONTest method test.
@Test
public void test() throws IOException, InterruptedException {
File baseDir = getExampleDir("rest2soap-json");
AssertUtils.replaceInFile(new File(baseDir, "proxies.xml"), "2000", "2043");
Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
try {
assertContains("\"bic\":\"COLSDE33XXX\"", getAndAssert200("http://localhost:2043/bank/37050198", new String[] { "Accept", "application/json" }));
assertContains("\"bic\":\"GENODE61KIR\"", getAndAssert200("http://localhost:2043/bank/66762332", new String[] { "Accept", "application/json" }));
} finally {
sl.killScript();
}
}
use of com.predic8.membrane.examples.Process2 in project service-proxy by membrane.
the class ProxiesXmlUtil method updateWith.
public void updateWith(String proxiesXmlContent, Process2 sl) throws IOException {
SubstringWaitableConsoleEvent reloaded = new SubstringWaitableConsoleEvent(sl, "Spring Hot Deployment Thread started.");
FileUtils.writeStringToFile(proxiesXml, proxiesXmlContent);
reloaded.waitFor(10000);
}
use of com.predic8.membrane.examples.Process2 in project service-proxy by membrane.
the class FileExchangeStoreTest method test.
@Test
public void test() throws IOException, InterruptedException {
File baseDir = getExampleDir("file-exchangestore");
Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
try {
getAndAssert200("http://localhost:2000/");
Thread.sleep(1000);
File exchangesDir = new File(baseDir, "exchanges");
if (!containsRecursively(exchangesDir, new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".msg");
}
}))
throw new AssertionError("Did not find *.msg in exchanges dir.");
} finally {
sl.killScript();
}
}
use of com.predic8.membrane.examples.Process2 in project service-proxy by membrane.
the class BasicAuthTest method test.
@Test
public void test() throws IOException, InterruptedException {
File baseDir = getExampleDir("basic-auth");
Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
try {
disableHTTPAuthentication();
getAndAssert(401, CUSTOMER_HOST_LOCAL + CUSTOMER_PATH);
setupHTTPAuthentication("localhost", 2000, "alice", "membrane");
getAndAssert200(CUSTOMER_HOST_LOCAL + CUSTOMER_PATH);
} finally {
sl.killScript();
}
}
use of com.predic8.membrane.examples.Process2 in project service-proxy by membrane.
the class RoutingTest method test.
@Test
public void test() throws IOException, InterruptedException {
File base = getExampleDir("versioning/routing");
String[] header = new String[] { "Content-Type", "text/xml" };
String request_v11 = FileUtils.readFileToString(new File(base, "request_v11.xml"));
String request_v20 = FileUtils.readFileToString(new File(base, "request_v20.xml"));
replaceInFile(new File(base, "proxies.xml"), "8080", "3024");
replaceInFile(new File(base, "proxies.xml"), "2000", "3025");
replaceInFile(new File(base, "src/com/predic8/contactservice/Launcher.java"), "8080", "3024");
Process2 sl = new Process2.Builder().in(base).script("service-proxy").waitForMembrane().start();
try {
Process2 antNode1 = new Process2.Builder().in(base).waitAfterStartFor("run:").executable("ant run").start();
try {
// wait for Endpoints to start
Thread.sleep(2000);
// directly talk to versioned endpoints
assertContains("1.1", postAndAssert(200, "http://localhost:3024/ContactService/v11", header, request_v11));
assertContains("2.0", postAndAssert(200, "http://localhost:3024/ContactService/v20", header, request_v20));
// talk to wrong endpoint
postAndAssert(500, "http://localhost:3024/ContactService/v20", header, request_v11);
// talk to proxy
assertContains("1.1", postAndAssert(200, "http://localhost:3025/ContactService", header, request_v11));
assertContains("2.0", postAndAssert(200, "http://localhost:3025/ContactService", header, request_v20));
} finally {
antNode1.killScript();
}
} finally {
sl.killScript();
}
}
Aggregations