This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 80e7e97  Adding test for XSLTFeature
80e7e97 is described below

commit 80e7e9720a77196ed6f996c46f7cff648a77628b
Author: Colm O hEigeartaigh <cohei...@apache.org>
AuthorDate: Wed Mar 7 15:43:02 2018 +0000

    Adding test for XSLTFeature
---
 .../org/apache/cxf/systest/soap/DoubleItImpl.java  | 40 +++++++++++
 .../apache/cxf/systest/soap/XSLTFeatureTest.java   | 84 ++++++++++++++++++++++
 .../org/apache/cxf/systest/soap/XSLTServer.java    | 47 ++++++++++++
 .../cxf/systest/soap/responseTransformation.xsl    | 11 +++
 .../org/apache/cxf/systest/soap/xslt-server.xml    | 57 +++++++++++++++
 5 files changed, 239 insertions(+)

diff --git 
a/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/DoubleItImpl.java
 
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/DoubleItImpl.java
new file mode 100644
index 0000000..14d12df
--- /dev/null
+++ 
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/DoubleItImpl.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.soap;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.feature.Features;
+import org.example.contract.doubleit.DoubleItFault;
+import org.example.contract.doubleit.DoubleItPortType;
+
+@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt";,
+            serviceName = "DoubleItService",
+            endpointInterface = 
"org.example.contract.doubleit.DoubleItPortType")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+public class DoubleItImpl implements DoubleItPortType {
+
+    public int doubleIt(int numberToDouble) throws DoubleItFault {
+        if (numberToDouble == 0) {
+            throw new DoubleItFault("0 can't be doubled!");
+        }
+        return numberToDouble * 2;
+    }
+
+}
diff --git 
a/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
 
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
new file mode 100644
index 0000000..aed326d
--- /dev/null
+++ 
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTFeatureTest.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.soap;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.example.contract.doubleit.DoubleItPortType;
+
+import org.junit.BeforeClass;
+
+/**
+ * Some tests for the XSLT Feature
+ */
+public class XSLTFeatureTest extends AbstractBusClientServerTestBase {
+    static final String PORT = allocatePort(XSLTServer.class);
+
+    private static final String NAMESPACE = 
"http://www.example.org/contract/DoubleIt";;
+    private static final QName SERVICE_QNAME = new QName(NAMESPACE, 
"DoubleItService");
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue(
+            "Server failed to launch",
+            // run the server in the same process
+            // set this to false to fork
+            launchServer(XSLTServer.class, true)
+        );
+    }
+
+    @org.junit.AfterClass
+    public static void cleanup() throws Exception {
+        stopAllServers();
+    }
+
+    @org.junit.Test
+    public void testNormalInvocation() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = XSLTFeatureTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        BusFactory.setDefaultBus(bus);
+        BusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = XSLTFeatureTest.class.getResource("DoubleIt.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort");
+        DoubleItPortType port =
+                service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+
+        // The XSLT Feature adds a "1" to the doubled response
+        assertEquals(150, port.doubleIt(25));
+
+        ((java.io.Closeable)port).close();
+
+        bus.shutdown(true);
+    }
+
+}
diff --git 
a/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTServer.java
 
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTServer.java
new file mode 100644
index 0000000..ae64927
--- /dev/null
+++ 
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/soap/XSLTServer.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.soap;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class XSLTServer extends AbstractBusTestServerBase {
+
+    public XSLTServer() {
+
+    }
+
+    protected void run()  {
+        URL busFile = XSLTServer.class.getResource("xslt-server.xml");
+        Bus busLocal = new SpringBusFactory().createBus(busFile);
+        BusFactory.setDefaultBus(busLocal);
+        setBus(busLocal);
+
+        try {
+            new XSLTServer();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
diff --git 
a/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/responseTransformation.xsl
 
b/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/responseTransformation.xsl
new file mode 100644
index 0000000..535030d
--- /dev/null
+++ 
b/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/responseTransformation.xsl
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+    <xsl:template match="/">
+        <soap:Envelope 
xmlns:soap="http://www.w3.org/2003/05/soap-envelope";><soap:Body>
+        <ns2:DoubleItResponse 
xmlns:ns2="http://www.example.org/schema/DoubleIt";>
+        <doubledNumber>1<xsl:value-of 
select="soap:Envelope/soap:Body/ns2:DoubleItResponse/doubledNumber"/></doubledNumber>
+        </ns2:DoubleItResponse></soap:Body></soap:Envelope>
+
+    </xsl:template>
+
+</xsl:stylesheet>
diff --git 
a/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/xslt-server.xml
 
b/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/xslt-server.xml
new file mode 100644
index 0000000..d592314
--- /dev/null
+++ 
b/systests/uncategorized/src/test/resources/org/apache/cxf/systest/soap/xslt-server.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"; 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
+    xmlns:http="http://cxf.apache.org/transports/http/configuration"; 
+    xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"; 
+    xmlns:sec="http://cxf.apache.org/configuration/security"; 
+    xmlns:cxf="http://cxf.apache.org/core"; 
+    xmlns:jaxws="http://cxf.apache.org/jaxws";
+    xmlns:util="http://www.springframework.org/schema/util";
+    xsi:schemaLocation="http://cxf.apache.org/jaxws 
http://cxf.apache.org/schemas/jaxws.xsd
+             http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+             http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
+             http://www.springframework.org/schema/util  
http://www.springframework.org/schema/util/spring-util-4.2.xsd
+             http://cxf.apache.org/transports/http/configuration 
http://cxf.apache.org/schemas/configuration/http-conf.xsd
+             http://cxf.apache.org/transports/http-jetty/configuration 
http://cxf.apache.org/schemas/configuration/http-jetty.xsd 
+             http://cxf.apache.org/configuration/security 
http://cxf.apache.org/schemas/configuration/security.xsd";>
+    <bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+    <cxf:bus>
+        <cxf:features>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+    
+    <bean id="xsltFeature" 
class="org.apache.cxf.feature.transform.XSLTFeature">
+        <property name="outXSLTPath" 
value="org/apache/cxf/systest/soap/responseTransformation.xsl" />
+    </bean>
+
+   <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt"; 
id="XSLTEndpoint" 
+                   
address="http://localhost:${testutil.ports.soap.XSLTServer}/doubleit"; 
+                   serviceName="s:DoubleItService" 
+                   endpointName="s:DoubleItPlaintextPort" 
+                   implementor="org.apache.cxf.systest.soap.DoubleItImpl"
+                   wsdlLocation="org/apache/cxf/systest/soap/DoubleIt.wsdl">
+        <jaxws:features>
+            <ref bean="xsltFeature" />
+        </jaxws:features>
+    </jaxws:endpoint>
+    
+</beans>

-- 
To stop receiving notification emails like this one, please contact
cohei...@apache.org.

Reply via email to