You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/08/25 20:24:37 UTC
svn commit: r807750 [2/2] - in /cxf/trunk:
api/src/main/java/org/apache/cxf/extension/
api/src/main/java/org/apache/cxf/ws/policy/
api/src/main/java/org/apache/cxf/wsdl/
common/common/src/main/java/org/apache/cxf/common/injection/
common/common/src/mai...
Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java Tue Aug 25 18:24:33 2009
@@ -56,7 +56,6 @@
private static final QName TEST_ASSERTION_TYPE = new QName("http://a.b.c", "x");
- private ExternalAttachmentProvider eap;
private IMocksControl control;
private Policy policy;
@@ -66,12 +65,12 @@
@Before
public void setUp() {
- eap = new ExternalAttachmentProvider();
control = EasyMock.createNiceControl();
}
@Test
public void testBasic() {
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
assertNull(eap.getLocation());
Resource uri = control.createMock(Resource.class);
eap.setLocation(uri);
@@ -81,14 +80,15 @@
@Test
public void testGetEffectiveFaultPolicy() {
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
- setUpAttachment(bfi, false);
+ setUpAttachment(bfi, false, eap);
control.replay();
assertTrue(eap.getEffectivePolicy(bfi).isEmpty());
control.verify();
control.reset();
- setUpAttachment(bfi, true);
+ setUpAttachment(bfi, true, eap);
control.replay();
assertSame(assertion, eap.getEffectivePolicy(bfi).getAssertions().get(0));
control.verify();
@@ -96,14 +96,15 @@
@Test
public void testGetEffectiveMessagePolicy() {
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class);
- setUpAttachment(bmi, false);
+ setUpAttachment(bmi, false, eap);
control.replay();
assertTrue(eap.getEffectivePolicy(bmi).isEmpty());
control.verify();
control.reset();
- setUpAttachment(bmi, true);
+ setUpAttachment(bmi, true, eap);
control.replay();
assertSame(assertion, eap.getEffectivePolicy(bmi).getAssertions().get(0));
control.verify();
@@ -112,13 +113,14 @@
@Test
public void testGetEffectiveOperationPolicy() {
BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
- setUpAttachment(boi, false);
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
+ setUpAttachment(boi, false, eap);
control.replay();
assertTrue(eap.getEffectivePolicy(boi).isEmpty());
control.verify();
control.reset();
- setUpAttachment(boi, true);
+ setUpAttachment(boi, true, eap);
control.replay();
assertSame(assertion, eap.getEffectivePolicy(boi).getAssertions().get(0));
control.verify();
@@ -126,14 +128,15 @@
@Test
public void testGetEffectiveEndpointPolicy() {
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
EndpointInfo ei = control.createMock(EndpointInfo.class);
- setUpAttachment(ei, false);
+ setUpAttachment(ei, false, eap);
control.replay();
assertTrue(eap.getEffectivePolicy(ei).isEmpty());
control.verify();
control.reset();
- setUpAttachment(ei, true);
+ setUpAttachment(ei, true, eap);
control.replay();
assertSame(assertion, eap.getEffectivePolicy(ei).getAssertions().get(0));
control.verify();
@@ -141,14 +144,15 @@
@Test
public void testGetEffectiveServicePolicy() {
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
ServiceInfo si = control.createMock(ServiceInfo.class);
- setUpAttachment(si, false);
+ setUpAttachment(si, false, eap);
control.replay();
assertTrue(eap.getEffectivePolicy(si).isEmpty());
control.verify();
control.reset();
- setUpAttachment(si, true);
+ setUpAttachment(si, true, eap);
control.replay();
assertSame(assertion, eap.getEffectivePolicy(si).getAssertions().get(0));
control.verify();
@@ -156,6 +160,7 @@
@Test
public void testReadDocumentNotExisting() throws MalformedURLException {
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments1.xml");
String uri = url.toExternalForm();
uri = uri.replaceAll("attachments1.xml", "attachments0.xml");
@@ -170,6 +175,7 @@
@Test
public void testReadDocumentWithoutAttachmentElements() throws MalformedURLException {
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments1.xml");
String uri = url.toExternalForm();
eap.setLocation(new UrlResource(uri));
@@ -179,6 +185,7 @@
@Test
public void testReadDocumentAttachmentElementWithoutAppliesTo() throws MalformedURLException {
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments2.xml");
String uri = url.toExternalForm();
eap.setLocation(new UrlResource(uri));
@@ -191,16 +198,16 @@
Bus bus = control.createMock(Bus.class);
- eap = new ExternalAttachmentProvider(bus);
DomainExpressionBuilderRegistry debr = control.createMock(DomainExpressionBuilderRegistry.class);
EasyMock.expect(bus.getExtension(DomainExpressionBuilderRegistry.class)).andReturn(debr);
EasyMock.expect(debr.build(EasyMock.isA(Element.class)))
.andThrow(new PolicyException(new Exception()));
URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments3.xml");
String uri = url.toExternalForm();
- eap.setLocation(new UrlResource(uri));
control.replay();
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider(bus);
+ eap.setLocation(new UrlResource(uri));
try {
eap.readDocument();
fail("Expected PolicyException not thrown.");
@@ -215,21 +222,21 @@
Bus bus = control.createMock(Bus.class);
- eap = new ExternalAttachmentProvider(bus);
DomainExpressionBuilderRegistry debr = control.createMock(DomainExpressionBuilderRegistry.class);
EasyMock.expect(bus.getExtension(DomainExpressionBuilderRegistry.class)).andReturn(debr);
DomainExpression de = control.createMock(DomainExpression.class);
EasyMock.expect(debr.build(EasyMock.isA(Element.class))).andReturn(de);
PolicyBuilder pb = control.createMock(PolicyBuilder.class);
- eap.setBuilder(pb);
+ EasyMock.expect(bus.getExtension(PolicyBuilder.class)).andReturn(pb).anyTimes();
Policy p = control.createMock(Policy.class);
EasyMock.expect(pb.getPolicy(EasyMock.isA(Element.class))).andReturn(p);
+
+ control.replay();
+ ExternalAttachmentProvider eap = new ExternalAttachmentProvider(bus);
URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments4.xml");
String uri = url.toExternalForm();
eap.setLocation(new UrlResource(uri));
-
- control.replay();
eap.readDocument();
assertEquals(1, eap.getAttachments().size());
PolicyAttachment pa = eap.getAttachments().iterator().next();
@@ -239,7 +246,7 @@
control.verify();
}
- void setUpAttachment(Object subject, boolean applies) {
+ void setUpAttachment(Object subject, boolean applies, ExternalAttachmentProvider eap) {
attachments.clear();
attachment = control.createMock(PolicyAttachment.class);
attachments.add(attachment);
Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java Tue Aug 25 18:24:33 2009
@@ -27,6 +27,7 @@
import org.apache.cxf.Bus;
import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.service.model.BindingMessageInfo;
import org.apache.cxf.service.model.BindingOperationInfo;
@@ -35,7 +36,9 @@
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.ws.policy.AssertionBuilderRegistry;
import org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl;
+import org.apache.cxf.ws.policy.PolicyBuilder;
import org.apache.cxf.ws.policy.PolicyBuilderImpl;
+import org.apache.cxf.ws.policy.PolicyEngine;
import org.apache.cxf.ws.policy.PolicyException;
import org.apache.cxf.ws.policy.PolicyRegistryImpl;
import org.apache.cxf.ws.policy.builder.xml.XMLPrimitiveAssertionBuilder;
@@ -117,6 +120,8 @@
public void setUp() {
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
+ bus.getExtension(ConfiguredBeanLocator.class);
+ EasyMock.expectLastCall().andReturn(null).anyTimes();
AssertionBuilderRegistry abr = new AssertionBuilderRegistryImpl();
abr.setIgnoreUnknownAssertions(false);
XMLPrimitiveAssertionBuilder ab = new XMLPrimitiveAssertionBuilder();
@@ -125,9 +130,14 @@
abr.register(new QName("http://cxf.apache.org/test/assertions", "B"), ab);
abr.register(new QName("http://cxf.apache.org/test/assertions", "C"), ab);
- PolicyBuilderImpl pb = new PolicyBuilderImpl();
+ PolicyBuilderImpl pb = new PolicyBuilderImpl();
+ bus.getExtension(PolicyBuilder.class);
+ EasyMock.expectLastCall().andReturn(pb).anyTimes();
+ bus.getExtension(PolicyEngine.class);
+ EasyMock.expectLastCall().andReturn(null).anyTimes();
+
pb.setAssertionBuilderRegistry(abr);
- app = new Wsdl11AttachmentPolicyProvider(bus);
+ app = new Wsdl11AttachmentPolicyProvider();
app.setBuilder(pb);
app.setRegistry(new PolicyRegistryImpl());
control.replay();
Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java Tue Aug 25 18:24:33 2009
@@ -125,10 +125,6 @@
@Resource
public void setBus(Bus b) {
bus = b;
- }
-
- @PostConstruct
- public void register() {
if (null != bus) {
bus.setExtension(this, RMManager.class);
}
Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMAssertionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMAssertionBuilder.java?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMAssertionBuilder.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMAssertionBuilder.java Tue Aug 25 18:24:33 2009
@@ -19,7 +19,11 @@
package org.apache.cxf.ws.rm.policy;
+import java.util.Collections;
+import java.util.List;
+
import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
import org.apache.cxf.ws.policy.PolicyAssertion;
import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
@@ -32,7 +36,9 @@
*
*/
public class RMAssertionBuilder extends JaxbAssertionBuilder<RMAssertion> {
-
+ public static final List<QName> KNOWN_ELEMENTS
+ = Collections.singletonList(RMConstants.getRMAssertionQName());
+
public RMAssertionBuilder() throws JAXBException {
super(RMAssertion.class, RMConstants.getRMAssertionQName());
}
Modified: cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension-rm.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension-rm.xml?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension-rm.xml (original)
+++ cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension-rm.xml Tue Aug 25 18:24:33 2009
@@ -23,23 +23,16 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="org.apache.cxf.ws.rm.RMManager" class="org.apache.cxf.ws.rm.RMManager">
+ <bean id="org.apache.cxf.ws.rm.RMManager" class="org.apache.cxf.ws.rm.RMManager" lazy-init="true">
<property name="bus" ref="cxf"/>
</bean>
<bean class="org.apache.cxf.ws.rm.policy.RMPolicyInterceptorProvider"
- id="org.apache.cxf.ws.rm.policy.RMPolicyInterceptorProvider">
- <constructor-arg><ref bean="cxf"/></constructor-arg>
- </bean>
-
- <bean id="org.apache.cxf.ws.rm.RMAssertionBuilder" class="org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilder">
- <constructor-arg value="org.apache.cxf.ws.rm.policy.RMAssertion"/>
- <constructor-arg>
- <bean class="javax.xml.namespace.QName">
- <constructor-arg value="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"/>
- <constructor-arg value="RMAssertion"/>
- </bean>
- </constructor-arg>
+ id="org.apache.cxf.ws.rm.policy.RMPolicyInterceptorProvider" lazy-init="true">
+ <constructor-arg ref="cxf"/>
</bean>
+ <bean id="org.apache.cxf.ws.rm.policy.RMAssertionBuilder"
+ class="org.apache.cxf.ws.rm.policy.RMAssertionBuilder"
+ lazy-init="true"/>
</beans>
\ No newline at end of file
Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java (original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java Tue Aug 25 18:24:33 2009
@@ -92,7 +92,7 @@
assertSame(store, manager.getStore());
assertSame(queue, manager.getRetransmissionQueue());
control.replay();
- control.verify();
+ control.reset();
}
@Test
Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/rmmanager.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/rmmanager.xml?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/rmmanager.xml (original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/rmmanager.xml Tue Aug 25 18:24:33 2009
@@ -28,6 +28,8 @@
</bean>
<bean class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"/>
<bean class="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor"/>
+ <bean class="org.apache.cxf.bus.spring.BusExtensionPostProcessor"/>
+
<import resource="../../../../../META-INF/cxf/cxf-extension-rm.xml"/>
</beans>
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java Tue Aug 25 18:24:33 2009
@@ -19,12 +19,12 @@
package org.apache.cxf.ws.security.policy;
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-
import org.apache.cxf.Bus;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.ws.policy.AssertionBuilderLoader;
import org.apache.cxf.ws.policy.AssertionBuilderRegistry;
import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.policy.PolicyInterceptorProviderLoader;
import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry;
import org.apache.cxf.ws.security.policy.builders.AlgorithmSuiteBuilder;
import org.apache.cxf.ws.security.policy.builders.AsymmetricBindingBuilder;
@@ -61,17 +61,12 @@
import org.apache.cxf.ws.security.policy.interceptors.WSSecurityInterceptorProvider;
import org.apache.cxf.ws.security.policy.interceptors.WSSecurityPolicyInterceptorProvider;
-
-public class WSSecurityPolicyLoader {
+@NoJSR250Annotations
+public final class WSSecurityPolicyLoader implements PolicyInterceptorProviderLoader, AssertionBuilderLoader {
Bus bus;
- @Resource(name = "cxf")
- public void setBus(Bus b) {
+ WSSecurityPolicyLoader(Bus b) {
bus = b;
- }
-
- @PostConstruct
- public void register() {
registerBuilders();
try {
registerProviders();
Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/ContentEncryptedElementsBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/ContentEncryptedElementsBuilder.java?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/ContentEncryptedElementsBuilder.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/builders/ContentEncryptedElementsBuilder.java Tue Aug 25 18:24:33 2009
@@ -37,7 +37,8 @@
public class ContentEncryptedElementsBuilder implements AssertionBuilder {
-
+ public static final List<QName> KNOWN_ELEMENTS
+ = Collections.singletonList(SP12Constants.CONTENT_ENCRYPTED_ELEMENTS);
public PolicyAssertion build(Element element) {
@@ -59,7 +60,7 @@
return contentEncryptedElements;
}
public List<QName> getKnownElements() {
- return Collections.singletonList(SP12Constants.CONTENT_ENCRYPTED_ELEMENTS);
+ return KNOWN_ELEMENTS;
}
private void processElement(Element element, ContentEncryptedElements parent) {
if (SPConstants.XPATH_EXPR.equals(element.getLocalName())) {
Modified: cxf/trunk/rt/ws/security/src/main/resources/META-INF/cxf/cxf-extension-ws-security.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/resources/META-INF/cxf/cxf-extension-ws-security.xml?rev=807750&r1=807749&r2=807750&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/resources/META-INF/cxf/cxf-extension-ws-security.xml (original)
+++ cxf/trunk/rt/ws/security/src/main/resources/META-INF/cxf/cxf-extension-ws-security.xml Tue Aug 25 18:24:33 2009
@@ -24,7 +24,8 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader"
- class="org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader">
- <property name="bus" ref="cxf"/>
+ class="org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader"
+ lazy-init="true">
+ <constructor-arg ref="cxf"/>
</bean>
</beans>
\ No newline at end of file