directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r415198 - in /directory/trunks/apacheds/core-unit/src/test: java/org/apache/directory/server/core/trigger/ resources/org/apache/directory/server/core/trigger/
Date Sun, 18 Jun 2006 21:28:16 GMT
Author: ersiner
Date: Sun Jun 18 14:28:15 2006
New Revision: 415198

URL: http://svn.apache.org/viewvc?rev=415198&view=rev
Log:
Modularized Stored Procedure Unit Loader utility method.
Moved Trigger Test data ( SP Units ) to resources.
Some minor changes.

Added:
    directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/
    directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/BackupUtilities.java
Removed:
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/Audit.java
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/BackupUtilities.java
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/HelloWorldProcedure.java
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/Logger.java
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/Restrictions.java
Modified:
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceTest.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=415198&r1=415197&r2=415198&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
Sun Jun 18 14:28:15 2006
@@ -28,6 +28,7 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.LdapContext;
 
 
 /**
@@ -38,10 +39,13 @@
  */
 public class DefaulTriggerServiceTest extends AbstractTriggerServiceTest
 {
-    private void loadStoredProcedure( String spClass ) throws NamingException
+    private void loadStoredProcedureUnit( LdapContext ctx, String fullClassName ) throws
NamingException
     {
-        URL url = getClass().getResource( spClass + ".class" );
-        InputStream in = getClass().getResourceAsStream( spClass + ".class" );
+        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];
@@ -57,20 +61,18 @@
             throw ne;
         }
         
-        String fullClassName = getClass().getPackage().getName() + "." + spClass;
-        
         Attributes attributes = new BasicAttributes( "objectClass", "top", true );
         attributes.get( "objectClass" ).add( "javaClass" );
         attributes.put( "fullyQualifiedClassName", fullClassName );
         attributes.put( "byteCode", buf );
         
-        sysRoot.createSubcontext( "fullyQualifiedClassName=" + fullClassName, attributes
);
+        ctx.createSubcontext( "fullyQualifiedClassName=" + fullClassName, attributes );
     }
     
     public void testAfterDeleteBackupDeletedEntry() throws NamingException
     {
-        // Load the stored procedure to be triggered.
-        loadStoredProcedure( "BackupUtilities" );
+        // Load the stored procedure unit which has the stored procedure to be triggered.
+        loadStoredProcedureUnit( sysRoot, BackupUtilities.class.getName() );
         
         // Create a container for backing up deleted entries.
         Attributes backupContext = new BasicAttributes( "ou", "backupContext", true );
@@ -80,9 +82,9 @@
         objectClass.add( "organizationalUnit" );
         sysRoot.createSubcontext( "ou=backupContext", backupContext );
         
-        // Create the Triger Specification via the Trigger Subentry.
-        createTriggerSubentry( "triggerSubentry1", "AFTER delete CALL \"" +
-            "org.apache.directory.server.core.trigger.BackupUtilities.backupDeleted\" ( $name,
$operationPrincipal, $deletedEntry )" );
+        // Create the Triger Specification within a Trigger Subentry.
+        createTriggerSubentry( "triggerSubentry1",
+            "AFTER delete CALL \"" + BackupUtilities.class.getName() + ".backupDeleted\"
( $name, $operationPrincipal, $deletedEntry )" );
         
         // Create a test entry which is selected by the Trigger Subentry.
         Attributes testEntry = new BasicAttributes( "ou", "testou", true );

Added: 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=415198&view=auto
==============================================================================
--- directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/BackupUtilities.java
(added)
+++ directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/trigger/BackupUtilities.java
Sun Jun 18 14:28:15 2006
@@ -0,0 +1,19 @@
+package org.apache.directory.server.core.trigger;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+
+public class BackupUtilities
+{
+    public static void backupDeleted( LdapContext ctx, Name deletedEntryName, Name operationPrincipal,
Attributes deletedEntry ) throws NamingException
+    {
+        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() + "\"" );
+    }
+}



Mime
View raw message