cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r689115 - in /cxf/branches/2.1.x-fixes: ./ api/src/main/java/org/apache/cxf/service/model/ api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ rt/ws/policy/src/test/java/org/apa...
Date Tue, 26 Aug 2008 15:43:32 GMT
Author: dkulp
Date: Tue Aug 26 08:43:31 2008
New Revision: 689115

URL: http://svn.apache.org/viewvc?rev=689115&view=rev
Log:
Merged revisions 688133 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r688133 | dkulp | 2008-08-22 13:43:16 -0400 (Fri, 22 Aug 2008) | 3 lines
  
  [CXF-1656] Updates to policy engine to store policies on the service model itself (so it
get's garbage collected with everything else)
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
    cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
    cxf/branches/2.1.x-fixes/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 26 08:43:31 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug 26 08:43:31 2008
@@ -1 +1 @@
-/cxf/trunk:1-686342,686344-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102
+/cxf/trunk:1-686342,686344-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java?rev=689115&r1=689114&r2=689115&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
(original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
Tue Aug 26 08:43:31 2008
@@ -42,6 +42,7 @@
         service = serv;
     }
     
+    
     public String getTransportId() {
         return transportId;
     }    
@@ -54,6 +55,9 @@
         return service.getInterface();
     }
     
+    public void setService(ServiceInfo s) {
+        service = s;
+    }
     public ServiceInfo getService() {
         return service;
     }
@@ -128,8 +132,8 @@
     }
 
     public String toString() {
-        return "BindingQName=" + binding.getName()
-                + ", ServiceQName=" + binding.getService().getName()
+        return "BindingQName=" + (binding == null ? "" : (binding.getName()
+                + ", ServiceQName=" + (binding.getService() == null ? "" : binding.getService().getName())))
                 + ", QName=" + name;
     }
 }

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java?rev=689115&r1=689114&r2=689115&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
(original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
Tue Aug 26 08:43:31 2008
@@ -68,6 +68,9 @@
         }
     }
 
+    public String toString() {
+        return name.toString();
+    }
     public boolean equal(PolicyComponent policyComponent) {
         if (policyComponent.getType() != Constants.TYPE_ASSERTION) {
             return false;

Modified: cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java?rev=689115&r1=689114&r2=689115&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
Tue Aug 26 08:43:31 2008
@@ -20,15 +20,11 @@
 package org.apache.cxf.ws.policy;
 
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javax.annotation.PostConstruct;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.endpoint.ServerLifeCycleListener;
-import org.apache.cxf.endpoint.ServerLifeCycleManager;
 import org.apache.cxf.extension.BusExtension;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.service.model.BindingFaultInfo;
@@ -49,8 +45,17 @@
 /**
  * 
  */
-public class PolicyEngineImpl implements PolicyEngine, BusExtension, ServerLifeCycleListener
{
-
+public class PolicyEngineImpl implements PolicyEngine, BusExtension {
+    private static final String POLICY_INFO_REQUEST_SERVER = "policy-engine-info-serve-request";
+    private static final String POLICY_INFO_FAULT_SERVER = "policy-engine-info-serve-fault";
+    private static final String POLICY_INFO_RESPONSE_SERVER = "policy-engine-info-serve-response";
+    private static final String POLICY_INFO_ENDPOINT_SERVER = "policy-engine-info-serve-rendpoint";
+    
+    private static final String POLICY_INFO_REQUEST_CLIENT = "policy-engine-info-client-request";
+    private static final String POLICY_INFO_FAULT_CLIENT = "policy-engine-info-client-fault";
+    private static final String POLICY_INFO_RESPONSE_CLIENT = "policy-engine-info-client-response";
+    private static final String POLICY_INFO_ENDPOINT_CLIENT = "policy-engine-info-client-endpoint";
+    
     private Bus bus;
     private PolicyRegistry registry;
     private Collection<PolicyProvider> policyProviders;
@@ -59,14 +64,6 @@
     private boolean addedBusInterceptors;
     private AlternativeSelector alternativeSelector;
 
-    private Map<BindingOperation, EffectivePolicy> clientRequestInfo;
-    private Map<BindingOperation, EffectivePolicy> clientResponseInfo;
-    private Map<BindingFault, EffectivePolicy> clientFaultInfo;
-    private Map<BindingOperation, EffectivePolicy> serverRequestInfo;
-    private Map<BindingOperation, EffectivePolicy> serverResponseInfo;
-    private Map<BindingFault, EffectivePolicy> serverFaultInfo;
-    private Map<EndpointInfo, EndpointPolicy> serverEndpointInfo;
-    private Map<EndpointInfo, EndpointPolicy> clientEndpointInfo;
 
     public PolicyEngineImpl() { 
         init();
@@ -137,16 +134,15 @@
 
     public EffectivePolicy getEffectiveClientRequestPolicy(EndpointInfo ei, BindingOperationInfo
boi, 
                                                            Conduit c) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        EffectivePolicy effectivePolicy = clientRequestInfo.get(bo);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_CLIENT);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
             Assertor assertor = null;
             if (c instanceof Assertor) {
                 assertor = (Assertor)c;
             }
-            epi.initialise(ei, bo.getBindingOperation(), this, assertor, true);
-            clientRequestInfo.put(bo, epi);
+            epi.initialise(ei, boi, this, assertor, true);
+            boi.setProperty(POLICY_INFO_REQUEST_CLIENT, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
@@ -154,22 +150,21 @@
 
     public void setEffectiveClientRequestPolicy(EndpointInfo ei, BindingOperationInfo boi,

                                                 EffectivePolicy ep) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        clientRequestInfo.put(bo, ep);
+        boi.setProperty(POLICY_INFO_REQUEST_CLIENT, ep);
     }
 
-    public EffectivePolicy getEffectiveServerResponsePolicy(EndpointInfo ei, BindingOperationInfo
boi,
+    public EffectivePolicy getEffectiveServerResponsePolicy(EndpointInfo ei,
+                                                            BindingOperationInfo boi,
                                                             Destination d) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        EffectivePolicy effectivePolicy = serverResponseInfo.get(bo);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_SERVER);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
             Assertor assertor = null;
             if (d instanceof Assertor) {
                 assertor = (Assertor)d;
             }
-            epi.initialise(ei, bo.getBindingOperation(), this, assertor, false);
-            serverResponseInfo.put(bo, epi);
+            epi.initialise(ei, boi, this, assertor, false);
+            boi.setProperty(POLICY_INFO_RESPONSE_SERVER, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
@@ -177,14 +172,12 @@
 
     public void setEffectiveServerResponsePolicy(EndpointInfo ei, BindingOperationInfo boi,

                                                  EffectivePolicy ep) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        serverResponseInfo.put(bo, ep);
+        boi.setProperty(POLICY_INFO_RESPONSE_SERVER, ep);
     }
   
     public EffectivePolicy getEffectiveServerFaultPolicy(EndpointInfo ei, BindingFaultInfo
bfi, 
                                                          Destination d) {
-        BindingFault bf = new BindingFault(ei, bfi);
-        EffectivePolicy effectivePolicy = serverFaultInfo.get(bf);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_SERVER);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
             Assertor assertor = null;
@@ -192,30 +185,33 @@
                 assertor = (Assertor)d;
             }
             epi.initialise(ei, bfi, this, assertor);
-            serverFaultInfo.put(bf, epi);
+            bfi.setProperty(POLICY_INFO_FAULT_SERVER, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
     }
 
     public void setEffectiveServerFaultPolicy(EndpointInfo ei, BindingFaultInfo bfi, EffectivePolicy
ep) {
-        BindingFault bf = new BindingFault(ei, bfi);
-        serverFaultInfo.put(bf, ep);
+        bfi.setProperty(POLICY_INFO_FAULT_SERVER, ep);
     }
 
     public EndpointPolicy getClientEndpointPolicy(EndpointInfo ei, Conduit conduit) {
         Assertor assertor = conduit instanceof Assertor ? (Assertor)conduit : null;
-        return getEndpointPolicy(ei, clientEndpointInfo.get(ei), true, assertor);
+        return getEndpointPolicy(ei, true, assertor);
     }
    
     public EndpointPolicy getServerEndpointPolicy(EndpointInfo ei, Destination destination)
{
     
         Assertor assertor = destination instanceof Assertor ? (Assertor)destination : null;
-        return getEndpointPolicy(ei, serverEndpointInfo.get(ei), false, assertor);
+        return getEndpointPolicy(ei, false, assertor);
     }
 
     private EndpointPolicy getEndpointPolicy(
-        EndpointInfo ei, EndpointPolicy ep, boolean isRequestor, Assertor assertor) {
+        EndpointInfo ei, 
+        boolean isRequestor,
+        Assertor assertor) {
+        EndpointPolicy ep = (EndpointPolicy)ei.getProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT

+                            : POLICY_INFO_ENDPOINT_SERVER);
         if (null != ep) {
             return ep; 
         }
@@ -223,20 +219,19 @@
     }
 
     public void setClientEndpointPolicy(EndpointInfo ei, EndpointPolicy ep) {
-        clientEndpointInfo.put(ei, ep);
+        ei.setProperty(POLICY_INFO_ENDPOINT_CLIENT, ep);
     }
 
     public void setServerEndpointPolicy(EndpointInfo ei, EndpointPolicy ep) {
-        serverEndpointInfo.put(ei, ep);
+        ei.setProperty(POLICY_INFO_ENDPOINT_SERVER, ep);
     }
 
     public EffectivePolicy getEffectiveServerRequestPolicy(EndpointInfo ei, BindingOperationInfo
boi) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        EffectivePolicy effectivePolicy = serverRequestInfo.get(bo);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
-            epi.initialisePolicy(ei, bo.getBindingOperation(), this, false);
-            serverRequestInfo.put(bo, epi);
+            epi.initialisePolicy(ei, boi, this, false);
+            boi.setProperty(POLICY_INFO_REQUEST_SERVER, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
@@ -244,17 +239,15 @@
 
     public void setEffectiveServerRequestPolicy(EndpointInfo ei, BindingOperationInfo boi,

                                                 EffectivePolicy ep) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        serverRequestInfo.put(bo, ep);
+        boi.setProperty(POLICY_INFO_REQUEST_SERVER, ep);        
     }
 
     public EffectivePolicy getEffectiveClientResponsePolicy(EndpointInfo ei, BindingOperationInfo
boi) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        EffectivePolicy effectivePolicy = clientResponseInfo.get(bo);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_CLIENT);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
-            epi.initialisePolicy(ei, bo.getBindingOperation(), this, true);        
-            clientResponseInfo.put(bo, epi);
+            epi.initialisePolicy(ei, boi, this, true);        
+            boi.setProperty(POLICY_INFO_RESPONSE_CLIENT, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
@@ -262,55 +255,29 @@
 
     public void setEffectiveClientResponsePolicy(EndpointInfo ei, BindingOperationInfo boi,

                                                  EffectivePolicy ep) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        clientResponseInfo.put(bo, ep);
+        boi.setProperty(POLICY_INFO_RESPONSE_CLIENT, ep);
     }
 
     public EffectivePolicy getEffectiveClientFaultPolicy(EndpointInfo ei, BindingFaultInfo
bfi) {
-        BindingFault bf = new BindingFault(ei, bfi);
-        EffectivePolicy effectivePolicy = clientFaultInfo.get(bf);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_CLIENT);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
             epi.initialisePolicy(ei, bfi, this);
-            clientFaultInfo.put(bf, epi);
+            bfi.setProperty(POLICY_INFO_FAULT_CLIENT, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
     }
 
     public void setEffectiveClientFaultPolicy(EndpointInfo ei, BindingFaultInfo bfi, EffectivePolicy
ep) {
-        BindingFault bf = new BindingFault(ei, bfi);
-        clientFaultInfo.put(bf, ep);
+        bfi.setProperty(POLICY_INFO_FAULT_CLIENT, ep);
     }
 
     // implementation
 
     protected final void init() {
-    
         registry = new PolicyRegistryImpl();
-    
-        clientRequestInfo 
-            = new ConcurrentHashMap<BindingOperation, EffectivePolicy>();
-
-        clientResponseInfo 
-            = new ConcurrentHashMap<BindingOperation, EffectivePolicy>();
-
-        clientFaultInfo 
-            = new ConcurrentHashMap<BindingFault, EffectivePolicy>();
-
-        serverEndpointInfo 
-            = new EndpointPolicyMap();
-        clientEndpointInfo 
-            = new EndpointPolicyMap();
-
-        serverRequestInfo 
-            = new ConcurrentHashMap<BindingOperation, EffectivePolicy>();
 
-        serverResponseInfo 
-            = new ConcurrentHashMap<BindingOperation, EffectivePolicy>();
-
-        serverFaultInfo 
-            = new ConcurrentHashMap<BindingFault, EffectivePolicy>();    
     }
 
 
@@ -364,14 +331,6 @@
         addedBusInterceptors = true;
     }  
 
-    @PostConstruct
-    public void registerListener() {
-        ServerLifeCycleManager slm = bus.getExtension(ServerLifeCycleManager.class);
-        if (slm != null) {
-            slm.registerListener(this);
-        }
-    }
-
     Policy getAggregatedServicePolicy(ServiceInfo si) {
         Policy aggregated = null;
         for (PolicyProvider pp : getPolicyProviders()) {
@@ -500,13 +459,12 @@
         return vocabulary;
     } 
 
-    EndpointPolicyImpl createEndpointPolicyInfo(EndpointInfo ei, boolean isRequestor, Assertor
assertor) {
+    EndpointPolicyImpl createEndpointPolicyInfo(EndpointInfo ei, 
+                                                boolean isRequestor, 
+                                                Assertor assertor) {
         EndpointPolicyImpl epi = new EndpointPolicyImpl(ei, this, isRequestor, assertor);
         epi.initialize();
-    
-        Map<EndpointInfo, EndpointPolicy> map = isRequestor ? clientEndpointInfo :
serverEndpointInfo;
-        map.put(ei, epi);
-
+        ei.setProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER,
epi);
         return epi;
     }
 
@@ -534,160 +492,11 @@
         return true;
     }
 
-    public void startServer(Server server) {
-        // empty
-    }
-
-    /**
-     * Callback recieved while the server side endpoint is being undeployed.
-     *
-     * @param server
-     */
-    public void stopServer(Server server) {
-        EndpointInfo ei = server.getEndpoint().getEndpointInfo();
-        serverEndpointInfo.remove(ei);
-        clientEndpointInfo.remove(ei);
-
-        /**
-         * While cleaning up the entries of requestInfo's, responseInfo's and faultInfo's
map, we create
-         * a temperory Set with all the keys. Later we iterate over the keys of this temp
set,
-         * and if it's same as that of the endpoint being undeployed, we remove the corresponding
-         * entries from the client and server maps.
-         */
-
-        cleanupBindingOperations(ei, new HashSet<BindingOperation>(clientRequestInfo.keySet()),
-                clientRequestInfo);
-        cleanupBindingOperations(ei, new HashSet<BindingOperation>(clientResponseInfo.keySet()),
-                clientResponseInfo);
-
-        cleanupBindingOperations(ei, new HashSet<BindingOperation>(serverRequestInfo.keySet()),
-                serverRequestInfo);
-        cleanupBindingOperations(ei, new HashSet<BindingOperation>(serverResponseInfo.keySet()),
-                serverResponseInfo);
-
-        cleanupBindingFaults(ei, new HashSet<BindingFault>(clientFaultInfo.keySet()),
-                clientFaultInfo);
-        cleanupBindingFaults(ei, new HashSet<BindingFault>(serverFaultInfo.keySet()),
-                serverFaultInfo);
-    }
-
-    private void cleanupBindingOperations(EndpointInfo ei,
-                                          Set<BindingOperation> bindingOperations,
-                                          Map<BindingOperation, EffectivePolicy> originalMap)
{
-        
-        Iterator<BindingOperation> bindingOpsItr = bindingOperations.iterator();
-        while (bindingOpsItr.hasNext()) {
-            BindingOperation bindingOperation = bindingOpsItr.next();
-            if (ei.isSameAs(bindingOperation.getEndpoint())) {
-                originalMap.remove(bindingOperation);
-            }
-        }
-    }
-
-    private void cleanupBindingFaults(EndpointInfo ei, Set <BindingFault> bindingFaults,
-                                      Map<BindingFault, EffectivePolicy> originalMap)
{
-        Iterator<BindingFault> bindingFaultsItr = bindingFaults.iterator();
-        while (bindingFaultsItr.hasNext()) {
-            BindingFault bindingFault = bindingFaultsItr.next();
-            if (ei.isSameAs(bindingFault.getEndpoint())) {
-                originalMap.remove(bindingFault);
-            }
-        }
-    }
-    /**
-     * Class used as key in the client request policy and server response policy maps.
-     */
-    class BindingOperation {
-        private EndpointInfo ei;
-        private BindingOperationInfo boi;
-    
-        BindingOperation(EndpointInfo e, BindingOperationInfo b) {
-            ei = e;
-            boi = b.isUnwrapped() ? b.getWrappedOperation() : b;
-        }
-    
-        EndpointInfo getEndpoint() {
-            return ei;
-        }
-    
-        BindingOperationInfo getBindingOperation() {
-            return boi;
-        }
-
-        @Override
-        public int hashCode() {
-            return boi.hashCode();
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            BindingOperation other = (BindingOperation)obj;
-            return boi.equals(other.boi) && ei.equals(other.ei);
-        }
-    
-        @Override
-        public String toString() {
-            return ei.getName().toString() + "." + boi.getName().toString();
-        }
-    
-    
-    }
-
-    /**
-     * Class used as key in the server fault policy map.
-     */
-    class BindingFault {
-        private EndpointInfo ei;
-        private BindingFaultInfo bfi;
-    
-        BindingFault(EndpointInfo e, BindingFaultInfo b) {
-            ei = e;
-            bfi = b;
-        }
-    
-        EndpointInfo getEndpoint() {
-            return ei;
-        }
-    
-        BindingFaultInfo getBindingFault() {
-            return bfi;
-        }
-    
-        @Override
-        public int hashCode() {
-            return bfi.hashCode();
-        }
-    
-        @Override
-        public boolean equals(Object obj) {
-            BindingFault other = (BindingFault)obj;
-            return bfi.equals(other.bfi) && ei.equals(other.ei);
-        }
-    
-        @Override
-        public String toString() {
-            return ei.getName().toString() + "." + bfi.getFaultInfo().toString();
-        }
-    }
 
     // for test
-
     EffectivePolicyImpl createOutPolicyInfo() {
         return new EffectivePolicyImpl();
     }
     
-    private class EndpointPolicyMap extends ConcurrentHashMap<EndpointInfo, EndpointPolicy>
{
-        public EndpointPolicy remove(Object key) {
-            EndpointInfo toRemove = (EndpointInfo) key;
-            EndpointPolicy pol = null;
-            for (EndpointInfo info : keySet()) {
-                if (info.isSameAs(toRemove)) {
-                    pol = super.remove(info);
-                }
-            }
-            return pol;
-        }
-    }
-
 
 }

Modified: cxf/branches/2.1.x-fixes/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java?rev=689115&r1=689114&r2=689115&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
Tue Aug 26 08:43:31 2008
@@ -66,8 +66,22 @@
         control = EasyMock.createNiceControl(); 
     } 
     
+    private EndpointInfo createMockEndpointInfo() throws Exception {
+        EndpointInfo ei = new EndpointInfo();
+        ei.setName(new QName("mock", "mock"));
+        return ei;
+    }
+    private BindingOperationInfo createMockBindingOperationInfo() throws Exception {
+        BindingOperationInfo boi = new BindingOperationInfo() {
+            public boolean isUnwrapped() {
+                return false;
+            }
+        };
+        return boi;
+    }
+    
     @Test
-    public void testAccessors() {
+    public void testAccessors() throws Exception {
         engine = new PolicyEngineImpl();
         assertNotNull(engine.getRegistry());
         assertNull(engine.getBus());
@@ -94,12 +108,12 @@
     }
     
     @Test
-    public void testGetEffectiveClientRequestPolicy() throws NoSuchMethodException {
+    public void testGetEffectiveClientRequestPolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[]
{});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo(); 
         AssertingConduit conduit = control.createMock(AssertingConduit.class);
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
@@ -112,11 +126,10 @@
     }
     
     @Test 
-    public void testSetEffectiveClientRequestPolicy() {
+    public void testSetEffectiveClientRequestPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EasyMock.expect(boi.isUnwrapped()).andReturn(false).times(2);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class);
         control.replay();
         engine.setEffectiveClientRequestPolicy(ei, boi, effectivePolicy);
@@ -126,12 +139,12 @@
     }
     
     @Test
-    public void testGetEffectiveServerResponsePolicy() throws NoSuchMethodException {
+    public void testGetEffectiveServerResponsePolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[]
{});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo(); 
         AssertingDestination destination = control.createMock(AssertingDestination.class);
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
@@ -144,11 +157,10 @@
     }
     
     @Test
-    public void testSetEffectiveServerResponsePolicy() {
+    public void testSetEffectiveServerResponsePolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EasyMock.expect(boi.isUnwrapped()).andReturn(false).times(2);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class);
         control.replay();
         engine.setEffectiveServerResponsePolicy(ei, boi, effectivePolicy);
@@ -158,12 +170,12 @@
     }
    
     @Test
-    public void testGetEffectiveServerFaultPolicy() throws NoSuchMethodException {
+    public void testGetEffectiveServerFaultPolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[]
{});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingFaultInfo bfi = new BindingFaultInfo(null, null); 
         AssertingDestination destination = control.createMock(AssertingDestination.class);
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
@@ -176,22 +188,22 @@
     }
     
     @Test
-    public void testSetEffectiveServerFaultPolicy() {
+    public void testSetEffectiveServerFaultPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingFaultInfo bfi = new BindingFaultInfo(null, null); 
         EffectivePolicy epi = control.createMock(EffectivePolicy.class);
         engine.setEffectiveServerFaultPolicy(ei, bfi, epi);
         assertSame(epi, engine.getEffectiveServerFaultPolicy(ei, bfi, (Destination)null));
  
     }
        
     @Test
-    public void testGetEffectiveServerRequestPolicyInfo() throws NoSuchMethodException {
+    public void testGetEffectiveServerRequestPolicyInfo() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[]
{});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo(); 
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
         epi.initialisePolicy(ei, boi, engine, false);
@@ -203,11 +215,10 @@
     }
     
     @Test 
-    public void testSetEffectiveServerRequestPolicy() {
+    public void testSetEffectiveServerRequestPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EasyMock.expect(boi.isUnwrapped()).andReturn(false).times(2);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class);
         control.replay();
         engine.setEffectiveServerRequestPolicy(ei, boi, effectivePolicy);
@@ -216,12 +227,12 @@
     }
     
     @Test
-    public void testGetEffectiveClientResponsePolicy() throws NoSuchMethodException {
+    public void testGetEffectiveClientResponsePolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[]
{});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo(); 
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
         epi.initialisePolicy(ei, boi, engine, true);
@@ -233,11 +244,10 @@
     }
     
     @Test 
-    public void testSetEffectiveClientResponsePolicy() {
+    public void testSetEffectiveClientResponsePolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EasyMock.expect(boi.isUnwrapped()).andReturn(false).times(2);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         EffectivePolicy epi = control.createMock(EffectivePolicy.class);
         control.replay();
         engine.setEffectiveClientResponsePolicy(ei, boi, epi);
@@ -246,12 +256,12 @@
     }
     
     @Test
-    public void testGetEffectiveClientFaultPolicy() throws NoSuchMethodException {
+    public void testGetEffectiveClientFaultPolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[]
{});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingFaultInfo bfi = new BindingFaultInfo(null, null); 
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
         epi.initialisePolicy(ei, bfi, engine);
@@ -263,22 +273,22 @@
     }
     
     @Test 
-    public void testSetEffectiveClientFaultPolicy() {
+    public void testSetEffectiveClientFaultPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingFaultInfo bfi = new BindingFaultInfo(null, null); 
         EffectivePolicy epi = control.createMock(EffectivePolicy.class);
         engine.setEffectiveClientFaultPolicy(ei, bfi, epi);
         assertSame(epi, engine.getEffectiveClientFaultPolicy(ei, bfi));        
     }
     
     @Test
-    public void testGetEndpointPolicyClientSide() throws NoSuchMethodException {
+    public void testGetEndpointPolicyClientSide() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createEndpointPolicyInfo", 
             new Class[] {EndpointInfo.class, boolean.class, Assertor.class});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         AssertingConduit conduit = control.createMock(AssertingConduit.class);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
         EasyMock.expect(engine.createEndpointPolicyInfo(ei, true, conduit)).andReturn(epi);
@@ -288,12 +298,12 @@
     }
     
     @Test
-    public void testGetEndpointPolicyServerSide() throws NoSuchMethodException {
+    public void testGetEndpointPolicyServerSide() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createEndpointPolicyInfo", 
             new Class[] {EndpointInfo.class, boolean.class, Assertor.class});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         AssertingDestination destination = control.createMock(AssertingDestination.class);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
         EasyMock.expect(engine.createEndpointPolicyInfo(ei, false, destination)).andReturn(epi);
@@ -303,12 +313,12 @@
     }
     
     @Test
-    public void testCreateEndpointPolicyInfo() throws NoSuchMethodException {
+    public void testCreateEndpointPolicyInfo() throws Exception {
         Method m1 = PolicyEngineImpl.class.getDeclaredMethod("createEndpointPolicyInfo",

             new Class[] {EndpointInfo.class, boolean.class, Assertor.class});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m1});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         Assertor assertor = control.createMock(Assertor.class);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
         EasyMock.expect(engine.createEndpointPolicyInfo(ei, false, assertor)).andReturn(epi);
@@ -318,12 +328,11 @@
     }
     
     @Test
-    public void testEndpointPolicyWithEqualPolicies() {
+    public void testEndpointPolicyWithEqualPolicies() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         ServiceInfo si = control.createMock(ServiceInfo.class);
-        ei.getService();
-        EasyMock.expectLastCall().andReturn(si).times(2);
+        ei.setService(si);
         si.getExtensor(Policy.class);
         EasyMock.expectLastCall().andReturn(null).times(2);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
@@ -335,8 +344,7 @@
         assertSame(epi, engine.getServerEndpointPolicy(ei, (Destination)null));
         
         control.reset();
-        ei.getService();
-        EasyMock.expectLastCall().andReturn(si).times(2);
+        ei.setService(si);
         Policy p = new Policy();
         si.getExtensor(Policy.class);
         EasyMock.expectLastCall().andReturn(p).times(2);
@@ -444,11 +452,11 @@
     }
     
     @Test
-    public void testGetAggregatedEndpointPolicy() {
+    public void testGetAggregatedEndpointPolicy() throws Exception {
         engine = new PolicyEngineImpl();
         List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
         engine.setPolicyProviders(providers);
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         
         control.replay();
         Policy p = engine.getAggregatedEndpointPolicy(ei);
@@ -480,11 +488,11 @@
     }
     
     @Test
-    public void testGetAggregatedOperationPolicy() {
+    public void testGetAggregatedOperationPolicy() throws Exception {
         engine = new PolicyEngineImpl();
         List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
         engine.setPolicyProviders(providers);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         
         control.replay();
         Policy p = engine.getAggregatedOperationPolicy(boi);
@@ -660,32 +668,7 @@
         assertEquals(1, assertions.size());
         assertSame(a, assertions.iterator().next());       
     }
-    
-    @Test
-    public void testKeys() {
-        engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);      
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);  
-        control.replay();
-        
-        PolicyEngineImpl.BindingOperation bo = engine.new BindingOperation(ei, boi); 
-        assertNotNull(bo);
-        PolicyEngineImpl.BindingOperation bo2 = engine.new BindingOperation(ei, boi);
-        assertEquals(bo, bo2);
-        assertEquals(bo.hashCode(), bo2.hashCode());
-                  
-        PolicyEngineImpl.BindingFault bf = engine.new BindingFault(ei, bfi);
-        assertNotNull(bf);
-        PolicyEngineImpl.BindingFault bf2 = engine.new BindingFault(ei, bfi);
-        assertEquals(bf, bf2);
-        assertEquals(bf.hashCode(), bf2.hashCode());
-              
-        control.verify();
-    }
-    
-    
-    
+        
     private Set<String> getInterceptorIds(List<Interceptor> interceptors) {
         Set<String> ids = new HashSet<String>();
         for (Interceptor i : interceptors) {



Mime
View raw message