You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by da...@apache.org on 2007/04/22 01:34:16 UTC
svn commit: r531126 [2/2] - in /incubator/cxf/trunk:
api/src/main/java/org/apache/cxf/feature/
api/src/main/java/org/apache/cxf/ws/
api/src/main/java/org/apache/cxf/ws/policy/
common/common/src/main/java/org/apache/cxf/configuration/spring/
distributio...
Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java?view=auto&rev=531126
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java Sat Apr 21 16:34:13 2007
@@ -0,0 +1,54 @@
+/**
+ * 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.ws.policy.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.ws.policy.PolicyConstants;
+import org.apache.cxf.ws.policy.WSPolicyFeature;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+
+public class PolicyFeatureBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
+
+ @Override
+ protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
+ List<Element> els = new ArrayList<Element>();
+ els.add(element);
+ bean.addPropertyValue("policyElements", els);
+ }
+
+ @Override
+ protected String resolveId(Element element, AbstractBeanDefinition bean,
+ ParserContext ctx) throws BeanDefinitionStoreException {
+ return element.getAttributeNS(PolicyConstants.getWSUNamespace(), PolicyConstants.getIdAttrName());
+ }
+
+ @Override
+ protected Class getBeanClass(Element el) {
+ return WSPolicyFeature.class;
+ }
+
+}
Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/spring/PolicyFeatureBeanDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml?view=diff&rev=531126&r1=531125&r2=531126
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/cxf/cxf-extension-policy.xml Sat Apr 21 16:34:13 2007
@@ -63,5 +63,9 @@
<bean class="org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider">
<constructor-arg ref="cxf"/>
</bean>
+
+ <bean class="org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider">
+ <constructor-arg ref="cxf"/>
+ </bean>
</beans>
Added: incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.handlers
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.handlers?view=auto&rev=531126
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.handlers (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.handlers Sat Apr 21 16:34:13 2007
@@ -0,0 +1,2 @@
+http\://www.w3.org/2006/07/ws-policy=org.apache.cxf.ws.policy.spring.NamespaceHandler
+http\://schemas.xmlsoap.org/ws/2004/09/policy=org.apache.cxf.ws.policy.spring.NamespaceHandler
\ No newline at end of file
Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.handlers
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.schemas
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.schemas?view=auto&rev=531126
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.schemas (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.schemas Sat Apr 21 16:34:13 2007
@@ -0,0 +1,2 @@
+http\://www.w3.org/2006/07/ws-policy=schemas/ws-policy-200607.xsd
+http\://schemas.xmlsoap.org/ws/2004/09/policy=schemas/ws-policy-200409.xsd
\ No newline at end of file
Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/resources/META-INF/spring.schemas
------------------------------------------------------------------------------
svn:executable = *
Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java?view=diff&rev=531126&r1=531125&r2=531126
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java Sat Apr 21 16:34:13 2007
@@ -30,6 +30,7 @@
import javax.xml.namespace.QName;
import org.apache.cxf.Bus;
+import org.apache.cxf.bus.CXFBusImpl;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.phase.PhaseInterceptor;
@@ -73,7 +74,8 @@
assertNull(engine.getBus());
assertNull(engine.getPolicyProviders());
assertTrue(!engine.isEnabled());
- Bus bus = control.createMock(Bus.class);
+ Bus bus = new CXFBusImpl();
+
engine.setBus(bus);
List<PolicyProvider> providers = CastUtils.cast(Collections.EMPTY_LIST, PolicyProvider.class);
engine.setPolicyProviders(providers);
Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyExtensionsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyExtensionsTest.java?view=diff&rev=531126&r1=531125&r2=531126
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyExtensionsTest.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyExtensionsTest.java Sat Apr 21 16:34:13 2007
@@ -30,6 +30,7 @@
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.interceptor.AbstractAttributedInterceptorProvider;
+import org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider;
import org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilder;
import org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry;
import org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProvider;
@@ -84,18 +85,22 @@
assertNotNull(engine.getRegistry());
Collection<PolicyProvider> pps = engine.getPolicyProviders();
- assertEquals(2, pps.size());
+ assertEquals(3, pps.size());
boolean wsdlProvider = false;
boolean externalProvider = false;
+ boolean serviceProvider = false;
for (PolicyProvider pp : pps) {
if (pp instanceof Wsdl11AttachmentPolicyProvider) {
wsdlProvider = true;
} else if (pp instanceof ExternalAttachmentProvider) {
externalProvider = true;
+ } else if (pp instanceof ServiceModelPolicyProvider) {
+ serviceProvider = true;
}
}
assertTrue(wsdlProvider);
assertTrue(externalProvider);
+ assertTrue(serviceProvider);
PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
Added: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyFeatureTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyFeatureTest.java?view=auto&rev=531126
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyFeatureTest.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyFeatureTest.java Sat Apr 21 16:34:13 2007
@@ -0,0 +1,160 @@
+/**
+ * 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.ws.policy.spring;
+
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.CXFBusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.ws.policy.PolicyEngine;
+import org.apache.cxf.ws.policy.WSPolicyFeature;
+import org.apache.hello_world_soap_http.GreeterImpl;
+import org.apache.neethi.Policy;
+import org.junit.After;
+import org.junit.Test;
+
+public class PolicyFeatureTest extends Assert {
+ @After
+ public void tearDown() {
+ BusFactory.setDefaultBus(null);
+ }
+
+ @Test
+ public void testServerFactory() {
+ Bus bus = new CXFBusFactory().createBus();
+
+ Policy p = new Policy();
+ p.setId("test");
+
+ JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+ sf.getFeatures().add(new WSPolicyFeature(p));
+ sf.setServiceBean(new GreeterImpl());
+ sf.setAddress("http://localhost/test");
+ sf.setStart(false);
+ sf.setBus(bus);
+ Server server = sf.create();
+
+ PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+ assertNotNull(pe);
+
+ List<ServiceInfo> sis = server.getEndpoint().getService().getServiceInfos();
+ ServiceInfo info = sis.get(0);
+
+ Policy p2 = info.getExtensor(Policy.class);
+ assertEquals(p, p2);
+ }
+
+
+ @Test
+ public void testServerFactoryWith2007Xml() {
+ Bus bus =
+ new SpringBusFactory().createBus("/org/apache/cxf/ws/policy/spring/server.xml");
+
+ JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+ sf.setServiceBean(new GreeterImpl());
+ sf.setAddress("http://localhost/test");
+ sf.setStart(false);
+ sf.setBus(bus);
+
+ Configurer c = bus.getExtension(Configurer.class);
+ c.configureBean("test", sf);
+
+ List<AbstractFeature> features = sf.getFeatures();
+ assertEquals(1, features.size());
+
+ Server server = sf.create();
+
+ PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+ assertNotNull(pe);
+
+ List<ServiceInfo> sis = server.getEndpoint().getService().getServiceInfos();
+ ServiceInfo info = sis.get(0);
+
+ Policy p2 = info.getExtensor(Policy.class);
+ assertNotNull(p2);
+ }
+
+ @Test
+ public void testServerFactoryWith2004Xml() {
+ Bus bus =
+ new SpringBusFactory().createBus("/org/apache/cxf/ws/policy/spring/server.xml");
+
+ JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+ sf.setServiceBean(new GreeterImpl());
+ sf.setAddress("http://localhost/test");
+ sf.setStart(false);
+ sf.setBus(bus);
+
+ Configurer c = bus.getExtension(Configurer.class);
+ c.configureBean("test2004", sf);
+
+ List<AbstractFeature> features = sf.getFeatures();
+ assertEquals(1, features.size());
+
+ Server server = sf.create();
+
+ PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+ assertNotNull(pe);
+
+ List<ServiceInfo> sis = server.getEndpoint().getService().getServiceInfos();
+ ServiceInfo info = sis.get(0);
+
+ Policy p2 = info.getExtensor(Policy.class);
+ assertNotNull(p2);
+ }
+
+ @Test
+ public void testPolicyReference() {
+ Bus bus =
+ new SpringBusFactory().createBus("/org/apache/cxf/ws/policy/spring/server.xml");
+
+ JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+ sf.setServiceBean(new GreeterImpl());
+ sf.setAddress("http://localhost/test");
+ sf.setStart(false);
+ sf.setBus(bus);
+
+ Configurer c = bus.getExtension(Configurer.class);
+ c.configureBean("testExternal", sf);
+
+ List<AbstractFeature> features = sf.getFeatures();
+ assertEquals(1, features.size());
+
+ Server server = sf.create();
+
+ PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+ assertNotNull(pe);
+
+ List<ServiceInfo> sis = server.getEndpoint().getService().getServiceInfos();
+ ServiceInfo info = sis.get(0);
+
+ Policy p = info.getExtensor(Policy.class);
+ assertNotNull(p);
+ assertEquals("External", p.getId());
+ }
+}
Propchange: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyFeatureTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyFeatureTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/PolicyFeatureTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/server.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/server.xml?view=auto&rev=531126
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/server.xml (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/server.xml Sat Apr 21 16:34:13 2007
@@ -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:wsa="http://cxf.apache.org/ws/addressing"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ xsi:schemaLocation="
+http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schema/transports/http.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <jaxws:server id="test" abstract="true">
+ <jaxws:features>
+ <wsp:Policy wsp:Name="test"
+ xmlns:wsp="http://www.w3.org/2006/07/ws-policy">
+
+ </wsp:Policy>
+ </jaxws:features>
+ </jaxws:server>
+
+ <jaxws:server id="test2004" abstract="true">
+ <jaxws:features>
+ <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+
+ </wsp:Policy>
+ </jaxws:features>
+ </jaxws:server>
+
+ <jaxws:server id="testExternal" abstract="true">
+ <jaxws:features>
+ <ref bean="External"/>
+ </jaxws:features>
+ </jaxws:server>
+
+ <wsp:Policy wsu:Id="External"
+ xmlns:wsp="http://www.w3.org/2006/07/ws-policy"/>
+
+</beans>
Propchange: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/server.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/server.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/server.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/spring/server.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/cxf-config.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/cxf-config.xml?view=diff&rev=531126&r1=531125&r2=531126
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/cxf-config.xml (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/cxf-config.xml Sat Apr 21 16:34:13 2007
@@ -27,7 +27,7 @@
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schema/bindings/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
- <jaxws:endpoint id="{http://apache.org/schema_validation}SoapPort" abstract="true">
+ <jaxws:endpoint id="{http://apache.org/schema_validation}SoapPort" createdFromAPI="true">
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java?view=auto&rev=531126
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java Sat Apr 21 16:34:13 2007
@@ -0,0 +1,148 @@
+/**
+ * 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.policy;
+
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.greeter_control.BasicGreeterService;
+import org.apache.cxf.greeter_control.Greeter;
+import org.apache.cxf.greeter_control.PingMeFault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.policy.ServerPolicyInInterceptor;
+import org.apache.cxf.ws.policy.ServerPolicyOutInterceptor;
+import org.apache.neethi.Policy;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests the use of the WS-Policy Framework to automatically engage WS-Addressing and
+ * WS-RM in response to Policies defined for the endpoint via an inline policy in addr-inline-policy.xml.
+ */
+public class AddressingInlinePolicyTest extends AbstractBusClientServerTestBase {
+
+ private static final Logger LOG = Logger.getLogger(AddressingInlinePolicyTest.class.getName());
+
+ public static class Server extends AbstractBusTestServerBase {
+
+ protected void run() {
+ SpringBusFactory bf = new SpringBusFactory();
+ Bus bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-inline-policy.xml");
+
+ GreeterImpl implementor = new GreeterImpl();
+ String address = "http://localhost:9020/SoapContext/GreeterPort";
+ Endpoint.publish(address, implementor);
+ LOG.info("Published greeter endpoint.");
+ testInterceptors(bus);
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+ }
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly", launchServer(Server.class));
+ }
+
+ @Test
+ public void testUsingAddressing() throws Exception {
+ SpringBusFactory bf = new SpringBusFactory();
+ bus = bf.createBus("org/apache/cxf/systest/ws/policy/addr-inline-policy.xml");
+ BusFactory.setDefaultBus(bus);
+
+ BasicGreeterService gs = new BasicGreeterService();
+ final Greeter greeter = gs.getGreeterPort();
+ LOG.fine("Created greeter client.");
+
+ Client client = ClientProxy.getClient(greeter);
+ List<ServiceInfo> sis = client.getEndpoint().getService().getServiceInfos();
+
+ ServiceInfo si = sis.get(0);
+ Policy p = si.getExtensor(Policy.class);
+ assertNotNull(p);
+
+ testInterceptors(bus);
+
+ // oneway
+
+ greeter.greetMeOneWay("CXF");
+
+ // two-way
+
+ assertEquals("CXF", greeter.greetMe("cxf"));
+
+ // exception
+
+ try {
+ greeter.pingMe();
+ } catch (PingMeFault ex) {
+ fail("First invocation should have succeeded.");
+ }
+
+ try {
+ greeter.pingMe();
+ fail("Expected PingMeFault not thrown.");
+ } catch (PingMeFault ex) {
+ assertEquals(2, (int)ex.getFaultInfo().getMajor());
+ assertEquals(1, (int)ex.getFaultInfo().getMinor());
+ }
+ }
+
+ private static void testInterceptors(Bus b) {
+ boolean hasServerIn = false;
+ boolean hasServerOut = false;
+ List<Interceptor> inInterceptors = b.getInInterceptors();
+ for (Interceptor i : inInterceptors) {
+ if (i instanceof ServerPolicyInInterceptor) {
+ hasServerIn = true;
+ }
+ }
+ assertTrue(hasServerIn);
+
+ for (Interceptor i : b.getOutInterceptors()) {
+ if (i instanceof ServerPolicyOutInterceptor) {
+ hasServerOut = true;
+ }
+ }
+ assertTrue(hasServerOut);
+ }
+}
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java?view=diff&rev=531126&r1=531125&r2=531126
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPClientPolicyTest.java Sat Apr 21 16:34:13 2007
@@ -122,6 +122,7 @@
greeter.sayHi();
fail("Did not receive expected PolicyException.");
} catch (WebServiceException wex) {
+ wex.printStackTrace();
PolicyException ex = (PolicyException)wex.getCause();
assertEquals("INCOMPATIBLE_HTTPCLIENTPOLICY_ASSERTIONS", ex.getCode());
}
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-inline-policy.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-inline-policy.xml?view=auto&rev=531126
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-inline-policy.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-inline-policy.xml Sat Apr 21 16:34:13 2007
@@ -0,0 +1,60 @@
+<?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:wsa="http://cxf.apache.org/ws/addressing"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
+http://cxf.apache.org/ws/policy http://cxf.apache.org/schema/ws/policy.xsd
+http://cxf.apache.org/ws/addressing http://cxf.apache.org/schema/ws/addressing.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schema/transports/http.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <http:conduit
+ id="{http://cxf.apache.org/greeter_control}GreeterPort.http-conduit">
+ <http:client
+ DecoupledEndpoint="http://localhost:9999/decoupled_endpoint" />
+ </http:conduit>
+
+ <jaxws:endpoint id="{http://cxf.apache.org/greeter_control}GreeterPort" createdFromAPI="true">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ <ref bean="AddressingPolicy" />
+ </jaxws:features>
+ </jaxws:endpoint>
+
+ <jaxws:client id="{http://cxf.apache.org/greeter_control}GreeterPort" createdFromAPI="true">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ <ref bean="AddressingPolicy" />
+ </jaxws:features>
+ </jaxws:client>
+
+ <wsp:Policy wsu:Id="AddressingPolicy"
+ xmlns:wsp="http://www.w3.org/2006/07/ws-policy"
+ xmlns:wsam="http://www.w3.org/2007/01/addressing/metadata">
+ <wsam:Addressing>
+ <wsp:Policy />
+ </wsam:Addressing>
+ </wsp:Policy>
+</beans>
\ No newline at end of file
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-inline-policy.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-inline-policy.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-inline-policy.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-inline-policy.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml?view=diff&rev=531126&r1=531125&r2=531126
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/http-server.xml Sat Apr 21 16:34:13 2007
@@ -31,7 +31,7 @@
<jaxws:endpoint
id="{http://cxf.apache.org/greeter_control}GreeterPort"
- abstract="true"
+ createdFromAPI="true"
wsdlLocation="org/apache/cxf/systest/ws/policy/http_server_greeter.wsdl"/>
<!--<jaxws:endpoint