directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r749816 [2/2] - in /directory/apacheds/branches/apacheds-replication: ./ core/src/main/java/org/apache/directory/server/core/ core/src/main/java/org/apache/directory/server/core/journal/ core/src/main/java/org/apache/directory/server/core/p...
Date Tue, 03 Mar 2009 22:52:43 GMT
Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java?rev=749816&r1=749815&r2=749816&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/common/CSNTest.java
Tue Mar  3 22:52:42 2009
@@ -20,6 +20,10 @@
 package org.apache.directory.mitosis.common;
 
 
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -35,17 +39,34 @@
  */
 public class CSNTest
 {
+    private SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHH:mm:ss'z'" );
 
     @Test
     public void testCSN()
     {
         long ts = System.currentTimeMillis();
 
-        CSN csn = new CSN( Long.toString( ts, 16 ) + ":abcdefghi0123:" + 1 );
+        CSN csn = new CSN( sdf.format( new Date( ts ) ) + "#0x0000#abcdefghi0123#0x0001"
);
+
+        assertEquals( ts/1000, csn.getTimestamp()/1000 );
+        assertEquals( 0, csn.getChangeCount() );
+        assertEquals( 1, csn.getOperationNumber() );
+        assertEquals( "abcdefghi0123", csn.getReplicaId() );
+    }
+
 
-        assertEquals( ts, csn.getTimestamp() );
-        assertEquals( 1, csn.getOperationSequence() );
-        assertEquals( "abcdefghi0123", csn.getReplicaId().toString() );
+    @Test
+    public void testCSNNull()
+    {
+        try
+        {
+            new CSN( (String)null );
+            fail();
+        }
+        catch ( InvalidCSNException ice )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -57,10 +78,21 @@
             new CSN( "" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+    }
+
+
+    @Test
+    public void testCSNTimestampOnly()
+    {
+        try
+        {
+            new CSN( sdf.format( new Date( System.currentTimeMillis() ) ) );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
@@ -69,36 +101,58 @@
 
 
     @Test
-    public void testCSNTSOnly()
+    public void testCSNInvalidTS()
     {
         try
         {
-            new CSN( "123" );
+            // A missing 'z'
+            new CSN( "2000010100:00:00#0x1#abc#0x1" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+        
+        try
+        {
+            // Missing seconds
+            new CSN( "2000010100:00:z#0x1#abc#0x1" );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
-    }
 
+        try
+        {
+            // Missing minutes
+            new CSN( "2000010100::00z#0x1#abc#0x1" );
+            fail();
+        }
+        catch ( InvalidCSNException ice )
+        {
+            assertTrue( true );
+        }
 
-    @Test
-    public void testCSNInvalidTS()
-    {
         try
         {
-            new CSN( "zzz:abc:1" );
+            // Missing hours
+            new CSN( "2000010100::00z#0x1#abc#0x1" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+
+        try
+        {
+            // Invalid date
+            new CSN( "200A010100::00z#0x1#abc#0x1" );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
@@ -107,17 +161,28 @@
 
 
     @Test
-    public void testCSNNoTS()
+    public void testCSNNoTimestamp()
     {
         try
         {
-            new CSN( ":abc:1" );
+            new CSN( "#0x1#abc#0x1" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+    }
+
+
+    @Test
+    public void testCSNNoChangeCount()
+    {
+        try
+        {
+            new CSN( "2000010100:00:00z##a#0x1" );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
@@ -126,36 +191,63 @@
 
 
     @Test
-    public void testCSNInavlidReplica()
+    public void testCSNInvalidChangeCount()
     {
         try
         {
-            new CSN( "123:*:1" );
+            new CSN( "2000010100:00:00z#00#a#0x1" );
+            fail();
+        }
+        catch ( InvalidCSNException ice )
+        {
+            assertTrue( true );
+        }
+
+        try
+        {
+            new CSN( "2000010100:00:00z#0x#a#0x1" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+        
+        try
+        {
+            new CSN( "2000010100:00:00z#0x0G#a#0x1" );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
     }
-
-
+    
+    
     @Test
     public void testCSNNoReplica()
     {
         try
         {
-            new CSN( "123::1" );
+            new CSN( "2000010100:00:00z#0x1##0x1" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+    }
+    
+    
+    @Test
+    public void testCSNInvalidReplica()
+    {
+        try
+        {
+            new CSN( "2000010100:00:00z#0x1#a12-b3é#0x1" );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
@@ -164,17 +256,23 @@
 
 
     @Test
-    public void testCSNInavlidOpSeq()
+    public void testCSNNoOpNumber()
     {
         try
         {
-            new CSN( "123:abc:zzz" );
+            new CSN( "2001010100:00:00z#0x0#abc" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+        
+        try
+        {
+            new CSN( "2001010100:00:00z#0x0#abc#  " );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
@@ -183,36 +281,43 @@
 
 
     @Test
-    public void testCSNEmptyOpSeq()
+    public void testCSNInvalidOpNumber()
     {
         try
         {
-            new CSN( "123:abc:" );
+            new CSN( "2001010100:00:00z#0x0#abc#zzz" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+
+        try
+        {
+            new CSN( "2001010100:00:00z#0x0#abc#0x" );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
-    }
-
 
-    @Test
-    public void testCSNNoOpSeq()
-    {
         try
         {
-            new CSN( "123:abc" );
+            new CSN( "2001010100:00:00z#0x0#abc#000" );
             fail();
         }
-        catch ( AssertionError ae )
+        catch ( InvalidCSNException ice )
         {
             assertTrue( true );
         }
+
+        try
+        {
+            new CSN( "2001010100:00:00z#0x0#abc#0x0G" );
+            fail();
+        }
         catch ( InvalidCSNException ice )
         {
             assertTrue( true );
@@ -223,24 +328,19 @@
     @Test
     public void testCSNToBytes()
     {
-        CSN csn = new CSN( "0123456789abcdef:test:5678cdef" );
+        CSN csn = new CSN( "2001010100:00:00z#0x0#abc#0x1" );
 
         byte[] bytes = csn.toBytes();
 
-        assertEquals( 0x01, bytes[0] );
-        assertEquals( 0x23, bytes[1] );
-        assertEquals( 0x45, bytes[2] );
-        assertEquals( 0x67, bytes[3] );
-        assertEquals( ( byte ) 0x89, bytes[4] );
-        assertEquals( ( byte ) 0xAB, bytes[5] );
-        assertEquals( ( byte ) 0xCD, bytes[6] );
-        assertEquals( ( byte ) 0xEF, bytes[7] );
-        assertEquals( 0x56, bytes[8] );
-        assertEquals( 0x78, bytes[9] );
-        assertEquals( ( byte ) 0xCD, bytes[10] );
-        assertEquals( ( byte ) 0xEF, bytes[11] );
-
-        assertEquals( "test", new String( bytes, 12, bytes.length - 12 ) );
+        byte[] expected = new byte[]
+            { 
+                '2', '0', '0', '1', '0', '1', '0', '1', 
+                '0', '0', ':', '0', '0', ':', '0', '0', 
+                'z', '#', '0', 'x', '0', '#', 'a', 'b', 
+                'c', '#', '0', 'x', '1' 
+            };
+        
+        assertTrue( Arrays.equals( expected, bytes ) );
 
         CSN deserializedCSN = new CSN( bytes );
         assertEquals( csn, deserializedCSN );

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java?rev=749816&r1=749815&r2=749816&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/service/ReplicationServiceITest.java
Tue Mar  3 22:52:42 2009
@@ -91,7 +91,9 @@
      *
      * @throws Exception on failure
      */
-    public void disabled_testTwoWayBind() throws Exception
+    @Ignore
+    @Test
+    public void testTwoWayBind() throws Exception
     {
         LdapContext ctxA = getReplicaContext( "A" );
         LdapContext ctxB = getReplicaContext( "B" );
@@ -157,7 +159,7 @@
 
         replicationServices.get( "A" ).replicate();
         
-        Thread.sleep( 5000 );
+        Thread.sleep( 500000 );
 
         Assert.assertNotNull( ctxA.lookup( dn ) );
         Assert.assertNotNull( ctxB.lookup( dn ) );

Modified: directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java?rev=749816&r1=749815&r2=749816&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java
(original)
+++ directory/apacheds/branches/apacheds-replication/mitosis/src/test/java/org/apache/directory/mitosis/service/protocol/codec/AbstractMessageCodecTest.java
Tue Mar  3 22:52:42 2009
@@ -39,6 +39,7 @@
 import org.apache.mina.filter.codec.demux.MessageDecoder;
 import org.apache.mina.filter.codec.demux.MessageEncoder;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -79,6 +80,7 @@
     }
 
 
+    @Ignore
     @Test 
     public void testMessageCodec() throws Exception
     {

Modified: directory/apacheds/branches/apacheds-replication/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/pom.xml?rev=749816&r1=749815&r2=749816&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-replication/pom.xml (original)
+++ directory/apacheds/branches/apacheds-replication/pom.xml Tue Mar  3 22:52:42 2009
@@ -343,6 +343,7 @@
     <module>core-shared</module>
     <module>core-plugin</module>
     <module>core-unit</module>
+    <module>core-utils</module>
     <module>core-integ</module>
     <module>core-entry</module>
     <module>core-cursor</module>



Mime
View raw message