Repository: cxf Updated Branches: refs/heads/master a64ded455 -> 131c3fdba
[CXF-5914]: Extend AbstractPolicyProvider.getEffectivePolicy() with optional message parameter Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/131c3fdb Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/131c3fdb Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/131c3fdb Branch: refs/heads/master Commit: 131c3fdba9c4825b739adc3d149d0297175b8a86 Parents: a64ded4 Author: Andrei Shakirin <andrei.shaki...@gmail.com> Authored: Thu Jul 31 13:32:52 2014 +0200 Committer: Andrei Shakirin <andrei.shaki...@gmail.com> Committed: Thu Jul 31 13:32:52 2014 +0200 ---------------------------------------------------------------------- .../cxf/ws/policy/EffectivePolicyImpl.java | 8 +-- .../cxf/ws/policy/EndpointPolicyImpl.java | 8 +-- .../apache/cxf/ws/policy/PolicyEngineImpl.java | 20 +++---- .../apache/cxf/ws/policy/PolicyProvider.java | 11 ++-- .../attachment/ServiceModelPolicyProvider.java | 11 ++-- .../external/ExternalAttachmentProvider.java | 18 +++--- .../wsdl11/Wsdl11AttachmentPolicyProvider.java | 11 ++-- .../cxf/ws/policy/EffectivePolicyImplTest.java | 8 +-- .../cxf/ws/policy/EndpointPolicyImplTest.java | 10 ++-- .../apache/cxf/ws/policy/PolicyEngineTest.java | 60 ++++++++++---------- .../ExternalAttachmentProviderTest.java | 20 +++---- .../Wsdl11AttachmentPolicyProviderTest.java | 40 ++++++------- 12 files changed, 115 insertions(+), 110 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java index 15bc32e..d46e3b6 100644 --- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java +++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java @@ -170,9 +170,9 @@ public class EffectivePolicyImpl implements EffectivePolicy { assertor = ((EndpointPolicyImpl)ep).getAssertor(); } - policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedOperationPolicy(boi)); + policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedOperationPolicy(boi, m)); if (null != bmi) { - policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedMessagePolicy(bmi)); + policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedMessagePolicy(bmi, m)); } policy = policy.normalize(engine.getRegistry(), true); return assertor; @@ -181,9 +181,9 @@ public class EffectivePolicyImpl implements EffectivePolicy { void initialisePolicy(EndpointInfo ei, BindingOperationInfo boi, BindingFaultInfo bfi, PolicyEngine engine, Message m) { policy = engine.getServerEndpointPolicy(ei, (Destination)null, m).getPolicy(); - policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedOperationPolicy(boi)); + policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedOperationPolicy(boi, m)); if (bfi != null) { - policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedFaultPolicy(bfi)); + policy = policy.merge(((PolicyEngineImpl)engine).getAggregatedFaultPolicy(bfi, m)); } policy = policy.normalize(engine.getRegistry(), true); } http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java index 7a8bad5..a2c56a4 100644 --- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java +++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java @@ -137,7 +137,7 @@ public class EndpointPolicyImpl implements EndpointPolicy { } public void initialize(Message m) { - initializePolicy(); + initializePolicy(m); checkExactlyOnes(); finalizeConfig(m); } @@ -146,10 +146,10 @@ public class EndpointPolicyImpl implements EndpointPolicy { chooseAlternative(m); } - void initializePolicy() { + void initializePolicy(Message m) { if (engine != null) { - policy = engine.getAggregatedServicePolicy(ei.getService()); - policy = policy.merge(engine.getAggregatedEndpointPolicy(ei)); + policy = engine.getAggregatedServicePolicy(ei.getService(), m); + policy = policy.merge(engine.getAggregatedEndpointPolicy(ei, m)); if (!policy.isEmpty()) { policy = policy.normalize(engine.getRegistry(), true); } http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java index 54e2c95..511a26c 100644 --- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java +++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java @@ -429,13 +429,13 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension { addedBusInterceptors = true; } - Policy getAggregatedServicePolicy(ServiceInfo si) { + Policy getAggregatedServicePolicy(ServiceInfo si, Message m) { if (si == null) { return new Policy(); } Policy aggregated = null; for (PolicyProvider pp : getPolicyProviders()) { - Policy p = pp.getEffectivePolicy(si); + Policy p = pp.getEffectivePolicy(si, m); if (null == aggregated) { aggregated = p; } else if (p != null) { @@ -445,10 +445,10 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension { return aggregated == null ? new Policy() : aggregated; } - Policy getAggregatedEndpointPolicy(EndpointInfo ei) { + Policy getAggregatedEndpointPolicy(EndpointInfo ei, Message m) { Policy aggregated = null; for (PolicyProvider pp : getPolicyProviders()) { - Policy p = pp.getEffectivePolicy(ei); + Policy p = pp.getEffectivePolicy(ei, m); if (null == aggregated) { aggregated = p; } else if (p != null) { @@ -458,10 +458,10 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension { return aggregated == null ? new Policy() : aggregated; } - Policy getAggregatedOperationPolicy(BindingOperationInfo boi) { + Policy getAggregatedOperationPolicy(BindingOperationInfo boi, Message m) { Policy aggregated = null; for (PolicyProvider pp : getPolicyProviders()) { - Policy p = pp.getEffectivePolicy(boi); + Policy p = pp.getEffectivePolicy(boi, m); if (null == aggregated) { aggregated = p; } else if (p != null) { @@ -471,10 +471,10 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension { return aggregated == null ? new Policy() : aggregated; } - Policy getAggregatedMessagePolicy(BindingMessageInfo bmi) { + Policy getAggregatedMessagePolicy(BindingMessageInfo bmi, Message m) { Policy aggregated = null; for (PolicyProvider pp : getPolicyProviders()) { - Policy p = pp.getEffectivePolicy(bmi); + Policy p = pp.getEffectivePolicy(bmi, m); if (null == aggregated) { aggregated = p; } else if (p != null) { @@ -484,10 +484,10 @@ public class PolicyEngineImpl implements PolicyEngine, BusExtension { return aggregated == null ? new Policy() : aggregated; } - Policy getAggregatedFaultPolicy(BindingFaultInfo bfi) { + Policy getAggregatedFaultPolicy(BindingFaultInfo bfi, Message m) { Policy aggregated = null; for (PolicyProvider pp : getPolicyProviders()) { - Policy p = pp.getEffectivePolicy(bfi); + Policy p = pp.getEffectivePolicy(bfi, m); if (null == aggregated) { aggregated = p; } else if (p != null) { http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyProvider.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyProvider.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyProvider.java index fb949d6..c031e88 100644 --- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyProvider.java +++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyProvider.java @@ -19,6 +19,7 @@ package org.apache.cxf.ws.policy; +import org.apache.cxf.message.Message; import org.apache.cxf.service.model.BindingFaultInfo; import org.apache.cxf.service.model.BindingMessageInfo; import org.apache.cxf.service.model.BindingOperationInfo; @@ -31,14 +32,14 @@ import org.apache.neethi.Policy; */ public interface PolicyProvider { - Policy getEffectivePolicy(ServiceInfo si); + Policy getEffectivePolicy(ServiceInfo si, Message m); - Policy getEffectivePolicy(EndpointInfo ei); + Policy getEffectivePolicy(EndpointInfo ei, Message m); - Policy getEffectivePolicy(BindingOperationInfo bi); + Policy getEffectivePolicy(BindingOperationInfo bi, Message m); - Policy getEffectivePolicy(BindingMessageInfo bmi); + Policy getEffectivePolicy(BindingMessageInfo bmi, Message m); - Policy getEffectivePolicy(BindingFaultInfo bfi); + Policy getEffectivePolicy(BindingFaultInfo bfi, Message m); } http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/ServiceModelPolicyProvider.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/ServiceModelPolicyProvider.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/ServiceModelPolicyProvider.java index 2ef2410..4012b07 100644 --- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/ServiceModelPolicyProvider.java +++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/ServiceModelPolicyProvider.java @@ -21,6 +21,7 @@ package org.apache.cxf.ws.policy.attachment; import org.apache.cxf.Bus; import org.apache.cxf.common.injection.NoJSR250Annotations; +import org.apache.cxf.message.Message; import org.apache.cxf.service.model.BindingFaultInfo; import org.apache.cxf.service.model.BindingMessageInfo; import org.apache.cxf.service.model.BindingOperationInfo; @@ -35,23 +36,23 @@ public class ServiceModelPolicyProvider extends AbstractPolicyProvider { super(b); } - public Policy getEffectivePolicy(BindingFaultInfo bfi) { + public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) { return bfi.getExtensor(Policy.class); } - public Policy getEffectivePolicy(BindingMessageInfo bmi) { + public Policy getEffectivePolicy(BindingMessageInfo bmi, Message m) { return bmi.getExtensor(Policy.class); } - public Policy getEffectivePolicy(BindingOperationInfo bi) { + public Policy getEffectivePolicy(BindingOperationInfo bi, Message m) { return bi.getExtensor(Policy.class); } - public Policy getEffectivePolicy(EndpointInfo ei) { + public Policy getEffectivePolicy(EndpointInfo ei, Message m) { return ei.getExtensor(Policy.class); } - public Policy getEffectivePolicy(ServiceInfo si) { + public Policy getEffectivePolicy(ServiceInfo si, Message m) { return si.getExtensor(Policy.class); } http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java index 30d0466..5167ce0 100644 --- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java +++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java @@ -29,11 +29,10 @@ import javax.xml.namespace.QName; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; - import org.apache.cxf.Bus; import org.apache.cxf.common.i18n.BundleUtils; -import org.apache.cxf.common.i18n.Message; import org.apache.cxf.common.injection.NoJSR250Annotations; +import org.apache.cxf.message.Message; import org.apache.cxf.service.model.BindingFaultInfo; import org.apache.cxf.service.model.BindingMessageInfo; import org.apache.cxf.service.model.BindingOperationInfo; @@ -79,7 +78,7 @@ public class ExternalAttachmentProvider extends AbstractPolicyProvider { return location; } - public Policy getEffectivePolicy(BindingFaultInfo bfi) { + public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) { readDocument(); Policy p = null; for (PolicyAttachment pa : attachments) { @@ -94,7 +93,7 @@ public class ExternalAttachmentProvider extends AbstractPolicyProvider { return p; } - public Policy getEffectivePolicy(BindingMessageInfo bmi) { + public Policy getEffectivePolicy(BindingMessageInfo bmi, Message m) { readDocument(); Policy p = null; for (PolicyAttachment pa : attachments) { @@ -108,7 +107,7 @@ public class ExternalAttachmentProvider extends AbstractPolicyProvider { return p; } - public Policy getEffectivePolicy(BindingOperationInfo boi) { + public Policy getEffectivePolicy(BindingOperationInfo boi, Message m) { readDocument(); Policy p = null; for (PolicyAttachment pa : attachments) { @@ -123,7 +122,7 @@ public class ExternalAttachmentProvider extends AbstractPolicyProvider { return p; } - public Policy getEffectivePolicy(EndpointInfo ei) { + public Policy getEffectivePolicy(EndpointInfo ei, Message m) { readDocument(); Policy p = null; for (PolicyAttachment pa : attachments) { @@ -138,7 +137,7 @@ public class ExternalAttachmentProvider extends AbstractPolicyProvider { return p; } - public Policy getEffectivePolicy(ServiceInfo si) { + public Policy getEffectivePolicy(ServiceInfo si, Message m) { readDocument(); Policy p = null; for (PolicyAttachment pa : attachments) { @@ -164,7 +163,10 @@ public class ExternalAttachmentProvider extends AbstractPolicyProvider { try { InputStream is = location.getInputStream(); if (null == is) { - throw new PolicyException(new Message("COULD_NOT_OPEN_ATTACHMENT_DOC_EXC", BUNDLE, location)); + throw new PolicyException( + new org.apache.cxf.common.i18n.Message( + "COULD_NOT_OPEN_ATTACHMENT_DOC_EXC", + BUNDLE, location)); } doc = StaxUtils.read(is); } catch (Exception ex) { http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java index 844b2e3..2b96a23 100644 --- a/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java +++ b/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java @@ -35,6 +35,7 @@ import org.apache.cxf.common.injection.NoJSR250Annotations; import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.message.Message; import org.apache.cxf.service.model.AbstractDescriptionElement; import org.apache.cxf.service.model.BindingFaultInfo; import org.apache.cxf.service.model.BindingMessageInfo; @@ -70,7 +71,7 @@ public class Wsdl11AttachmentPolicyProvider extends AbstractPolicyProvider { super(bus); } - public Policy getEffectivePolicy(ServiceInfo si) { + public Policy getEffectivePolicy(ServiceInfo si, Message m) { return getElementPolicy(si); } @@ -92,7 +93,7 @@ public class Wsdl11AttachmentPolicyProvider extends AbstractPolicyProvider { * @param ei the EndpointInfo object identifying the endpoint * @return the effective policy */ - public Policy getEffectivePolicy(EndpointInfo ei) { + public Policy getEffectivePolicy(EndpointInfo ei, Message m) { Policy p = getElementPolicy(ei); p = mergePolicies(p, getElementPolicy(ei.getBinding())); p = mergePolicies(p, getElementPolicy(ei.getInterface(), true)); @@ -109,7 +110,7 @@ public class Wsdl11AttachmentPolicyProvider extends AbstractPolicyProvider { * @param bi the BindingOperationInfo identifying the operation in relation to a port * @return the effective policy */ - public Policy getEffectivePolicy(BindingOperationInfo bi) { + public Policy getEffectivePolicy(BindingOperationInfo bi, Message m) { DescriptionInfo di = bi.getBinding().getDescription(); Policy p = getElementPolicy(bi, false, di); p = mergePolicies(p, getElementPolicy(bi.getOperationInfo(), false, di)); @@ -129,7 +130,7 @@ public class Wsdl11AttachmentPolicyProvider extends AbstractPolicyProvider { * @param bmi the BindingMessageInfo identifiying the message * @return the effective policy */ - public Policy getEffectivePolicy(BindingMessageInfo bmi) { + public Policy getEffectivePolicy(BindingMessageInfo bmi, Message m) { ServiceInfo si = bmi.getBindingOperation().getBinding().getService(); DescriptionInfo di = si.getDescription(); Policy p = getElementPolicy(bmi, false, di); @@ -143,7 +144,7 @@ public class Wsdl11AttachmentPolicyProvider extends AbstractPolicyProvider { - public Policy getEffectivePolicy(BindingFaultInfo bfi) { + public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) { ServiceInfo si = bfi.getBindingOperation().getBinding().getService(); DescriptionInfo di = si.getDescription(); http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java index 92a8749..ddacb3a 100644 --- a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java +++ b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java @@ -201,11 +201,11 @@ public class EffectivePolicyImplTest extends Assert { Policy ep = control.createMock(Policy.class); EasyMock.expect(effectivePolicy.getPolicy()).andReturn(ep); Policy op = control.createMock(Policy.class); - EasyMock.expect(engine.getAggregatedOperationPolicy(boi)).andReturn(op); + EasyMock.expect(engine.getAggregatedOperationPolicy(boi, null)).andReturn(op); Policy merged = control.createMock(Policy.class); EasyMock.expect(ep.merge(op)).andReturn(merged); Policy mp = control.createMock(Policy.class); - EasyMock.expect(engine.getAggregatedMessagePolicy(bmi)).andReturn(mp); + EasyMock.expect(engine.getAggregatedMessagePolicy(bmi, null)).andReturn(mp); EasyMock.expect(merged.merge(mp)).andReturn(merged); EasyMock.expect(merged.normalize(null, true)).andReturn(merged); @@ -230,11 +230,11 @@ public class EffectivePolicyImplTest extends Assert { Policy ep = control.createMock(Policy.class); EasyMock.expect(endpointPolicy.getPolicy()).andReturn(ep); Policy op = control.createMock(Policy.class); - EasyMock.expect(engine.getAggregatedOperationPolicy(boi)).andReturn(op); + EasyMock.expect(engine.getAggregatedOperationPolicy(boi, m)).andReturn(op); Policy merged = control.createMock(Policy.class); EasyMock.expect(ep.merge(op)).andReturn(merged); Policy fp = control.createMock(Policy.class); - EasyMock.expect(engine.getAggregatedFaultPolicy(bfi)).andReturn(fp); + EasyMock.expect(engine.getAggregatedFaultPolicy(bfi, m)).andReturn(fp); EasyMock.expect(merged.merge(fp)).andReturn(merged); EasyMock.expect(merged.normalize(null, true)).andReturn(merged); http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java index 42dc83b..cc863d1 100644 --- a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java +++ b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java @@ -113,7 +113,7 @@ public class EndpointPolicyImplTest extends Assert { @Test public void testInitialize() throws NoSuchMethodException { Message m = new MessageImpl(); - Method m1 = EndpointPolicyImpl.class.getDeclaredMethod("initializePolicy", new Class[] {}); + Method m1 = EndpointPolicyImpl.class.getDeclaredMethod("initializePolicy", new Class[] {Message.class}); Method m2 = EndpointPolicyImpl.class.getDeclaredMethod("checkExactlyOnes", new Class[] {}); Method m3 = EndpointPolicyImpl.class.getDeclaredMethod("chooseAlternative", new Class[] {Message.class}); Method m4 = EndpointPolicyImpl.class.getDeclaredMethod("initializeVocabulary", new Class[] {Message.class}); @@ -121,7 +121,7 @@ public class EndpointPolicyImplTest extends Assert { EndpointPolicyImpl epi = EasyMock.createMockBuilder(EndpointPolicyImpl.class) .addMockedMethods(m1, m2, m3, m4, m5).createMock(control); - epi.initializePolicy(); + epi.initializePolicy(m); EasyMock.expectLastCall(); epi.checkExactlyOnes(); EasyMock.expectLastCall(); @@ -140,16 +140,16 @@ public class EndpointPolicyImplTest extends Assert { ServiceInfo si = control.createMock(ServiceInfo.class); EasyMock.expect(ei.getService()).andReturn(si); Policy sp = control.createMock(Policy.class); - EasyMock.expect(engine.getAggregatedServicePolicy(si)).andReturn(sp); + EasyMock.expect(engine.getAggregatedServicePolicy(si, null)).andReturn(sp); Policy ep = control.createMock(Policy.class); - EasyMock.expect(engine.getAggregatedEndpointPolicy(ei)).andReturn(ep); + EasyMock.expect(engine.getAggregatedEndpointPolicy(ei, null)).andReturn(ep); Policy merged = control.createMock(Policy.class); EasyMock.expect(sp.merge(ep)).andReturn(merged); EasyMock.expect(merged.normalize(null, true)).andReturn(merged); control.replay(); EndpointPolicyImpl epi = new EndpointPolicyImpl(ei, engine, true, null); - epi.initializePolicy(); + epi.initializePolicy(null); assertSame(merged, epi.getPolicy()); control.verify(); } http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java index f993f79..0d123c7 100644 --- a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java +++ b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java @@ -429,7 +429,7 @@ public class PolicyEngineTest extends Assert { ServiceInfo si = control.createMock(ServiceInfo.class); control.replay(); - Policy p = engine.getAggregatedServicePolicy(si); + Policy p = engine.getAggregatedServicePolicy(si, null); assertTrue(p.isEmpty()); control.verify(); control.reset(); @@ -437,10 +437,10 @@ public class PolicyEngineTest extends Assert { PolicyProvider provider1 = control.createMock(PolicyProvider.class); engine.getPolicyProviders().add(provider1); Policy p1 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(si)).andReturn(p1); + EasyMock.expect(provider1.getEffectivePolicy(si, null)).andReturn(p1); control.replay(); - assertSame(p1, engine.getAggregatedServicePolicy(si)); + assertSame(p1, engine.getAggregatedServicePolicy(si, null)); control.verify(); control.reset(); @@ -448,12 +448,12 @@ public class PolicyEngineTest extends Assert { engine.getPolicyProviders().add(provider2); Policy p2 = control.createMock(Policy.class); Policy p3 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(si)).andReturn(p1); - EasyMock.expect(provider2.getEffectivePolicy(si)).andReturn(p2); + EasyMock.expect(provider1.getEffectivePolicy(si, null)).andReturn(p1); + EasyMock.expect(provider2.getEffectivePolicy(si, null)).andReturn(p2); EasyMock.expect(p1.merge(p2)).andReturn(p3); control.replay(); - assertSame(p3, engine.getAggregatedServicePolicy(si)); + assertSame(p3, engine.getAggregatedServicePolicy(si, null)); control.verify(); } @@ -463,7 +463,7 @@ public class PolicyEngineTest extends Assert { EndpointInfo ei = createMockEndpointInfo(); control.replay(); - Policy p = engine.getAggregatedEndpointPolicy(ei); + Policy p = engine.getAggregatedEndpointPolicy(ei, null); assertTrue(p.isEmpty()); control.verify(); control.reset(); @@ -471,10 +471,10 @@ public class PolicyEngineTest extends Assert { PolicyProvider provider1 = control.createMock(PolicyProvider.class); engine.getPolicyProviders().add(provider1); Policy p1 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(ei)).andReturn(p1); + EasyMock.expect(provider1.getEffectivePolicy(ei, null)).andReturn(p1); control.replay(); - assertSame(p1, engine.getAggregatedEndpointPolicy(ei)); + assertSame(p1, engine.getAggregatedEndpointPolicy(ei, null)); control.verify(); control.reset(); @@ -482,12 +482,12 @@ public class PolicyEngineTest extends Assert { engine.getPolicyProviders().add(provider2); Policy p2 = control.createMock(Policy.class); Policy p3 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(ei)).andReturn(p1); - EasyMock.expect(provider2.getEffectivePolicy(ei)).andReturn(p2); + EasyMock.expect(provider1.getEffectivePolicy(ei, null)).andReturn(p1); + EasyMock.expect(provider2.getEffectivePolicy(ei, null)).andReturn(p2); EasyMock.expect(p1.merge(p2)).andReturn(p3); control.replay(); - assertSame(p3, engine.getAggregatedEndpointPolicy(ei)); + assertSame(p3, engine.getAggregatedEndpointPolicy(ei, null)); control.verify(); } @@ -497,7 +497,7 @@ public class PolicyEngineTest extends Assert { BindingOperationInfo boi = createMockBindingOperationInfo(); control.replay(); - Policy p = engine.getAggregatedOperationPolicy(boi); + Policy p = engine.getAggregatedOperationPolicy(boi, null); assertTrue(p.isEmpty()); control.verify(); control.reset(); @@ -505,10 +505,10 @@ public class PolicyEngineTest extends Assert { PolicyProvider provider1 = control.createMock(PolicyProvider.class); engine.getPolicyProviders().add(provider1); Policy p1 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(boi)).andReturn(p1); + EasyMock.expect(provider1.getEffectivePolicy(boi, null)).andReturn(p1); control.replay(); - assertSame(p1, engine.getAggregatedOperationPolicy(boi)); + assertSame(p1, engine.getAggregatedOperationPolicy(boi, null)); control.verify(); control.reset(); @@ -516,12 +516,12 @@ public class PolicyEngineTest extends Assert { engine.getPolicyProviders().add(provider2); Policy p2 = control.createMock(Policy.class); Policy p3 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(boi)).andReturn(p1); - EasyMock.expect(provider2.getEffectivePolicy(boi)).andReturn(p2); + EasyMock.expect(provider1.getEffectivePolicy(boi, null)).andReturn(p1); + EasyMock.expect(provider2.getEffectivePolicy(boi, null)).andReturn(p2); EasyMock.expect(p1.merge(p2)).andReturn(p3); control.replay(); - assertSame(p3, engine.getAggregatedOperationPolicy(boi)); + assertSame(p3, engine.getAggregatedOperationPolicy(boi, null)); control.verify(); } @@ -531,7 +531,7 @@ public class PolicyEngineTest extends Assert { BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class); control.replay(); - Policy p = engine.getAggregatedMessagePolicy(bmi); + Policy p = engine.getAggregatedMessagePolicy(bmi, null); assertTrue(p.isEmpty()); control.verify(); control.reset(); @@ -539,10 +539,10 @@ public class PolicyEngineTest extends Assert { PolicyProvider provider1 = control.createMock(PolicyProvider.class); engine.getPolicyProviders().add(provider1); Policy p1 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(bmi)).andReturn(p1); + EasyMock.expect(provider1.getEffectivePolicy(bmi, null)).andReturn(p1); control.replay(); - assertSame(p1, engine.getAggregatedMessagePolicy(bmi)); + assertSame(p1, engine.getAggregatedMessagePolicy(bmi, null)); control.verify(); control.reset(); @@ -550,12 +550,12 @@ public class PolicyEngineTest extends Assert { engine.getPolicyProviders().add(provider2); Policy p2 = control.createMock(Policy.class); Policy p3 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(bmi)).andReturn(p1); - EasyMock.expect(provider2.getEffectivePolicy(bmi)).andReturn(p2); + EasyMock.expect(provider1.getEffectivePolicy(bmi, null)).andReturn(p1); + EasyMock.expect(provider2.getEffectivePolicy(bmi, null)).andReturn(p2); EasyMock.expect(p1.merge(p2)).andReturn(p3); control.replay(); - assertSame(p3, engine.getAggregatedMessagePolicy(bmi)); + assertSame(p3, engine.getAggregatedMessagePolicy(bmi, null)); control.verify(); } @@ -565,7 +565,7 @@ public class PolicyEngineTest extends Assert { BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); control.replay(); - Policy p = engine.getAggregatedFaultPolicy(bfi); + Policy p = engine.getAggregatedFaultPolicy(bfi, null); assertTrue(p.isEmpty()); control.verify(); control.reset(); @@ -573,10 +573,10 @@ public class PolicyEngineTest extends Assert { PolicyProvider provider1 = control.createMock(PolicyProvider.class); engine.getPolicyProviders().add(provider1); Policy p1 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(bfi)).andReturn(p1); + EasyMock.expect(provider1.getEffectivePolicy(bfi, null)).andReturn(p1); control.replay(); - assertSame(p1, engine.getAggregatedFaultPolicy(bfi)); + assertSame(p1, engine.getAggregatedFaultPolicy(bfi, null)); control.verify(); control.reset(); @@ -584,12 +584,12 @@ public class PolicyEngineTest extends Assert { engine.getPolicyProviders().add(provider2); Policy p2 = control.createMock(Policy.class); Policy p3 = control.createMock(Policy.class); - EasyMock.expect(provider1.getEffectivePolicy(bfi)).andReturn(p1); - EasyMock.expect(provider2.getEffectivePolicy(bfi)).andReturn(p2); + EasyMock.expect(provider1.getEffectivePolicy(bfi, null)).andReturn(p1); + EasyMock.expect(provider2.getEffectivePolicy(bfi, null)).andReturn(p2); EasyMock.expect(p1.merge(p2)).andReturn(p3); control.replay(); - assertSame(p3, engine.getAggregatedFaultPolicy(bfi)); + assertSame(p3, engine.getAggregatedFaultPolicy(bfi, null)); control.verify(); } http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java index bb98229..1e1dd56 100644 --- a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java +++ b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java @@ -84,13 +84,13 @@ public class ExternalAttachmentProviderTest extends Assert { BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); setUpAttachment(bfi, false, eap); control.replay(); - assertNull(eap.getEffectivePolicy(bfi)); + assertNull(eap.getEffectivePolicy(bfi, null)); control.verify(); control.reset(); setUpAttachment(bfi, true, eap); control.replay(); - assertSame(assertion, eap.getEffectivePolicy(bfi).getAssertions().get(0)); + assertSame(assertion, eap.getEffectivePolicy(bfi, null).getAssertions().get(0)); control.verify(); } @@ -100,13 +100,13 @@ public class ExternalAttachmentProviderTest extends Assert { BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class); setUpAttachment(bmi, false, eap); control.replay(); - assertNull(eap.getEffectivePolicy(bmi)); + assertNull(eap.getEffectivePolicy(bmi, null)); control.verify(); control.reset(); setUpAttachment(bmi, true, eap); control.replay(); - assertSame(assertion, eap.getEffectivePolicy(bmi).getAssertions().get(0)); + assertSame(assertion, eap.getEffectivePolicy(bmi, null).getAssertions().get(0)); control.verify(); } @@ -116,13 +116,13 @@ public class ExternalAttachmentProviderTest extends Assert { ExternalAttachmentProvider eap = new ExternalAttachmentProvider(); setUpAttachment(boi, false, eap); control.replay(); - assertNull(eap.getEffectivePolicy(boi)); + assertNull(eap.getEffectivePolicy(boi, null)); control.verify(); control.reset(); setUpAttachment(boi, true, eap); control.replay(); - assertSame(assertion, eap.getEffectivePolicy(boi).getAssertions().get(0)); + assertSame(assertion, eap.getEffectivePolicy(boi, null).getAssertions().get(0)); control.verify(); } @@ -132,13 +132,13 @@ public class ExternalAttachmentProviderTest extends Assert { EndpointInfo ei = control.createMock(EndpointInfo.class); setUpAttachment(ei, false, eap); control.replay(); - assertNull(eap.getEffectivePolicy(ei)); + assertNull(eap.getEffectivePolicy(ei, null)); control.verify(); control.reset(); setUpAttachment(ei, true, eap); control.replay(); - assertSame(assertion, eap.getEffectivePolicy(ei).getAssertions().get(0)); + assertSame(assertion, eap.getEffectivePolicy(ei, null).getAssertions().get(0)); control.verify(); } @@ -148,13 +148,13 @@ public class ExternalAttachmentProviderTest extends Assert { ServiceInfo si = control.createMock(ServiceInfo.class); setUpAttachment(si, false, eap); control.replay(); - assertNull(eap.getEffectivePolicy(si)); + assertNull(eap.getEffectivePolicy(si, null)); control.verify(); control.reset(); setUpAttachment(si, true, eap); control.replay(); - assertSame(assertion, eap.getEffectivePolicy(si).getAssertions().get(0)); + assertSame(assertion, eap.getEffectivePolicy(si, null).getAssertions().get(0)); control.verify(); } http://git-wip-us.apache.org/repos/asf/cxf/blob/131c3fdb/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java ---------------------------------------------------------------------- diff --git a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java index 279395c..f8dc7f5 100644 --- a/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java +++ b/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProviderTest.java @@ -195,25 +195,25 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { Policy ep; // no extensions - ep = app.getEffectivePolicy(services[0]); + ep = app.getEffectivePolicy(services[0], null); assertTrue(ep == null || ep.isEmpty()); p = app.getElementPolicy(services[0]); assertTrue(p == null || p.isEmpty()); // extensions not of type Policy or PolicyReference - ep = app.getEffectivePolicy(services[1]); + ep = app.getEffectivePolicy(services[1], null); assertTrue(ep == null || ep.isEmpty()); // one extension of type Policy, without assertion builder try { - ep = app.getEffectivePolicy(services[2]); + ep = app.getEffectivePolicy(services[2], null); fail("Expected PolicyException not thrown."); } catch (PolicyException ex) { // expected } // one extension of type Policy - ep = app.getEffectivePolicy(services[3]); + ep = app.getEffectivePolicy(services[3], null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 2); @@ -221,7 +221,7 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { assertTrue(PolicyComparator.compare(p, ep)); // two extensions of type Policy - ep = app.getEffectivePolicy(services[4]); + ep = app.getEffectivePolicy(services[4], null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 3); @@ -237,13 +237,13 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { // port has no extensions // porttype has no extensions // binding has no extensions - ep = app.getEffectivePolicy(endpoints[0]); + ep = app.getEffectivePolicy(endpoints[0], null); assertTrue(ep == null || ep.isEmpty()); // port has one extension of type Policy // binding has no extensions // porttype has no extensions - ep = app.getEffectivePolicy(endpoints[5]); + ep = app.getEffectivePolicy(endpoints[5], null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 1); @@ -253,7 +253,7 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { // port has no extensions // binding has one extension of type Policy // porttype has no extensions - ep = app.getEffectivePolicy(endpoints[6]); + ep = app.getEffectivePolicy(endpoints[6], null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 1); @@ -263,7 +263,7 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { // port has no extensions // binding has no extensions // porttype has one extension of type Policy - ep = app.getEffectivePolicy(endpoints[7]); + ep = app.getEffectivePolicy(endpoints[7], null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 1); @@ -273,7 +273,7 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { // port has one extension of type Policy // porttype has one extension of type Policy // binding has one extension of type Policy - ep = app.getEffectivePolicy(endpoints[8]); + ep = app.getEffectivePolicy(endpoints[8], null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 3); @@ -283,7 +283,7 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { // porttype has no extension elements but one extension attribute of type PolicyURIs // consisting of two references (one local, one external) - ep = app.getEffectivePolicy(endpoints[18]); + ep = app.getEffectivePolicy(endpoints[18], null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 2); @@ -295,26 +295,26 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { // operation has no extensions // binding operation has no extensions - ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[0])); + ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[0]), null); assertTrue(ep == null || ep.isEmpty()); // operation has no extensions // binding operation has one extension of type Policy - ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[9])); + ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[9]), null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 1); // operation has one extension of type Policy // binding operation has no extensions - ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[10])); + ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[10]), null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 2); // operation has one extension of type Policy // binding operation one extension of type Policy - ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[11])); + ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[11]), null); assertNotNull(ep); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 3); @@ -327,34 +327,34 @@ public class Wsdl11AttachmentPolicyProviderTest extends Assert { // binding operation message has no extensions // operation message has no extensions // message has no extensions - ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[0], true)); + ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[0], true), null); assertTrue(ep == null || ep.isEmpty()); // binding operation message has one extension of type Policy // operation message has no extensions // message has no extensions - ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[12], true)); + ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[12], true), null); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 1); // binding operation message has no extensions // operation message has one extension of type Policy // message has no extensions - ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[13], true)); + ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[13], true), null); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 1); // binding operation message has no extensions // operation message has no extensions // message has one extension of type Policy - ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[14], true)); + ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[14], true), null); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 1); // binding operation message has one extension of type Policy // operation message has one extension of type Policy // message has one extension of type Policy - ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[15], true)); + ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[15], true), null); assertTrue(!ep.isEmpty()); verifyAssertionsOnly(ep, 3); }