directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r781049 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/csn/ main/java/org/apache/directory/shared/ldap/schema/comparators/ main/java/org/apache/directory/shared/ldap/schema/syntaxes/ test/java/org/apache/d...
Date Tue, 02 Jun 2009 14:54:56 GMT
Author: elecharny
Date: Tue Jun  2 14:54:56 2009
New Revision: 781049

URL: http://svn.apache.org/viewvc?rev=781049&view=rev
Log:
* Fixed the CSN classes
* Renamed CSN to Csn, etc
o Added the code into the CsnSid classes

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/Csn.java
      - copied, changed from r780307, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java
      - copied, changed from r780307, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSNFactory.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java
      - copied, changed from r780307, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparator.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnFactoryTest.java
      - copied, changed from r780307, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNFactoryTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnTest.java
      - copied, changed from r780307, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparatorTest.java
      - copied, changed from r780307, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparatorTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparatorTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSidSyntaxCheckerTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSyntaxCheckerTest.java
Removed:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSNFactory.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparator.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNFactoryTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparatorTest.java
Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/InvalidCSNException.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UUIDComparator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSidSyntaxChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSyntaxChecker.java

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/Csn.java
(from r780307, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/Csn.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/Csn.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java&r1=780307&r2=781049&rev=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/Csn.java
Tue Jun  2 14:54:56 2009
@@ -53,7 +53,7 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CSN implements Serializable, Comparable<CSN>
+public class Csn implements Serializable, Comparable<Csn>
 {
     /**
      * Declares the Serial Version Uid.
@@ -65,7 +65,7 @@
     private static final long serialVersionUID = 1L;
 
     /** The logger for this class */
-    private static final Logger LOG = LoggerFactory.getLogger( CSN.class );
+    private static final Logger LOG = LoggerFactory.getLogger( Csn.class );
 
     /** The timeStamp of this operation */
     private final long timestamp;
@@ -102,7 +102,7 @@
      * @param replicaId Replica ID where modification occurred (<tt>[-_A-Za-z0-9]{1,16}</tt>)
      * @param operationNumber Operation number in a modification operation
      */
-    public CSN( long timestamp, int changeCount, int replicaId, int operationNumber )
+    public Csn( long timestamp, int changeCount, int replicaId, int operationNumber )
     {
         this.timestamp = timestamp;
         this.replicaId = replicaId;
@@ -119,7 +119,7 @@
      *
      * @param value The String containing the CSN
      */
-    public CSN( String value ) throws InvalidCSNException
+    public Csn( String value ) throws InvalidCSNException
     {
         if ( StringTools.isEmpty( value ) )
         {
@@ -318,9 +318,24 @@
         }
         
         // And add the milliseconds and microseconds now
+        String millisStr = timestampStr.substring( 15, 21 );
+
+        if ( StringTools.isEmpty( millisStr ) )
+        {
+            return false;
+        }
+        
+        for ( int i = 0; i < 6; i++ )
+        {
+            if ( !StringTools.isDigit( millisStr, i ) )
+            {
+                return false;
+            }
+        }
+
         try
         {
-            Integer.valueOf( timestampStr.substring( 15, 21 ) );
+            Integer.valueOf( millisStr );
         }
         catch ( NumberFormatException nfe )
         {
@@ -337,8 +352,26 @@
     
         String changeCountStr = value.substring( sepTS + 1, sepCC ).trim();
         
+        if ( StringTools.isEmpty( changeCountStr ) )
+        {
+            return false;
+        }
+        
+        if ( changeCountStr.length() != 6 )
+        {
+            return false;
+        }
+        
         try
         {
+            for ( int i = 0; i < 6; i++ )
+            {
+                if ( !StringTools.isHex( changeCountStr, i ) )
+                {
+                    return false;
+                }
+            }
+            
             Integer.parseInt( changeCountStr, 16 ); 
         }
         catch ( NumberFormatException nfe )
@@ -361,6 +394,19 @@
             return false;
         }
         
+        if ( replicaIdStr.length() != 3 )
+        {
+            return false;
+        }
+        
+        for ( int i = 0; i < 3; i++ )
+        {
+            if ( !StringTools.isHex( replicaIdStr, i ) )
+            {
+                return false;
+            }
+        }
+
         try
         {
             Integer.parseInt( replicaIdStr, 16 ); 
@@ -378,6 +424,19 @@
         
         String operationNumberStr = value.substring( sepRI + 1 ).trim();
         
+        if ( operationNumberStr.length() != 6 )
+        {
+            return false;
+        }
+
+        for ( int i = 0; i < 6; i++ )
+        {
+            if ( !StringTools.isHex( operationNumberStr, i ) )
+            {
+                return false;
+            }
+        }
+
         try
         {
             Integer.parseInt( operationNumberStr, 16 ); 
@@ -396,10 +455,10 @@
      *
      * @param value The byte array which contains the serialized CSN
      */
-    /** Package protected */ CSN( byte[] value )
+    Csn( byte[] value )
     {
         csnStr = StringTools.utf8ToString( value );
-        CSN csn = new CSN( csnStr );
+        Csn csn = new Csn( csnStr );
         timestamp = csn.timestamp;
         changeCount = csn.changeCount;
         replicaId = csn.replicaId;
@@ -538,12 +597,12 @@
             return true;
         }
 
-        if ( !( o instanceof CSN ) )
+        if ( !( o instanceof Csn ) )
         {
             return false;
         }
 
-        CSN that = ( CSN ) o;
+        Csn that = ( Csn ) o;
 
         return 
             ( timestamp == that.timestamp ) &&
@@ -562,7 +621,7 @@
      * @return  a negative integer, zero, or a positive integer as this object
      *      is less than, equal to, or greater than the specified object.
      */
-    public int compareTo( CSN csn )
+    public int compareTo( Csn csn )
     {
         if ( csn == null )
         {

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java
(from r780307, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSNFactory.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSNFactory.java&r1=780307&r2=781049&rev=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSNFactory.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CsnFactory.java
Tue Jun  2 14:54:56 2009
@@ -21,11 +21,11 @@
 
 
 /**
- * Generates a new {@link CSN}.
+ * Generates a new {@link Csn}.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CSNFactory
+public class CsnFactory
 {
     /** The last timestamp */
     private static volatile long lastTimestamp;
@@ -34,21 +34,21 @@
     private static volatile int changeCount;
 
 
-    public CSNFactory()
+    public CsnFactory()
     {
         changeCount = 0;
     }
 
 
     /**
-     * Returns a new {@link CSN}.
+     * Returns a new {@link Csn}.
      * Generated CSN can be duplicate if user generates CSNs more than 2G 
      * times a milliseconds.
      * 
      * @param replicaId Replica ID.  ReplicaID must be 1-3 digit alphanumeric
      *        value (from 000 to fff).
      */
-    public CSN newInstance( int replicaId )
+    public Csn newInstance( int replicaId )
     {
         long newTimestamp = System.currentTimeMillis();
         
@@ -63,12 +63,12 @@
             changeCount = 0;
         }
 
-        return new CSN( lastTimestamp, changeCount, replicaId, 0 );
+        return new Csn( lastTimestamp, changeCount, replicaId, 0 );
     }
 
 
     /**
-     * Returns a new {@link CSN} created from the given values.
+     * Returns a new {@link Csn} created from the given values.
      * 
      * This method is <b>not</b> to be used except for test purposes.
      * 
@@ -76,9 +76,9 @@
      * @param replicaId Replica ID.  ReplicaID must be 1-3 digit value
      * @param changeCount The change count to use
      */
-    public CSN newInstance( long timestamp, int replicaId, int changeCount )
+    public Csn newInstance( long timestamp, int replicaId, int changeCount )
     {
-        return new CSN( timestamp, changeCount, replicaId, 0 );
+        return new Csn( timestamp, changeCount, replicaId, 0 );
     }
     
     
@@ -88,8 +88,8 @@
      * 
      * @param expirationDate The time up to the first CSN we want to keep 
      */
-    public CSN newInstance( long expirationDate )
+    public Csn newInstance( long expirationDate )
     {
-        return new CSN( expirationDate, Integer.MAX_VALUE, -1, Integer.MAX_VALUE );
+        return new Csn( expirationDate, Integer.MAX_VALUE, -1, Integer.MAX_VALUE );
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/InvalidCSNException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/InvalidCSNException.java?rev=781049&r1=781048&r2=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/InvalidCSNException.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/InvalidCSNException.java
Tue Jun  2 14:54:56 2009
@@ -22,7 +22,7 @@
 
 /**
  * A {@link RuntimeException} which is thrown when a wrong string
- * representation is specified to create a new {@link CSN}.
+ * representation is specified to create a new {@link Csn}.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java
(from r780307, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparator.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparator.java&r1=780307&r2=781049&rev=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java
Tue Jun  2 14:54:56 2009
@@ -22,7 +22,7 @@
 
 import java.util.Comparator;
 
-import org.apache.directory.shared.ldap.csn.CSN;
+import org.apache.directory.shared.ldap.csn.Csn;
 
 
 /**
@@ -37,31 +37,34 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class CSNComparator implements Comparator<CSN>
+public class CsnComparator implements Comparator<String>
 {
     /** A static instance of this comparator */
-    public static final Comparator<CSN> INSTANCE = new CSNComparator();
+    public static final Comparator<String> INSTANCE = new CsnComparator();
     
     
     /**
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
-    public int compare( CSN csn1, CSN csn2 )
+    public int compare( String csnStr1, String csnStr2 )
     {
         // -------------------------------------------------------------------
         // Handle some basis cases
         // -------------------------------------------------------------------
 
-        if ( csn1 == null )
+        if ( csnStr1 == null )
         {
-            return ( csn2 == null ) ? 0 : -1;
+            return ( csnStr2 == null ) ? 0 : -1;
         }
         
-        if ( csn2 == null )
+        if ( csnStr2 == null )
         {
             return 1;
         }
         
+        Csn csn1 = new Csn( csnStr1 );
+        Csn csn2 = new Csn( csnStr2 );
+        
         if ( csn1.getTimestamp() != csn2.getTimestamp() )
         {
             return ( csn1.getTimestamp() < csn2.getTimestamp() ? -1 : 1 );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparator.java?rev=781049&r1=781048&r2=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparator.java
Tue Jun  2 14:54:56 2009
@@ -22,64 +22,68 @@
 
 import java.util.Comparator;
 
-import org.apache.directory.shared.ldap.csn.CSN;
-
 
 /**
  * A comparator for CSN SID.
  *
- * The CSN are ordered depending on an evaluation of its component, in this order :
- * - time, 
- * - changeCount,
- * - sid
- * - modifierNumber
+ * The SID is supposed to be an hexadecimal number between 0x0 and 0xfff
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class CsnSidComparator implements Comparator<CSN>
+public class CsnSidComparator implements Comparator<String>
 {
     /** A static instance of this comparator */
-    public static final Comparator<CSN> INSTANCE = new CsnSidComparator();
+    public static final Comparator<String> INSTANCE = new CsnSidComparator();
     
     
     /**
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
-    public int compare( CSN csn1, CSN csn2 )
+    public int compare( String sidStr1, String sidStr2 )
     {
         // -------------------------------------------------------------------
         // Handle some basis cases
         // -------------------------------------------------------------------
 
-        if ( csn1 == null )
+        if ( sidStr1 == null )
         {
-            return ( csn2 == null ) ? 0 : -1;
+            return ( sidStr2 == null ) ? 0 : -1;
         }
         
-        if ( csn2 == null )
+        if ( sidStr2 == null )
         {
             return 1;
         }
         
-        if ( csn1.getTimestamp() != csn2.getTimestamp() )
+        int sid1 = 0;
+        int sid2 = 0;
+        
+        try
         {
-            return ( csn1.getTimestamp() < csn2.getTimestamp() ? -1 : 1 );
+            sid1 = Integer.parseInt( sidStr1, 16 );
         }
-        
-        if ( csn1.getChangeCount() != csn2.getChangeCount() )
+        catch ( NumberFormatException nfe )
         {
-            return ( csn1.getChangeCount() < csn2.getChangeCount() ? -1 : 1 );
+            return -1;
         }
         
-        if ( csn1.getReplicaId() != csn2.getReplicaId() )
+        try
         {
-            return ( csn1.getReplicaId() < csn2.getReplicaId() ? -1 : 1 );
+            sid2 = Integer.parseInt( sidStr2, 16 );
+        }
+        catch ( NumberFormatException nfe )
+        {
+            return 1;
         }
         
-        if ( csn1.getOperationNumber() != csn2.getOperationNumber() )
+        if ( sid1 > sid2 )
+        {
+            return 1;
+        }
+        else if ( sid2 > sid1 )
         {
-            return ( csn1.getOperationNumber() < csn2.getOperationNumber() ? -1 : 1 );
+            return -1;
         }
         
         return 0;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UUIDComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UUIDComparator.java?rev=781049&r1=781048&r2=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UUIDComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/UUIDComparator.java
Tue Jun  2 14:54:56 2009
@@ -21,7 +21,6 @@
 
 
 import java.util.Comparator;
-import java.util.UUID;
 
 
 /**
@@ -30,16 +29,16 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class UUIDComparator implements Comparator<UUID>
+public class UUIDComparator implements Comparator<byte[]>
 {
     /** A static instance of this comparator */
-    public static final Comparator<UUID> INSTANCE = new UUIDComparator();
+    public static final Comparator<byte[]> INSTANCE = new UUIDComparator();
     
     
     /**
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
-    public int compare( UUID uuid1, UUID uuid2 )
+    public int compare( byte[] uuid1, byte[] uuid2 )
     {
         // -------------------------------------------------------------------
         // Handle some basis cases
@@ -54,6 +53,32 @@
             return 1;
         }
         
-        return uuid1.compareTo( uuid2 );
+        if ( uuid1.length < uuid2.length )
+        {
+            return -1;
+        }
+        else if ( uuid1.length > uuid2.length )
+        { 
+            return 1;
+        }
+        
+        for ( int pos = 0; pos < uuid1.length; pos++ )
+        {
+            if ( uuid1[pos] == uuid2[pos ] )
+            {
+                continue;
+            }
+            
+            if ( uuid1[pos] < uuid2[pos] )
+            {
+                return -1;
+            }
+            else
+            {
+                return 1;
+            }
+        }
+        
+        return 0;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSidSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSidSyntaxChecker.java?rev=781049&r1=781048&r2=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSidSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSidSyntaxChecker.java
Tue Jun  2 14:54:56 2009
@@ -77,8 +77,30 @@
         {
             return false;
         }
+        
+        String sidStr = (String)value;
+        
+        if ( sidStr.length() > 3 )
+        {
+            return false;
+        }
 
-        // TODO : add the check
-        return false;
+        // The SID must be an hexadecimal number between 0x00 and 0xFFF
+        
+        try
+        {
+            int sid = Integer.parseInt( sidStr, 16 );
+            
+            if ( ( sid < 0 ) || ( sid > 0x0fff ) )
+            {
+                return false;
+            }
+        }
+        catch ( NumberFormatException nfe )
+        {
+            return false;
+        }
+        
+        return true;
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSyntaxChecker.java?rev=781049&r1=781048&r2=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSyntaxChecker.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxes/CsnSyntaxChecker.java
Tue Jun  2 14:54:56 2009
@@ -20,7 +20,7 @@
 package org.apache.directory.shared.ldap.schema.syntaxes;
 
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.csn.CSN;
+import org.apache.directory.shared.ldap.csn.Csn;
 import org.apache.directory.shared.ldap.csn.InvalidCSNException;
 import org.apache.directory.shared.ldap.schema.AbstractSyntaxChecker;
 import org.apache.directory.shared.ldap.schema.SyntaxChecker;
@@ -85,7 +85,7 @@
         // It must be a valid CSN : try to create a new one.
         try
         {
-            return CSN.isValid( csnStr );
+            return Csn.isValid( csnStr );
         }
         catch ( InvalidCSNException icsne )
         {

Copied: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnFactoryTest.java
(from r780307, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNFactoryTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnFactoryTest.java?p2=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnFactoryTest.java&p1=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNFactoryTest.java&r1=780307&r2=781049&rev=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNFactoryTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnFactoryTest.java
Tue Jun  2 14:54:56 2009
@@ -31,7 +31,7 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CSNFactoryTest
+public class CsnFactoryTest
 {
     private static final int NUM_GENERATES = 10;
 
@@ -44,9 +44,9 @@
     public void testUnique()
     {
         int replicaID = 001;
-        CSNFactory defaultCSNFactory = new CSNFactory();
+        CsnFactory defaultCSNFactory = new CsnFactory();
 
-        CSN[] csns = new CSN[NUM_GENERATES];
+        Csn[] csns = new Csn[NUM_GENERATES];
 
         for ( int i = 0; i < NUM_GENERATES; i++ )
         {

Copied: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnTest.java
(from r780307, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnTest.java?p2=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnTest.java&p1=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java&r1=780307&r2=781049&rev=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CsnTest.java
Tue Jun  2 14:54:56 2009
@@ -37,7 +37,7 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CSNTest
+public class CsnTest
 {
     private SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmss.123456'Z'" );
 
@@ -46,7 +46,7 @@
     {
         long ts = System.currentTimeMillis();
 
-        CSN csn = new CSN( sdf.format( new Date( ts ) ) + "#123456#abc#654321" );
+        Csn csn = new Csn( sdf.format( new Date( ts ) ) + "#123456#abc#654321" );
 
         assertEquals( ts/1000, csn.getTimestamp()/1000 );
         
@@ -62,7 +62,7 @@
     {
         try
         {
-            new CSN( (String)null );
+            new Csn( (String)null );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -77,7 +77,7 @@
     {
         try
         {
-            new CSN( "" );
+            new Csn( "" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -92,7 +92,7 @@
     {
         try
         {
-            new CSN( sdf.format( new Date( System.currentTimeMillis() ) ) );
+            new Csn( sdf.format( new Date( System.currentTimeMillis() ) ) );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -108,7 +108,7 @@
         try
         {
             // A missing 'Z'
-            new CSN( "20010101000000.000000#000001#abc#000001" );
+            new Csn( "20010101000000.000000#000001#abc#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -119,7 +119,7 @@
         try
         {
             // Missing milliseconds
-            new CSN( "20000101000000.Z#000001#abc#000001" );
+            new Csn( "20000101000000.Z#000001#abc#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -130,7 +130,7 @@
         try
         {
             // Missing dot
-            new CSN( "20010101000000000000Z#0x1#abc#0x1" );
+            new Csn( "20010101000000000000Z#0x1#abc#0x1" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -141,7 +141,7 @@
         try
         {
             // Missing dot and millis
-            new CSN( "20010101000000Z#000001#abc#000001" );
+            new Csn( "20010101000000Z#000001#abc#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -152,7 +152,7 @@
         try
         {
             // Invalid date
-            new CSN( "200A01010000Z#000001#abc#000001" );
+            new Csn( "200A01010000Z#000001#abc#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -167,7 +167,7 @@
     {
         try
         {
-            new CSN( "#000001#abc#000001" );
+            new Csn( "#000001#abc#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -182,7 +182,7 @@
     {
         try
         {
-            new CSN( "20010101000000.000000Z##abc#000001" );
+            new Csn( "20010101000000.000000Z##abc#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -197,7 +197,7 @@
     {
         try
         {
-            new CSN( "20010101000000.000000Z#00#abc#000001" );
+            new Csn( "20010101000000.000000Z#00#abc#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -207,7 +207,7 @@
 
         try
         {
-            new CSN( "20010101000000.000000Z#00000G#abc#000001" );
+            new Csn( "20010101000000.000000Z#00000G#abc#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -222,7 +222,7 @@
     {
         try
         {
-            new CSN( "20010101000000.000000Z#000001##000001" );
+            new Csn( "20010101000000.000000Z#000001##000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -237,7 +237,7 @@
     {
         try
         {
-            new CSN( "20010101000000.000000Z#000001#a12-b3é#000001" );
+            new Csn( "20010101000000.000000Z#000001#a12-b3é#000001" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -252,7 +252,7 @@
     {
         try
         {
-            new CSN( "20010101000000.000000Z#000000#abc" );
+            new Csn( "20010101000000.000000Z#000000#abc" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -262,7 +262,7 @@
         
         try
         {
-            new CSN( "20010101000000.000000Z#000000#abc#  " );
+            new Csn( "20010101000000.000000Z#000000#abc#  " );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -277,7 +277,7 @@
     {
         try
         {
-            new CSN( "20010101000000.000000Z#000000#abc#000zzz" );
+            new Csn( "20010101000000.000000Z#000000#abc#000zzz" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -287,7 +287,7 @@
 
         try
         {
-            new CSN( "20010101000000.000000Z#000000#abc#00000" );
+            new Csn( "20010101000000.000000Z#000000#abc#00000" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -297,7 +297,7 @@
 
         try
         {
-            new CSN( "20010101000000.000000Z#000000#abc#" );
+            new Csn( "20010101000000.000000Z#000000#abc#" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -307,7 +307,7 @@
 
         try
         {
-            new CSN( "20010101000000.000000Z#000000#abc#00000G" );
+            new Csn( "20010101000000.000000Z#000000#abc#00000G" );
             fail();
         }
         catch ( InvalidCSNException ice )
@@ -320,7 +320,7 @@
     @Test
     public void testCSNToBytes()
     {
-        CSN csn = new CSN( "20010101000000.000000Z#000000#abc#000001" );
+        Csn csn = new Csn( "20010101000000.000000Z#000000#abc#000001" );
 
         byte[] bytes = csn.getBytes();
 
@@ -335,7 +335,7 @@
         
         assertTrue( Arrays.equals( expected, bytes ) );
 
-        CSN deserializedCSN = new CSN( bytes );
+        Csn deserializedCSN = new Csn( bytes );
         assertEquals( csn, deserializedCSN );
     }
 }

Copied: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparatorTest.java
(from r780307, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparatorTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparatorTest.java?p2=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparatorTest.java&p1=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparatorTest.java&r1=780307&r2=781049&rev=781049&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CSNComparatorTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparatorTest.java
Tue Jun  2 14:54:56 2009
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.shared.ldap.schema.comparators;
 
-import org.apache.directory.shared.ldap.csn.CSN;
+import org.apache.directory.shared.ldap.csn.Csn;
 import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
@@ -31,30 +31,26 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class CSNComparatorTest
+public class CsnComparatorTest
 {
-    private CSNComparator comparator;
+    private CsnComparator comparator;
     
     @Before
     public void init()
     {
-        comparator = new CSNComparator();
+        comparator = new CsnComparator();
     }
     
     
     @Test
     public void testNullCSNs()
     {
-        CSN csn1 = null;
-        CSN csn2 = null;
+        assertEquals( 0, comparator.compare( null, null ) );
         
-        assertEquals( 0, comparator.compare( csn1, csn2 ) );
-        
-        csn2 = new CSN( System.currentTimeMillis(), 1, 1, 1 );
-        assertEquals( -1, comparator.compare( csn1, csn2 ) );
+        Csn csn2 = new Csn( System.currentTimeMillis(), 1, 1, 1 );
+        assertEquals( -1, comparator.compare( null, csn2.toString() ) );
 
-        CSN csn3 = null;
-        assertEquals( 1, comparator.compare( csn2, csn3 ) );
+        assertEquals( 1, comparator.compare( csn2.toString(), null ) );
     }
 
 
@@ -62,10 +58,10 @@
     public void testEqualsCSNs()
     {
         long t0 = System.currentTimeMillis();
-        CSN csn1 = new CSN( t0, 0, 0, 0 );
-        CSN csn2 = new CSN( t0, 0, 0, 0 );
+        Csn csn1 = new Csn( t0, 0, 0, 0 );
+        Csn csn2 = new Csn( t0, 0, 0, 0 );
         
-        assertEquals( 0, comparator.compare( csn1, csn2 ) );
+        assertEquals( 0, comparator.compare( csn1.toString(), csn2.toString() ) );
     }
     
     
@@ -74,11 +70,11 @@
     {
         long t0 = System.currentTimeMillis();
         long t1 = System.currentTimeMillis() + 1000;
-        CSN csn1 = new CSN( t0, 0, 0, 0 );
-        CSN csn2 = new CSN( t1, 0, 0, 0 );
+        Csn csn1 = new Csn( t0, 0, 0, 0 );
+        Csn csn2 = new Csn( t1, 0, 0, 0 );
         
-        assertEquals( -1, comparator.compare( csn1, csn2 ) );
-        assertEquals( 1, comparator.compare( csn2, csn1 ) );
+        assertEquals( -1, comparator.compare( csn1.toString(), csn2.toString() ) );
+        assertEquals( 1, comparator.compare( csn2.toString(), csn1.toString() ) );
     }
     
     
@@ -86,11 +82,11 @@
     public void testDifferentChangeCountCSNs()
     {
         long t0 = System.currentTimeMillis();
-        CSN csn1 = new CSN( t0, 0, 0, 0 );
-        CSN csn2 = new CSN( t0, 1, 0, 0 );
+        Csn csn1 = new Csn( t0, 0, 0, 0 );
+        Csn csn2 = new Csn( t0, 1, 0, 0 );
         
-        assertEquals( -1, comparator.compare( csn1, csn2 ) );
-        assertEquals( 1, comparator.compare( csn2, csn1 ) );
+        assertEquals( -1, comparator.compare( csn1.toString(), csn2.toString() ) );
+        assertEquals( 1, comparator.compare( csn2.toString(), csn1.toString() ) );
     }
     
     
@@ -98,11 +94,11 @@
     public void testDifferentReplicaIdCSNs()
     {
         long t0 = System.currentTimeMillis();
-        CSN csn1 = new CSN( t0, 0, 0, 0 );
-        CSN csn2 = new CSN( t0, 0, 1, 0 );
+        Csn csn1 = new Csn( t0, 0, 0, 0 );
+        Csn csn2 = new Csn( t0, 0, 1, 0 );
         
-        assertEquals( -1, comparator.compare( csn1, csn2 ) );
-        assertEquals( 1, comparator.compare( csn2, csn1 ) );
+        assertEquals( -1, comparator.compare( csn1.toString(), csn2.toString() ) );
+        assertEquals( 1, comparator.compare( csn2.toString(), csn1.toString() ) );
     }
     
     
@@ -110,10 +106,10 @@
     public void testDifferentOperationNumberCSNs()
     {
         long t0 = System.currentTimeMillis();
-        CSN csn1 = new CSN( t0, 0, 0, 0 );
-        CSN csn2 = new CSN( t0, 0, 0, 1 );
+        Csn csn1 = new Csn( t0, 0, 0, 0 );
+        Csn csn2 = new Csn( t0, 0, 0, 1 );
         
-        assertEquals( -1, comparator.compare( csn1, csn2 ) );
-        assertEquals( 1, comparator.compare( csn2, csn1 ) );
+        assertEquals( -1, comparator.compare( csn1.toString(), csn2.toString() ) );
+        assertEquals( 1, comparator.compare( csn2.toString(), csn1.toString() ) );
     }
 }

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparatorTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparatorTest.java?rev=781049&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparatorTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/comparators/CsnSidComparatorTest.java
Tue Jun  2 14:54:56 2009
@@ -0,0 +1,72 @@
+/*
+ *  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.directory.shared.ldap.schema.comparators;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * Test the CSN comparator
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class CsnSidComparatorTest
+{
+    private CsnSidComparator comparator;
+    
+    @Before
+    public void init()
+    {
+        comparator = new CsnSidComparator();
+    }
+    
+    
+    @Test
+    public void testNullSids()
+    {
+        assertEquals( 0, comparator.compare( null, null ) );
+        
+        assertEquals( -1, comparator.compare( null, "000" ) );
+
+        assertEquals( 1, comparator.compare( "000", null ) );
+    }
+
+
+    @Test
+    public void testEqualsSids()
+    {
+        assertEquals( 0, comparator.compare( "000", "000" ) );
+        assertEquals( 0, comparator.compare( "000", "0" ) );
+        assertEquals( 0, comparator.compare( "fff", "fff" ) );
+    }
+    
+    
+    
+    @Test
+    public void testDifferentSids()
+    {
+        assertEquals( -1, comparator.compare( "123", "456" ) );
+        assertEquals( 1, comparator.compare( "FFF", "000" ) );
+        assertEquals( 1, comparator.compare( "FFF", "GGG" ) );
+    }
+}

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSidSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSidSyntaxCheckerTest.java?rev=781049&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSidSyntaxCheckerTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSidSyntaxCheckerTest.java
Tue Jun  2 14:54:56 2009
@@ -0,0 +1,72 @@
+/*
+ *  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.directory.shared.ldap.schema.syntax;
+
+import org.apache.directory.shared.ldap.schema.syntaxes.CsnSidSyntaxChecker;
+
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test cases for CsnSidSyntaxChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class CsnSidSyntaxCheckerTest
+{
+    CsnSidSyntaxChecker checker = new CsnSidSyntaxChecker();
+
+
+    @Test
+    public void testNullCsnSid()
+    {
+        assertFalse( checker.isValidSyntax( null ) );
+    }
+
+
+    @Test
+    public void testEmptyCsnSid()
+    {
+        assertFalse( checker.isValidSyntax( "" ) );
+    }
+
+
+    @Test
+    public void testValidCsnSid()
+    {
+        assertTrue( checker.isValidSyntax( "000" ) );
+        assertTrue( checker.isValidSyntax( "0" ) );
+        assertTrue( checker.isValidSyntax( "123" ) );
+        assertTrue( checker.isValidSyntax( "fff" ) );
+        assertTrue( checker.isValidSyntax( "FFF" ) );
+    }
+
+
+    @Test
+    public void testInvalidCsnSid()
+    {
+        assertFalse( checker.isValidSyntax( "Ggg" ) );
+        assertFalse( checker.isValidSyntax( "0-0" ) );
+        assertFalse( checker.isValidSyntax( "-1" ) );
+        assertFalse( checker.isValidSyntax( "0000" ) );
+    }
+}

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSyntaxCheckerTest.java?rev=781049&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSyntaxCheckerTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/CsnSyntaxCheckerTest.java
Tue Jun  2 14:54:56 2009
@@ -0,0 +1,81 @@
+/*
+ *  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.directory.shared.ldap.schema.syntax;
+
+import org.apache.directory.shared.ldap.schema.syntaxes.CsnSyntaxChecker;
+
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test cases for CsnSyntaxChecker.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class CsnSyntaxCheckerTest
+{
+    CsnSyntaxChecker checker = new CsnSyntaxChecker();
+
+
+    @Test
+    public void testNullCsn()
+    {
+        assertFalse( checker.isValidSyntax( null ) );
+    }
+
+
+    @Test
+    public void testEmptyCsn()
+    {
+        assertFalse( checker.isValidSyntax( "" ) );
+    }
+    
+    
+    /**
+     * Test that a replicaId not being an integer between 000 and fff
+     * is seen as invalid
+     */
+    @Test
+    public void testBadReplicaId()
+    {
+        assertFalse( checker.isValidSyntax( "20090602120000.100000Z#000000##000000" ) );
+        assertFalse( checker.isValidSyntax( "20090602120000.100000Z#000000#00P#000000" )
);
+        assertFalse( checker.isValidSyntax( "20090602120000.100000Z#000000#-1#000000" ) );
+        assertFalse( checker.isValidSyntax( "20090602120000.100000Z#000000#-01#000000" )
);
+        assertFalse( checker.isValidSyntax( "20090602120000.100000Z#000000#0#000000" ) );
+        assertFalse( checker.isValidSyntax( "20090602120000.100000Z#000000#0 0#000000" )
);
+        assertFalse( checker.isValidSyntax( "20090602120000.100000Z#000000#   #000000" )
);
+    }
+    
+    
+    /**
+     * Test that a replicaId is a valid number between 000 and fff
+     */
+    @Test
+    public void testValidReplicaId()
+    {
+        assertTrue( checker.isValidSyntax( "20090602120000.100000Z#000000#000#000000" ) );
+        assertTrue( checker.isValidSyntax( "20090602120000.100000Z#000000#00f#000000" ) );
+        assertTrue( checker.isValidSyntax( "20090602120000.100000Z#000000#fff#000000" ) );
+        assertTrue( checker.isValidSyntax( "20090602120000.100000Z#000000#123#000000" ) );
+    }
+}



Mime
View raw message