directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r740824 - in /directory/apacheds/trunk: core-integ/src/main/java/org/apache/directory/server/core/integ/ core-integ/src/main/java/org/apache/directory/server/core/integ/state/ server-integ/src/main/java/org/apache/directory/server/integ/ se...
Date Wed, 04 Feb 2009 18:59:26 GMT
Author: elecharny
Date: Wed Feb  4 18:59:25 2009
New Revision: 740824

URL: http://svn.apache.org/viewvc?rev=740824&view=rev
Log:
Fixed DIRSERVER -1303. The @ApplyLdifFiles now works.

Modified:
    directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/InheritableSettings.java
    directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java
    directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java
    directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java

Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/InheritableSettings.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/InheritableSettings.java?rev=740824&r1=740823&r2=740824&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/InheritableSettings.java
(original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/InheritableSettings.java
Wed Feb  4 18:59:25 2009
@@ -28,8 +28,6 @@
 import org.apache.directory.server.core.integ.annotations.CleanupLevel;
 import org.apache.directory.server.core.integ.annotations.Factory;
 import org.apache.directory.server.core.integ.annotations.Mode;
-
-
 import org.junit.runner.Description;
 
 
@@ -236,7 +234,7 @@
 
         ApplyLdifFiles annotation = description.getAnnotation( ApplyLdifFiles.class );
         
-        if ( annotation != null && annotation.value() != null )
+        if ( ( annotation != null ) && ( annotation.value() != null ) )
         {
             ldifFiles.addAll( Arrays.asList( annotation.value() ) );
         }

Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java?rev=740824&r1=740823&r2=740824&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java
(original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/state/AbstractState.java
Wed Feb  4 18:59:25 2009
@@ -19,8 +19,11 @@
 package org.apache.directory.server.core.integ.state;
 
 
+import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
+import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -177,7 +180,38 @@
     protected void injectLdifs( DirectoryService service, InheritableSettings settings )
     {
         List<String> ldifs = new ArrayList<String>();
+        List<String> ldifFiles = new ArrayList<String>();
 
+        // First inject the LDIF files if any
+        ldifFiles = settings.getLdifFiles( ldifFiles );
+        
+        if ( ldifFiles.size() != 0 )
+        {
+            for ( String ldifFile:ldifFiles )
+            {
+                try
+                {
+                    String className = settings.getParent().getDescription().getDisplayName();
+                    Class<?> clazz = Class.forName( className );
+                    URL url = clazz.getResource( ldifFile );
+                    URI uri = url.toURI();
+                    File file = new File( uri );
+
+                    LdifReader ldifReader = new LdifReader( file ); 
+    
+                    for ( LdifEntry entry : ldifReader )
+                    {
+                        service.getAdminSession().add( 
+                            new DefaultServerEntry( service.getRegistries(), entry.getEntry()
) ); 
+                        LOG.debug( "Successfully injected LDIF enry for test {}: {}", settings.getDescription(),
entry );
+                    }
+                }
+                catch ( Exception e )
+                {
+                    LOG.error( "Cannot inject the following entry : {}. Error : {}.", ldifFile,
e.getMessage() );
+                }
+            }
+        }
         ldifs =  settings.getLdifs( ldifs );
         
         if ( ldifs.size() != 0 )

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java?rev=740824&r1=740823&r2=740824&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java
(original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java
Wed Feb  4 18:59:25 2009
@@ -236,7 +236,7 @@
 
         ApplyLdifFiles annotation = description.getAnnotation( ApplyLdifFiles.class );
         
-        if ( annotation != null && annotation.value() != null )
+        if ( ( annotation != null ) && ( annotation.value() != null ) )
         {
             ldifFiles.addAll( Arrays.asList( annotation.value() ) );
         }

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java?rev=740824&r1=740823&r2=740824&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
(original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
Wed Feb  4 18:59:25 2009
@@ -19,8 +19,11 @@
 package org.apache.directory.server.integ.state;
 
 
+import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
+import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -177,7 +180,32 @@
     protected void injectLdifs( DirectoryService service, InheritableServerSettings settings
) throws Exception
     {
         List<String> ldifs = new ArrayList<String>();
+        List<String> ldifFiles = new ArrayList<String>();
 
+        // First inject the LDIF files if any
+        ldifFiles = settings.getLdifFiles( ldifFiles );
+        
+        if ( ldifFiles.size() != 0 )
+        {
+            for ( String ldifFile:ldifFiles )
+            {
+                String className = settings.getParent().getDescription().getDisplayName();
+                Class<?> clazz = Class.forName( className );
+                URL url = clazz.getResource( ldifFile );
+                URI uri = url.toURI();
+                File file = new File( uri );
+                
+                LdifReader ldifReader = new LdifReader( file ); 
+
+                for ( LdifEntry entry : ldifReader )
+                {
+                    service.getAdminSession().add( 
+                        new DefaultServerEntry( service.getRegistries(), entry.getEntry()
) ); 
+                    LOG.debug( "Successfully injected LDIF enry for test {}: {}", settings.getDescription(),
entry );
+                }
+            }
+        }
+        
         ldifs =  settings.getLdifs( ldifs );
         
         if ( ldifs.size() != 0 )



Mime
View raw message