directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r375441 - in /directory/sandbox/akarasulu/rc1refactor: apacheds/core-unit/src/main/java/org/apache/ldap/server/unit/ apacheds/core-unit/src/test/java/org/apache/ldap/server/core/schema/ apacheds/core-unit/src/test/java/org/apache/ldap/serve...
Date Tue, 07 Feb 2006 01:31:12 GMT
Author: akarasulu
Date: Mon Feb  6 17:31:10 2006
New Revision: 375441

URL: http://svn.apache.org/viewcvs?rev=375441&view=rev
Log:
added tests to try to reproduce bug in DIREVE-308 but failed to do so

Added:
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/normalization/
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/normalization/NormalizationServiceTest.java
  (with props)
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/schema/
      - copied from r375361, directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/core/schema/
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/normalization/
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/normalization/testDireve308Example.ldif
  (with props)
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/schema/
      - copied from r375361, directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/core/schema/
Removed:
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/core/schema/
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/core/schema/
Modified:
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/main/java/org/apache/ldap/server/unit/AbstractTestCase.java
    directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/schema/SchemaServiceTest.java
    directory/sandbox/akarasulu/rc1refactor/common/ldap/src/test/java/org/apache/ldap/common/name/DnParserTest.java
  (contents, props changed)

Modified: directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/main/java/org/apache/ldap/server/unit/AbstractTestCase.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/main/java/org/apache/ldap/server/unit/AbstractTestCase.java?rev=375441&r1=375440&r2=375441&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/main/java/org/apache/ldap/server/unit/AbstractTestCase.java
(original)
+++ directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/main/java/org/apache/ldap/server/unit/AbstractTestCase.java
Mon Feb  6 17:31:10 2006
@@ -104,6 +104,7 @@
         this.username = username;
         this.password = password;
     }
+    
 
     /**
      * Sets the LDIF path as a relative resource path to use with the
@@ -115,7 +116,6 @@
     protected void setLdifPath( String ldifPath, Class loadClass )
     {
         this.loadClass = loadClass;
-
         this.ldifPath = ldifPath;
     }
 
@@ -147,9 +147,7 @@
         // -------------------------------------------------------------------
 
         Attributes attributes = new LockableAttributesImpl();
-
         LdifParserImpl parser = new LdifParserImpl();
-
         try
         {
             parser.parse( attributes, LDIF );
@@ -158,7 +156,6 @@
         {
             throw new NestableRuntimeException( e );
         }
-
         testEntries.add( attributes );
 
         // -------------------------------------------------------------------
@@ -166,11 +163,13 @@
         // -------------------------------------------------------------------
 
         InputStream in = null;
-
-        if ( loadClass == null && ldifPath != null )
+        if ( loadClass != null && ldifPath == null )
+        {
+            in = loadClass.getResourceAsStream( getName() + ".ldif" );
+        }
+        else if ( loadClass == null && ldifPath != null )
         {
             File ldifFile = new File( ldifPath );
-
             if ( ldifFile.exists() )
             {
                 in = new FileInputStream( ldifPath );
@@ -179,7 +178,6 @@
             {
                 in = getClass().getResourceAsStream( ldifPath );
             }
-
             throw new FileNotFoundException( ldifPath );
         }
         else if ( loadClass != null && ldifPath != null )
@@ -190,15 +188,11 @@
         if ( in != null )
         {
             LdifIterator list = new LdifIterator( in );
-
             while ( list.hasNext() )
             {
                 String ldif = ( String ) list.next();
-
                 attributes = new LockableAttributesImpl();
-
                 parser.parse( attributes, ldif );
-
                 testEntries.add( attributes );
             }
         }
@@ -319,21 +313,19 @@
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
 
         try { new InitialContext( env ); } catch( Exception e ) {}
-
         sysRoot = null;
-
         Runtime.getRuntime().gc();
-
         testEntries.clear();
-
         ldifPath = null;
-
         loadClass = null;
-        
         overrides.clear();
-        
         configuration = new MutableStartupConfiguration();
-        
         doDelete( configuration.getWorkingDirectory() );
+    }
+
+
+    protected void setLoadClass( Class loadClass )
+    {
+        this.loadClass = loadClass;
     }
 }

Added: directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/normalization/NormalizationServiceTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/normalization/NormalizationServiceTest.java?rev=375441&view=auto
==============================================================================
--- directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/normalization/NormalizationServiceTest.java
(added)
+++ directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/normalization/NormalizationServiceTest.java
Mon Feb  6 17:31:10 2006
@@ -0,0 +1,51 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.ldap.server.normalization;
+
+
+import org.apache.ldap.server.unit.AbstractAdminTestCase;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+
+/**
+ * Test cases for the normalization service.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public final class NormalizationServiceTest extends AbstractAdminTestCase
+{
+    public NormalizationServiceTest()
+    {
+        super.setLoadClass( getClass() );
+    }
+    
+    
+    public void testDireve308Example() throws NamingException
+    {
+        Attributes attrs = sysRoot.getAttributes( "ou=corporate category\\, operations,ou=direct
report view" );
+        assertNotNull( attrs );
+        Attribute ou = attrs.get( "ou" );
+        assertEquals( "corporate category\\, operations", ou.get() );
+        Attribute oc = attrs.get( "objectClass" );
+        assertTrue( oc.contains( "top" ) );
+        assertTrue( oc.contains( "organizationalUnit" ) );
+    }
+}

Propchange: directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/normalization/NormalizationServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/schema/SchemaServiceTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/schema/SchemaServiceTest.java?rev=375441&r1=375361&r2=375441&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/schema/SchemaServiceTest.java
(original)
+++ directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/java/org/apache/ldap/server/schema/SchemaServiceTest.java
Mon Feb  6 17:31:10 2006
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.ldap.server.core.schema;
+package org.apache.ldap.server.schema;
 
 
 import java.util.HashMap;

Added: directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/normalization/testDireve308Example.ldif
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/normalization/testDireve308Example.ldif?rev=375441&view=auto
==============================================================================
--- directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/normalization/testDireve308Example.ldif
(added)
+++ directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/normalization/testDireve308Example.ldif
Mon Feb  6 17:31:10 2006
@@ -0,0 +1,7 @@
+dn: ou=direct report view,ou=system
+objectClass: organizationalUnit
+ou: direct report view
+
+dn: ou=corporate category\, operations,ou=direct report view,ou=system
+objectClass: organizationalUnit
+ou: corporate category\, operations

Propchange: directory/sandbox/akarasulu/rc1refactor/apacheds/core-unit/src/test/resources/org/apache/ldap/server/normalization/testDireve308Example.ldif
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/sandbox/akarasulu/rc1refactor/common/ldap/src/test/java/org/apache/ldap/common/name/DnParserTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1refactor/common/ldap/src/test/java/org/apache/ldap/common/name/DnParserTest.java?rev=375441&r1=375440&r2=375441&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1refactor/common/ldap/src/test/java/org/apache/ldap/common/name/DnParserTest.java
(original)
+++ directory/sandbox/akarasulu/rc1refactor/common/ldap/src/test/java/org/apache/ldap/common/name/DnParserTest.java
Mon Feb  6 17:31:10 2006
@@ -25,6 +25,7 @@
 import junit.framework.TestCase;
 
 import org.apache.ldap.common.schema.DnNormalizer;
+import org.apache.ldap.common.schema.Normalizer;
 
 
 /**
@@ -318,6 +319,25 @@
         
         assertEquals( cn, result.toString() );
 
+    }
+    
+    public void testDireve308Example() throws Exception
+    {
+        // seems to work without normalizers 
+        String dn = "ou=Corporate Category\\, Operations,ou=direct report view";
+        DnParser parser = new DnParser();
+        String result = parser.parse( dn ).toString();
+        assertEquals( dn, result );
+        
+        // now we try with normalization: simple as is normalizer
+        parser = new DnParser( new SimpleNameComponentNormalizer( new Normalizer() {
+            public Object normalize( Object value ) throws NamingException
+            {
+                return ( ( String ) value ).toLowerCase();
+            }
+        } ) );
+        result = parser.parse( dn ).toString();
+        assertEquals( dn.toLowerCase(), result.toString() );
     }
 
 }  // end class DnParserTest

Propchange: directory/sandbox/akarasulu/rc1refactor/common/ldap/src/test/java/org/apache/ldap/common/name/DnParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message