Added some annotation based tests
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c3787b32 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c3787b32 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c3787b32 Branch: refs/heads/3.0.x-fixes Commit: c3787b3237058380711da6753ecf37fd60ab3865 Parents: 203a6cf Author: Colm O hEigeartaigh <[email protected]> Authored: Thu Jan 22 12:12:01 2015 +0000 Committer: Colm O hEigeartaigh <[email protected]> Committed: Thu Jan 22 12:15:47 2015 +0000 ---------------------------------------------------------------------- .../systest/ws/x509/DoubleItPropertiesImpl.java | 51 ++++++++++++++++++++ .../cxf/systest/ws/x509/X509TokenTest.java | 27 +++++++++++ .../cxf/systest/ws/x509/DoubleItX509.wsdl | 3 ++ .../org/apache/cxf/systest/ws/x509/client.xml | 9 ++++ .../org/apache/cxf/systest/ws/x509/server.xml | 2 + .../apache/cxf/systest/ws/x509/stax-server.xml | 5 ++ 6 files changed, 97 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/c3787b32/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/DoubleItPropertiesImpl.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/DoubleItPropertiesImpl.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/DoubleItPropertiesImpl.java new file mode 100644 index 0000000..622d15d --- /dev/null +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/DoubleItPropertiesImpl.java @@ -0,0 +1,51 @@ +/** + * 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.x509; + +import javax.jws.WebService; + +import org.apache.cxf.annotations.EndpointProperties; +import org.apache.cxf.annotations.EndpointProperty; +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") + +@EndpointProperties({ + @EndpointProperty(key = "ws-security.encryption.username", value = "alice"), + @EndpointProperty(key = "ws-security.encryption.properties", value = "alice.properties"), + @EndpointProperty(key = "ws-security.signature.properties", value = "bob.properties"), + @EndpointProperty(key = "ws-security.callback-handler", + value = "org.apache.cxf.systest.ws.common.KeystorePasswordCallback") +}) +public class DoubleItPropertiesImpl implements DoubleItPortType { + + public int doubleIt(int numberToDouble) throws DoubleItFault { + if (numberToDouble == 0) { + throw new DoubleItFault("0 can't be doubled!"); + } + return numberToDouble * 2; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/c3787b32/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java index a376a2b..d6b3403 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java @@ -1436,4 +1436,31 @@ public class X509TokenTest extends AbstractBusClientServerTestBase { bus.shutdown(true); } + @org.junit.Test + public void testAsymmetricProperties() throws Exception { + + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = X509TokenTest.class.getResource("client.xml"); + + Bus bus = bf.createBus(busFile.toString()); + SpringBusFactory.setDefaultBus(bus); + SpringBusFactory.setThreadDefaultBus(bus); + + URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPropertiesPort"); + DoubleItPortType x509Port = + service.getPort(portQName, DoubleItPortType.class); + updateAddressPort(x509Port, test.getPort()); + + if (test.isStreaming()) { + SecurityTestUtil.enableStreaming(x509Port); + } + + x509Port.doubleIt(25); + + ((java.io.Closeable)x509Port).close(); + bus.shutdown(true); + } + } http://git-wip-us.apache.org/repos/asf/cxf/blob/c3787b32/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl index 567af07..64adb76 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl @@ -723,6 +723,9 @@ <wsdl:port name="DoubleItTransportNegativeEndorsingPort2" binding="tns:DoubleItNoSecurityBinding"> <soap:address location="https://localhost:9002/DoubleItX509TransportNegativeEndorsing2"/> </wsdl:port> + <wsdl:port name="DoubleItAsymmetricPropertiesPort" binding="tns:DoubleItAsymmetricIssuerSerialBinding"> + <soap:address location="http://localhost:9001/DoubleItX509AsymmetricProperties"/> + </wsdl:port> </wsdl:service> <wsp:Policy wsu:Id="DoubleItKeyIdentifierPolicy"> <wsp:ExactlyOne> http://git-wip-us.apache.org/repos/asf/cxf/blob/c3787b32/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml index be02dbb..fccc71c 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client.xml @@ -391,6 +391,15 @@ <entry key="ws-security.encryption.username" value="bob"/> </jaxws:properties> </jaxws:client> + <jaxws:client name="{http://www.example.org/contract/DoubleIt}DoubleItAsymmetricPropertiesPort" createdFromAPI="true"> + <jaxws:properties> + <entry key="ws-security.encryption.properties" value="bob.properties"/> + <entry key="ws-security.encryption.username" value="bob"/> + <entry key="ws-security.signature.properties" value="alice.properties"/> + <entry key="ws-security.signature.username" value="alice"/> + <entry key="ws-security.callback-handler" value="org.apache.cxf.systest.ws.common.KeystorePasswordCallback"/> + </jaxws:properties> + </jaxws:client> <http:conduit name="https://localhost:.*"> <http:tlsClientParameters disableCNCheck="true"> http://git-wip-us.apache.org/repos/asf/cxf/blob/c3787b32/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml index 61c5519..183e783 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server.xml @@ -367,4 +367,6 @@ <entry key="ws-security.subject.cert.constraints" value=".*O=apache.org.*"/> </jaxws:properties> </jaxws:endpoint> + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="AsymmetricProperties" address="http://localhost:${testutil.ports.Server}/DoubleItX509AsymmetricProperties" serviceName="s:DoubleItService" endpointName="s:DoubleItAsymmetricPropertiesPort" implementor="org.apache.cxf.systest.ws.x509.DoubleItPropertiesImpl" wsdlLocation="org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl"> + </jaxws:endpoint> </beans> http://git-wip-us.apache.org/repos/asf/cxf/blob/c3787b32/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml ---------------------------------------------------------------------- diff --git a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml index d57fda6..37073f5 100644 --- a/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml +++ b/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/stax-server.xml @@ -410,4 +410,9 @@ <entry key="ws-security.enable.streaming" value="true"/> </jaxws:properties> </jaxws:endpoint> + <jaxws:endpoint xmlns:s="http://www.example.org/contract/DoubleIt" id="AsymmetricProperties" address="http://localhost:${testutil.ports.StaxServer}/DoubleItX509AsymmetricProperties" serviceName="s:DoubleItService" endpointName="s:DoubleItAsymmetricPropertiesPort" implementor="org.apache.cxf.systest.ws.x509.DoubleItPropertiesImpl" wsdlLocation="org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl"> + <jaxws:properties> + <entry key="ws-security.enable.streaming" value="true"/> + </jaxws:properties> + </jaxws:endpoint> </beans>
