cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1189290 - in /cxf/branches/2.3.x-fixes: ./ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
Date Wed, 26 Oct 2011 16:19:27 GMT
Author: dkulp
Date: Wed Oct 26 16:19:27 2011
New Revision: 1189290

URL: http://svn.apache.org/viewvc?rev=1189290&view=rev
Log:
Merged revisions 1189076 via svnmerge from 
https://svn.us.apache.org/repos/asf/cxf/branches/2.4.x-fixes

................
  r1189076 | ay | 2011-10-26 04:39:58 -0400 (Wed, 26 Oct 2011) | 9 lines
  
  Merged revisions 1189058 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1189058 | ay | 2011-10-26 09:53:31 +0200 (Wed, 26 Oct 2011) | 1 line
    
    [CXF-3845] avoid using setBoolean in RMTxStore to increase compatibility
  ........
................

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
    cxf/branches/2.3.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java?rev=1189290&r1=1189289&r2=1189290&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
Wed Oct 26 16:19:27 2011
@@ -176,7 +176,7 @@ public class RMTxStore implements RMStor
     
     public String getUserName() {
         return userName;
-    }    
+    }
    
     public void setConnection(Connection c) {
         connection = c;
@@ -482,8 +482,10 @@ public class RMTxStore implements RMStor
         String id = sid.getValue();
         BigInteger nr = msg.getMessageNumber();
         String to = msg.getTo();
-        LOG.log(Level.FINE, "Storing {0} message number {1} for sequence {2}, to = {3}",
-            new Object[] {outbound ? "outbound" : "inbound", nr, id, to});
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.log(Level.FINE, "Storing {0} message number {1} for sequence {2}, to = {3}",
+                    new Object[] {outbound ? "outbound" : "inbound", nr, id, to});
+        }
         PreparedStatement stmt = outbound ? createOutboundMessageStmt : createInboundMessageStmt;
         if (null == stmt) {
             stmt = connection.prepareStatement(MessageFormat.format(CREATE_MESSAGE_STMT_STR,
@@ -505,8 +507,10 @@ public class RMTxStore implements RMStor
             }
         }, bytes.length);
         stmt.execute();
-        LOG.log(Level.FINE, "Successfully stored {0} message number {1} for sequence {2}",
-                new Object[] {outbound ? "outbound" : "inbound", nr, id});
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.log(Level.FINE, "Successfully stored {0} message number {1} for sequence
{2}",
+                    new Object[] {outbound ? "outbound" : "inbound", nr, id});
+        }
         
     }
     
@@ -516,7 +520,7 @@ public class RMTxStore implements RMStor
             updateSrcSequenceStmt = connection.prepareStatement(UPDATE_SRC_SEQUENCE_STMT_STR);
         }
         updateSrcSequenceStmt.setBigDecimal(1, new BigDecimal(seq.getCurrentMessageNr()));

-        updateSrcSequenceStmt.setBoolean(2, seq.isLastMessage()); 
+        updateSrcSequenceStmt.setString(2, seq.isLastMessage() ? "1" : "0"); 
         updateSrcSequenceStmt.setString(3, seq.getIdentifier().getValue());
         updateSrcSequenceStmt.execute();
     }

Modified: cxf/branches/2.3.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java?rev=1189290&r1=1189289&r2=1189290&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
Wed Oct 26 16:19:27 2011
@@ -25,6 +25,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
+import java.util.List;
 
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.ws.addressing.v200408.EndpointReferenceType;
@@ -407,6 +408,66 @@ public class RMTxStoreTest extends Asser
     }
 
     @Test
+    public void testGetDestinationSequence() throws SQLException, IOException {
+        
+        Identifier sid1 = null;
+        Identifier sid2 = null;
+        
+        DestinationSequence seq = store.getDestinationSequence(RMUtils.getWSRMFactory().createIdentifier());
+        assertNull(seq);
+
+        try {
+            sid1 = setupDestinationSequence("sequence1");
+
+            seq = store.getDestinationSequence(sid1);
+            assertNotNull(seq);
+            verifyDestinationSequence("sequence1", seq);
+
+            sid2 = setupDestinationSequence("sequence2");
+            seq = store.getDestinationSequence(sid2);
+            assertNotNull(seq);
+            verifyDestinationSequence("sequence2", seq);
+        } finally {
+            if (null != sid1) {
+                store.removeDestinationSequence(sid1);
+            }
+            if (null != sid2) {
+                store.removeDestinationSequence(sid2);
+            }
+        }
+    }
+
+    @Test
+    public void testGetSourceSequence() throws SQLException, IOException {
+        
+        Identifier sid1 = null;
+        Identifier sid2 = null;
+        
+        SourceSequence seq = store.getSourceSequence(RMUtils.getWSRMFactory().createIdentifier());
+        assertNull(seq);
+        
+        try {
+            sid1 = setupSourceSequence("sequence1");
+
+            seq = store.getSourceSequence(sid1);
+            assertNotNull(seq);
+            verifySourceSequence("sequence1", seq);
+            
+            sid2 = setupSourceSequence("sequence2");
+            seq = store.getSourceSequence(sid2);
+            assertNotNull(seq);
+            verifySourceSequence("sequence2", seq);
+        } 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();
@@ -518,8 +579,54 @@ public class RMTxStoreTest extends Asser
         
         return sid;
     }
+
+    private void verifyDestinationSequence(String s, DestinationSequence seq) {
+        Identifier sid = seq.getIdentifier();
+        assertNotNull(sid);
+        assertEquals(s, sid.getValue());
+        if ("sequence1".equals(s)) {
+            assertEquals(0, seq.getLastMessageNumber());
+            SequenceAcknowledgement sa = seq.getAcknowledgment();
+            assertNotNull(sa);
+            verifyAcknowledgementRanges(sa.getAcknowledgementRange(), new long[]{1, 1});
+        } else if ("sequence2".equals(s)) {
+            assertEquals(10, seq.getLastMessageNumber());
+            SequenceAcknowledgement sa = seq.getAcknowledgment();
+            assertNotNull(sa);
+            verifyAcknowledgementRanges(sa.getAcknowledgementRange(), new long[]{1, 1, 3,
10});
+        }
+    }
+    
+    private void verifySourceSequence(String s, SourceSequence seq) {
+        Identifier sid = seq.getIdentifier();
+        assertNotNull(sid);
+        assertEquals(s, sid.getValue());
+        if ("sequence1".equals(s)) {
+            assertNull(seq.getExpires());
+            assertEquals(1, seq.getCurrentMessageNr());
+            assertFalse(seq.isLastMessage());
+        } else if ("sequence2".equals(s)) {
+            Date expires = seq.getExpires();
+            assertNotNull(expires);
+            expires.after(new Date());
+            assertEquals(10, seq.getCurrentMessageNr());
+            assertTrue(seq.isLastMessage());
+        }
+    }
+    
+    private void verifyAcknowledgementRanges(List<SequenceAcknowledgement.AcknowledgementRange>
ranges, 
+                                             long[] values) {
+        assertNotNull(ranges);
+        assertEquals(values.length / 2, ranges.size());
+        
+        int v = 0;
+        for (SequenceAcknowledgement.AcknowledgementRange range : ranges) {
+            assertEquals(values[v++], (long)range.getLower());   
+            assertEquals(values[v++], (long)range.getUpper());   
+        }
+    }
     
-    private void setupMessage(Identifier sid, BigInteger mn, String to, boolean outbound)

+    private void setupMessage(Identifier sid, Long mn, String to, boolean outbound) 
         throws IOException, SQLException  {
         RMMessage msg = control.createMock(RMMessage.class);
         EasyMock.expect(msg.getMessageNumber()).andReturn(mn);



Mime
View raw message