cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r538850 [2/2] - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/configuration/spring/ common/common/src/main/resources/META-INF/ common/common/src/main/resources/schemas/configuration/ parent/ rt/core/src/main/java/org/a...
Date Thu, 17 May 2007 09:38:21 GMT
Copied: incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/manager.xsd (from r537806, incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/manager.xsd?view=diff&rev=538850&p1=incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd&r1=537806&p2=incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/manager.xsd&r2=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager.xsd (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/resources/schemas/configuration/manager.xsd Thu May 17 02:38:18 2007
@@ -18,185 +18,36 @@
   under the License.
 -->
 
+    
 <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"
+           xmlns:beans="http://www.springframework.org/schema/beans" 
+           xmlns:cxf-beans="http://cxf.apache.org/configuration/beans" 
            elementFormDefault="qualified" 
-           attributeFormDefault="unqualified"
-           jaxb:version="2.0">
-
-    <xs:import namespace="http://schemas.xmlsoap.org/ws/2005/02/rm/policy" schemaLocation="wsrm-policy.xsd"/>
-
-    <xs:complexType name="SourcePolicyType">
-        <xs:annotation>
-            <xs:documentation>RM source configuration properties. 
-            Used for configuring an RM source.
-            </xs:documentation>
-        </xs:annotation>
-        
-       <xs:sequence>  
-            <xs:element name="sequenceTerminationPolicy" type="tns:SequenceTerminationPolicyType" minOccurs="0"/>
-       </xs:sequence>
-        
-        <xs:attribute name="sequenceExpiration" type="xs:duration" use="optional" default="PT0S">
-            <xs:annotation>
-                <xs:documentation>
-                    Preferred lifetime of a sequence - included in createSequence 
-                    requests issued by an RM source. 
-                    A default of PT0S means that the sequence should never expire.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute>
-        <xs:attribute name="acksTo" type="xs:string" use="optional">
-            <xs:annotation>
-                <xs:documentation>
-                    Address to which sequence acknowledgements should be sent. 
-                    If this attribute is not set, defaults to the anonymous address.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute>
-        <xs:attribute name="includeOffer" type="xs:boolean" use="optional" default="true">
-            <xs:annotation>
-                <xs:documentation>
-                    Indicates if an RM source should include an offer for an inbound sequence
-                    when issuing a createSequence request.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute>
-        <xs:attribute name="offeredSequenceExpiration" type="xs:duration" use="optional" default="PT0S">
-            <xs:annotation>
-                <xs:documentation>
-                    The lifetime of an offered inbound sequence.
-                    A default of PT0S means that the sequence never expires.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute>
-    </xs:complexType>
-    
-    <xs:complexType name="DestinationPolicyType">
-        <xs:annotation>
-            <xs:documentation>RM destination configuration properties. 
-            Used for configuring an RM destination.
-            </xs:documentation>
-        </xs:annotation>
-
-        <xs:sequence>  
-            <xs:element name="acksPolicy" type="tns:AcksPolicyType" minOccurs="0"/>
-        </xs:sequence>
-        
-        <xs:attribute name="sequenceExpiration" type="xs:duration" use="optional" default="PT0S">
-            <xs:annotation>
-                <xs:documentation>
-                    Preferred lifetime of a sequence - can be lower than the duration
-                    requested by the RM source in a CreateSequence request. 
-                    A default of PT0S means that the sequence should never expire.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute>
-        
-        <xs:attribute name="acceptOffers" type="xs:boolean" use="optional" default="true">
-            <xs:annotation>
-                <xs:documentation>
-                    Indicates if an RM destination should accept inbound sequence offers.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute>
-        
-    </xs:complexType>
-
-    <xs:complexType name="SequenceTerminationPolicyType">    
-        <xs:attribute name="maxLength" type="xs:unsignedLong" use="optional" default="0">
-            <xs:annotation>
-                <xs:documentation>
-                    The maximum length of a sequence. 
-                    A value of 0 means the sequence length is unbound.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute> 
-        <xs:attribute name="maxRanges" type="xs:int" use="optional" default="0">
-            <xs:annotation>
-                <xs:documentation>
-                    The maximum number of acknowledgment ranges tolerated in sequence
-                    acknowledgment. When this value is exceeded the sequence
-                    will be terminated. 
-                    A value of 0 means sequence termination does not depend on
-                    the number of acknowledgment ranges.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute>
-        <xs:attribute name="maxUnacknowledged" type="xs:int" use="optional" default="0">
-            <xs:annotation>
-                <xs:documentation>
-                    The maximum number of unacknowledged messages that can accrue within per
-                    sequence before the sequence is terminated.
-                    A value of 0 means sequence termination does not depend on
-                    the number of unacknowledgment messages.
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute>
-        <xs:attribute name="terminateOnShutdown" type="xs:boolean" use ="optional" default="false">
-        <xs:annotation>
-                <xs:documentation>
-                    Specifies if sequences should be terminated when the bus is shutdown.
-                    If set to true, and no last message had been sent for a sequence,
-                    an out of band LastMessage will be issued (in response to which 
-                    a sequence acknowledgment will be sent). If a last message had already been
-                    sent, an acknowledgment is requested instead. 
-                    If, after processing these acknowledgement, all messages have been acknowledged,
-                    an attempt is then made to terminates these sequences.
-                </xs:documentation>
-            </xs:annotation>
-        </xs:attribute>
-    </xs:complexType>
-    
-    <xs:complexType name="AcksPolicyType">    
-        <xs:attribute name="intraMessageThreshold" type="xs:int" use="optional" default="10">
-            <xs:annotation>
-                <xs:documentation>
-                    Restricts the deferred sending of acknowledgments to the case where the stream of incoming 
-                    messages is steady, i.e. the number of messages for one destination per minute stays above the 
-                    specified threshold (only effective if the AcknowledgmentInterval specified in the
-                    RMAssertion is greater 0).
-                </xs:documentation>
-            </xs:annotation>      
-        </xs:attribute> 
-    </xs:complexType>
-    
-    <xs:complexType name="DeliveryAssuranceType">
-        <xs:sequence>
-            <xs:element name="AtMostOnce" minOccurs="0">
-                <xs:complexType>
-                    <xs:sequence/>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="AtLeastOnce" minOccurs="0">
-                <xs:complexType>
-                    <xs:sequence/>
-                </xs:complexType>
-            </xs:element>
-            <xs:element name="InOrder" minOccurs="0">
-                <xs:complexType>
-                    <xs:sequence/>
-                </xs:complexType>
-            </xs:element>
-        </xs:sequence>
-    </xs:complexType>
-
- 
-    <xs:element name="deliveryAssurance" type="tns:DeliveryAssuranceType"/>
-    <xs:element name="sourcePolicy" type="tns:SourcePolicyType"/>
-    <xs:element name="destinationPolicy" type="tns:DestinationPolicyType"/>
+           attributeFormDefault="unqualified">
 
-    <xs:complexType name="RMManagerConfigBean">
-        <xs:sequence>
-            <xs:element ref="wsrmp:RMAssertion" minOccurs="0"/>
-            <xs:element ref="tns:deliveryAssurance" minOccurs="0"/>
-            <xs:element ref="tns:sourcePolicy" minOccurs="0"/>
-            <xs:element ref="tns:destinationPolicy" minOccurs="0"/>
-        </xs:sequence>
-    </xs:complexType>
+    <xs:include schemaLocation="http://cxf.apache.org/ws/rm/manager-types.xsd"/>
+    <xs:import namespace="http://www.springframework.org/schema/beans" />
+    <xs:import namespace="http://cxf.apache.org/configuration/beans" />
+    <xs:import namespace="http://schemas.xmlsoap.org/ws/2005/02/rm/policy" />
+
+    <xs:element name="rmManager">
+        <xs:complexType>
+            <xs:complexContent>
+                <xs:extension base="beans:identifiedType">
+                    <xs:sequence>
+                        <xs:element ref="wsrmp:RMAssertion" minOccurs="0"/>
+                        <xs:element ref="tns:deliveryAssurance" minOccurs="0"/>
+                        <xs:element ref="tns:sourcePolicy" minOccurs="0"/>
+                        <xs:element ref="tns:destinationPolicy" minOccurs="0"/>
+                        <xs:element ref="beans:property" minOccurs="0" maxOccurs="unbounded"/>
+                    </xs:sequence>
+                    <xs:attributeGroup ref="cxf-beans:beanAttributes"/>
+                </xs:extension>
+            </xs:complexContent>
+        </xs:complexType>
+    </xs:element>
 
-	<xs:element name="rmManager" type="tns:RMManagerConfigBean"/>
- </xs:schema>
+</xs:schema>

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java?view=diff&rev=538850&r1=538849&r2=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java Thu May 17 02:38:18 2007
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.ws.rm;
 
-import javax.xml.namespace.QName;
-
 import org.apache.cxf.endpoint.Endpoint;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
@@ -50,7 +48,7 @@
     
     @Test
     public void testAccessors() {
-        QName n = new QName("abc");
+        String n = "abc";
         EasyMock.expect(rme.getName()).andReturn(n);
         Endpoint ae = control.createMock(Endpoint.class);
         EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae);

Modified: 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=diff&rev=538850&r1=538849&r2=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java Thu May 17 02:38:18 2007
@@ -25,8 +25,6 @@
 import java.util.List;
 import java.util.Timer;
 
-import javax.xml.namespace.QName;
-
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -131,12 +129,12 @@
     @Test
     public void testGetEndpointIdentifier() {
         setUpDestination();
-        QName qn = new QName("abc", "xyz");
-        EasyMock.expect(destination.getName()).andReturn(qn);
+        String name = "abc";
+        EasyMock.expect(destination.getName()).andReturn(name);
         control.replay();
         
         DestinationSequence seq = new DestinationSequence(id, ref, destination);
-        assertEquals("Unexpected endpoint identifier", "{abc}xyz", seq.getEndpointIdentifier());
+        assertEquals("Unexpected endpoint identifier", name, seq.getEndpointIdentifier());
         control.verify();
     }
     

Modified: 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=diff&rev=538850&r1=538849&r2=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java Thu May 17 02:38:18 2007
@@ -86,11 +86,15 @@
     @Test
     public void testGetName() {
         EndpointInfo aei = control.createMock(EndpointInfo.class);
-        EasyMock.expect(ae.getEndpointInfo()).andReturn(aei);
-        QName qn = new QName("cxf");
-        EasyMock.expect(aei.getName()).andReturn(qn);
+        EasyMock.expect(ae.getEndpointInfo()).andReturn(aei).times(2);
+        QName eqn = new QName("ns2", "endpoint");
+        EasyMock.expect(aei.getName()).andReturn(eqn);
+        ServiceInfo asi = control.createMock(ServiceInfo.class);
+        EasyMock.expect(aei.getService()).andReturn(asi);
+        QName sqn = new QName("ns1", "service");
+        EasyMock.expect(asi.getName()).andReturn(sqn);
         control.replay();
-        assertSame(qn, rme.getName());
+        assertEquals("{ns1}service.{ns2}endpoint", rme.getName());
     }
 
     @Test

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerConfigurationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerConfigurationTest.java?view=auto&rev=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerConfigurationTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerConfigurationTest.java Thu May 17 02:38:18 2007
@@ -0,0 +1,128 @@
+/**
+ * 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 org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.ws.rm.persistence.RMMessage;
+import org.apache.cxf.ws.rm.persistence.RMStore;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class RMManagerConfigurationTest extends Assert {
+
+    @Test
+    public void testConfiguration() {
+        SpringBusFactory factory = new SpringBusFactory();
+        Bus bus = factory.createBus("org/apache/cxf/ws/rm/custom-rmmanager.xml");
+        RMManager manager = bus.getExtension(RMManager.class);
+        assertNotNull(manager);
+        assertTrue(manager.getSourcePolicy().getSequenceTerminationPolicy().isTerminateOnShutdown());
+        assertEquals(10000L, manager.getRMAssertion().getBaseRetransmissionInterval()
+                     .getMilliseconds().longValue());
+        assertEquals(10000L, manager.getRMAssertion().getAcknowledgementInterval()
+                     .getMilliseconds().longValue());        
+        TestStore store = (TestStore)manager.getStore();
+        assertEquals("here", store.getLocation());
+        
+    }
+    
+    static class TestStore implements RMStore {
+        
+        private String location;
+        
+        public TestStore() {
+            // this(null);
+        }
+        
+        /*
+        public TestStore(String l) {
+            location = l;
+        }
+        */
+        
+        public String getLocation() {
+            return location;
+        }
+
+        public void setLocation(String location) {
+            this.location = location;
+        }
+
+
+
+        public void createDestinationSequence(DestinationSequence seq) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void createSourceSequence(SourceSequence seq) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public Collection<DestinationSequence> getDestinationSequences(String endpointIdentifier) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Collection<RMMessage> getMessages(Identifier sid, boolean outbound) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Collection<SourceSequence> getSourceSequences(String endpointIdentifier) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public void persistIncoming(DestinationSequence seq, RMMessage msg) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void persistOutgoing(SourceSequence seq, RMMessage msg) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void removeDestinationSequence(Identifier seq) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void removeMessages(Identifier sid, Collection<BigInteger> messageNrs, boolean outbound) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void removeSourceSequence(Identifier seq) {
+            // TODO Auto-generated method stub
+            
+        }
+        
+    }
+}

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

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

Modified: 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=diff&rev=538850&r1=538849&r2=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java Thu May 17 02:38:18 2007
@@ -89,17 +89,17 @@
     @Test
     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());
+        assertNull("RMAssertion is set.", manager.getRMAssertion());
+        assertNull("sourcePolicy is set.", manager.getSourcePolicy());
+        assertNull("destinationPolicy is set.", manager.getDestinationPolicy());
+        assertNull("deliveryAssirance is set.", manager.getDeliveryAssurance());
         
         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());
+        assertNotNull("RMAssertion is not set.", manager.getRMAssertion());
+        assertNotNull("sourcePolicy is not set.", manager.getSourcePolicy());
+        assertNotNull("destinationPolicy is not set.", manager.getDestinationPolicy());
+        assertNotNull("deliveryAssirance is not set.", manager.getDeliveryAssurance());
         
         RMAssertion rma = manager.getRMAssertion();
         assertTrue(rma.isSetExponentialBackoff());
@@ -420,5 +420,6 @@
         assertTrue(!id1.getValue().equals(id2.getValue()));     
         control.replay();
     }
+    
      
 } 

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java?view=diff&rev=538850&r1=538849&r2=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java Thu May 17 02:38:18 2007
@@ -23,7 +23,6 @@
 import java.util.Date;
 
 import javax.xml.datatype.Duration;
-import javax.xml.namespace.QName;
 
 import org.apache.cxf.jaxb.DatatypeFactory;
 import org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType;
@@ -281,13 +280,13 @@
     @Test
     public void testGetEndpointIdentfier() {
         setUpSource();
-        QName qn = new QName("abc", "xyz");
-        EasyMock.expect(source.getName()).andReturn(qn);
+        String name = "abc";
+        EasyMock.expect(source.getName()).andReturn(name);
         control.replay();
         
         SourceSequence seq = new SourceSequence(id);
         seq.setSource(source);
-        assertEquals("Unexpected endpoint identifier", "{abc}xyz", seq.getEndpointIdentifier());
+        assertEquals("Unexpected endpoint identifier", name, seq.getEndpointIdentifier());
         control.verify();
     }
     

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/custom-rmmanager.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/custom-rmmanager.xml?view=auto&rev=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/custom-rmmanager.xml (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/custom-rmmanager.xml Thu May 17 02:38:18 2007
@@ -0,0 +1,52 @@
+<?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:cxf-beans="http://cxf.apache.org/configuration/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager"       
+       xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
+       xsi:schemaLocation="
+http://cxf.apache.org/ws/rm/manager http://cxf.apache.org/ws/rm/manager.xsd
+http://schemas.xmlsoap.org/ws/2005/02/rm/policy http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd
+http://cxf.apache.org/configuration/beans http://cxf.apache.org/schemas/configuration/cxf-beans.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+    
+    <import resource="rmmanager.xml"/>  
+    
+    <wsrm-mgr:rmManager name="{http://cxf.apache.org}ws.rm.RMManager">
+      <wsrm-policy:RMAssertion>         
+          <wsrm-policy:BaseRetransmissionInterval Milliseconds="10000"/>           
+          <wsrm-policy:AcknowledgementInterval Milliseconds="10000"/>                                                        
+      </wsrm-policy:RMAssertion>
+      <wsrm-mgr:sourcePolicy>
+          <wsrm-mgr:sequenceTerminationPolicy terminateOnShutdown="true"/>                    
+      </wsrm-mgr:sourcePolicy>
+      <wsrm-mgr:destinationPolicy>
+          <wsrm-mgr:acksPolicy intraMessageThreshold="0"/>                    
+      </wsrm-mgr:destinationPolicy>
+      <!--property name="store" ref="txStore"/-->  
+      <property name="store">
+          <bean class="org.apache.cxf.ws.rm.RMManagerConfigurationTest$TestStore">
+              <property name="location" value="here"/>
+          </bean>
+      </property>
+    </wsrm-mgr:rmManager>
+    
+</beans>

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

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

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/custom-rmmanager.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/PersistenceUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/PersistenceUtilsTest.java?view=auto&rev=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/PersistenceUtilsTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/PersistenceUtilsTest.java Thu May 17 02:38:18 2007
@@ -0,0 +1,50 @@
+/**
+ * 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.persistence;
+
+import java.io.InputStream;
+import java.math.BigInteger;
+
+import org.apache.cxf.ws.rm.SequenceAcknowledgement;
+import org.apache.cxf.ws.rm.SequenceAcknowledgement.AcknowledgementRange;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class PersistenceUtilsTest extends Assert {
+
+    @Test
+    public void testSerialiseDeserialiseAcknowledgement() {
+        SequenceAcknowledgement ack = new SequenceAcknowledgement();
+        AcknowledgementRange range = new AcknowledgementRange();
+        range.setLower(BigInteger.ONE);
+        range.setUpper(BigInteger.TEN);
+        ack.getAcknowledgementRange().add(range);
+        PersistenceUtils utils = PersistenceUtils.getInstance();
+        InputStream is = utils.serialiseAcknowledgment(ack);
+        SequenceAcknowledgement refAck = utils.deserialiseAcknowledgment(is);
+        assertEquals(refAck.getAcknowledgementRange().size(), refAck.getAcknowledgementRange().size());
+        AcknowledgementRange refRange = refAck.getAcknowledgementRange().get(0);
+        assertEquals(range.getLower(), refRange.getLower());
+        assertEquals(range.getUpper(), refRange.getUpper());
+    }
+}

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

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

Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java?view=auto&rev=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java Thu May 17 02:38:18 2007
@@ -0,0 +1,593 @@
+/**
+ * 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.persistence.jdbc;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+
+import org.apache.cxf.ws.addressing.v200408.EndpointReferenceType;
+import org.apache.cxf.ws.rm.DestinationSequence;
+import org.apache.cxf.ws.rm.Identifier;
+import org.apache.cxf.ws.rm.RMConstants;
+import org.apache.cxf.ws.rm.RMUtils;
+import org.apache.cxf.ws.rm.SequenceAcknowledgement;
+import org.apache.cxf.ws.rm.SourceSequence;
+import org.apache.cxf.ws.rm.persistence.RMMessage;
+import org.apache.cxf.ws.rm.persistence.RMStoreException;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class RMTxStoreTest extends Assert {
+    
+    private static final String CLIENT_ENDPOINT_ID = 
+        "celtix.{http://celtix.objectweb.org/greeter_control}GreeterService/GreeterPort";
+    private static final String SERVER_ENDPOINT_ID = 
+        "celtix.{http://celtix.objectweb.org/greeter_control}GreeterService";
+    private static final String NON_ANON_ACKS_TO = 
+        "http://localhost:9999/decoupled_endpoint";
+    
+    private static RMTxStore store;    
+    private static SequenceAcknowledgement ack1;
+    private static SequenceAcknowledgement ack2;
+    
+    private IMocksControl control;
+    
+    @BeforeClass 
+    public static void setUpOnce() {
+        
+        RMTxStore.deleteDatabaseFiles();
+
+        store = new RMTxStore();
+        store.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
+        store.setUrl("jdbc:derby:rmdb;create=true");
+        store.init();
+        
+        ack1 = new SequenceAcknowledgement();
+        SequenceAcknowledgement.AcknowledgementRange range = 
+            new SequenceAcknowledgement.AcknowledgementRange();
+        range.setLower(BigInteger.ONE);
+        range.setUpper(BigInteger.ONE);
+        ack1.getAcknowledgementRange().add(range);
+        
+        ack2 = new SequenceAcknowledgement();
+        range = new SequenceAcknowledgement.AcknowledgementRange();
+        range.setLower(BigInteger.ONE);
+        range.setUpper(BigInteger.ONE);
+        ack2.getAcknowledgementRange().add(range);
+        range = new SequenceAcknowledgement.AcknowledgementRange();
+        range.setLower(new BigInteger("3"));
+        range.setUpper(BigInteger.TEN);
+        ack2.getAcknowledgementRange().add(range);
+    }
+    
+    @AfterClass
+    public static void tearDownOnce() {
+        /*
+        try {
+            store.getConnection().close();
+        } catch (SQLException ex) {
+            ex.printStackTrace();
+        }
+        */
+        RMTxStore.deleteDatabaseFiles(RMTxStore.DEFAULT_DATABASE_DIR, false);
+    }
+    
+    
+    @Before
+    public void setUp() {
+        control = EasyMock.createNiceControl();        
+    }
+       
+    @Test
+    public void testCreateTables() throws SQLException {
+        // tables should  have been created during initialisation
+        // but verify the operation is idempotent
+        store.createTables();     
+    }
+    
+    @Test
+    public void testCreateDeleteSrcSequences() {
+        SourceSequence seq = control.createMock(SourceSequence.class);
+        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
+        sid1.setValue("sequence1");
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        EasyMock.expect(seq.getExpires()).andReturn(null);
+        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
+        
+        control.replay();
+        store.createSourceSequence(seq);   
+        control.verify();
+        
+        control.reset();
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        EasyMock.expect(seq.getExpires()).andReturn(null);
+        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
+        
+        control.replay();
+        try {
+            store.createSourceSequence(seq);  
+            fail("Expected RMStoreException was not thrown.");
+        } catch (RMStoreException ex) {
+            SQLException se = (SQLException)ex.getCause();
+            // duplicate key value 
+            assertEquals("23505", se.getSQLState());
+        }
+        control.verify();
+        
+        control.reset();
+        Identifier sid2 = RMUtils.getWSRMFactory().createIdentifier();
+        sid2.setValue("sequence2");
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid2);  
+        EasyMock.expect(seq.getExpires()).andReturn(new Date());
+        Identifier sid3 = RMUtils.getWSRMFactory().createIdentifier();
+        sid3.setValue("offeringSequence3");
+        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(sid3);
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
+        
+         
+        control.replay();
+        store.createSourceSequence(seq);   
+        control.verify();
+            
+        store.removeSourceSequence(sid1);
+        store.removeSourceSequence(sid2);
+        
+        // deleting once again is a no-op
+        store.removeSourceSequence(sid2);       
+    }
+    
+    @Test
+    public void testCreateDeleteDestSequences() {
+        DestinationSequence seq = control.createMock(DestinationSequence.class);
+        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
+        sid1.setValue("sequence1");
+        EndpointReferenceType epr = RMUtils.createAnonymousReference2004();
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        EasyMock.expect(seq.getAcksTo()).andReturn(epr);        
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
+        
+        control.replay();
+        store.createDestinationSequence(seq);   
+        control.verify();
+        
+        control.reset();
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        EasyMock.expect(seq.getAcksTo()).andReturn(epr);        
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
+        
+        control.replay();
+        try {
+            store.createDestinationSequence(seq);  
+            fail("Expected RMStoreException was not thrown.");
+        } catch (RMStoreException ex) {
+            SQLException se = (SQLException)ex.getCause();
+            // duplicate key value 
+            assertEquals("23505", se.getSQLState());
+        }
+        control.verify();
+        
+        control.reset();
+        Identifier sid2 = RMUtils.getWSRMFactory().createIdentifier();
+        sid2.setValue("sequence2");
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid2); 
+        epr = RMUtils.createReference2004(NON_ANON_ACKS_TO);
+        EasyMock.expect(seq.getAcksTo()).andReturn(epr);
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
+        
+        control.replay();
+        store.createDestinationSequence(seq);   
+        control.verify();
+            
+        store.removeDestinationSequence(sid1);
+        store.removeDestinationSequence(sid2);
+        
+        // deleting once again is a no-op
+        store.removeDestinationSequence(sid2);        
+    }
+    
+    @Test
+    public void testCreateDeleteMessages() throws IOException, SQLException  {
+        RMMessage msg = control.createMock(RMMessage.class);
+        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
+        sid1.setValue("sequence1");
+        EasyMock.expect(msg.getMessageNumber()).andReturn(BigInteger.ONE).times(2); 
+        byte[] bytes = new byte[89];
+        EasyMock.expect(msg.getContent()).andReturn(bytes).times(2);
+        
+        control.replay();
+        store.beginTransaction();
+        store.storeMessage(sid1, msg, true);
+        store.storeMessage(sid1, msg, false);
+        store.commit();
+        control.verify();
+        
+        control.reset();
+        EasyMock.expect(msg.getMessageNumber()).andReturn(BigInteger.ONE); 
+        EasyMock.expect(msg.getContent()).andReturn(bytes);
+        
+        control.replay();
+        store.beginTransaction();
+        try {
+            store.storeMessage(sid1, msg, true);
+        } catch (SQLException ex) {
+            assertEquals("23505", ex.getSQLState());
+        }
+        store.abort();
+        control.verify();
+        
+        control.reset();
+        EasyMock.expect(msg.getMessageNumber()).andReturn(BigInteger.TEN).times(2); 
+        EasyMock.expect(msg.getContent()).andReturn(bytes).times(2); 
+        
+        control.replay();
+        store.beginTransaction();
+        store.storeMessage(sid1, msg, true);
+        store.storeMessage(sid1, msg, false);
+        store.commit();
+        control.verify();
+        
+        Collection<BigInteger> messageNrs = new ArrayList<BigInteger>();
+        messageNrs.add(BigInteger.ZERO);
+        messageNrs.add(BigInteger.TEN);
+        messageNrs.add(BigInteger.ONE);
+        messageNrs.add(BigInteger.TEN);
+        
+        store.removeMessages(sid1, messageNrs, true);
+        store.removeMessages(sid1, messageNrs, false);
+        
+        Identifier sid2 = RMUtils.getWSRMFactory().createIdentifier();
+        sid1.setValue("sequence2");
+        store.removeMessages(sid2, messageNrs, true);
+    }
+    
+    @Test
+    public void testUpdateDestinationSequence() throws SQLException, IOException {
+        DestinationSequence seq = control.createMock(DestinationSequence.class);
+        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
+        sid1.setValue("sequence1");
+        EndpointReferenceType epr = RMUtils.createAnonymousReference2004();
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        EasyMock.expect(seq.getAcksTo()).andReturn(epr);        
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
+        
+        control.replay();
+        store.createDestinationSequence(seq);   
+        control.verify();
+        
+        control.reset();
+        EasyMock.expect(seq.getLastMessageNumber()).andReturn(null);
+        EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1);        
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        
+        control.replay();
+        store.beginTransaction();
+        store.updateDestinationSequence(seq);
+        store.abort();
+        
+        control.reset();
+        EasyMock.expect(seq.getLastMessageNumber()).andReturn(BigInteger.TEN);
+        EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1);        
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        
+        control.replay();
+        store.beginTransaction();
+        store.updateDestinationSequence(seq);
+        store.abort();
+        
+        store.removeDestinationSequence(sid1);
+    }
+    
+    @Test
+    public void testUpdateSourceSequence() throws SQLException {
+        SourceSequence seq = control.createMock(SourceSequence.class);
+        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
+        sid1.setValue("sequence1");
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        EasyMock.expect(seq.getExpires()).andReturn(null);
+        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
+        
+        control.replay();
+        store.createSourceSequence(seq);   
+        control.verify();        
+        
+        control.reset();
+        EasyMock.expect(seq.getCurrentMessageNr()).andReturn(BigInteger.ONE);
+        EasyMock.expect(seq.isLastMessage()).andReturn(false);
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);   
+        
+        control.replay();
+        store.beginTransaction();
+        store.updateSourceSequence(seq);
+        store.abort();
+        
+        control.reset();
+        EasyMock.expect(seq.getCurrentMessageNr()).andReturn(BigInteger.TEN);
+        EasyMock.expect(seq.isLastMessage()).andReturn(true);  
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
+        
+        control.replay();
+        store.beginTransaction();
+        store.updateSourceSequence(seq);
+        store.abort();
+        
+        store.removeSourceSequence(sid1);
+        
+    }
+
+    @Test
+    public void testGetDestinationSequences() throws SQLException, IOException {
+        
+        Identifier sid1 = null;
+        Identifier sid2 = null;
+        
+        Collection<DestinationSequence> seqs = store.getDestinationSequences("unknown");
+        assertEquals(0, seqs.size());
+        
+        try {
+            sid1 = setupDestinationSequence("sequence1");
+
+            seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
+            assertEquals(1, seqs.size());
+            checkRecoveredDestinationSequences(seqs);
+
+            sid2 = setupDestinationSequence("sequence2");
+            seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
+            assertEquals(2, seqs.size());
+            checkRecoveredDestinationSequences(seqs);
+        } finally {
+            if (null != sid1) {
+                store.removeDestinationSequence(sid1);
+            }
+            if (null != sid2) {
+                store.removeDestinationSequence(sid2);
+            }
+        }
+    }
+
+    @Test
+    public void testGetSourceSequences() throws SQLException, IOException {
+        
+        Identifier sid1 = null;
+        Identifier sid2 = null;
+        
+        Collection<SourceSequence> seqs = store.getSourceSequences("unknown");
+        assertEquals(0, seqs.size());
+        
+        try {
+            sid1 = setupSourceSequence("sequence1");
+
+            seqs = store.getSourceSequences(CLIENT_ENDPOINT_ID);
+            assertEquals(1, seqs.size());
+            checkRecoveredSourceSequences(seqs);
+
+            sid2 = setupSourceSequence("sequence2");
+            seqs = store.getSourceSequences(CLIENT_ENDPOINT_ID);
+            assertEquals(2, seqs.size());
+            checkRecoveredSourceSequences(seqs);
+        } finally {
+            if (null != sid1) {
+                store.removeSourceSequence(sid1);
+            }
+            if (null != sid2) {
+                store.removeSourceSequence(sid2);
+            }
+        }
+    }
+
+    @Test
+    public void testGetMessages() throws SQLException, IOException {
+        
+        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
+        sid1.setValue("sequence1");
+        Identifier sid2 = RMUtils.getWSRMFactory().createIdentifier();
+        sid2.setValue("sequence2");
+        
+        Collection<RMMessage> out = store.getMessages(sid1, true);
+        assertEquals(0, out.size());
+        Collection<RMMessage> in = store.getMessages(sid1, false);
+        assertEquals(0, out.size());
+        
+        try {
+            setupMessage(sid1, BigInteger.ONE, true);
+            setupMessage(sid1, BigInteger.ONE, false);
+
+            out = store.getMessages(sid1, true);
+            assertEquals(1, out.size());
+            checkRecoveredMessages(out);
+            
+            in = store.getMessages(sid1, false);
+            assertEquals(1, in.size());
+            checkRecoveredMessages(in);
+            
+            setupMessage(sid1, BigInteger.TEN, true);
+            setupMessage(sid1, BigInteger.TEN, false);
+            
+            out = store.getMessages(sid1, true);
+            assertEquals(2, out.size());
+            checkRecoveredMessages(out);
+            
+            in = store.getMessages(sid1, false);
+            assertEquals(2, in.size());
+            checkRecoveredMessages(in);
+        } finally {
+            Collection<BigInteger> msgNrs = new ArrayList<BigInteger>();
+            msgNrs.add(BigInteger.ONE);
+            msgNrs.add(BigInteger.TEN);
+         
+            store.removeMessages(sid1, msgNrs, true);
+            store.removeMessages(sid1, msgNrs, false);
+        }
+    }
+    
+    private Identifier setupDestinationSequence(String s) throws IOException, SQLException {
+        DestinationSequence seq = control.createMock(DestinationSequence.class);
+        
+        Identifier sid = RMUtils.getWSRMFactory().createIdentifier();
+        sid.setValue(s);
+        EndpointReferenceType epr = RMUtils.createAnonymousReference2004();
+        
+        SequenceAcknowledgement ack = ack1;
+        BigInteger lmn = null;
+         
+        if ("sequence2".equals(s)) {
+            ack = ack2;
+            lmn = BigInteger.TEN;
+        }
+        
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid);
+        EasyMock.expect(seq.getAcksTo()).andReturn(epr);
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
+        EasyMock.expect(seq.getLastMessageNumber()).andReturn(lmn);
+        EasyMock.expect(seq.getAcknowledgment()).andReturn(ack);
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid);
+        
+        control.replay();
+        store.createDestinationSequence(seq);           
+        store.beginTransaction();
+        store.updateDestinationSequence(seq);        
+        store.commit();
+        control.reset();
+        
+        return sid;
+    }
+    
+    private Identifier setupSourceSequence(String s) throws IOException, SQLException {
+        SourceSequence seq = control.createMock(SourceSequence.class);        
+        Identifier sid = RMUtils.getWSRMFactory().createIdentifier();
+        sid.setValue(s);      
+            
+        Date expiry = null;
+        Identifier osid = null;
+        BigInteger cmn = BigInteger.ONE;
+        boolean lm = false;
+        
+        if ("sequence2".equals(s)) {
+            expiry = new Date(System.currentTimeMillis() + 3600 * 1000);
+            osid = RMUtils.getWSRMFactory().createIdentifier();
+            osid.setValue("offeringSequence");
+            cmn = BigInteger.TEN;
+            lm = true;            
+        } 
+        
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid);
+        EasyMock.expect(seq.getExpires()).andReturn(expiry);
+        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(osid);
+        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
+        EasyMock.expect(seq.getCurrentMessageNr()).andReturn(cmn);
+        EasyMock.expect(seq.isLastMessage()).andReturn(lm);
+        EasyMock.expect(seq.getIdentifier()).andReturn(sid);
+        
+        control.replay();
+        store.createSourceSequence(seq);           
+        store.beginTransaction();
+        store.updateSourceSequence(seq); 
+        store.commit();
+        control.reset();
+        
+        return sid;
+    }
+    
+    private void setupMessage(Identifier sid, BigInteger mn, boolean outbound) 
+        throws IOException, SQLException  {
+        RMMessage msg = control.createMock(RMMessage.class);
+        EasyMock.expect(msg.getMessageNumber()).andReturn(mn);
+        String value = "Message " + mn.longValue();
+        EasyMock.expect(msg.getContent()).andReturn(value.getBytes());
+        
+        control.replay();
+        store.beginTransaction();
+        store.storeMessage(sid, msg, outbound);        
+        store.commit();
+        control.reset();
+    }
+    
+    private void checkRecoveredDestinationSequences(Collection<DestinationSequence> seqs) {
+        
+        for (DestinationSequence recovered : seqs) {
+            assertTrue("sequence1".equals(recovered.getIdentifier().getValue())
+                                          || "sequence2".equals(recovered.getIdentifier().getValue()));
+            assertEquals(RMConstants.getAnonymousAddress(), recovered.getAcksTo().getAddress().getValue());
+            if ("sequence1".equals(recovered.getIdentifier().getValue())) {                      
+                assertNull(recovered.getLastMessageNumber());                
+                assertEquals(1, recovered.getAcknowledgment().getAcknowledgementRange().size());
+                SequenceAcknowledgement.AcknowledgementRange r = 
+                    recovered.getAcknowledgment().getAcknowledgementRange().get(0);
+                assertEquals(BigInteger.ONE, r.getLower());
+                assertEquals(BigInteger.ONE, r.getUpper());
+            } else {
+                assertEquals(BigInteger.TEN, recovered.getLastMessageNumber());
+                assertEquals(2, recovered.getAcknowledgment().getAcknowledgementRange().size());
+                SequenceAcknowledgement.AcknowledgementRange r = 
+                    recovered.getAcknowledgment().getAcknowledgementRange().get(0);
+                assertEquals(BigInteger.ONE, r.getLower());
+                assertEquals(BigInteger.ONE, r.getUpper());
+                r = recovered.getAcknowledgment().getAcknowledgementRange().get(1);
+                assertEquals(new BigInteger("3"), r.getLower());
+                assertEquals(BigInteger.TEN, r.getUpper());                
+            }
+        }
+    }
+    
+    private void checkRecoveredSourceSequences(Collection<SourceSequence> seqs) {
+        
+        for (SourceSequence recovered : seqs) {
+            assertTrue("sequence1".equals(recovered.getIdentifier().getValue())
+                                          || "sequence2".equals(recovered.getIdentifier().getValue()));
+            if ("sequence1".equals(recovered.getIdentifier().getValue())) {                      
+                assertFalse(recovered.isLastMessage());
+                assertEquals(BigInteger.ONE, recovered.getCurrentMessageNr());  
+                assertNull(recovered.getExpires());
+                assertNull(recovered.getOfferingSequenceIdentifier());
+            } else {
+                assertTrue(recovered.isLastMessage());
+                assertEquals(BigInteger.TEN, recovered.getCurrentMessageNr()); 
+                assertNotNull(recovered.getExpires());
+                assertEquals("offeringSequence", recovered.getOfferingSequenceIdentifier().getValue());
+            }
+        }
+    }
+    
+    private void checkRecoveredMessages(Collection<RMMessage> msgs) {
+        for (RMMessage msg : msgs) {
+            BigInteger mn = msg.getMessageNumber();
+            assertTrue(BigInteger.ONE.equals(mn) || BigInteger.TEN.equals(mn));
+            byte[] actual = msg.getContent();
+            assertEquals(new String("Message " + mn.longValue()), new String(actual));
+        }
+    }
+    
+    
+
+}

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

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

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/rmmanager.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/rmmanager.xml?view=diff&rev=538850&r1=538849&r2=538850
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/rmmanager.xml (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/rmmanager.xml Thu May 17 02:38:18 2007
@@ -19,11 +19,7 @@
 -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:wsrm-mgmt="http://cxf.apache.org/ws/rm/manager"
-       xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
-       xmlns:http="http://cxf.apache.org/transports/http/configuration"
        xsi:schemaLocation="
-http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schema/transports/http.xsd
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
     
     <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>

Modified: incubator/cxf/trunk/systests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?view=diff&rev=538850&r1=538849&r2=538850
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Thu May 17 02:38:18 2007
@@ -34,6 +34,7 @@
 
     <properties>
         <surefire.fork.mode>pertest</surefire.fork.mode>
+        <spring.validation.mode>VALIDATION_NONE</spring.validation.mode>
     </properties>
 
     <dependencies>
@@ -224,6 +225,13 @@
         <dependency>
             <groupId>xmlbeans</groupId>
             <artifactId>xbean</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>${derby.version}</version>
             <scope>test</scope>
         </dependency>
 

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/PersistenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/PersistenceTest.java?view=auto&rev=538850
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/PersistenceTest.java (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/PersistenceTest.java Thu May 17 02:38:18 2007
@@ -0,0 +1,193 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.ws.rm;
+
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.greeter_control.Greeter;
+import org.apache.cxf.greeter_control.GreeterService;
+import org.apache.cxf.systest.ws.policy.GreeterImpl;
+import org.apache.cxf.systest.ws.util.InMessageRecorder;
+import org.apache.cxf.systest.ws.util.MessageFlow;
+import org.apache.cxf.systest.ws.util.MessageRecorder;
+import org.apache.cxf.systest.ws.util.OutMessageRecorder;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.rm.DestinationSequence;
+import org.apache.cxf.ws.rm.RMConstants;
+import org.apache.cxf.ws.rm.RMManager;
+import org.apache.cxf.ws.rm.SourceSequence;
+import org.apache.cxf.ws.rm.persistence.RMMessage;
+import org.apache.cxf.ws.rm.persistence.RMStore;
+import org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Tests the addition of WS-RM properties to application messages and the
+ * exchange of WS-RM protocol messages.
+ */
+public class PersistenceTest extends AbstractBusClientServerTestBase {
+
+    private static final Logger LOG = Logger.getLogger(PersistenceTest.class.getName());
+    private static final String GREETMEONEWAY_ACTION = null;
+    
+    private Greeter greeter;
+    private OutMessageRecorder out;
+    private InMessageRecorder in;
+
+    public static class Server extends AbstractBusTestServerBase {
+
+        protected void run() {
+            SpringBusFactory bf = new SpringBusFactory();
+            Bus bus = bf.createBus("/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml");
+            BusFactory.setDefaultBus(bus);
+
+            GreeterImpl implementor = new GreeterImpl();
+            String address = "http://localhost:9020/SoapContext/GreeterPort";
+            Endpoint.publish(address, implementor);
+            LOG.info("Published greeter endpoint.");
+        }
+
+        public static void main(String[] args) {
+            try {
+                Server s = new Server();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                System.out.println("done!");
+            }
+        }
+    }
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        RMTxStore.deleteDatabaseFiles("rmdb", true);
+        assertTrue("server did not launch correctly", launchServer(Server.class));
+    }
+
+    @Before
+    public void setUp() {
+        SpringBusFactory bf = new SpringBusFactory();
+        bus = bf.createBus("/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml");
+        BusFactory.setDefaultBus(bus);
+
+        GreeterService gs = new GreeterService();
+        greeter = gs.getGreeterPort();
+
+        out = new OutMessageRecorder();
+        in = new InMessageRecorder();
+
+        bus.getOutInterceptors().add(out);
+        bus.getInInterceptors().add(in);
+    }
+
+    // TODO: refactor into one test as we cannot rely on the order in which the tests are executed
+    // (especially on IBM)
+
+    @Test
+    public void testPopulateStore() throws Exception {
+        greeter.greetMeOneWay("one");
+        greeter.greetMeOneWay("two");
+        greeter.greetMeOneWay("three");
+        
+        MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages());
+        
+        awaitMessages(4, 4);
+        
+        mf.verifyMessages(4, true);
+        String[] expectedActions = new String[] {RMConstants.getCreateSequenceAction(), 
+                                                 GREETMEONEWAY_ACTION,
+                                                 GREETMEONEWAY_ACTION, 
+                                                 GREETMEONEWAY_ACTION};
+        mf.verifyActions(expectedActions, true);
+        mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, true);
+
+
+        mf.verifyMessages(4, false);
+        mf.verifyPartialResponses(3);
+        mf.verifyMessageNumbers(new String[4], false);
+        boolean[] expectedAcks = new boolean[4];
+        mf.verifyAcknowledgements(expectedAcks, false);
+        mf.purgePartialResponses();
+        expectedActions = new String[] {RMConstants.getCreateSequenceResponseAction()};
+        mf.verifyActions(expectedActions, false);
+                
+        RMManager manager = bus.getExtension(RMManager.class);
+        assertNotNull(manager);
+        
+        RMStore store = manager.getStore();
+        assertNotNull(store);
+        
+        Client client = ClientProxy.getClient(greeter);
+        String id = client.getEndpoint().getEndpointInfo().getService().getName()
+            + "." + client.getEndpoint().getEndpointInfo().getName();
+        
+        Collection<DestinationSequence> dss =
+            store.getDestinationSequences(id);
+        assertEquals(1, dss.size());
+        
+        Collection<SourceSequence> sss =
+            store.getSourceSequences(id);
+        assertEquals(1, sss.size());
+        
+        Collection<RMMessage> msgs = 
+            store.getMessages(sss.iterator().next().getIdentifier(), true);
+        assertEquals(3, msgs.size());            
+    }
+    
+    @Ignore
+    @Test
+    public void testRecover() throws Exception {
+        // do nothing - resends should happen in the background
+        
+        int expectedOut = 2;
+        awaitMessages(2, 0);
+    
+        MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages());        
+        String[] expectedActions = new String[expectedOut];
+        for (int i = 0; i < expectedOut; i++) {
+            expectedActions[i] = GREETMEONEWAY_ACTION;
+        }
+        mf.verifyActions(expectedActions, true);
+    }
+    
+    private void awaitMessages(int nExpectedOut, int nExpectedIn) {
+        awaitMessages(nExpectedOut, nExpectedIn, 10000);
+    }
+    
+    private void awaitMessages(int nExpectedOut, int nExpectedIn, int timeout) {
+        MessageRecorder mr = new MessageRecorder(out, in);
+        mr.awaitMessages(nExpectedOut, nExpectedIn, timeout);
+    }
+
+}

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

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

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml?view=auto&rev=538850
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml (added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml Thu May 17 02:38:18 2007
@@ -0,0 +1,47 @@
+<?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:wsrm-mgr="http://cxf.apache.org/ws/rm/manager"
+       xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
+       xsi:schemaLocation="
+http://cxf.apache.org/ws/rm/manager http://cxf.apache.org/ws/rm/manager.xsd
+http://schemas.xmlsoap.org/ws/2005/02/rm/policy http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd
+http://cxf.apache.org/configuration/beans http://cxf.apache.org/schemas/configuration/cxf-beans.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+    
+    <import resource="rminterceptors.xml"/>
+    
+    <bean class="org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore"/>
+    
+    
+    <wsrm-mgr:rmManager id="org.apache.cxf.ws.rm.RMManager"> 
+      <wsrm-policy:RMAssertion>         
+          <wsrm-policy:BaseRetransmissionInterval Milliseconds="10000"/>           
+          <wsrm-policy:AcknowledgementInterval Milliseconds="2000"/>                                                        
+      </wsrm-policy:RMAssertion>     
+      <wsrm-mgr:destinationPolicy>
+          <wsrm-mgr:acksPolicy intraMessageThreshold="0"/>                    
+      </wsrm-mgr:destinationPolicy>      
+      <property name="store" ref="org.apache.cxf.ws.rm.persistence.jdbc.RMTxStore"/>
+      
+    </wsrm-mgr:rmManager>
+    
+</beans>
\ No newline at end of file

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/oneway-client-crash.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java?view=diff&rev=538850&r1=538849&r2=538850
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java (original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java Thu May 17 02:38:18 2007
@@ -348,6 +348,10 @@
         if (null != transformerProperty) {
             cmd.add("-Djavax.xml.transform.TransformerFactory=" + transformerProperty);
         }
+        String validationMode = System.getProperty("spring.validation.mode");
+        if (null != validationMode) {
+            cmd.add("-Dspring.validation.mode=" + validationMode);
+        }
         
         cmd.add(className);
 



Mime
View raw message