Search in sources :

Example 51 with Service

use of com.predic8.wsdl.Service in project service-proxy by membrane.

the class ProxyTest method test.

@Test
public void test() throws IOException, InterruptedException {
    File baseDir = getExampleDir("proxy");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        getAndAssert200("http://localhost:2000/axis2/services/BLZService?wsdl");
        getAndAssert200("http://localhost:2001/axis2/services/BLZService?wsdl");
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) File(java.io.File) Test(org.junit.Test)

Example 52 with Service

use of com.predic8.wsdl.Service in project service-proxy by membrane.

the class QuickstartRESTTest method doit.

@Test
public void doit() throws IOException, InterruptedException {
    File baseDir = getExampleDir("quickstart-rest");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        String result = getAndAssert200("http://localhost:2000/restnames/name.groovy?name=Pia");
        assertContains("Italy", result);
        AssertUtils.closeConnections();
        new ProxiesXmlUtil(new File(baseDir, "proxies.xml")).updateWith("<spring:beans xmlns=\"http://membrane-soa.org/proxies/1/\"\r\n" + "	xmlns:spring=\"http://www.springframework.org/schema/beans\"\r\n" + "	xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n" + "	xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd\r\n" + "					    http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd\">\r\n" + "\r\n" + "	<router>\r\n" + "\r\n" + "       <serviceProxy name=\"names\" port=\"2000\">\r\n" + "         <path isRegExp=\"true\">/(rest)?names.*</path>\r\n" + "         <rewriter>\r\n" + "           <map from=\"/names/(.*)\" to=\"/restnames/name\\.groovy\\?name=$1\" />\r\n" + "         </rewriter>\r\n" + "         <statisticsCSV file=\"log.csv\" />\r\n" + "         <response>\r\n" + "           <regExReplacer regex=\"\\s*,\\s*&lt;\" replace=\"&lt;\" />\r\n" + "           <transform xslt=\"restnames.xsl\" />\r\n" + "         </response>\r\n" + "         <target host=\"thomas-bayer.com\" port=\"80\" />\r\n" + "       </serviceProxy>\r\n" + "     \r\n" + "       <serviceProxy name=\"Console\" port=\"9000\">\r\n" + "         <basicAuthentication>\r\n" + "           <user name=\"alice\" password=\"membrane\" />\r\n" + "         </basicAuthentication>			\r\n" + "         <adminConsole />\r\n" + "       </serviceProxy>	\r\n" + "     </router>\r\n" + "</spring:beans>", sl);
        result = getAndAssert200("http://localhost:2000/names/Pia");
        assertContains("Italy, Spain", result);
        assertContainsNot(",<", result);
        String csvLog = FileUtils.readFileToString(new File(baseDir, "log.csv"));
        assertContains("Pia", csvLog);
        AssertUtils.setupHTTPAuthentication("localhost", 9000, "alice", "membrane");
        result = getAndAssert200("http://localhost:9000/admin/");
        assertContains("ServiceProxies", result);
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) ProxiesXmlUtil(com.predic8.membrane.examples.ProxiesXmlUtil) File(java.io.File) Test(org.junit.Test)

Example 53 with Service

use of com.predic8.wsdl.Service in project service-proxy by membrane.

the class SSLServer method test.

@Test
public void test() throws IOException, InterruptedException, NoSuchAlgorithmException, KeyManagementException {
    File baseDir = getExampleDir("ssl-server");
    AssertUtils.replaceInFile(new File(baseDir, "proxies.xml"), "443", "3023");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        AssertUtils.trustAnyHTTPSServer(3023);
        assertContains("wsdl:documentation", getAndAssert200("https://localhost:3023/axis2/services/BLZService?wsdl"));
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) File(java.io.File) Test(org.junit.Test)

Example 54 with Service

use of com.predic8.wsdl.Service in project service-proxy by membrane.

the class FormValidationTest method test.

@Test
public void test() throws IOException, InterruptedException {
    File baseDir = getExampleDir("validation" + File.separator + "form");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        getAndAssert(400, "http://localhost:2000/?name=Abcde0");
        getAndAssert(200, "http://localhost:2000/?name=Abcde");
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) File(java.io.File) Test(org.junit.Test)

Example 55 with Service

use of com.predic8.wsdl.Service in project service-proxy by membrane.

the class XSLTTest method test.

@Test
public void test() throws IOException, InterruptedException {
    File baseDir = getExampleDir("xslt");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        String result = getAndAssert200(BasicAuthTest.CUSTOMER_HOST_REMOTE + BasicAuthTest.CUSTOMER_PATH);
        AssertUtils.assertContains("FIRSTNAME", result);
        result = getAndAssert200(BasicAuthTest.CUSTOMER_HOST_LOCAL + BasicAuthTest.CUSTOMER_PATH);
        AssertUtils.assertContains("first", result);
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) File(java.io.File) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)39 Process2 (com.predic8.membrane.examples.Process2)35 File (java.io.File)29 StringWriter (java.io.StringWriter)5 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)4 Rule (com.predic8.membrane.core.rules.Rule)4 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)4 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)3 HttpRouter (com.predic8.membrane.core.HttpRouter)3 ProxiesXmlUtil (com.predic8.membrane.examples.ProxiesXmlUtil)3 BufferLogger (com.predic8.membrane.examples.util.BufferLogger)3 SubstringWaitableConsoleEvent (com.predic8.membrane.examples.util.SubstringWaitableConsoleEvent)3 Definitions (com.predic8.wsdl.Definitions)3 Port (com.predic8.wsdl.Port)3 Service (com.predic8.wsdl.Service)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Exchange (com.predic8.membrane.core.exchange.Exchange)2 Request (com.predic8.membrane.core.http.Request)2 Response (com.predic8.membrane.core.http.Response)2