You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/04/27 15:38:18 UTC

[cxf] 02/02: Adding an @Ignore'd MTOM test-case for the WS-Security StAX code

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

commit 80b0d4fda16c1e3aaf3873e6884f92671a2918b5
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Fri Apr 27 16:37:44 2018 +0100

    Adding an @Ignore'd MTOM test-case for the WS-Security StAX code
---
 .../cxf/systest/ws/mtom/MTOMSecurityTest.java      | 35 ++++++++++++++++++
 .../org/apache/cxf/systest/ws/mtom/StaxServer.java | 41 ++++++++++++++++++++++
 .../org/apache/cxf/systest/ws/mtom/stax-server.xml | 38 ++++++++++++++++++++
 3 files changed, 114 insertions(+)

diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/mtom/MTOMSecurityTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/mtom/MTOMSecurityTest.java
index 53b9801..bf0d448 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/mtom/MTOMSecurityTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/mtom/MTOMSecurityTest.java
@@ -44,6 +44,7 @@ import org.junit.BeforeClass;
  */
 public class MTOMSecurityTest extends AbstractBusClientServerTestBase {
     public static final String PORT = allocatePort(Server.class);
+    public static final String STAX_PORT = allocatePort(StaxServer.class);
 
     private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
     private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
@@ -56,6 +57,12 @@ public class MTOMSecurityTest extends AbstractBusClientServerTestBase {
                 // set this to false to fork
                 launchServer(Server.class, true)
         );
+        assertTrue(
+                 "Server failed to launch",
+                 // run the server in the same process
+                 // set this to false to fork
+                 launchServer(StaxServer.class, true)
+        );
     }
 
     @org.junit.AfterClass
@@ -271,4 +278,32 @@ public class MTOMSecurityTest extends AbstractBusClientServerTestBase {
         ((java.io.Closeable)port).close();
         bus.shutdown(true);
     }
+
+    @org.junit.Test
+    @org.junit.Ignore
+    public void testSymmetricBinaryBytesInAttachmentStAX() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = MTOMSecurityTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        BusFactory.setDefaultBus(bus);
+        BusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = MTOMSecurityTest.class.getResource("DoubleItMtom.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItSymmetricBinaryPort");
+        DoubleItMtomPortType port =
+            service.getPort(portQName, DoubleItMtomPortType.class);
+        updateAddressPort(port, STAX_PORT);
+
+        DataSource source = new FileDataSource(new File("src/test/resources/java.jpg"));
+        DoubleIt4 doubleIt = new DoubleIt4();
+        doubleIt.setNumberToDouble(25);
+        assertEquals(50, port.doubleIt4(25, new DataHandler(source)));
+
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+
 }
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/mtom/StaxServer.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/mtom/StaxServer.java
new file mode 100644
index 0000000..83c6dfb
--- /dev/null
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/mtom/StaxServer.java
@@ -0,0 +1,41 @@
+/**
+ * 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.ws.mtom;
+
+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 StaxServer extends AbstractBusTestServerBase {
+
+    public StaxServer() {
+
+    }
+
+    protected void run()  {
+        URL busFile = StaxServer.class.getResource("stax-server.xml");
+        Bus busLocal = new SpringBusFactory().createBus(busFile);
+        BusFactory.setDefaultBus(busLocal);
+        setBus(busLocal);
+    }
+}
diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/mtom/stax-server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/mtom/stax-server.xml
new file mode 100644
index 0000000..7cef94d
--- /dev/null
+++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/mtom/stax-server.xml
@@ -0,0 +1,38 @@
+<?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:util="http://www.springframework.org/schema/util" xmlns:jaxws="http://cxf.apache.org/jaxws" 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:p="http://cxf.apache.org/policy" xsi:schem [...]
+    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+    <cxf:bus>
+        <cxf:features>
+            <p:policies/>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+
+    <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="SymmetricBinary" address="http://localhost:${testutil.ports.mtom.StaxServer}/DoubleItX509SymmetricBinary" serviceName="s:DoubleItService" endpointName="s:DoubleItSymmetricBinaryPort" implementor="org.apache.cxf.systest.ws.mtom.DoubleIt4Impl" wsdlLocation="org/apache/cxf/systest/ws/mtom/DoubleItMtom.wsdl">
+        <jaxws:properties>
+            <entry key="security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/>
+            <entry key="security.signature.properties" value="bob.properties"/>
+            <entry key="mtom-enabled" value="true"/>
+            <entry key="ws-security.enable.streaming" value="true"/>
+        </jaxws:properties>
+    </jaxws:endpoint>
+    
+</beans>

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