directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r415452 - in /directory/trunks/apacheds/core-unit/src/test: java/org/apache/directory/server/core/trigger/DefaulTriggerServiceTest.java resources/org/apache/directory/server/core/trigger/BackupUtilities.java
Date Mon, 19 Jun 2006 22:56:57 GMT
Author: ersiner
Date: Mon Jun 19 15:56:56 2006
New Revision: 415452

URL: http://svn.apache.org/viewvc?rev=415452&view=rev
Log:
Modified test case to use new SP Utils.
Fixed test data ( sample SP ) for LdapDN usage.

Modified:
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceTest.java
    directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/BackupUtilities.java

Modified: directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceTest.java?rev=415452&r1=415451&r2=415452&view=diff
==============================================================================
--- directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceTest.java
(original)
+++ directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceTest.java
Mon Jun 19 15:56:56 2006
@@ -18,17 +18,13 @@
 package org.apache.directory.server.core.trigger;
 
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
-import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.shared.ldap.sp.StoredProcedureUtils;
 
 
 /**
@@ -39,40 +35,11 @@
  */
 public class DefaulTriggerServiceTest extends AbstractTriggerServiceTest
 {
-    private void loadStoredProcedureUnit( LdapContext ctx, String fullClassName ) throws
NamingException
-    {
-        int lastDot = fullClassName.lastIndexOf( '.' );
-        String classFileName = fullClassName.substring( lastDot + 1 ) + ".class";
-        
-        URL url = getClass().getResource( classFileName );
-        InputStream in = getClass().getResourceAsStream( classFileName );
-        File file = new File( url.getFile() );
-        int size = ( int ) file.length();
-        byte[] buf = new byte[size];
-        try
-        {
-            in.read( buf );
-            in.close();
-        }
-        catch ( IOException e )
-        {
-            NamingException ne = new NamingException();
-            ne.setRootCause( e );
-            throw ne;
-        }
-        
-        Attributes attributes = new BasicAttributes( "objectClass", "top", true );
-        attributes.get( "objectClass" ).add( "javaClass" );
-        attributes.put( "fullyQualifiedClassName", fullClassName );
-        attributes.put( "byteCode", buf );
-        
-        ctx.createSubcontext( "fullyQualifiedClassName=" + fullClassName, attributes );
-    }
     
     public void testAfterDeleteBackupDeletedEntry() throws NamingException
     {
         // Load the stored procedure unit which has the stored procedure to be triggered.
-        loadStoredProcedureUnit( sysRoot, BackupUtilities.class.getName() );
+        StoredProcedureUtils.loadStoredProcedureClass( sysRoot, BackupUtilities.class.getName(),
getClass() );
         
         // Create a container for backing up deleted entries.
         Attributes backupContext = new BasicAttributes( "ou", "backupContext", true );

Modified: directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/BackupUtilities.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/BackupUtilities.java?rev=415452&r1=415451&r2=415452&view=diff
==============================================================================
--- directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/BackupUtilities.java
(original)
+++ directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/BackupUtilities.java
Mon Jun 19 15:56:56 2006
@@ -13,7 +13,8 @@
         System.out.println( "User \"" + operationPrincipal + "\" has deleted entry \"" +
deletedEntryName + "\"" );
         System.out.println( "Entry content was: " + deletedEntry );
         LdapContext backupCtx = ( LdapContext ) ctx.lookup( "ou=backupContext,ou=system"
);
-        backupCtx.createSubcontext( deletedEntryName.get( 1 ), deletedEntry );
-        System.out.println( "Backed up deleted entry to \"" + ( ( LdapContext ) backupCtx.lookup(
deletedEntryName.get( 1 ) ) ).getNameInNamespace() + "\"" );
+        String deletedEntryRdn = deletedEntryName.get( deletedEntryName.size() - 1 );
+        backupCtx.createSubcontext( deletedEntryRdn, deletedEntry );
+        System.out.println( "Backed up deleted entry to \"" + ( ( LdapContext ) backupCtx.lookup(
deletedEntryRdn ) ).getNameInNamespace() + "\"" );
     }
 }



Mime
View raw message