Search in sources :

Example 16 with Process2

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();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) File(java.io.File) Test(org.junit.Test)

Example 17 with Process2

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);
}
Also used : SubstringWaitableConsoleEvent(com.predic8.membrane.examples.util.SubstringWaitableConsoleEvent)

Example 18 with Process2

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();
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) Process2(com.predic8.membrane.examples.Process2) File(java.io.File) Test(org.junit.Test)

Example 19 with Process2

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();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) File(java.io.File) Test(org.junit.Test)

Example 20 with Process2

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();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) AssertUtils.replaceInFile(com.predic8.membrane.test.AssertUtils.replaceInFile) File(java.io.File) Test(org.junit.Test)

Aggregations

Process2 (com.predic8.membrane.examples.Process2)37 Test (org.junit.Test)36 File (java.io.File)30 BufferLogger (com.predic8.membrane.examples.util.BufferLogger)4 SubstringWaitableConsoleEvent (com.predic8.membrane.examples.util.SubstringWaitableConsoleEvent)4 ProxiesXmlUtil (com.predic8.membrane.examples.ProxiesXmlUtil)3 FileUtils.readFileToString (org.apache.commons.io.FileUtils.readFileToString)3 AssertUtils.replaceInFile (com.predic8.membrane.test.AssertUtils.replaceInFile)2 OtpProvider (com.predic8.membrane.core.interceptor.authentication.session.totp.OtpProvider)1 FilenameFilter (java.io.FilenameFilter)1 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)1