directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r412954 - in /directory/branches/apacheds/optimization: core-unit/src/test/java/org/apache/directory/server/core/jndi/ core-unit/src/test/java/org/apache/directory/server/core/prefs/ core/src/main/java/org/apache/directory/server/core/excep...
Date Fri, 09 Jun 2006 06:51:36 GMT
Author: akarasulu
Date: Thu Jun  8 23:51:35 2006
New Revision: 412954

URL: http://svn.apache.org/viewvc?rev=412954&view=rev
Log:
fixed non-normalized return of resolved name and fixed tests that were using bogus attributes

Modified:
    directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/jndi/ExtensibleObjectTest.java
    directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesTest.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java

Modified: directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/jndi/ExtensibleObjectTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/jndi/ExtensibleObjectTest.java?rev=412954&r1=412953&r2=412954&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/jndi/ExtensibleObjectTest.java
(original)
+++ directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/jndi/ExtensibleObjectTest.java
Thu Jun  8 23:51:35 2006
@@ -53,7 +53,7 @@
         assertTrue( attribute.contains( "organizationalUnit" ) );
 
         Attributes newattribs = new BasicAttributes( true );
-        Attribute freeform = new BasicAttribute( "freeform" );
+        Attribute freeform = new BasicAttribute( "cn" );
         freeform.add( "testing" );
         newattribs.put( freeform );
         Attribute objectClass = new BasicAttribute( "objectClass" );
@@ -71,7 +71,7 @@
         assertTrue( attribute.contains( "top" ) );
         assertTrue( attribute.contains( "organizationalUnit" ) );
         assertTrue( attribute.contains( "extensibleObject" ) );
-        attribute = attributes.get( "freeform" );
+        attribute = attributes.get( "cn" );
         assertTrue( attribute.contains( "testing" ) );
     }
 

Modified: directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesTest.java?rev=412954&r1=412953&r2=412954&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesTest.java
(original)
+++ directory/branches/apacheds/optimization/core-unit/src/test/java/org/apache/directory/server/core/prefs/ServerSystemPreferencesTest.java
Thu Jun  8 23:51:35 2006
@@ -60,7 +60,7 @@
     {
         Preferences testNode = prefs.node( "testNode" );
 
-        testNode.put( "testNodeKey", "testNodeValue" );
+        testNode.put( "cn", "testNodeValue" );
         testNode.sync();
     }
 
@@ -70,28 +70,27 @@
      *
      * @throws BackingStoreException if there are failures with the store
      */
-    public void testCreateAndSet() throws BackingStoreException
+    public void testCreateAndSetBoolean() throws BackingStoreException
     {
         Preferences testNode = prefs.node( "testNode" );
-
-        testNode.put( "testNodeKey", "testNodeValue" );
+        testNode.putBoolean( "cn", false );
         testNode.sync();
+        testNode = prefs.node( "testNode" );
+        assertEquals( false, testNode.getBoolean( "cn", false ) );
+    }
 
-        testNode.putBoolean( "boolKey", true );
-        testNode.putByteArray( "arrayKey", new byte[10] );
-        testNode.putDouble( "doubleKey", 3.14 );
-        testNode.putFloat( "floatKey", ( float ) 3.14 );
-        testNode.putInt( "intKey", 345 );
-        testNode.putLong( "longKey", 75449559185447L );
-        testNode.sync();
 
+    /**
+     * Tests the creation and use of a new preferences node.
+     *
+     * @throws BackingStoreException if there are failures with the store
+     */
+    public void testCreateAndSetByteArray() throws BackingStoreException
+    {
+        Preferences testNode = prefs.node( "testNode" );
+        testNode.put( "jpegPhoto", "testNodeValue" );
+        testNode.sync();
         testNode = prefs.node( "testNode" );
-
-        assertEquals( true, testNode.getBoolean( "boolKey", false ) );
-        assertTrue( 3.14 == testNode.getDouble( "doubleKey", 9.20 ) );
-        assertTrue( ( float ) 3.14 == testNode.getFloat( "floatKey", ( float ) 3.90 ) );
-        assertEquals( 345, testNode.getInt( "intKey", 87 ) );
-        assertEquals( 75449559185447L, testNode.getLong( "longKey", 75449547L ) );
     }
 
 
@@ -100,38 +99,81 @@
      *
      * @throws BackingStoreException if there are failures with the store
      */
-    public void testCreateAndRemove() throws BackingStoreException
+    public void testCreateAndSetDouble() throws BackingStoreException
     {
         Preferences testNode = prefs.node( "testNode" );
+        testNode.putDouble( "cn", 3.14 );
+        testNode.sync();
+        testNode = prefs.node( "testNode" );
+        assertTrue( 3.14 == testNode.getDouble( "cn", 9.20 ) );
+    }
 
-        testNode.put( "testNodeKey", "testNodeValue" );
+
+    /**
+     * Tests the creation and use of a new preferences node.
+     *
+     * @throws BackingStoreException if there are failures with the store
+     */
+    public void testCreateAndSetFloat() throws BackingStoreException
+    {
+        Preferences testNode = prefs.node( "testNode" );
+        testNode.putFloat( "cn", ( float ) 9.20 );
         testNode.sync();
+        testNode = prefs.node( "testNode" );
+        assertTrue( ( float ) 9.20 == ( float ) testNode.getFloat( "cn", ( float ) 9.20 )
);
+    }
+
 
-        testNode.putBoolean( "boolKey", true );
-        testNode.putByteArray( "arrayKey", new byte[10] );
-        testNode.putDouble( "doubleKey", 3.14 );
-        testNode.putFloat( "floatKey", ( float ) 3.14 );
-        testNode.putInt( "intKey", 345 );
-        testNode.putLong( "longKey", 75449559185447L );
+    /**
+     * Tests the creation and use of a new preferences node.
+     *
+     * @throws BackingStoreException if there are failures with the store
+     */
+    public void testCreateAndSetInt() throws BackingStoreException
+    {
+        Preferences testNode = prefs.node( "testNode" );
+        testNode.putInt( "cn", 345 );
         testNode.sync();
+        testNode = prefs.node( "testNode" );
+        assertTrue( 345 == testNode.getInt( "cn", 345 ) );
+    }
+
 
+    /**
+     * Tests the creation and use of a new preferences node.
+     *
+     * @throws BackingStoreException if there are failures with the store
+     */
+    public void testCreateAndSetLong() throws BackingStoreException
+    {
+        Preferences testNode = prefs.node( "testNode" );
+        testNode.putLong( "cn", 75449559185447L );
+        testNode.sync();
         testNode = prefs.node( "testNode" );
+        assertTrue( 75449559185447L == testNode.getLong( "cn", 75449559185447L ) );
+    }
 
-        assertEquals( true, testNode.getBoolean( "boolKey", false ) );
-        assertTrue( 3.14 == testNode.getDouble( "doubleKey", 9.20 ) );
-        assertTrue( ( float ) 3.14 == testNode.getFloat( "floatKey", ( float ) 3.90 ) );
-        assertEquals( 345, testNode.getInt( "intKey", 87 ) );
-        assertEquals( 75449559185447L, testNode.getLong( "longKey", 75449547L ) );
 
-        testNode.remove( "doubleKey" );
-        testNode.remove( "arrayKey" );
+    /**
+     * Tests the creation and use of a new preferences node.
+     *
+     * @throws BackingStoreException if there are failures with the store
+     */
+    public void testCreateAndRemove() throws BackingStoreException
+    {
+        Preferences testNode = prefs.node( "testNode" );
 
-        assertEquals( "no value", testNode.get( "doubleKey", "no value" ) );
-        assertEquals( "no value", testNode.get( "arrayKey", "no value" ) );
+        testNode.put( "cn", "testNodeValue" );
+        testNode.putInt( "roomNumber", 345 );
+        testNode.sync();
 
+        testNode = prefs.node( "testNode" );
+        assertEquals( 345, testNode.getInt( "roomNumber", 87 ) );
+        testNode.remove( "cn" );
+        testNode.remove( "roomNumber" );
         testNode.sync();
 
-        assertEquals( "no value", testNode.get( "doubleKey", "no value" ) );
-        assertEquals( "no value", testNode.get( "arrayKey", "no value" ) );
+        assertEquals( "no value", testNode.get( "cn", "no value" ) );
+        assertEquals( "no value", testNode.get( "roomNumber", "no value" ) );
     }
 }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java?rev=412954&r1=412953&r2=412954&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
Thu Jun  8 23:51:35 2006
@@ -290,9 +290,14 @@
         target.add( rdn );
         if ( nextInterceptor.hasEntry( target ) )
         {
+            // we must calculate the resolved name using the user provided Rdn value
+            String upRdn = new LdapDN( oriChildName.toUpName() ).get( oriChildName.size()
- 1 );
+            LdapDN upTarget = ( LdapDN ) newParentName.clone();
+            upTarget.add( upRdn );
+
             LdapNameAlreadyBoundException e;
-            e = new LdapNameAlreadyBoundException( "target entry " + target + " already exists!"
);
-            e.setResolvedName( target );
+            e = new LdapNameAlreadyBoundException( "target entry " + upTarget.toUpName()
+ " already exists!" );
+            e.setResolvedName( new LdapDN( upTarget.toUpName() ) );
             throw e;
         }
 
@@ -318,11 +323,16 @@
         // check to see if target entry exists
         LdapDN target = ( LdapDN ) newParentName.clone();
         target.add( newRn );
+        target.normalize();
         if ( nextInterceptor.hasEntry( target ) )
         {
+            // we must calculate the resolved name using the user provided Rdn value
+            LdapDN upTarget = ( LdapDN ) newParentName.clone();
+            upTarget.add( newRn );
+
             LdapNameAlreadyBoundException e;
-            e = new LdapNameAlreadyBoundException( "target entry " + target + " already exists!"
);
-            e.setResolvedName( target );
+            e = new LdapNameAlreadyBoundException( "target entry " + upTarget.toUpName()
+ " already exists!" );
+            e.setResolvedName( new LdapDN( upTarget.toUpName() ) );
             throw e;
         }
 
@@ -380,7 +390,7 @@
                 e = new LdapNameNotFoundException( dn.toString() );
             }
 
-            e.setResolvedName( proxy.getMatchedName( dn ) );
+            e.setResolvedName( new LdapDN( proxy.getMatchedName( dn ).toUpName() ) );
             throw e;
         }
     }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=412954&r1=412953&r2=412954&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
Thu Jun  8 23:51:35 2006
@@ -432,8 +432,12 @@
             throw new LdapNoPermissionException( "can't rename the rootDSE" );
         }
 
-        LdapDN oldBase = ( LdapDN ) oldName.getPrefix( 1 );
-        LdapDN newBase = ( LdapDN ) newName.getPrefix( 1 );
+        // calculate parents
+        LdapDN oldBase = ( LdapDN ) oldName.clone();
+        oldBase.remove( oldName.size() - 1 );
+        LdapDN newBase = ( LdapDN ) newName.clone();
+        newBase.remove( newName.size() - 1 );
+        
         String newRdn = newName.get( newName.size() - 1 );
         String oldRdn = oldName.get( oldName.size() - 1 );
         boolean delOldRdn = true;
@@ -464,7 +468,8 @@
         }
         else
         {
-            LdapDN parent = ( LdapDN ) newDn.getPrefix( 1 );
+            LdapDN parent = ( LdapDN ) newDn.clone();
+            parent.remove( newDn.size() - 1 );
             if ( newRdn.equalsIgnoreCase( oldRdn ) )
             {
                 nexusProxy.move( oldDn, parent );



Mime
View raw message