Search in sources :

Example 21 with Process2

use of com.predic8.membrane.examples.Process2 in project service-proxy by membrane.

the class SOAPProxyValidationTest method test.

@Test
public void test() throws IOException, InterruptedException {
    File baseDir = getExampleDir("validation" + File.separator + "soap-Proxy");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        String url = "http://localhost:2000/axis2/services/BLZService/getBankResponse";
        String[] headers = new String[] { "Content-Type", "application/soap+xml" };
        postAndAssert(200, url, headers, readFileToString(new File(baseDir, "blz-soap.xml")));
        postAndAssert(400, url, headers, readFileToString(new File(baseDir, "invalid-blz-soap.xml")));
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) FileUtils.readFileToString(org.apache.commons.io.FileUtils.readFileToString) File(java.io.File) Test(org.junit.Test)

Example 22 with Process2

use of com.predic8.membrane.examples.Process2 in project service-proxy by membrane.

the class XMLValidationTest method test.

@Test
public void test() throws IOException, InterruptedException {
    File baseDir = getExampleDir("validation" + File.separator + "xml");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        String url = "http://localhost:2000/";
        postAndAssert(200, url, readFileToString(new File(baseDir, "year.xml")));
        postAndAssert(400, url, readFileToString(new File(baseDir, "invalid-year.xml")));
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) FileUtils.readFileToString(org.apache.commons.io.FileUtils.readFileToString) File(java.io.File) Test(org.junit.Test)

Example 23 with Process2

use of com.predic8.membrane.examples.Process2 in project service-proxy by membrane.

the class AntInPath method checkThatAntExecutableIsAvailable.

/**
 * Please make sure that the Apache Ant executable can be found in the PATH.
 */
@Test
public void checkThatAntExecutableIsAvailable() throws IOException, InterruptedException {
    BufferLogger antOutput = new BufferLogger();
    Process2 ant = new Process2.Builder().in(new File(".")).executable("ant -version").withWatcher(antOutput).start();
    Assert.assertEquals(0, ant.waitFor(20000));
    AssertUtils.assertContains("Apache Ant", antOutput.toString());
}
Also used : Process2(com.predic8.membrane.examples.Process2) BufferLogger(com.predic8.membrane.examples.util.BufferLogger) File(java.io.File) Test(org.junit.Test)

Example 24 with Process2

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

Example 25 with Process2

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