cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1189058 - in /cxf/trunk/rt/ws/rm/src: main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
Date Wed, 26 Oct 2011 07:53:31 GMT
Author: ay
Date: Wed Oct 26 07:53:31 2011
New Revision: 1189058

URL: http://svn.apache.org/viewvc?rev=1189058&view=rev
Log:
[CXF-3845] avoid using setBoolean in RMTxStore to increase compatibility

Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java?rev=1189058&r1=1189057&r2=1189058&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
(original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
Wed Oct 26 07:53:31 2011
@@ -179,7 +179,7 @@ public class RMTxStore implements RMStor
     
     public String getUserName() {
         return userName;
-    }    
+    }
     
     public void setConnection(Connection c) {
         connection = c;
@@ -547,8 +547,10 @@ public class RMTxStore implements RMStor
         String id = sid.getValue();
         long 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,
@@ -565,8 +567,10 @@ public class RMTxStore implements RMStor
         stmt.setString(i++, to); 
         stmt.setBinaryStream(i++, msg.getInputStream(), msg.getSize());
         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});
+        }
         
     }
     
@@ -576,7 +580,7 @@ public class RMTxStore implements RMStor
             updateSrcSequenceStmt = connection.prepareStatement(UPDATE_SRC_SEQUENCE_STMT_STR);
         }
         updateSrcSequenceStmt.setLong(1, seq.getCurrentMessageNr()); 
-        updateSrcSequenceStmt.setBoolean(2, seq.isLastMessage()); 
+        updateSrcSequenceStmt.setString(2, seq.isLastMessage() ? "1" : "0"); 
         updateSrcSequenceStmt.setString(3, seq.getIdentifier().getValue());
         updateSrcSequenceStmt.execute();
     }

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java?rev=1189058&r1=1189057&r2=1189058&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
(original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStoreTest.java
Wed Oct 26 07:53:31 2011
@@ -26,6 +26,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.EndpointReferenceType;
@@ -441,10 +442,12 @@ public class RMTxStoreTest extends Asser
 
             seq = store.getDestinationSequence(sid1, ProtocolVariation.RM10WSA200408);
             assertNotNull(seq);
+            verifyDestinationSequence("sequence1", seq);
 
             sid2 = setupDestinationSequence("sequence2");
             seq = store.getDestinationSequence(sid2, ProtocolVariation.RM10WSA200408);
             assertNotNull(seq);
+            verifyDestinationSequence("sequence2", seq);
         } finally {
             if (null != sid1) {
                 store.removeDestinationSequence(sid1);
@@ -470,10 +473,12 @@ public class RMTxStoreTest extends Asser
 
             seq = store.getSourceSequence(sid1, ProtocolVariation.RM10WSA200408);
             assertNotNull(seq);
-
+            verifySourceSequence("sequence1", seq);
+            
             sid2 = setupSourceSequence("sequence2");
             seq = store.getSourceSequence(sid2, ProtocolVariation.RM10WSA200408);
             assertNotNull(seq);
+            verifySourceSequence("sequence2", seq);
         } finally {
             if (null != sid1) {
                 store.removeSourceSequence(sid1);
@@ -596,6 +601,52 @@ 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, Long mn, String to, boolean outbound) 
         throws IOException, SQLException  {



Mime
View raw message