directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r414015 [5/5] - in /directory/trunks/shared: ./ asn1/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/ asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/ ldap/ ldap/src/main/antlr/ ldap/src/main/java/org/apache/directo...
Date Wed, 14 Jun 2006 01:15:18 GMT
Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java?rev=414015&r1=414014&r2=414015&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
(original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
Tue Jun 13 18:15:12 2006
@@ -27,9 +27,7 @@
 import org.apache.directory.shared.ldap.filter.AbstractExprNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
-import org.apache.directory.shared.ldap.name.LdapName;
-import org.apache.directory.shared.ldap.name.SimpleNameComponentNormalizer;
-import org.apache.directory.shared.ldap.schema.DeepTrimNormalizer;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
 import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationParser;
 
@@ -88,10 +86,7 @@
 
     /** An invalid specification with completely unrelated content */
     private static final String INVALID_SILLY_THING = "How much wood would a wood chuck chuck
if a wood chuck would chuck wood?";
-
-    /** A valid specification only with base set and normalizing to be applied */
-    private static final String SPEC_WITH_BASE_NORMALIZING = "{ base \"ou=system   \" }";
-
+    
     /** the ss parser wrapper */
     SubtreeSpecificationParser parser;
 
@@ -176,22 +171,22 @@
         SubtreeSpecification ss = parser.parse( SPEC_WITH_SPECIFICEXCLUSIONS );
         assertFalse( ss.getChopBeforeExclusions().isEmpty() );
         assertFalse( ss.getChopAfterExclusions().isEmpty() );
-        assertTrue( ss.getChopBeforeExclusions().contains( new LdapName( "ab=cd" ) ) );
-        assertTrue( ss.getChopAfterExclusions().contains( new LdapName( "ef=gh" ) ) );
+        assertTrue( ss.getChopBeforeExclusions().contains( new LdapDN( "ab=cd" ) ) );
+        assertTrue( ss.getChopAfterExclusions().contains( new LdapDN( "ef=gh" ) ) );
 
         // try a second time
         ss = parser.parse( SPEC_WITH_SPECIFICEXCLUSIONS );
         assertFalse( ss.getChopBeforeExclusions().isEmpty() );
         assertFalse( ss.getChopAfterExclusions().isEmpty() );
-        assertTrue( ss.getChopBeforeExclusions().contains( new LdapName( "ab=cd" ) ) );
-        assertTrue( ss.getChopAfterExclusions().contains( new LdapName( "ef=gh" ) ) );
+        assertTrue( ss.getChopBeforeExclusions().contains( new LdapDN( "ab=cd" ) ) );
+        assertTrue( ss.getChopAfterExclusions().contains( new LdapDN( "ef=gh" ) ) );
 
         // try a third time
         ss = parser.parse( SPEC_WITH_SPECIFICEXCLUSIONS );
         assertFalse( ss.getChopBeforeExclusions().isEmpty() );
         assertFalse( ss.getChopAfterExclusions().isEmpty() );
-        assertTrue( ss.getChopBeforeExclusions().contains( new LdapName( "ab=cd" ) ) );
-        assertTrue( ss.getChopAfterExclusions().contains( new LdapName( "ef=gh" ) ) );
+        assertTrue( ss.getChopBeforeExclusions().contains( new LdapDN( "ab=cd" ) ) );
+        assertTrue( ss.getChopAfterExclusions().contains( new LdapDN( "ef=gh" ) ) );
     }
 
 
@@ -237,7 +232,7 @@
     {
         SubtreeSpecification ss = parser.parse( SPEC_WITH_BASE_AND_MINIMUM_AND_MAXIMUM );
 
-        assertEquals( new LdapName( "ou=ORGANIZATION UNIT" ), ss.getBase() );
+        assertEquals( new LdapDN( "ou=ORGANIZATION UNIT" ), ss.getBase() );
         assertEquals( 1, ss.getMinBaseDistance() );
         assertEquals( 2, ss.getMaxBaseDistance() );
     }
@@ -253,10 +248,10 @@
         assertNotNull( ss );
 
         assertEquals( "ou=people", ss.getBase().toString() );
-        assertTrue( ss.getChopBeforeExclusions().contains( new LdapName( "x=y" ) ) );
-        assertTrue( ss.getChopBeforeExclusions().contains( new LdapName( "y=z" ) ) );
-        assertTrue( ss.getChopAfterExclusions().contains( new LdapName( "k=l" ) ) );
-        assertTrue( ss.getChopAfterExclusions().contains( new LdapName( "l=m" ) ) );
+        assertTrue( ss.getChopBeforeExclusions().contains( new LdapDN( "x=y" ) ) );
+        assertTrue( ss.getChopBeforeExclusions().contains( new LdapDN( "y=z" ) ) );
+        assertTrue( ss.getChopAfterExclusions().contains( new LdapDN( "k=l" ) ) );
+        assertTrue( ss.getChopAfterExclusions().contains( new LdapDN( "l=m" ) ) );
         assertEquals( 7, ss.getMinBaseDistance() );
         assertEquals( 77, ss.getMaxBaseDistance() );
     }
@@ -336,23 +331,6 @@
         {
             assertNotNull( e );
         }
-    }
-
-
-    /**
-     * Tests the parser with a valid specification with base set and normalizing
-     * active.
-     */
-    public void testSpecWithBaseNormalizing() throws Exception
-    {
-        // create a new normalizing parser for this test case
-        SubtreeSpecificationParser parser = new SubtreeSpecificationParser( new SimpleNameComponentNormalizer(
-            new DeepTrimNormalizer() ) );
-        SubtreeSpecification ss = parser.parse( SPEC_WITH_BASE_NORMALIZING );
-        assertNotNull( ss );
-
-        // looking for "ou=system" and not "ou=system " due to normalizing
-        assertEquals( "ou=system", ss.getBase().toString() );
     }
 
 

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java?rev=414015&r1=414014&r2=414015&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java
(original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/util/NamespaceToolsTest.java
Tue Jun 13 18:15:12 2006
@@ -20,8 +20,10 @@
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
+import javax.naming.Name;
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 
@@ -91,5 +93,20 @@
         args = NamespaceTools.getCompositeComponents( "cn=Alex" );
         assertEquals( "expecting one part : ", 1, args.length );
         assertEquals( "cn=Alex", args[0] );
+    }
+    
+    
+    public void testGetRelativeName() throws NamingException
+    {
+        // test the basis case first with the root
+        LdapDN ancestor = new LdapDN( "" );
+        LdapDN descendant = new LdapDN( "ou=system" );
+        Name relativeName = NamespaceTools.getRelativeName( ancestor, descendant );
+        assertEquals( relativeName.toString(), "ou=system" );
+        
+        ancestor = new LdapDN( "ou=system" );
+        descendant = new LdapDN( "ou=users,ou=system" );
+        relativeName = NamespaceTools.getRelativeName( ancestor, descendant );
+        assertEquals( relativeName.toString(), "ou=users" );
     }
 }



Mime
View raw message