Search in sources :

Example 1 with SubstringWaitableConsoleEvent

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

the class CustomInterceptorTest method test.

@Test
public void test() throws IOException, InterruptedException {
    File baseDir = getExampleDir("custom-interceptor");
    BufferLogger b = new BufferLogger();
    Process2 ant = new Process2.Builder().in(baseDir).executable("ant compile").withWatcher(b).start();
    try {
        int exitCode = ant.waitFor(60000);
        if (exitCode != 0)
            throw new RuntimeException("Ant exited with code " + exitCode + ": " + b.toString());
    } finally {
        ant.killScript();
    }
    FileUtils.copyDirectoryToDirectory(new File(baseDir, "build/classes"), getMembraneHome());
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        SubstringWaitableConsoleEvent invoked = new SubstringWaitableConsoleEvent(sl, "MyInterceptor invoked");
        getAndAssert200("http://localhost:2000/");
        assertTrue(invoked.occurred());
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) BufferLogger(com.predic8.membrane.examples.util.BufferLogger) File(java.io.File) SubstringWaitableConsoleEvent(com.predic8.membrane.examples.util.SubstringWaitableConsoleEvent) Test(org.junit.Test)

Example 2 with SubstringWaitableConsoleEvent

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

the class GroovyTest method test.

@Test
public void test() throws IOException, InterruptedException {
    Process2 sl = new Process2.Builder().in(getExampleDir("groovy")).script("service-proxy").waitForMembrane().start();
    try {
        SubstringWaitableConsoleEvent groovyCalled = new SubstringWaitableConsoleEvent(sl, "X-Groovy header added with value :Groovy interceptor");
        getAndAssert200("http://localhost:2000/");
        assertTrue(groovyCalled.occurred());
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) SubstringWaitableConsoleEvent(com.predic8.membrane.examples.util.SubstringWaitableConsoleEvent) Test(org.junit.Test)

Example 3 with SubstringWaitableConsoleEvent

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

the class LoggingTest method test.

@Test
public void test() throws IOException, InterruptedException {
    Process2 sl = new Process2.Builder().in(getExampleDir("logging")).script("service-proxy").waitForMembrane().start();
    try {
        SubstringWaitableConsoleEvent logged = new SubstringWaitableConsoleEvent(sl, "HTTP/1.1");
        AssertUtils.getAndAssert200("http://localhost:2000/");
        assertEquals(true, logged.occurred());
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) SubstringWaitableConsoleEvent(com.predic8.membrane.examples.util.SubstringWaitableConsoleEvent) Test(org.junit.Test)

Example 4 with SubstringWaitableConsoleEvent

use of com.predic8.membrane.examples.util.SubstringWaitableConsoleEvent 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)

Aggregations

SubstringWaitableConsoleEvent (com.predic8.membrane.examples.util.SubstringWaitableConsoleEvent)4 Process2 (com.predic8.membrane.examples.Process2)3 Test (org.junit.Test)3 BufferLogger (com.predic8.membrane.examples.util.BufferLogger)1 File (java.io.File)1