You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by an...@apache.org on 2006/11/01 18:36:09 UTC

svn commit: r470005 [2/3] - in /incubator/cxf/trunk/rt/ws/rm: ./ src/main/java/org/apache/cxf/ws/rm/ src/main/java/org/apache/cxf/ws/rm/impl/ src/main/java/org/apache/cxf/ws/rm/persistence/ src/main/java/org/apache/cxf/ws/rm/soap/ src/main/resources/ME...

Added: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java?view=auto&rev=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java Wed Nov  1 09:36:06 2006
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.ws.addressing.AddressingProperties;
+import org.apache.cxf.ws.addressing.MAPAggregator;
+import org.apache.cxf.ws.addressing.VersionTransformer;
+import org.apache.cxf.ws.addressing.v200408.AttributedURI;
+
+/**
+ * 
+ */
+public class RMOutInterceptor extends AbstractRMInterceptor {
+    
+    private static final Logger LOG = LogUtils.getL7dLogger(RMOutInterceptor.class);
+    private Set<String> after = Collections.singleton(MAPAggregator.class.getName());
+    
+    public Set<String> getAfter() {
+        return after;
+    }
+    
+    public Set<String> getBefore() {
+        return CastUtils.cast(Collections.EMPTY_SET);
+    }
+
+    public String getId() {
+        return RMOutInterceptor.class.getName();
+    }
+    
+    void handleMessage(Message message, boolean isFault) throws SequenceFault {
+        LOG.entering(getClass().getName(), "handleMessage");
+       
+        AddressingProperties maps =
+            RMContextUtils.retrieveMAPs(message, false, true);
+        RMContextUtils.ensureExposedVersion(maps);
+        
+        Source source = getManager().getSource(message);
+        Destination destination = getManager().getDestination(message);
+
+        String action = null;
+        if (maps != null && null != maps.getAction()) {
+            action = maps.getAction().getValue();
+        }
+        
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Action: " + action);
+        }
+
+        boolean isApplicationMessage = isAplicationMessage(action);
+        
+        RMProperties rmpsOut = (RMProperties)RMContextUtils.retrieveRMProperties(message, true);
+        if (null == rmpsOut) {
+            rmpsOut = new RMProperties();
+            RMContextUtils.storeRMProperties(message, rmpsOut, true);
+        }
+        
+        RMProperties rmpsIn = null;
+        Identifier inSeqId = null;
+        BigInteger inMessageNumber = null;
+        
+        if (isApplicationMessage) {
+                        
+            rmpsIn = (RMProperties)RMContextUtils.retrieveRMProperties(message, false);
+            
+            if (null != rmpsIn && null != rmpsIn.getSequence()) {
+                inSeqId = rmpsIn.getSequence().getIdentifier();
+                inMessageNumber = rmpsIn.getSequence().getMessageNumber();
+            }
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("inbound sequence: " + (null == inSeqId ? "null" : inSeqId.getValue()));
+            }
+            
+            // get the current sequence, requesting the creation of a new one if necessary
+            
+            SourceSequence seq = getManager().getSequence(inSeqId, message, maps);
+            assert null != seq;
+
+            // increase message number and store a sequence type object in
+            // context
+
+            seq.nextMessageNumber(inSeqId, inMessageNumber);
+            rmpsOut.setSequence(seq);
+
+            // if this was the last message in the sequence, reset the
+            // current sequence so that a new one will be created next 
+            // time the handler is invoked
+
+            if (seq.isLastMessage()) {
+                source.setCurrent(null);
+            }
+        }
+        
+        // add Acknowledgements (to application messages or explicitly 
+        // created Acknowledgement messages only)
+
+        if (isApplicationMessage 
+            || RMConstants.getSequenceAcknowledgmentAction().equals(action)) {
+            AttributedURI to = VersionTransformer.convert(maps.getTo());
+            assert null != to;
+            addAcknowledgements(destination, rmpsOut, inSeqId, to);
+        }     
+    }
+    
+    void addAcknowledgements(Destination destination, 
+                             RMProperties rmpsOut, 
+                             Identifier inSeqId, 
+                             AttributedURI to) {
+
+        for (DestinationSequence seq : destination.getAllSequences()) {
+            if (seq.sendAcknowledgement()
+                && ((seq.getAcksTo().getAddress().getValue().equals(RMUtils.getAddressingConstants()
+                    .getAnonymousURI()) && AbstractSequence.identifierEquals(seq.getIdentifier(), 
+                                                                                inSeqId))
+                    || to.getValue().equals(seq.getAcksTo().getAddress().getValue()))) {
+                rmpsOut.addAck(seq);
+            } else if (LOG.isLoggable(Level.FINE)) {
+                if (!seq.sendAcknowledgement()) {
+                    LOG.fine("no need to add an acknowledgements for sequence "
+                             + seq.getIdentifier().getValue());
+                } else {
+                    LOG.fine("sequences acksTo (" + seq.getAcksTo().getAddress().getValue()
+                             + ") does not match to (" + to.getValue() + ")");
+                }
+            }
+        }
+
+        if (LOG.isLoggable(Level.FINE)) {
+            Collection<SequenceAcknowledgement> acks = rmpsOut.getAcks();
+            if (null == acks) {
+                LOG.fine("No acknowledgements added");
+            } else {
+                LOG.fine("Added " + acks.size() + " acknowledgements.");
+            }
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java?view=diff&rev=470005&r1=470004&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMProperties.java Wed Nov  1 09:36:06 2006
@@ -22,8 +22,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.cxf.ws.rm.impl.RMUtils;
-
 public class RMProperties {
     private SequenceType sequence;
     private Collection<SequenceAcknowledgement> acks;

Copied: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java (from r469824, incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/RMUtils.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java?view=diff&rev=470005&p1=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/RMUtils.java&r1=469824&p2=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/RMUtils.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java Wed Nov  1 09:36:06 2006
@@ -17,27 +17,22 @@
  * under the License.
  */
 
-package org.apache.cxf.ws.rm.impl;
+package org.apache.cxf.ws.rm;
 
 import org.apache.cxf.ws.addressing.AddressingConstants;
 import org.apache.cxf.ws.addressing.AddressingConstantsImpl;
 import org.apache.cxf.ws.addressing.VersionTransformer;
 
-import org.apache.cxf.ws.policy.PolicyConstants;
-import org.apache.cxf.ws.policy.PolicyConstantsImpl;
-
 public final class RMUtils {
    
     private static final org.apache.cxf.ws.addressing.v200408.ObjectFactory WSA_FACTORY;
     private static final org.apache.cxf.ws.rm.ObjectFactory WSRM_FACTORY;
     private static final AddressingConstants WSA_CONSTANTS; 
-    private static final PolicyConstants WSP_CONSTANTS;
     
     static {
         WSA_FACTORY = new org.apache.cxf.ws.addressing.v200408.ObjectFactory();
         WSRM_FACTORY = new org.apache.cxf.ws.rm.ObjectFactory();        
-        WSA_CONSTANTS = new AddressingConstantsImpl();
-        WSP_CONSTANTS = new PolicyConstantsImpl();       
+        WSA_CONSTANTS = new AddressingConstantsImpl();      
     }
     
     protected RMUtils() {        
@@ -53,10 +48,6 @@
     
     public static AddressingConstants getAddressingConstants() {
         return WSA_CONSTANTS;
-    }
-    
-    public static PolicyConstants getPolicyConstants() {
-        return WSP_CONSTANTS;
     }
     
     public static org.apache.cxf.ws.addressing.EndpointReferenceType createAnonymousReference() {

Copied: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SequenceFaultFactory.java (from r469824, incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/SequenceFaultFactory.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SequenceFaultFactory.java?view=diff&rev=470005&p1=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/SequenceFaultFactory.java&r1=469824&p2=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SequenceFaultFactory.java&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/SequenceFaultFactory.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SequenceFaultFactory.java Wed Nov  1 09:36:06 2006
@@ -17,22 +17,18 @@
  * under the License.
  */
 
-package org.apache.cxf.ws.rm.impl;
+package org.apache.cxf.ws.rm;
 
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.ws.rm.Identifier;
-import org.apache.cxf.ws.rm.RMConstants;
-import org.apache.cxf.ws.rm.SequenceFault;
-import org.apache.cxf.ws.rm.SequenceFaultType;
 
 /**
- * 
+ * Utility class to construct SequenceFaults.
  */
 
-public class SequenceFaultFactory { 
+class SequenceFaultFactory { 
 
     private static final Logger LOG = LogUtils.getL7dLogger(SequenceFaultFactory.class);
 

Copied: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SequenceMonitor.java (from r469824, incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/SequenceMonitor.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SequenceMonitor.java?view=diff&rev=470005&p1=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/SequenceMonitor.java&r1=469824&p2=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SequenceMonitor.java&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/SequenceMonitor.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SequenceMonitor.java Wed Nov  1 09:36:06 2006
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.cxf.ws.rm.impl;
+package org.apache.cxf.ws.rm;
 
 import java.util.ArrayList;
 import java.util.List;

Copied: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java (from r469824, incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/Servant.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java?view=diff&rev=470005&p1=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/Servant.java&r1=469824&p2=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/Servant.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java Wed Nov  1 09:36:06 2006
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.cxf.ws.rm.impl;
+package org.apache.cxf.ws.rm;
 
 import java.io.IOException;
 import java.util.List;
@@ -32,22 +32,14 @@
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.VersionTransformer;
 import org.apache.cxf.ws.addressing.v200408.AttributedURI;
-import org.apache.cxf.ws.rm.AcceptType;
-import org.apache.cxf.ws.rm.CreateSequenceResponseType;
-import org.apache.cxf.ws.rm.CreateSequenceType;
-import org.apache.cxf.ws.rm.Expires;
-import org.apache.cxf.ws.rm.Identifier;
-import org.apache.cxf.ws.rm.OfferType;
-import org.apache.cxf.ws.rm.SequenceFault;
-import org.apache.cxf.ws.rm.TerminateSequenceType;
-import org.apache.cxf.ws.rm.interceptor.DestinationPolicyType;
+import org.apache.cxf.ws.rm.manager.DestinationPolicyType;
 
 /**
  * 
  */
 public class Servant {
 
-    private static final Logger LOG = LogUtils.getL7dLogger(RMInterceptor.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(AbstractRMInterceptor.class);
     private RMEndpoint reliableEndpoint;
     // REVISIT assumption there is only a single outstanding unattached Identifier
     private Identifier unattachedIdentifier;
@@ -67,7 +59,7 @@
             RMUtils.getWSRMFactory().createCreateSequenceResponseType();        
         createResponse.setIdentifier(destination.generateSequenceIdentifier());
         
-        DestinationPolicyType dp = reliableEndpoint.getInterceptor().getDestinationPolicy();
+        DestinationPolicyType dp = reliableEndpoint.getManager().getDestinationPolicy();
         Duration supportedDuration = dp.getSequenceExpiration();
         if (null == supportedDuration) {
             supportedDuration = DatatypeFactory.PT0S;
@@ -90,10 +82,10 @@
             if (dp.isAcceptOffers()) {
                 Source source = reliableEndpoint.getSource();
                 LOG.fine("Accepting inbound sequence offer");
-                AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, false);
+                AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false);
                 AttributedURI to = VersionTransformer.convert(maps.getTo());
                 accept.setAcksTo(RMUtils.createReference2004(to.getValue()));
-                SourceSequenceImpl seq = new SourceSequenceImpl(offer.getIdentifier(), 
+                SourceSequence seq = new SourceSequence(offer.getIdentifier(), 
                                                                     null, 
                                                                     createResponse.getIdentifier());
                 seq.setExpires(offer.getExpires());
@@ -120,7 +112,7 @@
         LOG.fine("Creating sequence response");
         
         CreateSequenceResponseType createResponse = (CreateSequenceResponseType)getParameter(message);
-        SourceSequenceImpl seq = new SourceSequenceImpl(createResponse.getIdentifier());
+        SourceSequence seq = new SourceSequence(createResponse.getIdentifier());
         seq.setExpires(createResponse.getExpires());
         Source source  = reliableEndpoint.getSource();
         source.addSequence(seq);
@@ -134,15 +126,15 @@
         // to the local destination sequence list, otherwise we have to wait for
         // and incoming CreateSequence request
         
-        Identifier offeredId = reliableEndpoint.getProxy().getOfferedIdentifier();
+        Identifier offeredId = reliableEndpoint.getOfferedIdentifier();
         if (null != offeredId) {
             AcceptType accept = createResponse.getAccept();
             assert null != accept;
             Destination dest = reliableEndpoint.getDestination();
             String address = accept.getAcksTo().getAddress().getValue();
             if (!RMUtils.getAddressingConstants().getNoneURI().equals(address)) {
-                DestinationSequenceImpl ds = 
-                    new DestinationSequenceImpl(offeredId, accept.getAcksTo(), dest);
+                DestinationSequence ds = 
+                    new DestinationSequence(offeredId, accept.getAcksTo(), dest);
                 dest.addSequence(ds);
             }
         }
@@ -158,7 +150,7 @@
         
         Destination destination = reliableEndpoint.getDestination();
         Identifier sid = terminate.getIdentifier();
-        DestinationSequenceImpl terminatedSeq = destination.getSequenceImpl(sid);
+        DestinationSequence terminatedSeq = destination.getSequence(sid);
         if (null == terminatedSeq) {
             //  TODO
             LOG.severe("No such sequence.");
@@ -170,13 +162,13 @@
         // the following may be necessary if the last message for this sequence was a oneway
         // request and hence there was no response to which a last message could have been added
         
-        for (SourceSequenceImpl outboundSeq : reliableEndpoint.getSource().getAllSequences()) {
+        for (SourceSequence outboundSeq : reliableEndpoint.getSource().getAllSequences()) {
             if (outboundSeq.offeredBy(sid) && !outboundSeq.isLastMessage()) {
                 
                 // send an out of band message with an empty body and a 
                 // sequence header containing a lastMessage element.
                
-                Proxy proxy = reliableEndpoint.getProxy();
+                Proxy proxy = new Proxy(reliableEndpoint);
                 try {
                     proxy.lastMessage(outboundSeq);
                 } catch (IOException ex) {

Copied: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Source.java (from r469824, incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/Source.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Source.java?view=diff&rev=470005&p1=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/Source.java&r1=469824&p2=incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Source.java&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/impl/Source.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Source.java Wed Nov  1 09:36:06 2006
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.cxf.ws.rm.impl;
+package org.apache.cxf.ws.rm;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -28,25 +28,22 @@
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.ws.rm.Identifier;
-import org.apache.cxf.ws.rm.SequenceAcknowledgement;
-import org.apache.cxf.ws.rm.SourceSequence;
 import org.apache.cxf.ws.rm.persistence.RMStore;
 
 public class Source extends AbstractEndpoint {
 
     private static final String REQUESTOR_SEQUENCE_ID = "";
     
-    private Map<String, SourceSequenceImpl> map;
-    private Map<String, SourceSequenceImpl> current;     
+    private Map<String, SourceSequence> map;
+    private Map<String, SourceSequence> current;     
     private Lock sequenceCreationLock;
     private Condition sequenceCreationCondition;
     private boolean sequenceCreationNotified;
 
     Source(RMEndpoint reliableEndpoint) {
         super(reliableEndpoint);
-        map = new HashMap<String, SourceSequenceImpl>();
-        current = new HashMap<String, SourceSequenceImpl>();
+        map = new HashMap<String, SourceSequence>();
+        current = new HashMap<String, SourceSequence>();
              
         sequenceCreationLock = new ReentrantLock();
         sequenceCreationCondition = sequenceCreationLock.newCondition();
@@ -58,15 +55,19 @@
         return map.get(id.getValue());
     }
     
-    public void addSequence(SourceSequenceImpl seq) { 
+    public Collection<SourceSequence> getAllSequences() {                 
+        return CastUtils.cast(map.values());
+    } 
+    
+    public void addSequence(SourceSequence seq) { 
         addSequence(seq, true);
     }
     
-    public void addSequence(SourceSequenceImpl seq, boolean persist) {
+    public void addSequence(SourceSequence seq, boolean persist) {
         seq.setSource(this);
         map.put(seq.getIdentifier().getValue(), seq);
         if (persist) {
-            RMStore store = getInterceptor().getStore();
+            RMStore store = getReliableEndpoint().getManager().getStore();
             if (null != store) {
                 store.createSourceSequence(seq);
             }
@@ -75,16 +76,12 @@
     
     public void removeSequence(SourceSequence seq) {        
         map.remove(seq.getIdentifier().getValue());
-        RMStore store = getInterceptor().getStore();
+        RMStore store = getReliableEndpoint().getManager().getStore();
         if (null != store) {
             store.removeSourceSequence(seq.getIdentifier());
         }
     }
     
-    public Collection<SourceSequenceImpl> getAllSequences() {                 
-        return CastUtils.cast(map.values());
-    } 
-    
     /**
      * Stores the received acknowledgment in the Sequence object identified in
      * the <code>SequenceAcknowldgement</code> parameter. Then purges any
@@ -95,10 +92,10 @@
      */
     public void setAcknowledged(SequenceAcknowledgement acknowledgment) {
         Identifier sid = acknowledgment.getIdentifier();
-        SourceSequenceImpl seq = getSequenceImpl(sid);        
+        SourceSequence seq = getSequence(sid);        
         if (null != seq) {
             seq.setAcknowledged(acknowledgment);
-            getInterceptor().getRetransmissionQueue().purgeAcknowledged(seq);
+            getManager().getRetransmissionQueue().purgeAcknowledged(seq);
             if (seq.allAcknowledged()) {
                 // TODO
                 /*
@@ -122,7 +119,7 @@
      */
     public Collection<SourceSequence> getAllUnacknowledgedSequences() {
         Collection<SourceSequence> seqs = new ArrayList<SourceSequence>();
-        for (SourceSequenceImpl seq : map.values()) {
+        for (SourceSequence seq : map.values()) {
             if (!seq.allAcknowledged()) {
                 seqs.add(seq);
             }
@@ -143,7 +140,7 @@
      * Sets the current sequence used by a client side source.
      * @param s the current sequence.
      */
-    void setCurrent(SourceSequenceImpl s) {
+    public void setCurrent(SourceSequence s) {
         setCurrent(null, s);
     }
     
@@ -153,7 +150,7 @@
      * 
      * @return the current sequence.
      */
-    SourceSequenceImpl getCurrent(Identifier i) {        
+    SourceSequence getCurrent(Identifier i) {        
         sequenceCreationLock.lock();
         try {
             return getAssociatedSequence(i);
@@ -169,7 +166,7 @@
      * @return the associated sequence
      * @pre the sequenceCreationLock is already held
      */
-    SourceSequenceImpl getAssociatedSequence(Identifier i) {        
+    SourceSequence getAssociatedSequence(Identifier i) {        
         return current.get(i == null ? REQUESTOR_SEQUENCE_ID : i.getValue());
     }
     
@@ -179,10 +176,10 @@
      * @param i the sequence identifier
      * @return
      */
-    SourceSequenceImpl awaitCurrent(Identifier i) {
+    SourceSequence awaitCurrent(Identifier i) {
         sequenceCreationLock.lock();
         try {
-            SourceSequenceImpl seq = getAssociatedSequence(i);
+            SourceSequence seq = getAssociatedSequence(i);
             while (seq == null) {
                 while (!sequenceCreationNotified) {
                     try {
@@ -204,7 +201,7 @@
      * sent as part of the inbound sequence with the specified identifier.
      * @param s the current sequence.
      */
-    void setCurrent(Identifier i, SourceSequenceImpl s) {        
+    void setCurrent(Identifier i, SourceSequence s) {        
         sequenceCreationLock.lock();
         try {
             current.put(i == null ? REQUESTOR_SEQUENCE_ID : i.getValue(), s);
@@ -213,9 +210,5 @@
         } finally {
             sequenceCreationLock.unlock();
         }
-    }
-    
-    SourceSequenceImpl getSequenceImpl(Identifier id) {        
-        return map.get(id.getValue());
     }
 }

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java?view=diff&rev=470005&r1=470004&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/SourceSequence.java Wed Nov  1 09:36:06 2006
@@ -21,39 +21,83 @@
 
 import java.math.BigInteger;
 import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
-public interface SourceSequence {
+import javax.xml.datatype.Duration;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxb.DatatypeFactory;
+import org.apache.cxf.ws.addressing.ContextUtils;
+import org.apache.cxf.ws.rm.SequenceAcknowledgement.AcknowledgementRange;
+import org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType;
+
+public class SourceSequence extends AbstractSequence {
     
-    /**
-     * @return the sequence identifier
-     */
-    Identifier getIdentifier();
+    private static final Logger LOG = LogUtils.getL7dLogger(SourceSequence.class);
+    
+    private Date expires;
+    private Source source;
+    private BigInteger currentMessageNumber;
+    private boolean lastMessage;
+    private Identifier offeringId;
+    private org.apache.cxf.ws.addressing.EndpointReferenceType target;
+    
+    public SourceSequence(Identifier i) {
+        this(i, null, null);
+    }
+    
+    public SourceSequence(Identifier i, Date e, Identifier oi) {
+        this(i, e, oi, BigInteger.ZERO, false);
+    }
+    
+    public SourceSequence(Identifier i, Date e, Identifier oi, BigInteger cmn, boolean lm) {
+        super(i);
+        expires = e;
+
+        offeringId = oi;
+
+        currentMessageNumber = cmn;
+        lastMessage = lm;
+        acknowledgement = RMUtils.getWSRMFactory().createSequenceAcknowledgement();
+        acknowledgement.setIdentifier(id);
+    }
     
     /**
      * @return the message number assigned to the most recent outgoing application message.
      */
-    BigInteger getCurrentMessageNr();
+    public BigInteger getCurrentMessageNr() {
+        return currentMessageNumber;
+    }
     
     /**
      * @return true if the last message had been sent for this sequence. 
      */
-    boolean isLastMessage();
+    public boolean isLastMessage() {
+        return lastMessage;
+    }
     
     /**
      * @return the identifier of the sequence that was created on behalf of the CreateSequence request 
      * that included this sequence as an offer
      */
-    Identifier getOfferingSequenceIdentifier();
+    public Identifier getOfferingSequenceIdentifier() {
+        return offeringId;
+    }
     
     /**
      * @return the identifier of the rm source
      */
-    String getEndpointIdentifier(); 
+    public String getEndpointIdentifier() {
+        return source.getName().toString();
+    }
     
     /**
      * @return the expiry data of this sequence
      */
-    Date getExpires();
+    public Date getExpires() {
+        return expires;
+    }
     
     /**
      * Returns true if this sequence was constructed from an offer for an inbound sequence
@@ -63,5 +107,181 @@
      * @param id the sequence identifier
      * @return true if the sequence was constructed from an offer.
      */
-    boolean offeredBy(Identifier sid);
+    public boolean offeredBy(Identifier sid) {
+        return null != offeringId && offeringId.getValue().equals(sid.getValue());
+    }
+    
+    /**
+     * Returns true if a last message had been sent for this sequence and if all
+     * messages for this sequence have been acknowledged.
+     * 
+     * @return true if all messages have been acknowledged.
+     */
+    public boolean allAcknowledged() {
+        if (!lastMessage) {
+            return false;
+        }
+
+        if (acknowledgement.getAcknowledgementRange().size() == 1) {         
+            AcknowledgementRange r = acknowledgement.getAcknowledgementRange().get(0);
+            return r.getLower().equals(BigInteger.ONE) && r.getUpper().equals(currentMessageNumber);
+        }
+        return false;
+    }
+
+    /**
+     * Used by the RM source to cache received acknowledgements for this
+     * sequence.
+     * 
+     * @param acknowledgement an acknowledgement for this sequence
+     */
+    public void setAcknowledged(SequenceAcknowledgement a) {
+        acknowledgement = a;    
+    }
+     
+    void setSource(Source s) {
+        source = s;
+    }
+    
+    void setLastMessage(boolean lm) {
+        lastMessage = lm;
+    }
+    
+    /**
+     * Returns true if the sequence is expired.
+     * 
+     * @return true if the sequence is expired.
+     */
+
+    boolean isExpired() {
+        return expires == null ? false : new Date().after(expires);
+        
+    }
+    
+    public void setExpires(Expires ex) {
+        Duration d = null;
+        expires = null;
+        if (null != ex) {
+            d = ex.getValue();
+        }
+
+        if (null != d && !d.equals(DatatypeFactory.PT0S)) {
+            Date now = new Date();
+            expires = new Date(now.getTime() + ex.getValue().getTimeInMillis(now));
+        }
+    }
+    
+    /**
+     * Returns the next message number and increases the message number.
+     * 
+     * @return the next message number.
+     */
+    BigInteger nextMessageNumber() {
+        return nextMessageNumber(null, null);
+    }
+
+    /**
+     * Returns the next message number and increases the message number.
+     * The parameters, if not null, indicate that this message is being sent as a response 
+     * to the message with the specified message number in the sequence specified by the
+     * by the identifier, and are used to decide if this message should be the last in
+     * this sequence.
+     * 
+     * @return the next message number.
+     */
+    public BigInteger nextMessageNumber(Identifier inSeqId, BigInteger inMsgNumber) {
+        assert !lastMessage;
+        
+        BigInteger result = null;
+        synchronized (this) {
+            currentMessageNumber = currentMessageNumber.add(BigInteger.ONE);
+            checkLastMessage(inSeqId, inMsgNumber);
+            result = currentMessageNumber;
+        } 
+        return result;
+    }
+    
+    void nextAndLastMessageNumber() {
+        assert !lastMessage;
+        
+        synchronized (this) {
+            currentMessageNumber = currentMessageNumber.add(BigInteger.ONE);
+            lastMessage = true;
+        }
+    }
+    
+
+   
+    
+    SequenceAcknowledgement getAcknowledgement() {
+        return acknowledgement;
+    }
+    
+   
+    
+    
+    /**
+     * The target for the sequence is the first non-anonymous address that
+     * a message is sent to as part of this sequence. It is subsequently used
+     * for as the target of out-of-band protocol messages related to that
+     * sequence that originate from the sequnce source (i.e. TerminateSequence 
+     * and LastMessage, but not AckRequested or SequenceAcknowledgement as these 
+     * are orignate from the sequence destination).
+     * 
+     * @param to
+     */
+    synchronized void setTarget(org.apache.cxf.ws.addressing.EndpointReferenceType to) {
+        if (target == null && !ContextUtils.isGenericAddress(to)) {
+            target = to;
+        }
+    }
+    
+    synchronized org.apache.cxf.ws.addressing.EndpointReferenceType getTarget() {
+        return target;
+    } 
+   
+    /**
+     * Checks if the current message should be the last message in this sequence
+     * and if so sets the lastMessageNumber property.
+     */
+    private void checkLastMessage(Identifier inSeqId, BigInteger inMsgNumber) { 
+        
+        // check if this is a response to a message that was is the last message in the sequence
+        // that included this sequence as an offer 
+
+        if (null != inSeqId && null != inMsgNumber) {
+            Destination destination = source.getReliableEndpoint().getDestination();
+            DestinationSequence inSeq = null;
+            if (null != destination) {
+                inSeq = destination.getSequence(inSeqId);
+            }
+             
+            if (null != inSeq && offeredBy(inSeqId)
+                && inMsgNumber.equals(inSeq.getLastMessageNumber())) {
+                lastMessage = true;
+            }
+        } 
+
+        
+        if (!lastMessage) {
+            SequenceTerminationPolicyType stp = source.getManager().getSourcePolicy()
+               .getSequenceTerminationPolicy();
+
+            assert null != stp;
+
+            if ((!stp.getMaxLength().equals(BigInteger.ZERO) && stp.getMaxLength()
+                .compareTo(currentMessageNumber) <= 0)
+                || (stp.getMaxRanges() > 0
+                    && acknowledgement.getAcknowledgementRange().size() >= stp.getMaxRanges())
+                || (stp.getMaxUnacknowledged() > 0
+                    && source.getManager().getRetransmissionQueue()
+                        .countUnacknowledged(this) >= stp.getMaxUnacknowledged())) {
+                lastMessage = true;
+            }
+        }
+        
+        if (LOG.isLoggable(Level.FINE) && lastMessage) {
+            LOG.fine(currentMessageNumber + " should be the last message in this sequence.");
+        }
+    }   
 }

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/RMStore.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/RMStore.java?view=diff&rev=470005&r1=470004&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/RMStore.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/RMStore.java Wed Nov  1 09:36:06 2006
@@ -27,7 +27,6 @@
 import org.apache.cxf.ws.rm.Identifier;
 import org.apache.cxf.ws.rm.SourceSequence;
 
-
 public interface RMStore {
    
     /**

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java?view=diff&rev=470005&r1=470004&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java Wed Nov  1 09:36:06 2006
@@ -90,7 +90,7 @@
     }
 
     public String getPhase() {
-        return Phase.PRE_LOGICAL;
+        return Phase.PRE_PROTOCOL;
     }
       
     // AbstractSoapInterceptor interface 
@@ -363,6 +363,7 @@
             */
         }
     }
+    
     
     /**
      * When invoked inbound, check if the action indicates that this is one of the 

Added: incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension.xml?view=auto&rev=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension.xml (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension.xml Wed Nov  1 09:36:06 2006
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:foo="http://cxf.apache.org/configuration/foo"
+       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">
+        <property name="bus" ref="cxf"/>
+    </bean>
+    
+</beans>
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/ws/rm/src/main/resources/META-INF/cxf/cxf-extension.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd (from r469824, incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-interceptor.xsd)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd?view=diff&rev=470005&p1=incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-interceptor.xsd&r1=469824&p2=incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd&r2=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-interceptor.xsd (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd Wed Nov  1 09:36:06 2006
@@ -18,8 +18,8 @@
   under the License.
 -->
 
-<xs:schema targetNamespace="http://cxf.apache.org/ws/rm/interceptor" 
-           xmlns:tns="http://cxf.apache.org/ws/rm/interceptor"
+<xs:schema targetNamespace="http://cxf.apache.org/ws/rm/manager" 
+           xmlns:tns="http://cxf.apache.org/ws/rm/manager"
            xmlns:xs="http://www.w3.org/2001/XMLSchema" 
            xmlns:wsrmp="http://schemas.xmlsoap.org/ws/2005/02/rm/policy" 
            xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
@@ -191,7 +191,7 @@
     <xs:element name="sourcePolicy" type="tns:SourcePolicyType"/>
     <xs:element name="destinationPolicy" type="tns:DestinationPolicyType"/>
 
-    <xs:complexType name="RMInterceptorConfigBean">        
+    <xs:complexType name="RMManagerConfigBean">        
         <xs:annotation>
             <xs:appinfo>                
                 <cfg:configurable/>

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java?view=auto&rev=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java Wed Nov  1 09:36:06 2006
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.rm;
+
+import junit.framework.TestCase;
+
+public class AbstractSequenceTest extends TestCase {
+
+    public void testIdentifierEquals() {
+        Identifier id1 = null;
+        Identifier id2 = null;   
+        assertTrue(AbstractSequence.identifierEquals(id1, id2));
+        
+        ObjectFactory factory = new ObjectFactory();
+        id1 = factory.createIdentifier();
+        id1.setValue("seq1"); 
+        assertTrue(!AbstractSequence.identifierEquals(id1, id2));
+        
+        id2 = factory.createIdentifier();
+        id2.setValue("seq2"); 
+        assertTrue(!AbstractSequence.identifierEquals(id1, id2));
+        
+        id2.setValue("seq1");
+        assertTrue(AbstractSequence.identifierEquals(id1, id2));
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java?view=auto&rev=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java Wed Nov  1 09:36:06 2006
@@ -0,0 +1,578 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.ws.rm;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+
+import javax.xml.namespace.QName;
+
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.ws.addressing.v200408.EndpointReferenceType;
+import org.apache.cxf.ws.rm.SequenceAcknowledgement.AcknowledgementRange;
+import org.apache.cxf.ws.rm.manager.AcksPolicyType;
+import org.apache.cxf.ws.rm.manager.DeliveryAssuranceType;
+import org.apache.cxf.ws.rm.manager.DestinationPolicyType;
+import org.apache.cxf.ws.rm.policy.RMAssertion;
+import org.apache.cxf.ws.rm.policy.RMAssertion.AcknowledgementInterval;
+import org.apache.cxf.ws.rm.policy.RMAssertion.BaseRetransmissionInterval;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
+public class DestinationSequenceTest extends TestCase {
+
+    private IMocksControl control;
+    private ObjectFactory factory;
+    private Identifier id;
+    private EndpointReferenceType ref;
+    private Destination destination;
+    private RMManager manager;
+    private RMAssertion rma;
+    private AcksPolicyType ap;
+    private DestinationPolicyType dp;
+ 
+    public void setUp() {
+        control = EasyMock.createNiceControl();
+        factory = new ObjectFactory();
+        
+        ref = control.createMock(EndpointReferenceType.class);                
+        id = factory.createIdentifier();
+        id.setValue("seq");
+    }
+    
+    public void tearDown() {
+        ref = null;
+        destination = null;
+        manager = null;
+        rma = null;
+        dp = null;
+        ap = null;
+        
+    }
+
+    public void testConstructors() {
+  
+        Identifier otherId = factory.createIdentifier();
+        otherId.setValue("otherSeq");
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        assertEquals(id, seq.getIdentifier());
+        assertNull(seq.getLastMessageNumber());
+        assertSame(ref, seq.getAcksTo());
+        assertNotNull(seq.getAcknowledgment());
+        assertNotNull(seq.getMonitor());   
+        
+        SequenceAcknowledgement ack = RMUtils.getWSRMFactory().createSequenceAcknowledgement();        
+        seq = new DestinationSequence(id, ref, BigInteger.TEN, ack);
+        assertEquals(id, seq.getIdentifier());
+        assertEquals(BigInteger.TEN, seq.getLastMessageNumber());
+        assertSame(ref, seq.getAcksTo());
+        assertSame(ack, seq.getAcknowledgment());
+        assertNotNull(seq.getMonitor());  
+
+    }
+    
+    public void testEqualsAndHashCode() {     
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        DestinationSequence otherSeq = null;
+        assertTrue(!seq.equals(otherSeq));
+        otherSeq = new DestinationSequence(id, ref, destination);
+        assertEquals(seq, otherSeq);
+        assertEquals(seq.hashCode(), otherSeq.hashCode());
+        Identifier otherId = factory.createIdentifier();
+        otherId.setValue("otherSeq");
+        otherSeq = new DestinationSequence(otherId, ref, destination);
+        assertTrue(!seq.equals(otherSeq));
+        assertTrue(seq.hashCode() != otherSeq.hashCode()); 
+        assertTrue(!seq.equals(this));
+    }
+    
+    public void testGetSetDestination() {
+        control.replay();
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        seq.setDestination(destination);
+        assertSame(destination, seq.getDestination());
+    }
+    
+    public void testGetEndpointIdentifier() {
+        setUpDestination();
+        QName qn = new QName("abc", "xyz");
+        EasyMock.expect(destination.getName()).andReturn(qn);
+        control.replay();
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        assertEquals("Unexpected endpoint identifier", "{abc}xyz", seq.getEndpointIdentifier());
+        control.verify();
+    }
+    
+    public void testGetAcknowledgementAsStream() throws SequenceFault {
+        /*
+        destination.getHandler();
+        expectLastCall().andReturn(handler).times(3);
+        handler.getStore();
+        expectLastCall().andReturn(null);
+        handler.getConfigurationHelper();
+        expectLastCall().andReturn(configurationHelper).times(2);
+        configurationHelper.getRMAssertion();
+        expectLastCall().andReturn(rma);
+        configurationHelper.getAcksPolicy();
+        expectLastCall().andReturn(ap);
+        control.replay();
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        List<AcknowledgementRange> ranges = seq.getAcknowledgment().getAcknowledgementRange();
+        assertEquals(0, ranges.size());
+              
+        seq.acknowledge(new BigInteger("1"));  
+        assertNotNull(seq.getAcknowledgmentAsStream());
+        
+        control.verify();
+        */
+    }
+    
+    public void testAcknowledgeBasic() throws SequenceFault {
+        setUpDestination();
+        control.replay();
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        List<AcknowledgementRange> ranges = seq.getAcknowledgment().getAcknowledgementRange();
+        assertEquals(0, ranges.size());
+              
+        seq.acknowledge(new BigInteger("1"));        
+        assertEquals(1, ranges.size());
+        AcknowledgementRange r1 = ranges.get(0);
+        assertEquals(1, r1.getLower().intValue());
+        assertEquals(1, r1.getUpper().intValue());
+        
+        seq.acknowledge(new BigInteger("2"));
+        assertEquals(1, ranges.size());
+        r1 = ranges.get(0);
+        assertEquals(1, r1.getLower().intValue());
+        assertEquals(2, r1.getUpper().intValue());
+        
+        control.verify();
+    }
+    
+    public void testAcknowledgeLastMessageNumberExceeded() throws SequenceFault {  
+        setUpDestination();
+        control.replay();
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        
+        seq.acknowledge(BigInteger.ONE);
+        seq.setLastMessageNumber(BigInteger.ONE);
+        try {
+            seq.acknowledge(new BigInteger("2"));
+            fail("Expected SequenceFault not thrown.");
+        } catch (SequenceFault sf) {
+            assertEquals("LastMessageNumberExceeded", sf.getFaultInfo().getFaultCode().getLocalPart());
+        }
+        
+        control.verify();
+    }
+    
+    public void testAcknowledgeAppendRange() throws SequenceFault {
+        setUpDestination();
+        control.replay();
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        List<AcknowledgementRange> ranges = seq.getAcknowledgment().getAcknowledgementRange();        
+        seq.acknowledge(new BigInteger("1"));
+        seq.acknowledge(new BigInteger("2"));  
+        seq.acknowledge(new BigInteger("5"));
+        seq.acknowledge(new BigInteger("4"));
+        seq.acknowledge(new BigInteger("6"));
+        assertEquals(2, ranges.size());
+        AcknowledgementRange r = ranges.get(0);
+        assertEquals(1, r.getLower().intValue());
+        assertEquals(2, r.getUpper().intValue());
+        r = ranges.get(1);
+        assertEquals(4, r.getLower().intValue());
+        assertEquals(6, r.getUpper().intValue()); 
+        
+        control.verify();
+    }
+    
+    public void testAcknowledgeInsertRange() throws SequenceFault {
+        setUpDestination();
+        control.replay();
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        List<AcknowledgementRange> ranges = seq.getAcknowledgment().getAcknowledgementRange();        
+        seq.acknowledge(new BigInteger("1"));
+        seq.acknowledge(new BigInteger("2"));
+        seq.acknowledge(new BigInteger("9"));
+        seq.acknowledge(new BigInteger("10"));
+        seq.acknowledge(new BigInteger("4"));
+        seq.acknowledge(new BigInteger("9"));
+        seq.acknowledge(new BigInteger("2"));
+        
+        assertEquals(3, ranges.size());
+        AcknowledgementRange r = ranges.get(0);
+        assertEquals(1, r.getLower().intValue());
+        assertEquals(2, r.getUpper().intValue());
+        r = ranges.get(1);
+        assertEquals(4, r.getLower().intValue());
+        assertEquals(4, r.getUpper().intValue()); 
+        r = ranges.get(2);
+        assertEquals(9, r.getLower().intValue());
+        assertEquals(10, r.getUpper().intValue()); 
+        
+        control.verify();
+    }
+    
+    public void testAcknowledgePrependRange() throws SequenceFault { 
+        setUpDestination();
+        control.replay();
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        List<AcknowledgementRange> ranges = seq.getAcknowledgment().getAcknowledgementRange();
+        seq.acknowledge(new BigInteger("4"));
+        seq.acknowledge(new BigInteger("5"));
+        seq.acknowledge(new BigInteger("6"));
+        seq.acknowledge(new BigInteger("4"));
+        seq.acknowledge(new BigInteger("2"));
+        seq.acknowledge(new BigInteger("2"));
+        assertEquals(2, ranges.size());
+        AcknowledgementRange r = ranges.get(0);
+        assertEquals(2, r.getLower().intValue());
+        assertEquals(2, r.getUpper().intValue());
+        r = ranges.get(1);
+        assertEquals(4, r.getLower().intValue());
+        assertEquals(6, r.getUpper().intValue()); 
+        
+        control.verify();
+    }
+    
+    public void testMonitor() throws SequenceFault {
+        setUpDestination();
+        control.replay();
+                
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        SequenceMonitor monitor = seq.getMonitor();
+        assertNotNull(monitor);
+        monitor.setMonitorInterval(500);
+        
+        assertEquals(0, monitor.getMPM());
+        
+        BigInteger mn = BigInteger.ONE;
+        
+        for (int i = 0; i < 10; i++) {
+            seq.acknowledge(mn);
+            mn = mn.add(BigInteger.ONE);
+            try {
+                Thread.sleep(50);
+            } catch (InterruptedException ex) {
+                // ignore
+            }
+        }
+        int mpm1 = monitor.getMPM();
+        assertTrue(mpm1 > 0);
+        
+        for (int i = 0; i < 5; i++) {
+            seq.acknowledge(mn);
+            mn = mn.add(BigInteger.ONE);
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException ex) {
+                // ignore
+            }
+        }
+        int mpm2 = monitor.getMPM();
+        assertTrue(mpm2 > 0);
+        assertTrue(mpm1 > mpm2);
+        
+        control.verify();
+    }
+    
+    public void testAcknowledgeImmediate() throws SequenceFault {
+        setUpDestination();
+        control.replay();
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        assertTrue(!seq.sendAcknowledgement());
+              
+        seq.acknowledge(new BigInteger("1")); 
+        
+        assertTrue(seq.sendAcknowledgement());
+        seq.acknowledgmentSent();
+        assertFalse(seq.sendAcknowledgement());
+        
+        control.verify();
+    }
+    
+    public void testAcknowledgeDeferred() throws SequenceFault, IOException {
+        Timer timer = new Timer();
+        setUpDestination(timer);
+        
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        RMEndpoint rme = control.createMock(RMEndpoint.class);
+        EasyMock.expect(destination.getReliableEndpoint()).andReturn(rme).anyTimes();
+        Proxy proxy = control.createMock(Proxy.class);
+        EasyMock.expect(rme.getProxy()).andReturn(proxy).anyTimes();        
+        proxy.acknowledge(seq);
+        EasyMock.expectLastCall();
+        
+        control.replay();
+        
+        ap.setIntraMessageThreshold(0);
+        AcknowledgementInterval ai = new org.apache.cxf.ws.rm.policy.ObjectFactory()
+            .createRMAssertionAcknowledgementInterval();
+        ai.setMilliseconds(new BigInteger("200"));
+        rma.setAcknowledgementInterval(ai);        
+
+        assertTrue(!seq.sendAcknowledgement());   
+              
+        seq.acknowledge(new BigInteger("1")); 
+        seq.acknowledge(new BigInteger("2"));
+        seq.acknowledge(new BigInteger("3"));
+        
+        assertFalse(seq.sendAcknowledgement());
+        
+        try {
+            Thread.sleep(250);
+        } catch (InterruptedException ex) {
+            // ignore
+        }
+        assertTrue(seq.sendAcknowledgement());
+        seq.acknowledgmentSent();
+        assertFalse(seq.sendAcknowledgement());
+        
+        control.verify();
+    }
+    
+    public void testCorrelationID() {
+        setUpDestination();
+        DestinationSequence seq = new DestinationSequence(id, ref, destination);
+        String correlationID = "abdc1234";
+        assertNull("unexpected correlation ID", seq.getCorrelationID());
+        seq.setCorrelationID(correlationID);
+        assertEquals("unexpected correlation ID",
+                     correlationID,
+                     seq.getCorrelationID());
+    }
+    
+    public void testApplyDeliveryAssuranceAtMostOnce() {
+        setUpDestination();
+        
+        BigInteger mn = BigInteger.TEN;        
+        SequenceAcknowledgement ack = control.createMock(SequenceAcknowledgement.class);
+        List<AcknowledgementRange> ranges = new ArrayList<AcknowledgementRange>();
+        AcknowledgementRange r = control.createMock(AcknowledgementRange.class);
+        EasyMock.expect(ack.getAcknowledgementRange()).andReturn(ranges);
+        DeliveryAssuranceType da = control.createMock(DeliveryAssuranceType.class);
+        EasyMock.expect(manager.getDeliveryAssurance()).andReturn(da);
+        EasyMock.expect(da.isSetAtMostOnce()).andReturn(true);                    
+        
+        control.replay();        
+        DestinationSequence ds = new DestinationSequence(id, ref, null, ack);
+        ds.setDestination(destination);
+        assertTrue("message had already been delivered", ds.applyDeliveryAssurance(mn));
+        control.verify();
+        
+        control.reset();
+        ranges.add(r);
+        EasyMock.expect(destination.getManager()).andReturn(manager);
+        EasyMock.expect(manager.getDeliveryAssurance()).andReturn(da);
+        EasyMock.expect(da.isSetAtMostOnce()).andReturn(true);            
+        EasyMock.expect(ack.getAcknowledgementRange()).andReturn(ranges);
+        EasyMock.expect(r.getLower()).andReturn(new BigInteger("5"));
+        EasyMock.expect(r.getUpper()).andReturn(new BigInteger("15"));
+        control.replay();        
+        assertTrue("message has not yet been delivered", !ds.applyDeliveryAssurance(mn));
+        control.verify();
+
+    }
+    
+    public void testInOrderNoWait() {
+        setUpDestination();
+
+        BigInteger mn = BigInteger.TEN;
+        
+        DeliveryAssuranceType da = control.createMock(DeliveryAssuranceType.class);
+        EasyMock.expect(manager.getDeliveryAssurance()).andReturn(da);
+        EasyMock.expect(da.isSetAtMostOnce()).andReturn(false);
+        EasyMock.expect(da.isSetAtLeastOnce()).andReturn(true);
+        EasyMock.expect(da.isSetInOrder()).andReturn(true); 
+        
+        SequenceAcknowledgement ack = control.createMock(SequenceAcknowledgement.class);
+        List<AcknowledgementRange> ranges = new ArrayList<AcknowledgementRange>();
+        AcknowledgementRange r = control.createMock(AcknowledgementRange.class);
+        ranges.add(r);
+        EasyMock.expect(ack.getAcknowledgementRange()).andReturn(ranges).times(3);
+        EasyMock.expect(r.getLower()).andReturn(BigInteger.ONE);
+        EasyMock.expect(r.getUpper()).andReturn(new BigInteger("15"));
+        
+        control.replay(); 
+        
+        DestinationSequence ds = new DestinationSequence(id, ref, null, ack);
+        ds.setDestination(destination);
+        assertTrue(ds.applyDeliveryAssurance(mn));
+        control.verify();
+    }
+    
+    public void testInOrderWait() {
+        setUpDestination();
+        
+        DeliveryAssuranceType da = control.createMock(DeliveryAssuranceType.class);
+        EasyMock.expect(manager.getDeliveryAssurance()).andReturn(da).anyTimes();
+        EasyMock.expect(da.isSetAtMostOnce()).andReturn(false).anyTimes();
+        EasyMock.expect(da.isSetAtLeastOnce()).andReturn(true).anyTimes();
+        EasyMock.expect(da.isSetInOrder()).andReturn(true).anyTimes(); 
+        
+        SequenceAcknowledgement ack = factory.createSequenceAcknowledgement();
+        List<AcknowledgementRange> ranges = new ArrayList<AcknowledgementRange>();
+        final int n = 5;
+        final AcknowledgementRange r = 
+            factory.createSequenceAcknowledgementAcknowledgementRange();
+        r.setUpper(new BigInteger(Integer.toString(n)));
+        ranges.add(r);
+        final DestinationSequence ds = new DestinationSequence(id, ref, null, ack);
+        ds.setDestination(destination);
+          
+        class Acknowledger extends Thread {
+            BigInteger mn;
+            
+            Acknowledger(String mnStr) {
+                mn = new BigInteger(mnStr);
+            }
+            
+            public void run() {
+                try {
+                    ds.acknowledge(mn);
+                    ds.applyDeliveryAssurance(mn);
+                } catch (SequenceFault ex) {
+                    // ignore
+                }
+            }            
+        }
+ 
+        control.replay(); 
+        
+        Thread[] threads = new Thread[n];
+        for (int i = n - 1; i >= 0; i--) {
+            threads[i] = new Acknowledger(Integer.toString(i + 1));
+            threads[i].start();
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException ex) {
+                // ignore
+            }
+        }
+        
+        boolean timedOut = false;
+        for (int i = 0; i < n; i++) {
+            try {
+                threads[i].join(1000); 
+            } catch (InterruptedException ex) {
+                timedOut = true;
+            }
+        }
+        assertTrue("timed out waiting for messages to be processed in order", !timedOut);
+        
+        control.verify();
+    }
+    
+    public void testAllPredecessorsAcknowledged() {
+
+        SequenceAcknowledgement ack = control.createMock(SequenceAcknowledgement.class);
+        List<AcknowledgementRange> ranges = new ArrayList<AcknowledgementRange>();
+        AcknowledgementRange r = control.createMock(AcknowledgementRange.class);
+        EasyMock.expect(ack.getAcknowledgementRange()).andReturn(ranges);
+        control.replay();
+        DestinationSequence ds = new DestinationSequence(id, ref, null, ack);
+        ds.setDestination(destination);
+        assertTrue("all predecessors acknowledged", !ds.allPredecessorsAcknowledged(BigInteger.TEN));
+        control.verify();
+        
+        control.reset();
+        ranges.add(r);
+        EasyMock.expect(ack.getAcknowledgementRange()).andReturn(ranges).times(2);
+        EasyMock.expect(r.getLower()).andReturn(BigInteger.TEN);
+        control.replay();
+        assertTrue("all predecessors acknowledged", !ds.allPredecessorsAcknowledged(BigInteger.TEN));
+        control.verify();
+        
+        control.reset();
+        EasyMock.expect(ack.getAcknowledgementRange()).andReturn(ranges).times(3);
+        EasyMock.expect(r.getLower()).andReturn(BigInteger.ONE);
+        EasyMock.expect(r.getUpper()).andReturn(new BigInteger("5"));
+        control.replay();
+        assertTrue("all predecessors acknowledged", !ds.allPredecessorsAcknowledged(BigInteger.TEN));
+        control.verify();
+        
+        control.reset();
+        EasyMock.expect(ack.getAcknowledgementRange()).andReturn(ranges).times(3);
+        EasyMock.expect(r.getLower()).andReturn(BigInteger.ONE);
+        EasyMock.expect(r.getUpper()).andReturn(BigInteger.TEN);
+        control.replay();
+        assertTrue("not all predecessors acknowledged", ds.allPredecessorsAcknowledged(BigInteger.TEN));
+        control.verify();
+        
+        ranges.add(r);
+        control.reset();
+        EasyMock.expect(ack.getAcknowledgementRange()).andReturn(ranges);
+        control.replay();
+        assertTrue("all predecessors acknowledged", !ds.allPredecessorsAcknowledged(BigInteger.TEN));
+        control.verify();
+    }
+    
+    private void setUpDestination() {
+        setUpDestination(null);
+    }
+    
+    private void setUpDestination(Timer timer) {
+        
+        manager = control.createMock(RMManager.class);
+
+        org.apache.cxf.ws.rm.manager.ObjectFactory cfgFactory =
+            new org.apache.cxf.ws.rm.manager.ObjectFactory();
+        dp = cfgFactory.createDestinationPolicyType();
+        ap = cfgFactory.createAcksPolicyType();
+        dp.setAcksPolicy(ap);
+        
+        org.apache.cxf.ws.rm.policy.ObjectFactory policyFactory =
+            new org.apache.cxf.ws.rm.policy.ObjectFactory();
+        rma = policyFactory.createRMAssertion();
+        BaseRetransmissionInterval bri =
+            policyFactory.createRMAssertionBaseRetransmissionInterval();
+        bri.setMilliseconds(new BigInteger("3000"));
+        rma.setBaseRetransmissionInterval(bri);  
+
+        EasyMock.expect(manager.getRMAssertion()).andReturn(rma).anyTimes();
+        EasyMock.expect(manager.getDestinationPolicy()).andReturn(dp).anyTimes();
+        EasyMock.expect(manager.getStore()).andReturn(null).anyTimes();
+        
+        destination = control.createMock(Destination.class);
+        EasyMock.expect(destination.getManager()).andReturn(manager).anyTimes();
+        
+        if (null != timer) {
+            EasyMock.expect(manager.getTimer()).andReturn(timer).anyTimes();
+        }
+
+    }
+
+
+}

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java?view=auto&rev=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java Wed Nov  1 09:36:06 2006
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+
+public class RMEndpointTest extends TestCase {
+    
+    public void testCreateService() throws NoSuchMethodException {
+        RMEndpoint rme = new RMEndpoint(null, null);
+        rme.createService();
+        
+        Service service = rme.getService();
+        ServiceInfo si = service.getServiceInfo();
+        assertNotNull("service info is null", si);
+
+        InterfaceInfo intf = si.getInterface();
+        
+        assertEquals(3, intf.getOperations().size());
+        
+        String ns = si.getName().getNamespaceURI();
+        OperationInfo oi = intf.getOperation(new QName(ns, "CreateSequence"));
+        assertNotNull("No operation info.", oi);
+        
+    }
+    
+
+    
+}

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java?view=auto&rev=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java Wed Nov  1 09:36:06 2006
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.ws.addressing.MAPAggregator;
+
+public class RMInInterceptorTest extends TestCase {
+    
+    
+    public void testOrdering() {
+        Phase p = new Phase(Phase.PRE_LOGICAL, 1);
+        PhaseInterceptorChain chain = 
+            new PhaseInterceptorChain(Collections.singletonList(p));
+        MAPAggregator map = new MAPAggregator();
+        RMInInterceptor rmi = new RMInInterceptor();        
+        chain.add(rmi);
+        chain.add(map);
+        Iterator it = chain.iterator();
+        assertSame("Unexpected order.", rmi, it.next());
+        assertSame("Unexpected order.", map, it.next());
+                              
+    } 
+}

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java?view=auto&rev=470005
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java Wed Nov  1 09:36:06 2006
@@ -0,0 +1,207 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.math.BigInteger;
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.ws.addressing.AddressingProperties;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.addressing.RelatesToType;
+import org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType;
+import org.apache.cxf.ws.rm.manager.SourcePolicyType;
+import org.apache.cxf.ws.rm.persistence.RMStore;
+import org.apache.cxf.ws.rm.policy.RMAssertion;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
+public class RMManagerTest extends TestCase {
+    
+    private IMocksControl control;
+    
+    public void setUp() {
+        control = EasyMock.createNiceControl();
+    }
+   
+    public void testAccessors() {
+        RMManager manager = new RMManager();
+        assertNull(manager.getStore());
+        assertNull(manager.getRetransmissionQueue());
+        assertNotNull(manager.getTimer());
+        
+        RMStore store = control.createMock(RMStore.class);
+        RetransmissionQueue queue = control.createMock(RetransmissionQueue.class);
+        
+        manager.setStore(store);
+        manager.setRetransmissionQueue(queue);
+        assertSame(store, manager.getStore());
+        assertSame(queue, manager.getRetransmissionQueue());
+        control.replay();
+        control.verify();
+        
+    }
+    
+    public void testInitialisation() {
+        RMManager manager = new RMManager();
+        assertTrue("RMAssertion is set.", !manager.isSetRMAssertion());
+        assertTrue("sourcePolicy is set.", !manager.isSetSourcePolicy());
+        assertTrue("destinationPolicy is set.", !manager.isSetDestinationPolicy());
+        assertTrue("deliveryAssirance is set.", !manager.isSetDeliveryAssurance());
+        
+        manager.initialise();
+        
+        assertTrue("RMAssertion is not set.", manager.isSetRMAssertion());
+        assertTrue("sourcePolicy is not set.", manager.isSetSourcePolicy());
+        assertTrue("destinationPolicy is not set.", manager.isSetDestinationPolicy());
+        assertTrue("deliveryAssirance is not set.", manager.isSetDeliveryAssurance());
+        
+        RMAssertion rma = manager.getRMAssertion();
+        assertTrue(rma.isSetExponentialBackoff());
+        assertEquals(3000L, rma.getBaseRetransmissionInterval().getMilliseconds().longValue());
+        assertTrue(!rma.isSetAcknowledgementInterval());
+        assertTrue(!rma.isSetInactivityTimeout());   
+        
+        SourcePolicyType sp = manager.getSourcePolicy();
+        assertEquals(0, sp.getSequenceExpiration().getTimeInMillis(new Date()));
+        assertEquals(0, sp.getOfferedSequenceExpiration().getTimeInMillis(new Date()));
+        assertNull(sp.getAcksTo());
+        assertTrue(sp.isIncludeOffer());
+        SequenceTerminationPolicyType stp = sp.getSequenceTerminationPolicy();
+        assertEquals(0, stp.getMaxRanges());
+        assertEquals(0, stp.getMaxUnacknowledged());
+        assertTrue(!stp.isTerminateOnShutdown());
+        assertEquals(BigInteger.ZERO, stp.getMaxLength());
+   
+    }   
+    
+    public void xtestGetReliableEndpoint() {
+        
+        RMManager manager = new RMManager();
+        Bus bus = control.createMock(Bus.class);
+        manager.setBus(bus);
+        Message message = control.createMock(Message.class);
+        EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).times(2);
+        Exchange exchange = control.createMock(Exchange.class);
+        EasyMock.expect(message.getExchange()).andReturn(exchange).times(2);
+        // Endpoint endpoint = control.createMock(Endpoint.class);
+        EasyMock.expect(exchange.get(Endpoint.class)).andReturn(null).times(2);
+        control.replay();
+        RMEndpoint reliableEndpoint = manager.getReliableEndpoint(message);
+        // assertSame(endpoint, reliableEndpoint.getEndpoint());
+        RMEndpoint rme = manager.getReliableEndpoint(message);
+        assertSame(reliableEndpoint, rme); 
+        control.verify();
+    }
+    
+    public void testGetDestination() throws NoSuchMethodException {
+        Method  m = RMManager.class
+            .getDeclaredMethod("getReliableEndpoint", new Class[] {Message.class});        
+        RMManager manager = control.createMock(RMManager.class, new Method[] {m});
+        Message message = control.createMock(Message.class);
+        RMEndpoint rme = control.createMock(RMEndpoint.class);
+        EasyMock.expect(manager.getReliableEndpoint(message)).andReturn(rme);    
+        Destination destination = control.createMock(Destination.class);
+        EasyMock.expect(rme.getDestination()).andReturn(destination);
+       
+        control.replay();
+        assertSame(destination, manager.getDestination(message));
+        control.verify();
+        
+        control.reset();
+        EasyMock.expect(manager.getReliableEndpoint(message)).andReturn(null);
+        control.replay();
+        assertNull(manager.getDestination(message));
+        control.verify();        
+    }
+        
+    public void testGetSource() throws NoSuchMethodException {
+        Method m = RMManager.class
+            .getDeclaredMethod("getReliableEndpoint", new Class[] {Message.class});
+        RMManager manager = control.createMock(RMManager.class, new Method[] {m});
+        Message message = control.createMock(Message.class);
+        RMEndpoint rme = control.createMock(RMEndpoint.class);
+        EasyMock.expect(manager.getReliableEndpoint(message)).andReturn(rme);
+        Source source = control.createMock(Source.class);
+        EasyMock.expect(rme.getSource()).andReturn(source);
+
+        control.replay();
+        assertSame(source, manager.getSource(message));
+        control.verify();
+
+        control.reset();
+        EasyMock.expect(manager.getReliableEndpoint(message)).andReturn(null);
+        control.replay();
+        assertNull(manager.getSource(message));
+        control.verify();
+    }
+        
+    public void testGetExistingSequence() throws NoSuchMethodException, SequenceFault {
+        Method m = RMManager.class
+           .getDeclaredMethod("getSource", new Class[] {Message.class});
+        RMManager manager = control.createMock(RMManager.class, new Method[] {m});
+        Message message = control.createMock(Message.class);
+        Identifier inSid = control.createMock(Identifier.class);
+        
+        Source source = control.createMock(Source.class);
+        EasyMock.expect(manager.getSource(message)).andReturn(source);
+        SourceSequence sseq = control.createMock(SourceSequence.class);
+        EasyMock.expect(source.getCurrent(inSid)).andReturn(sseq);
+        control.replay();
+        assertSame(sseq, manager.getSequence(inSid, message, null));
+        control.verify();
+    }
+    
+    public void testGetNewSequence() throws NoSuchMethodException, SequenceFault, IOException {
+        Method m = RMManager.class.getDeclaredMethod("getSource", new Class[] {Message.class});
+        RMManager manager = control.createMock(RMManager.class, new Method[] {m});
+        Message message = control.createMock(Message.class);
+        Identifier inSid = control.createMock(Identifier.class);
+        AddressingProperties maps = control.createMock(AddressingProperties.class);
+        Source source = control.createMock(Source.class);
+        EasyMock.expect(manager.getSource(message)).andReturn(source);
+        EasyMock.expect(source.getCurrent(inSid)).andReturn(null);
+        EndpointReferenceType epr = RMUtils.createNoneReference();
+        EasyMock.expect(maps.getReplyTo()).andReturn(epr);
+        RMEndpoint rme = control.createMock(RMEndpoint.class);
+        EasyMock.expect(source.getReliableEndpoint()).andReturn(rme);
+        Proxy proxy = control.createMock(Proxy.class);
+        EasyMock.expect(rme.getProxy()).andReturn(proxy);
+        proxy.createSequence((EndpointReferenceType)EasyMock.isNull(),
+                             EasyMock.isA(org.apache.cxf.ws.addressing.v200408.EndpointReferenceType.class),
+                             (RelatesToType)EasyMock.isNull());
+        EasyMock.expectLastCall();
+        SourceSequence sseq = control.createMock(SourceSequence.class);
+        EasyMock.expect(source.awaitCurrent(inSid)).andReturn(sseq);
+        sseq.setTarget((EndpointReferenceType)EasyMock.isNull());
+        EasyMock.expectLastCall();
+        
+        control.replay();
+        assertSame(sseq, manager.getSequence(inSid, message, maps));
+        control.verify();
+    }
+}

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date