directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r674863 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java server-unit/src/test/java/org/apache/directory/server/SearchITest.java
Date Tue, 08 Jul 2008 15:49:34 GMT
Author: elecharny
Date: Tue Jul  8 08:49:34 2008
New Revision: 674863

URL: http://svn.apache.org/viewvc?rev=674863&view=rev
Log:
Fixed DIRSERVER-1180

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
    directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SearchITest.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java?rev=674863&r1=674862&r2=674863&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
Tue Jul  8 08:49:34 2008
@@ -1185,12 +1185,17 @@
             if ( cause.getCause() instanceof ResponseCarryingMessageException )
             {
                 ResponseCarryingMessageException rcme = ( ResponseCarryingMessageException
) cause.getCause();
-                session.write( rcme.getResponse() );
-                return;
+                
+                if ( rcme.getResponse() != null )
+                {
+                    session.write( rcme.getResponse() );
+                    return;
+                }
             }
             
             SessionLog.warn( session,
                 "Unexpected exception forcing session to close: sending disconnect notice
to client.", cause );
+            
             session.write( NoticeOfDisconnect.PROTOCOLERROR );
             registry.remove( session );
             session.close();

Modified: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SearchITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SearchITest.java?rev=674863&r1=674862&r2=674863&view=diff
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SearchITest.java
(original)
+++ directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SearchITest.java
Tue Jul  8 08:49:34 2008
@@ -43,6 +43,9 @@
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.SubentriesControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 
 /**
@@ -56,9 +59,8 @@
 public class SearchITest extends AbstractServerTest
 {
     private LdapContext ctx;
-    public static final String RDN = "cn=Tori Amos";
-    public static final String RDN2 = "cn=Rolling-Stones";
-    public static final String PERSON_DESCRIPTION = "an American singer-songwriter";
+    private static final String RDN = "cn=Tori Amos";
+    private static final String RDN2 = "cn=Rolling-Stones";
     private static final String HEATHER_RDN = "cn=Heather Graham";
     private static final String FILTER = "(objectclass=*)";
 
@@ -114,7 +116,7 @@
     /**
      * Creation of required attributes of a person entry.
      */
-    protected Attributes getPersonAttributes( String sn, String cn )
+    private Attributes getPersonAttributes( String sn, String cn )
     {
         Attributes attributes = new AttributesImpl();
         Attribute attribute = new AttributeImpl( "objectClass" );
@@ -131,7 +133,7 @@
     }
 
 
-    protected void checkForAttributes( Attributes attrs, String[] attrNames )
+    private void checkForAttributes( Attributes attrs, String[] attrNames )
     {
         for ( String attrName : attrNames )
         {
@@ -143,6 +145,7 @@
     /**
      * Create context and a person entry.
      */
+    @Before
     public void setUp() throws Exception
     {
         super.setUp();
@@ -183,11 +186,22 @@
     /**
      * Remove person entry and close context.
      */
+    @After
     public void tearDown() throws Exception
     {
-        ctx.unbind( RDN );
-        ctx.close();
-        
+        try
+        {
+            ctx.unbind( RDN );
+        }
+        catch ( Exception e )
+        {
+            // Do nothing
+        }
+        finally
+        {
+            ctx.close();
+        }
+            
         ctx = null;
         super.tearDown();
     }
@@ -215,6 +229,7 @@
     }
 
     
+    @Test
     public void testDirserver635() throws NamingException
     {
         nbTests = 26;
@@ -251,7 +266,8 @@
     /**
      * Search operation with a base DN which contains a BER encoded value.
      */
-    /*public void testSearchBEREncodedBase() throws NamingException
+    /*
+    public void testSearchBEREncodedBase() throws NamingException
     {
         // create additional entry
         Attributes attributes = this.getPersonAttributes( "Ferry", "Bryan Ferry" );
@@ -288,6 +304,7 @@
     /**
      * Search operation with a base DN which contains a BER encoded value.
      */
+    @Test
     public void testSearchWithBackslashEscapedBase() throws NamingException
     {
         // create additional entry
@@ -327,6 +344,7 @@
      * 
      * @throws NamingException
      */
+    @Test
     public void testSearchValue() throws NamingException
     {
         // Setting up search controls for compare op
@@ -411,14 +429,14 @@
     
     /**
      * Search operation with a base DN with quotes
-     */
+     *
     public void testSearchWithQuotesInBase() throws NamingException {
 
         SearchControls sctls = new SearchControls();
         sctls.setSearchScope(SearchControls.OBJECT_SCOPE);
         String filter = "(cn=Tori Amos)";
 
-        // sn="Kylie Minogue" (with quotes)
+        // sn="Tori Amos" (with quotes)
         String base = "cn=\"Tori Amos\"";
 
         try {
@@ -444,6 +462,7 @@
      * DIRSERVER-645<\a>: Wrong search FILTER evaluation with AND
      * operator and undefined operands.
      */
+    @Test
     public void testUndefinedAvaInBranchFilters() throws Exception
     {
         // create additional entry
@@ -461,6 +480,7 @@
     }
     
     
+    @Test
     public void testSearchSchema() throws Exception
     {
         SearchControls controls = new SearchControls();
@@ -506,7 +526,7 @@
      * @param aciItem the prescriptive ACI attribute value
      * @throws NamingException if there is a problem creating the subentry
      */
-    public void createAccessControlSubentry( String cn, String subtree, String aciItem )
throws NamingException
+    private void createAccessControlSubentry( String cn, String subtree, String aciItem )
throws NamingException
     {
         DirContext adminCtx = ctx;
 
@@ -536,6 +556,7 @@
      * Test case to demonstrate DIRSERVER-705 ("object class top missing in search
      * result, if scope is base and attribute objectClass is requested explicitly").
      */
+    @Test
     public void testAddWithObjectclasses() throws NamingException
     {
 
@@ -579,6 +600,7 @@
      * Test case to demonstrate DIRSERVER-705 ("object class top missing in search
      * result, if scope is base and attribute objectClass is requested explicitly").
      */
+    @Test
     public void testAddWithMissingObjectclasses() throws NamingException
     {
 
@@ -617,6 +639,7 @@
     }
 
 
+    @Test
     public void testSubentryControl() throws Exception
     {
         // create a real access control subentry
@@ -652,6 +675,7 @@
      * Create a person entry with multivalued RDN and check its content. This
      * testcase was created to demonstrate DIRSERVER-628.
      */
+    @Test
     public void testMultiValuedRdnContent() throws NamingException
     {
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
@@ -683,6 +707,7 @@
     /**
      * Create a person entry with multivalued RDN and check its name.
      */
+    @Test
     public void testMultiValuedRdnName() throws NamingException
     {
         Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
@@ -711,6 +736,7 @@
     }
     
     
+    @Test
     public void testSearchJpeg() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -741,6 +767,7 @@
     }
     
     
+    @Test
     public void testSearchOID() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -765,6 +792,7 @@
     }
 
     
+    @Test
     public void testSearchAttrCN() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -790,6 +818,7 @@
     }
 
     
+    @Test
     public void testSearchAttrName() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -818,6 +847,7 @@
     }
 
     
+    @Test
     public void testSearchAttrCommonName() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -849,6 +879,7 @@
     }
 
     
+    @Test
     public void testSearchAttrOID() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -879,6 +910,7 @@
     }
     
     
+    @Test
     public void testSearchAttrC_L() throws NamingException
     {
         // create administrative area
@@ -931,6 +963,7 @@
         assertEquals( "Munich", (String)attrs.get("c-l").get() );
     }
 
+    @Test
     public void testSearchUsersAttrs() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -959,6 +992,8 @@
         assertNull( attrs.get( "creatorsname" ) );
     }
 
+
+    @Test
     public void testSearchOperationalAttrs() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -988,6 +1023,8 @@
         assertNotNull( attrs.get( "creatorsname" ) );
     }
     
+
+    @Test
     public void testSearchAllAttrs() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -1016,6 +1053,8 @@
         assertNotNull( attrs.get( "creatorsname" ) );
     }
 
+
+    @Test
     public void testSearchBadDN() throws NamingException
     {
         SearchControls controls = new SearchControls();
@@ -1031,6 +1070,8 @@
         }
     }
     
+
+    @Test
     public void testSearchInvalidDN() throws NamingException, Exception
     {
         SearchControls controls = new SearchControls();
@@ -1047,9 +1088,11 @@
         }
     }
     
+
     /**
      * Check if operational attributes are present, if "+" is requested.
      */
+    @Test
     public void testSearchOperationalAttributes() throws NamingException
     {
         SearchControls ctls = new SearchControls();
@@ -1077,9 +1120,11 @@
         result.close();
     }
 
+
     /**
      * Check if user attributes are present, if "*" is requested.
      */
+    @Test
     public void testSearchUserAttributes() throws NamingException
     {
         SearchControls ctls = new SearchControls();
@@ -1107,9 +1152,11 @@
         result.close();
     }
     
+    
     /**
      * Check if user and operational attributes are present, if both "*" and "+" are requested.
      */
+    @Test
     public void testSearchOperationalAndUserAttributes() throws NamingException
     {
         SearchControls ctls = new SearchControls();
@@ -1173,6 +1220,7 @@
      * @see https://issues.apache.org/jira/browse/DIRSERVER-1183
      * @throws Exception
      */
+    @Test
     public void testDIRSERVER_1183() throws Exception
     {
     	Attributes attrs = new AttributesImpl( "objectClass", "inetOrgPerson", true );
@@ -1184,30 +1232,34 @@
     	
     	ctx.createSubcontext( "cn=\"Jim, Bean\"", attrs );
     }
+
     
-    
-    // TODO - fix 1180 and uncomment 
-//    
-//
-//    /**
-//     * Test for DIRSERVER-1180 where search hangs when an invalid a substring 
-//     * expression missing an any field is used in a filter: i.e. (cn=**).
-//     * 
-//     * @see https://issues.apache.org/jira/browse/DIRSERVER-1180
-//     */
-//    public void testMissingAnyInSubstring_DIRSERVER_1180() throws Exception
-//    {
-//    	Attributes attrs = new AttributesImpl( "objectClass", "inetOrgPerson", true );
-//    	attrs.get( "objectClass" ).add( "organizationalPerson" );
-//    	attrs.get( "objectClass" ).add( "person" );
-//    	attrs.put( "givenName", "Jim" );
-//    	attrs.put( "sn", "Bean" );
-//    	attrs.put( "cn", "jimbean" );
-//    	
-//    	ctx.createSubcontext( "cn=jimbean", attrs );
-//    	
-//    	NamingEnumeration<SearchResult> results = ctx.search( "", "(cn=**)", new SearchControls()
);
-//    	assertTrue( results.hasMore() );
-//    	results.close();
-//    }
+    /**
+     * Test for DIRSERVER-1180 where search hangs when an invalid a substring 
+     * expression missing an any field is used in a filter: i.e. (cn=**).
+     * 
+     * @see https://issues.apache.org/jira/browse/DIRSERVER-1180
+     */
+    @Test
+    public void testMissingAnyInSubstring_DIRSERVER_1180() throws Exception
+    {
+        Attributes attrs = new AttributesImpl( "objectClass", "inetOrgPerson", true );
+        attrs.get( "objectClass" ).add( "organizationalPerson" );
+        attrs.get( "objectClass" ).add( "person" );
+        attrs.put( "givenName", "Jim" );
+        attrs.put( "sn", "Bean" );
+        attrs.put( "cn", "jimbean" );
+        
+        ctx.createSubcontext( "cn=jimbean", attrs );
+        
+        try
+        {
+            ctx.search( "", "(cn=**)", new SearchControls() );
+            fail();
+        }
+        catch ( Exception e )
+        {
+            assertTrue( true );
+        }
+    }
 }



Mime
View raw message