directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r895830 - in /directory/apacheds/branches/apacheds-schema: core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
Date Mon, 04 Jan 2010 23:52:36 GMT
Author: elecharny
Date: Mon Jan  4 23:52:36 2010
New Revision: 895830

URL: http://svn.apache.org/viewvc?rev=895830&view=rev
Log:
Fixed the PersistentSearch tests

Modified:
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
    directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java

Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=895830&r1=895829&r2=895830&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
Mon Jan  4 23:52:36 2010
@@ -189,8 +189,7 @@
 
     public void modify( NextInterceptor next, final ModifyOperationContext opContext ) throws
Exception
     {
-        ClonedServerEntry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS
);
-        List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(),
oriEntry );
+        List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(),
opContext.getEntry() );
         next.modify( opContext );
 
         if ( selecting.isEmpty() )
@@ -198,6 +197,10 @@
             return;
         }
 
+        // Get the modifed entry
+        ClonedServerEntry alteredEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS
);
+        opContext.setAlteredEntry( alteredEntry );
+
         for ( final RegistrationEntry registration : selecting )
         {
             if ( EventType.isModify( registration.getCriteria().getEventMask() ) )
@@ -210,8 +213,7 @@
 
     public void rename( NextInterceptor next, RenameOperationContext opContext ) throws Exception
     {
-        ServerEntry oriEntry = opContext.getEntry().getOriginalEntry();
-        List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(),
oriEntry );
+        List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(),
opContext.getEntry() );
         next.rename( opContext );
 
         if ( selecting.isEmpty() )
@@ -219,7 +221,9 @@
             return;
         }
 
-        //opContext.setAlteredEntry( opContext.lookup( opContext.getNewDn(), ByPassConstants.LOOKUP_BYPASS
) );
+        // Get the modifed entry
+        ClonedServerEntry alteredEntry = opContext.lookup( opContext.getNewDn(), ByPassConstants.LOOKUP_BYPASS
);
+        opContext.setAlteredEntry( alteredEntry );
         
         for ( final RegistrationEntry registration : selecting )
         {
@@ -262,10 +266,11 @@
 
     public void move( NextInterceptor next, MoveOperationContext opContext ) throws Exception
     {
-        ClonedServerEntry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS
);
-        List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(),
oriEntry );
+        List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(),
opContext.getEntry() );
         next.move( opContext );
 
+        ClonedServerEntry alteredEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS
);
+
         if ( selecting.isEmpty() )
         {
             return;

Modified: directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java?rev=895830&r1=895829&r2=895830&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
(original)
+++ directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
Mon Jan  4 23:52:36 2010
@@ -31,9 +31,8 @@
 import java.util.List;
 
 import javax.naming.NamingEnumeration;
-import javax.naming.directory.Attribute;
+import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.SearchResult;
@@ -57,6 +56,8 @@
 import org.apache.directory.shared.ldap.codec.search.controls.entryChange.EntryChangeControlCodec;
 import org.apache.directory.shared.ldap.codec.search.controls.entryChange.EntryChangeControlDecoder;
 import org.apache.directory.shared.ldap.message.control.PersistentSearchControl;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -97,15 +98,13 @@
     /**
      * Creation of required attributes of a person entry.
      */
-    protected Attributes getPersonAttributes( String sn, String cn )
+    private Attributes getPersonAttributes( String sn, String cn ) throws NamingException
     {
-        Attributes attributes = new BasicAttributes( true );
-        Attribute attribute = new BasicAttribute( "objectClass" );
-        attribute.add( "top" );
-        attribute.add( "person" );
-        attributes.put( attribute );
-        attributes.put( "cn", cn );
-        attributes.put( "sn", sn );
+        Attributes attributes = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: person",
+            "cn", cn,
+            "sn", sn );
 
         return attributes;
     }
@@ -117,13 +116,13 @@
     Thread t;
     
 
-    public void setUpListenerReturnECs() throws Exception
+    private void setUpListenerReturnECs() throws Exception
     {
         setUpListener( true, new PersistentSearchControl(), false );
     }
     
     
-    public void setUpListener( boolean returnECs, PersistentSearchControl control, boolean
ignoreEmptyRegistryCheck ) 
+    private void setUpListener( boolean returnECs, PersistentSearchControl control, boolean
ignoreEmptyRegistryCheck ) 
         throws Exception
     {
         ctx = ( EventDirContext ) getWiredContext( ldapServer).lookup( BASE );
@@ -145,12 +144,13 @@
         {
             Thread.sleep( 100 );
         }
+        
         // Now we wait until the listener is registered (timing dependent crap)
         Thread.sleep( 250 );
     }
     
     
-    public void setUpListener() throws Exception
+    private void setUpListener() throws Exception
     {
         ctx = ( EventDirContext ) getWiredContext( ldapServer).lookup( BASE );
         eventService = ldapServer.getDirectoryService().getEventService();
@@ -166,11 +166,13 @@
         {
             Thread.sleep( 100 );
         }
+        
         // Now we wait until the listener is registered (timing dependent crap)
         Thread.sleep( 250 );
     }
     
     
+    @After
     public void tearDownListener() throws Exception
     {
         listener.close();
@@ -186,6 +188,7 @@
     private void waitForThreadToDie( Thread t ) throws Exception
     {
         long start = System.currentTimeMillis();
+        
         while ( t.isAlive() )
         {
             Thread.sleep( 200 );
@@ -209,7 +212,6 @@
         waitForThreadToDie( t );
         assertNotNull( listener.result );
         assertEquals( RDN, listener.result.getName() );
-        tearDownListener();
     }
 
 
@@ -224,7 +226,6 @@
         waitForThreadToDie( t );
         assertNotNull( listener.result );
         assertEquals( "cn=Jack Black", listener.result.getName() );
-        tearDownListener();
     }
 
 
@@ -239,7 +240,6 @@
         waitForThreadToDie( t );
         assertNotNull( listener.result );
         assertEquals( RDN, listener.result.getName() );
-        tearDownListener();
     }
 
 
@@ -254,7 +254,6 @@
         waitForThreadToDie( t );
         assertNotNull( listener.result );
         assertEquals( "cn=Jack Black", listener.result.getName() );
-        tearDownListener();
     }
 
 
@@ -272,7 +271,6 @@
         assertNotNull( listener.result );
         assertEquals( RDN, listener.result.getName() );
         assertEquals( listener.result.control.getChangeType(), ChangeType.MODIFY );
-        tearDownListener();
     }
 
 
@@ -290,7 +288,6 @@
         assertEquals( "cn=Jack Black", listener.result.getName() );
         assertEquals( listener.result.control.getChangeType(), ChangeType.MODDN );
         assertEquals( ( RDN + ",ou=system" ), listener.result.control.getPreviousDn().getName()
);
-        tearDownListener();
     }
 
 
@@ -307,7 +304,6 @@
         assertNotNull( listener.result );
         assertEquals( RDN, listener.result.getName() );
         assertEquals( listener.result.control.getChangeType(), ChangeType.DELETE );
-        tearDownListener();
     }
 
 
@@ -324,7 +320,6 @@
         assertNotNull( listener.result );
         assertEquals( "cn=Jack Black", listener.result.getName() );
         assertEquals( listener.result.control.getChangeType(), ChangeType.ADD );
-        tearDownListener();
     }
 
 
@@ -361,8 +356,6 @@
         assertNotNull( listener.result );
         assertEquals( RDN, listener.result.getName() );
         assertEquals( listener.result.control.getChangeType(), ChangeType.MODIFY );
-        
-        tearDownListener();
     }
 
 
@@ -595,6 +588,7 @@
                     LOG.debug( "PSearchListener search request got an item." );
                     Control[] controls = null;
                     SearchResult sresult = list.next();
+                    
                     if ( sresult instanceof HasControls )
                     {
                         controls = ( ( HasControls ) sresult ).getControls();
@@ -611,9 +605,11 @@
                             }
                         }
                     }
+                    
                     result = new PSearchNotification( sresult, ecControl );
                     break;
                 }
+                
                 LOG.debug( "PSearchListener broke out of while loop." );
             }
             catch ( Exception e )



Mime
View raw message