Search in sources :

Example 26 with Path

use of com.predic8.membrane.core.config.Path 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 27 with Path

use of com.predic8.membrane.core.config.Path 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 28 with Path

use of com.predic8.membrane.core.config.Path in project carbon-business-process by wso2.

the class HTRenderingApiImpl method createSoapTemplate.

/**
 * Function to create response message template
 *
 * @param SrcWsdl   source wsld : wsdl file path or url
 * @param portType  callback port type
 * @param operation callback operation name
 * @param binding   callback binding
 * @return DOM element of response message template
 * @throws IOException  If error occurred while parsing string xml to Dom element
 * @throws SAXException If error occurred while parsing string xml to Dom element
 */
private static Element createSoapTemplate(String SrcWsdl, String portType, String operation, String binding) throws IOException, SAXException {
    WSDLParser parser = new WSDLParser();
    // BPS-677
    int fileLocationPrefixIndex = SrcWsdl.indexOf(HumanTaskConstants.FILE_LOCATION_FILE_PREFIX);
    if (SrcWsdl.indexOf(HumanTaskConstants.FILE_LOCATION_FILE_PREFIX) != -1) {
        SrcWsdl = SrcWsdl.substring(fileLocationPrefixIndex + HumanTaskConstants.FILE_LOCATION_FILE_PREFIX.length());
    }
    Definitions wsdl = parser.parse(SrcWsdl);
    StringWriter writer = new StringWriter();
    // SOAPRequestCreator constructor: SOARequestCreator(Definitions, Creator, MarkupBuilder)
    SOARequestCreator creator = new SOARequestCreator(wsdl, new RequestTemplateCreator(), new MarkupBuilder(writer));
    // creator.createRequest(PortType name, Operation name, Binding name);
    creator.createRequest(portType, operation, binding);
    Element outGenMessageDom = DOMUtils.stringToDOM(writer.toString());
    Element outMsgElement = null;
    NodeList nodes = outGenMessageDom.getElementsByTagNameNS(outGenMessageDom.getNamespaceURI(), "Body").item(0).getChildNodes();
    if (nodes != null) {
        for (int i = 0; i < nodes.getLength(); i++) {
            if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
                outMsgElement = (Element) nodes.item(i);
                break;
            }
        }
    }
    if (outMsgElement != null) {
        // convert element to string and back to element to remove Owner Document
        return DOMUtils.stringToDOM(DOMUtils.domToString(outMsgElement));
    }
    return null;
}
Also used : RequestTemplateCreator(com.predic8.wstool.creator.RequestTemplateCreator) StringWriter(java.io.StringWriter) Definitions(com.predic8.wsdl.Definitions) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) MarkupBuilder(groovy.xml.MarkupBuilder) WSDLParser(com.predic8.wsdl.WSDLParser) SOARequestCreator(com.predic8.wstool.creator.SOARequestCreator)

Example 29 with Path

use of com.predic8.membrane.core.config.Path in project irontest by zheng-wang.

the class WSDLResource method getWSDLBindings.

@GET
@Path("/{wsdlUrl}/bindings")
public List<WSDLBinding> getWSDLBindings(@PathParam("wsdlUrl") String wsdlUrl) throws UnsupportedEncodingException {
    List<WSDLBinding> result = new ArrayList<WSDLBinding>();
    WSDLParser parser = new WSDLParser();
    parser.setResourceResolver(new SSLTrustedExternalResolver());
    Definitions definition = parser.parse(wsdlUrl);
    for (Binding binding : definition.getBindings()) {
        List<String> operationNames = new ArrayList<String>();
        for (BindingOperation operation : binding.getOperations()) {
            operationNames.add(operation.getName());
        }
        result.add(new WSDLBinding(binding.getName(), operationNames));
    }
    return result;
}
Also used : WSDLBinding(io.irontest.models.WSDLBinding) Binding(com.predic8.wsdl.Binding) BindingOperation(com.predic8.wsdl.BindingOperation) WSDLBinding(io.irontest.models.WSDLBinding) Definitions(com.predic8.wsdl.Definitions) ArrayList(java.util.ArrayList) WSDLParser(com.predic8.wsdl.WSDLParser) SSLTrustedExternalResolver(io.irontest.core.SSLTrustedExternalResolver) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

Exchange (com.predic8.membrane.core.exchange.Exchange)8 Test (org.junit.Test)6 Request (com.predic8.membrane.core.http.Request)4 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)4 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)4 Process2 (com.predic8.membrane.examples.Process2)3 Definitions (com.predic8.wsdl.Definitions)3 WSDLParser (com.predic8.wsdl.WSDLParser)3 File (java.io.File)3 IOException (java.io.IOException)3 StringWriter (java.io.StringWriter)3 ParseException (com.floreysoft.jmte.message.ParseException)2 Header (com.predic8.membrane.core.http.Header)2 Response (com.predic8.membrane.core.http.Response)2 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)2 ProxiesXmlUtil (com.predic8.membrane.examples.ProxiesXmlUtil)2 RequestTemplateCreator (com.predic8.wstool.creator.RequestTemplateCreator)2 SOARequestCreator (com.predic8.wstool.creator.SOARequestCreator)2 MarkupBuilder (groovy.xml.MarkupBuilder)2 MalformedURLException (java.net.MalformedURLException)2