directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r893089 - in /directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ: DirectoryServiceFactory.java FrameworkDirectoryServiceFactory.java FrameworkRunner.java TestClassA.java TestClassB.java
Date Tue, 22 Dec 2009 07:02:09 GMT
Author: kayyagari
Date: Tue Dec 22 07:02:05 2009
New Revision: 893089

URL: http://svn.apache.org/viewvc?rev=893089&view=rev
Log:
o modified the DSFactory to create a unique server-work directory for each DS instance
o modified the way the LDIFs are applied
o replaced the CoreSession.lookup() methods with exists()
o removed the global DirectoryService field in FrameworkRunner 

Modified:
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkRunner.java
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java
    directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java?rev=893089&r1=893088&r2=893089&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
Tue Dec 22 07:02:05 2009
@@ -25,6 +25,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.UUID;
 
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DefaultDirectoryService;
@@ -72,7 +73,7 @@
             {
                 String path = DirectoryServiceFactory.class.getResource( "" ).getPath();
                 int targetPos = path.indexOf( "target" );
-                workingDirectory = path.substring( 0, targetPos + 6 ) + "/server-work";
+                workingDirectory = path.substring( 0, targetPos + 6 ) + "/server-work-" +
UUID.randomUUID().toString();
             }
 
             service = new DefaultDirectoryService();

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java?rev=893089&r1=893088&r2=893089&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkDirectoryServiceFactory.java
Tue Dec 22 07:02:05 2009
@@ -7,6 +7,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.UUID;
 
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DefaultDirectoryService;
@@ -39,7 +40,7 @@
         {
             String path = DirectoryServiceFactory.class.getResource( "" ).getPath();
             int targetPos = path.indexOf( "target" );
-            workingDirectory = path.substring( 0, targetPos + 6 ) + "/server-work";
+            workingDirectory = path.substring( 0, targetPos + 6 ) + "/server-work-" + UUID.randomUUID().toString();
         }
 
         service = new DefaultDirectoryService();

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkRunner.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkRunner.java?rev=893089&r1=893088&r2=893089&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkRunner.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/FrameworkRunner.java
Tue Dec 22 07:02:05 2009
@@ -63,7 +63,7 @@
 {
     private static final String DIRECTORYSERVICE_FIELD_NAME = "service";
     private FrameworkSuite suite;
-    protected DirectoryService service;
+
 
     public FrameworkRunner( Class<?> clazz ) throws InitializationError
     {
@@ -78,18 +78,19 @@
         try
         {
             Field field = getTestClass().getJavaClass().getDeclaredField( DIRECTORYSERVICE_FIELD_NAME
);
-            
+
             Object val = null;
             if ( fac != null )
             {
                 val = fac.value().newInstance();
-                service = ( ( DirectoryServiceFactory ) val ).newInstance();
+                val = ( ( DirectoryServiceFactory ) val ).newInstance();
             }
-            else // set the parent suit's factory value
+            else
+            // set the parent suit's factory value
             {
                 TestLevelFactory suitFactory = getSuite().getDescription().getAnnotation(
TestLevelFactory.class );
-                
-                if( suitFactory == null )
+
+                if ( suitFactory == null )
                 {
                     // instantiate a default factory
                     val = DirectoryServiceFactory.DEFAULT;
@@ -98,16 +99,21 @@
                 {
                     val = suitFactory.value().newInstance();
                 }
-                
-                service = ( ( DirectoryServiceFactory ) val ).newInstance();
-                applyLdifs( getSuite().getDescription(), service );
-            }
-            
-            field.set( getTestClass().getJavaClass(), service );
-            init();
-            
-            applyLdifs( getDescription(), service );
-            
+
+                val = ( ( DirectoryServiceFactory ) val ).newInstance();
+            }
+
+            init( ( DirectoryService ) val );
+
+            if ( getSuite() != null )
+            {
+                applyLdifs( getSuite().getDescription(), ( DirectoryService ) val );
+            }
+
+            applyLdifs( getDescription(), ( DirectoryService ) val );
+
+            field.set( getTestClass().getJavaClass(), val );
+
             super.run( notifier );
         }
         catch ( Exception e )
@@ -115,10 +121,15 @@
             e.printStackTrace();
         }
     }
-    
-    
-    public void init() throws Exception
+
+
+    public void init( DirectoryService service ) throws Exception
     {
+        if ( service.isStarted() )
+        {
+            return;
+        }
+
         SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
 
         // Init the LdifPartition
@@ -173,8 +184,9 @@
         ( ( JdbmPartition ) systemPartition ).setIndexedAttributes( indexedAttrs );
 
         service.setSystemPartition( systemPartition );
-    }
 
+        service.startup();
+    }
 
 
     @Override
@@ -195,16 +207,18 @@
 
             TestLevelFactory fac = description.getAnnotation( TestLevelFactory.class );
 
-            Object  childDirServiceObj = null; 
+            Object childDirServiceObj = null;
             if ( fac != null )
             {
                 childDirServiceObj = ( ( DirectoryServiceFactory ) fac.value().newInstance()
).newInstance();
+
+                DirectoryService service = ( DirectoryService ) childDirServiceObj;
+                init( service );
+                // TODO only applying is present, revert should be added
+                applyLdifs( description, service );
                 field.set( getTestClass().getJavaClass(), childDirServiceObj );
             }
 
-            // TODO only applying is present, revert should be added
-            applyLdifs( description, ( ( DirectoryService ) ( childDirServiceObj == null
? parentDirServiceObj : childDirServiceObj ) ) );
-            
             super.runChild( method, notifier );
 
             // reset the parent's value
@@ -228,24 +242,24 @@
     {
         return suite;
     }
-    
+
 
     private void applyLdifs( Description description, DirectoryService service ) throws Exception
     {
         ApplyLdifs annotation = description.getAnnotation( ApplyLdifs.class );
-        
+
         if ( ( annotation != null ) && ( annotation.value() != null ) )
         {
             String[] ldifs = annotation.value();
-            
-            for( String s : ldifs )
+
+            for ( String s : ldifs )
             {
                 injectEntries( service, s );
             }
         }
     }
-    
-    
+
+
     // copied from IntegrationUtils
     /**
      * Inject an ldif String into the server. DN must be relative to the
@@ -264,22 +278,19 @@
         {
             if ( entry.isChangeAdd() )
             {
-                service.getAdminSession().add( 
-                    new DefaultServerEntry( service.getSchemaManager(), entry.getEntry()
) );
+                service.getAdminSession().add( new DefaultServerEntry( service.getSchemaManager(),
entry.getEntry() ) );
             }
             else if ( entry.isChangeModify() )
             {
-                service.getAdminSession().modify( 
-                    entry.getDn(), entry.getModificationItems() );
+                service.getAdminSession().modify( entry.getDn(), entry.getModificationItems()
);
             }
             else
             {
-                String message = "Unsupported changetype found in LDIF: " + 
-                    entry.getChangeType();
+                String message = "Unsupported changetype found in LDIF: " + entry.getChangeType();
                 throw new NamingException( message );
             }
         }
-        
+
         // And close the reader
         reader.close();
     }

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java?rev=893089&r1=893088&r2=893089&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassA.java
Tue Dec 22 07:02:05 2009
@@ -1,8 +1,10 @@
 package org.apache.directory.server.core.integ;
 
 
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -17,7 +19,7 @@
         "dn: cn=testClassA,ou=system\n" + 
         "objectClass: person\n" + 
         "cn: testClassA\n" + 
-        "sn: sn_testClassA\n" 
+        "sn: sn_testClassA\n"
     })
 public class TestClassA
 {
@@ -36,14 +38,15 @@
         })
     public void testWithFactoryAnnotation() throws Exception
     {
-        assertNull( service.getAdminSession().lookup( new LdapDN( "cn=testClassA,ou=system"
) ) );
-        assertNotNull( service.getAdminSession().lookup( new LdapDN( "cn=testMethodA,ou=system"
) ) );
+        assertFalse( service.getAdminSession().exists( new LdapDN( "cn=testClassA,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testMethodA,ou=system"
) ) );
     }
 
 
     @Test
     public void testWithoutFactoryAnnotation() throws Exception
     {
-        assertNotNull( service.getAdminSession().lookup( new LdapDN( "cn=testClassA,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testClassA,ou=system"
) ) );
+        assertFalse( service.getAdminSession().exists( new LdapDN( "cn=testMethodA,ou=system"
) ) );
     }
 }

Modified: directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java?rev=893089&r1=893088&r2=893089&view=diff
==============================================================================
--- directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java
(original)
+++ directory/sandbox/kayyagari/integ-test-framework/src/test/java/org/apache/directory/server/core/integ/TestClassB.java
Tue Dec 22 07:02:05 2009
@@ -1,8 +1,8 @@
 package org.apache.directory.server.core.integ;
 
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -19,13 +19,13 @@
     @TestLevelFactory( FrameworkDirectoryServiceFactory.class )
     public void testWithFactoryAnnotation() throws Exception
     {
-        assertNull( service.getAdminSession().lookup( new LdapDN( "cn=testSuite,ou=system"
) ) );
+        assertFalse( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
     }
     
     
     @Test
     public void testWithoutFactoryAnnotation() throws Exception
     {
-        assertNotNull( service.getAdminSession().lookup( new LdapDN( "cn=testSuite,ou=system"
) ) );
+        assertTrue( service.getAdminSession().exists( new LdapDN( "cn=testSuite,ou=system"
) ) );
     }
 }



Mime
View raw message