directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r475805 [11/17] - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/direc...
Date Thu, 16 Nov 2006 16:38:51 GMT
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchRequest/SearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchRequest/SearchRequestTest.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchRequest/SearchRequestTest.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchRequest/SearchRequestTest.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,1595 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2.searchRequest;
+
+import java.util.ArrayList;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.ldapstudio.dsmlv2.AbstractTest;
+import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2Parser;
+import org.apache.directory.shared.ldap.codec.AttributeValueAssertion;
+import org.apache.directory.shared.ldap.codec.Control;
+import org.apache.directory.shared.ldap.codec.LdapConstants;
+import org.apache.directory.shared.ldap.codec.search.AndFilter;
+import org.apache.directory.shared.ldap.codec.search.AttributeValueAssertionFilter;
+import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
+import org.apache.directory.shared.ldap.codec.search.Filter;
+import org.apache.directory.shared.ldap.codec.search.NotFilter;
+import org.apache.directory.shared.ldap.codec.search.OrFilter;
+import org.apache.directory.shared.ldap.codec.search.PresentFilter;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+/**
+ * Tests for the Del Request parsing
+ */
+public class SearchRequestTest extends AbstractTest
+{ 
+    /**
+     * Test parsing of a request without the dn attribute
+     */
+    public void testRequestWithoutDn()
+    {
+        testParsingFail( SearchRequestTest.class, "request_without_dn_attribute.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with the dn attribute
+     */
+    public void testRequestWithDn()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_dn_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( "ou=marketing,dc=microsoft,dc=com", searchRequest.getBaseObject().toString() );
+    }
+    
+    /**
+     * Test parsing of a request with the (optional) requestID attribute
+     */
+    public void testRequestWithRequestId()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( 456, searchRequest.getMessageId() );
+    }
+    
+
+    /**
+     * Test parsing of a request with a (optional) Control element
+     */
+    public void testRequestWith1Control()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_1_control.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( 1, searchRequest.getControls().size() );
+        
+        Control control = searchRequest.getCurrentControl();
+        
+        assertTrue( control.getCriticality() );
+        
+        assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
+        
+        assertEquals( "Some text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
+    }
+    
+
+    /**
+     * Test parsing of a request with 2 (optional) Control elements
+     */
+    public void testRequestWith2Controls()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_2_controls.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( 2, searchRequest.getControls().size() );
+        
+        Control control = searchRequest.getCurrentControl();
+        
+        assertFalse( control.getCriticality() );
+        
+        assertEquals( "1.2.840.113556.1.4.789", control.getControlType() );
+        
+        assertEquals( "Some other text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
+    }
+    
+    /**
+     * Test parsing of a request with 3 (optional) Control elements without value
+     */
+    public void testRequestWith3ControlsWithoutValue()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_3_controls_without_value.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( 3, searchRequest.getControls().size() );
+        
+        Control control = searchRequest.getCurrentControl();
+        
+        assertTrue( control.getCriticality() );
+        
+        assertEquals( "1.2.840.113556.1.4.456", control.getControlType() );
+        
+        assertEquals( StringTools.EMPTY_BYTES, control.getControlValue() );
+    }
+    
+    /**
+     * Test parsing of a request without the Filter element
+     */
+    public void testRequestWithoutFilter()
+    {
+        testParsingFail( SearchRequestTest.class, "request_without_filter.xml" );
+    }
+    
+    /**
+     * Test parsing of a request without scope attribute
+     */
+    public void testRequestWithoutScopeAttribute()
+    {
+        testParsingFail( SearchRequestTest.class, "request_without_scope_attribute.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with scope attribute to BaseObject value
+     * @throws NamingException 
+     */
+    public void testRequestWithScopeBaseObject()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_scope_baseObject.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( LdapConstants.SCOPE_BASE_OBJECT, searchRequest.getScope() );
+    }
+    
+    /**
+     * Test parsing of a request with scope attribute to SingleLevel value
+     * @throws NamingException 
+     */
+    public void testRequestWithScopeSingleLevel()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_scope_singleLevel.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( LdapConstants.SCOPE_SINGLE_LEVEL, searchRequest.getScope() );
+    }
+    
+    /**
+     * Test parsing of a request with scope attribute to WholeSubtree value
+     * @throws NamingException 
+     */
+    public void testRequestWithScopeWholeSubtree()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_scope_wholeSubtree.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( LdapConstants.SCOPE_WHOLE_SUBTREE, searchRequest.getScope() );
+    }
+    
+    /**
+     * Test parsing of a request with scope attribute to Error value
+     */
+    public void testRequestWithScopeError()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_scope_error.xml" );
+    }
+    
+    /**
+     * Test parsing of a request without derefAliases attribute
+     */
+    public void testRequestWithoutDerefAliasesAttribute()
+    {
+        testParsingFail( SearchRequestTest.class, "request_without_derefAliases_attribute.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with derefAliases attribute to derefAlways value
+     * @throws NamingException 
+     */
+    public void testRequestWithDerefAliasesDerefAlways()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_derefAliases_derefAlways.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( LdapConstants.DEREF_ALWAYS, searchRequest.getDerefAliases() );
+    }
+    
+    /**
+     * Test parsing of a request with derefAliases attribute to derefFindingBaseObj value
+     * @throws NamingException 
+     */
+    public void testRequestWithDerefAliasesDerefFindingBaseObj()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_derefAliases_derefFindingBaseObj.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( LdapConstants.DEREF_FINDING_BASE_OBJ, searchRequest.getDerefAliases() );
+    }
+    
+    /**
+     * Test parsing of a request with derefAliases attribute to derefinSearching value
+     * @throws NamingException 
+     */
+    public void testRequestWithDerefAliasesDerefinSearching()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_derefAliases_derefInSearching.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( LdapConstants.DEREF_IN_SEARCHING, searchRequest.getDerefAliases() );
+    }
+    
+    /**
+     * Test parsing of a request with derefAliases attribute to neverDerefAliases value
+     * @throws NamingException 
+     */
+    public void testRequestWithDerefAliasesNeverDerefAliases()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_derefAliases_neverDerefAliases.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( LdapConstants.NEVER_DEREF_ALIASES, searchRequest.getDerefAliases() );
+    }
+    
+    /**
+     * Test parsing of a request with derefAliases attribute to Error value
+     * @throws NamingException 
+     */
+    public void testRequestWithDerefAliasesError()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_derefAliases_error.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with the sizeLimit (optional) attribute
+     * @throws NamingException 
+     */
+    public void testRequestWithSizeLimitAttribute()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_sizeLimit_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( 1000, searchRequest.getSizeLimit() );
+    }
+    
+    /**
+     * Test parsing of a request with sizeLimit attribute to Error value
+     * @throws NamingException 
+     */
+    public void testRequestWithSizeLimitError()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_sizeLimit_error.xml" );
+    }
+    
+    
+    /**
+     * Test parsing of a request with the timeLimit (optional) attribute
+     * @throws NamingException 
+     */
+    public void testRequestWithTimeLimitAttribute()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_timeLimit_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertEquals( 60, searchRequest.getTimeLimit() );
+    }
+    
+    /**
+     * Test parsing of a request with timeLimit attribute to Error value
+     * @throws NamingException 
+     */
+    public void testRequestWithTimeLimitError()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_timeLimit_error.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with typesOnly to true
+     */
+    public void testRequestWithTypesOnlyTrue()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_typesOnly_true.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertTrue( searchRequest.isTypesOnly() );
+    }
+    
+    
+    /**
+     * Test parsing of a request with typesOnly to 1
+     */
+    public void testRequestWithTypesOnly1()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_typesOnly_1.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertTrue( searchRequest.isTypesOnly() );
+    }
+    
+    /**
+     * Test parsing of a request with typesOnly to false
+     */
+    public void testRequestWithTypesOnlyFalse()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_typesOnly_false.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertFalse( searchRequest.isTypesOnly() );
+    }
+    
+
+    /**
+     * Test parsing of a request with typesOnly to 0
+     */
+    public void testRequestWithTypesOnlyRdn0()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_typesOnly_0.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        assertFalse( searchRequest.isTypesOnly() );
+    }
+    
+    /**
+     * Test parsing of a request with typesOnly to an error value
+     */
+    public void testRequestWithTypesOnlyError()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_typesOnly_error.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with 2 Filter elements
+     */
+    public void testRequestWith2Filters()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_2_filters.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with Attibutes Element but not any Attribute element
+     */
+    public void testRequestWithAttributesButNoAttribute()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_attributes_but_no_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        assertTrue( true );
+    }
+    
+    /**
+     * Test parsing of a request with 2 Attributes elements
+     */
+    public void testRequestWith2AttributesElements()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_2_attributes_elements.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with an Attributes element with 1 Attribute element
+     * @throws NamingException 
+     */
+    public void testRequestWithAttributes1Attribute() throws NamingException
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_attributes_1_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Attributes attributes = searchRequest.getAttributes();
+        
+        assertEquals( 1, attributes.size() );
+        
+        NamingEnumeration ne = attributes.getAll();
+        
+        Attribute attribute = ( Attribute ) ne.next();
+        
+        assertEquals( "sn", attribute.getID() );
+    }
+    
+    /**
+     * Test parsing of a request with an Attributes element with 2 Attribute elements
+     * @throws NamingException 
+     */
+    public void testRequestWithAttributes2Attribute() throws NamingException
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "request_with_attributes_2_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Attributes attributes = searchRequest.getAttributes();
+        
+        assertEquals( 2, attributes.size() );
+        
+        NamingEnumeration ne = attributes.getAll();
+        
+        Attribute attribute = ( Attribute ) ne.next();
+        
+        assertEquals( "givenname", attribute.getID() );
+        
+        attribute = ( Attribute ) ne.next();
+        
+        assertEquals( "sn", attribute.getID() );
+    }
+    
+    /**
+     * Test parsing of a request with 1 Attribute without name attribute
+     */
+    public void testRequestWithAttributeWithoutNameAttribute()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_attribute_without_name_attribute.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with empty Filter element
+     */
+    public void testRequestWithEmptyFilter()
+    {
+        testParsingFail( SearchRequestTest.class, "request_with_empty_filter.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with an And Filter
+     */
+    public void testRequestWithAndFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_and.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof AndFilter);
+    }
+    
+    /**
+     * Test parsing of a request with an Or Filter
+     */
+    public void testRequestWithOrFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_or.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof OrFilter);
+    }
+    
+    /**
+     * Test parsing of a request with an Or Filter
+     */
+    public void testRequestWithNotFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_not.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof NotFilter);
+    }
+    
+    /**
+     * Test parsing of a request with empty Filter element
+     */
+    public void testRequestWithNotFilterWith2Children()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_not_with_2_children.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with an approxMatch Filter
+     */
+    public void testRequestWithApproxMatchFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_approxMatch.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof AttributeValueAssertionFilter );
+        
+        AttributeValueAssertionFilter approxMatchFilter = ( AttributeValueAssertionFilter ) filter;
+        
+        assertEquals( LdapConstants.APPROX_MATCH_FILTER, approxMatchFilter.getFilterType() );
+        
+        AttributeValueAssertion assertion = approxMatchFilter.getAssertion();
+        
+        assertEquals( "sn", assertion.getAttributeDesc() );
+        
+        assertEquals( "foobar", assertion.getAssertionValue() );
+    }
+    
+    
+    /**
+     * Test parsing of a request with approxMatch Filter but no name attribute
+     */
+    public void testRequestWithApproxMatchFilterWithoutName()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_approxMatch_without_name.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with approxMatch Filter but no value element
+     */
+    public void testRequestWithApproxMatchFilterWithoutValue()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_approxMatch_without_value.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with approxMatch Filter with 2 Value elements
+     */
+    public void testRequestWithApproxMatchFilterWith2Values()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_approxMatch_with_2_values.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with an greaterOrEqual Filter
+     */
+    public void testRequestWithGreaterOrEqualFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_greaterOrEqual.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof AttributeValueAssertionFilter );
+        
+        AttributeValueAssertionFilter approxMatchFilter = ( AttributeValueAssertionFilter ) filter;
+        
+        assertEquals( LdapConstants.GREATER_OR_EQUAL_FILTER, approxMatchFilter.getFilterType() );
+        
+        AttributeValueAssertion assertion = approxMatchFilter.getAssertion();
+        
+        assertEquals( "sn", assertion.getAttributeDesc() );
+        
+        assertEquals( "foobar", assertion.getAssertionValue() );
+    }
+    
+    /**
+     * Test parsing of a request with greaterOrEqual Filter but no name attribute
+     */
+    public void testRequestWithGreaterOrEqualFilterWithoutName()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_greaterOrEqual_without_name.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with greaterOrEqual Filter but no value element
+     */
+    public void testRequestWithGreaterOrEqualFilterWithoutValue()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_greaterOrEqual_without_value.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with greaterOrEqual Filter with 2 Value elements
+     */
+    public void testRequestWithGreaterOrEqualFilterWith2Values()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_greaterOrEqual_with_2_values.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with an lessOrEqual Filter
+     */
+    public void testRequestWithLessOrEqualFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_lessOrEqual.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof AttributeValueAssertionFilter );
+        
+        AttributeValueAssertionFilter approxMatchFilter = ( AttributeValueAssertionFilter ) filter;
+        
+        assertEquals( LdapConstants.LESS_OR_EQUAL_FILTER, approxMatchFilter.getFilterType() );
+        
+        AttributeValueAssertion assertion = approxMatchFilter.getAssertion();
+        
+        assertEquals( "sn", assertion.getAttributeDesc() );
+        
+        assertEquals( "foobar", assertion.getAssertionValue() );
+    }
+    
+    /**
+     * Test parsing of a request with lessOrEqual Filter but no name attribute
+     */
+    public void testRequestWithLessOrEqualFilterWithoutName()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_lessOrEqual_without_name.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with lessOrEqual Filter but no value element
+     */
+    public void testRequestWithLessOrEqualFilterWithoutValue()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_lessOrEqual_without_value.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with lessOrEqual Filter with 2 Value elements
+     */
+    public void testRequestWithLessOrEqualFilterWith2Values()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_lessOrEqual_with_2_values.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with an Equality Filter
+     */
+    public void testRequestWithEqualityMatchFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_equalityMatch.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof AttributeValueAssertionFilter );
+        
+        AttributeValueAssertionFilter approxMatchFilter = ( AttributeValueAssertionFilter ) filter;
+        
+        assertEquals( LdapConstants.EQUALITY_MATCH_FILTER, approxMatchFilter.getFilterType() );
+        
+        AttributeValueAssertion assertion = approxMatchFilter.getAssertion();
+        
+        assertEquals( "sn", assertion.getAttributeDesc() );
+        
+        assertEquals( "foobar", assertion.getAssertionValue() );
+    }
+    
+    /**
+     * Test parsing of a request with EqualityMatch Filter but no name attribute
+     */
+    public void testRequestWithEqualityMatchFilterWithoutName()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_equalityMatch_without_name.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with EqualityMatch Filter but no value element
+     */
+    public void testRequestWithEqualityMatchFilterWithoutValue()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_equalityMatch_without_value.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with EqualityMatch Filter with 2 Value elements
+     */
+    public void testRequestWithEqualityMatchFilterWith2Values()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_equalityMatch_with_2_values.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with an Present Filter
+     */
+    public void testRequestWithPresentFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_present.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof PresentFilter );
+        
+        PresentFilter presentFilter = ( PresentFilter ) filter;
+                
+        assertEquals( "givenName", presentFilter.getAttributeDescription().toString() );
+    }
+    
+    /**
+     * Test parsing of a request with Present Filter without name attribute
+     */
+    public void testRequestWithPresentWithoutName()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_present_without_name.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with an ExtensibleMatch Filter
+     */
+    public void testRequestWithExtensibleMatchFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof ExtensibleMatchFilter );
+        
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
+                
+        assertEquals( "A Value", extensibleMatchFilter.getMatchValue() );
+        
+        assertEquals( false, extensibleMatchFilter.isDnAttributes() );
+    }
+    
+    /**
+     * Test parsing of a request with ExtensibleMatch Filter without Value element
+     */
+    public void testRequestWithExtensibleMatchWithoutValue()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_extensibleMatch_without_value.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with ExtensibleMatch Filter with 2 Value elements
+     */
+    public void testRequestWithExtensibleMatchWith2Values()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_extensibleMatch_with_2_values.xml" );
+    }
+    
+
+    /**
+     * Test parsing of a request with typesOnly to true
+     */
+    public void testRequestWithExtensibleMatchWithDnAttributesTrue()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch_with_dnAttributes_true.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof ExtensibleMatchFilter );
+        
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
+        
+        assertTrue( extensibleMatchFilter.isDnAttributes() );
+    }
+    
+    
+    /**
+     * Test parsing of a request with typesOnly to 1
+     */
+    public void testRequestWithExtensibleMatchWithDnAttributes1()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch_with_dnAttributes_1.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof ExtensibleMatchFilter );
+        
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
+        
+        assertTrue( extensibleMatchFilter.isDnAttributes() );
+    }
+    
+    /**
+     * Test parsing of a request with typesOnly to false
+     */
+    public void testRequestWithExtensibleMatchWithDnAttributesFalse()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch_with_dnAttributes_false.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof ExtensibleMatchFilter );
+        
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
+        
+        assertFalse( extensibleMatchFilter.isDnAttributes() );
+    }
+    
+
+    /**
+     * Test parsing of a request with typesOnly to 0
+     */
+    public void testRequestWithExtensibleMatchWithDnAttributes0()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch_with_dnAttributes_0.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof ExtensibleMatchFilter );
+        
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
+        
+        assertFalse( extensibleMatchFilter.isDnAttributes() );
+    }
+    
+    /**
+     * Test parsing of a request with typesOnly to an error value
+     */
+    public void testRequestWithExtensibleMatchWithDnAttributesError()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_extensibleMatch_with_dnAttributes_error.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with a matchingRule attribute
+     */
+    public void testRequestWithExtensibleMatchWithMatchingRule()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch_with_matchingRule.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof ExtensibleMatchFilter );
+        
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
+        
+        assertEquals( "AMatchingRuleName", extensibleMatchFilter.getMatchingRule().toString() );
+    }
+    
+    /**
+     * Test parsing of a request with a name attribute
+     */
+    public void testRequestWithExtensibleMatchWithName()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_extensibleMatch_with_name.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof ExtensibleMatchFilter );
+        
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) filter;
+        
+        assertEquals( "givenName", extensibleMatchFilter.getType().toString() );
+    }
+    
+    /**
+     * Test parsing of a request with an Substrings Filter
+     */
+    public void testRequestWithSubstringsFilter()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_substrings.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof SubstringFilter );
+        
+        SubstringFilter substringFilter = ( SubstringFilter ) filter;
+                
+        assertEquals( "sn", substringFilter.getType().toString() );
+    }
+    
+    /**
+     * Test parsing of a request with Substrings Filter without name
+     */
+    public void testRequestWithSubstringsWithoutName()
+    {
+        testParsingFail( SearchRequestTest.class, "filters/request_with_substrings_without_name.xml" );
+    }
+    
+    /**
+     * Test parsing of a request with a Substrings Filter with 1 Initial element
+     */
+    public void testRequestWithSubstrings1Initial()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_substrings_1_initial.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof SubstringFilter );
+        
+        SubstringFilter substringFilter = ( SubstringFilter ) filter;
+        
+        assertEquals( "jack", substringFilter.getInitialSubstrings().toString() );
+    }
+    
+    /**
+     * Test parsing of a request with a Substrings Filter with 1 Initial and 1 Any elements
+     */
+    public void testRequestWithSubstrings1Initial1Any()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_substrings_1_initial_1_any.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof SubstringFilter );
+        
+        SubstringFilter substringFilter = ( SubstringFilter ) filter;
+        
+        assertEquals( "jack", substringFilter.getInitialSubstrings().toString() );
+        
+        ArrayList initials = substringFilter.getAnySubstrings();
+        
+        assertEquals( 1, initials.size() );
+        
+        assertEquals( "kate", initials.get( 0 ).toString() );
+    }
+    
+    /**
+     * Test parsing of a request with a Substrings Filter with 1 Initial and 1 Final elements
+     */
+    public void testRequestWithSubstrings1Initial1Final()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_substrings_1_initial_1_final.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof SubstringFilter );
+        
+        SubstringFilter substringFilter = ( SubstringFilter ) filter;
+        
+        assertEquals( "jack", substringFilter.getInitialSubstrings().toString() );
+
+        assertEquals( "john", substringFilter.getFinalSubstrings().toString() );
+    }
+    
+    /**
+     * Test parsing of a request with a Substrings Filter with 1 Any element
+     */
+    public void testRequestWithSubstrings1Any()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_substrings_1_any.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof SubstringFilter );
+        
+        SubstringFilter substringFilter = ( SubstringFilter ) filter;
+        
+        ArrayList initials = substringFilter.getAnySubstrings();
+        
+        assertEquals( 1, initials.size() );
+        
+        assertEquals( "kate", initials.get( 0 ).toString() );
+    }
+    
+    /**
+     * Test parsing of a request with a Substrings Filter with 1 Any element
+     */
+    public void testRequestWithSubstrings2Any()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_substrings_2_any.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof SubstringFilter );
+        
+        SubstringFilter substringFilter = ( SubstringFilter ) filter;
+        
+        ArrayList initials = substringFilter.getAnySubstrings();
+        
+        assertEquals( 2, initials.size() );
+        
+        assertEquals( "kate", initials.get( 0 ).toString() );
+        
+        assertEquals( "sawyer", initials.get( 1 ).toString() );
+    }
+    
+    /**
+     * Test parsing of a request with a Substrings Filter with 1 Any and 1 Final elements
+     */
+    public void testRequestWithSubstrings1Any1Final()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_substrings_1_any_1_final.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof SubstringFilter );
+        
+        SubstringFilter substringFilter = ( SubstringFilter ) filter;
+        
+        ArrayList initials = substringFilter.getAnySubstrings();
+        
+        assertEquals( 1, initials.size() );
+        
+        assertEquals( "kate", initials.get( 0 ).toString() );
+        
+        assertEquals( "john", substringFilter.getFinalSubstrings().toString() );
+    }
+    
+    /**
+     * Test parsing of a request with a Substrings Filter with 1 Final element
+     */
+    public void testRequestWithSubstrings1Final()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+            
+            parser.setInputFile( SearchRequestTest.class.getResource( "filters/request_with_substrings_1_final.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchRequest searchRequest = ( SearchRequest ) parser.getBatchRequest().getCurrentRequest();
+        
+        Filter filter = searchRequest.getFilter();
+
+        assertTrue( filter instanceof SubstringFilter );
+        
+        SubstringFilter substringFilter = ( SubstringFilter ) filter;
+        
+        assertEquals( "john", substringFilter.getFinalSubstrings().toString() );
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/SearchResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/SearchResponseTest.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/SearchResponseTest.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/SearchResponseTest.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,266 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2.searchResponse;
+
+import org.apache.directory.ldapstudio.dsmlv2.AbstractResponseTest;
+import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResponse;
+
+/**
+ * Tests for the Search Result Done Response parsing
+ */
+public class SearchResponseTest extends AbstractResponseTest
+{
+	 /**
+     * Test parsing of a Response with the (optional) requestID attribute
+     */
+    public void testResponseWithRequestId()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResponse searchResponse = ( SearchResponse ) parser.getBatchResponse().getCurrentResponse();
+        
+        assertEquals( 456, searchResponse.getMessageId() );
+    }
+    
+    
+	 /**
+     * Test parsing of a Response with a Search Result Done
+     */
+    public void testResponseWithSRD()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResponseTest.class.getResource( "response_with_1_SRD.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResponse searchResponse = ( SearchResponse ) parser.getBatchResponse().getCurrentResponse();
+        
+        assertNotNull( searchResponse.getSearchResultDone() );
+    }
+    
+	 /**
+     * Test parsing of a Response with 1 Search Result Entry and a Search Result Done
+     */
+    public void testResponseWith1SRE1SRD()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResponseTest.class.getResource( "response_with_1_SRE_1_SRD.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResponse searchResponse = ( SearchResponse ) parser.getBatchResponse().getCurrentResponse();
+        
+        assertEquals( 1, searchResponse.getSearchResultEntryList().size() );
+        
+        assertNotNull( searchResponse.getSearchResultDone() );
+    }
+    
+    
+	 /**
+     * Test parsing of a Response with 1 Search Result Reference and a Search Result Done
+     */
+    public void testResponseWith1SRR1SRD()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResponseTest.class.getResource( "response_with_1_SRR_1_SRD.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResponse searchResponse = ( SearchResponse ) parser.getBatchResponse().getCurrentResponse();
+        
+        assertEquals( 1, searchResponse.getSearchResultReferenceList().size() );
+        
+        assertNotNull( searchResponse.getSearchResultDone() );
+    }
+    
+    /**
+     * Test parsing of a Response with 1 Search Result Entry, 1 Search Result Reference and a Search Result Done
+     */
+    public void testResponseWith1SRE1SRR1SRD()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResponseTest.class.getResource( "response_with_1_SRE_1_SRR_1_SRD.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResponse searchResponse = ( SearchResponse ) parser.getBatchResponse().getCurrentResponse();
+        
+        assertEquals( 1, searchResponse.getSearchResultEntryList().size() );
+        
+        assertEquals( 1, searchResponse.getSearchResultReferenceList().size() );
+        
+        assertNotNull( searchResponse.getSearchResultDone() );
+    }
+    
+    /**
+     * Test parsing of a Response with 2 Search Result Entry and a Search Result Done
+     */
+    public void testResponseWith2SRE1SRD()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResponseTest.class.getResource( "response_with_2_SRE_1_SRD.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResponse searchResponse = ( SearchResponse ) parser.getBatchResponse().getCurrentResponse();
+        
+        assertEquals( 2, searchResponse.getSearchResultEntryList().size() );
+        
+        assertNotNull( searchResponse.getSearchResultDone() );
+    }
+    
+    /**
+     * Test parsing of a Response with 2 Search Result Reference and a Search Result Done
+     */
+    public void testResponseWith2SRR1SRD()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResponseTest.class.getResource( "response_with_2_SRR_1_SRD.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResponse searchResponse = ( SearchResponse ) parser.getBatchResponse().getCurrentResponse();
+        
+        assertEquals( 2, searchResponse.getSearchResultReferenceList().size() );
+        
+        assertNotNull( searchResponse.getSearchResultDone() );
+    }
+    
+    /**
+     * Test parsing of a Response with 2 Search Result Entry, 2 Search Result Reference and a Search Result Done
+     */
+    public void testResponseWith2SRE2SRR1SRD()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResponseTest.class.getResource( "response_with_2_SRE_2_SRR_1_SRD.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResponse searchResponse = ( SearchResponse ) parser.getBatchResponse().getCurrentResponse();
+        
+        assertEquals( 2, searchResponse.getSearchResultEntryList().size() );
+        
+        assertEquals( 2, searchResponse.getSearchResultReferenceList().size() );
+        
+        assertNotNull( searchResponse.getSearchResultDone() );
+    }
+    
+    
+    /**
+     * Test parsing of a response with no Search Result Done
+     */
+    public void testResponseWith0SRD()
+    {
+        testParsingFail( SearchResponseTest.class, "response_with_0_SRD.xml");
+    }
+    
+    /**
+     * Test parsing of a response with 1 Search Result Entry but no Search Result Done
+     */
+    public void testResponseWith1SRE0SRD()
+    {
+        testParsingFail( SearchResponseTest.class, "response_with_1_SRE_0_SRD.xml");
+    }
+    
+    /**
+     * Test parsing of a response with 1 Search Result Reference but no Search Result Done
+     */
+    public void testResponseWith1SRR0SRD()
+    {
+        testParsingFail( SearchResponseTest.class, "response_with_1_SRR_0_SRD.xml");
+    }
+}

Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultDone/SearchResultDoneTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultDone/SearchResultDoneTest.java?view=auto&rev=475805
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultDone/SearchResultDoneTest.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/searchResponse/searchResultDone/SearchResultDoneTest.java Thu Nov 16 08:38:31 2006
@@ -0,0 +1,402 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.ldapstudio.dsmlv2.searchResponse.searchResultDone;
+
+import java.util.List;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.ldapstudio.dsmlv2.AbstractResponseTest;
+import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
+import org.apache.directory.ldapstudio.dsmlv2.reponse.SearchResponse;
+import org.apache.directory.shared.ldap.codec.Control;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import com.sun.jndi.ldap.LdapURL;
+
+/**
+ * Tests for the Search Result Done Response parsing
+ */
+public class SearchResultDoneTest extends AbstractResponseTest
+{
+    /**
+     * Test parsing of a response with a (optional) Control element
+     */
+    public void testResponseWith1Control()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_1_control.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        assertEquals( 1, searchResultDone.getControls().size() );
+        
+        Control control = searchResultDone.getCurrentControl();
+        
+        assertTrue( control.getCriticality() );
+        
+        assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
+        
+        assertEquals( "Some text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
+    }
+    
+
+    /**
+     * Test parsing of a response with 2 (optional) Control elements
+     */
+    public void testResponseWith2Controls()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_2_controls.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        assertEquals( 2, searchResultDone.getControls().size() );
+        
+        Control control = searchResultDone.getCurrentControl();
+        
+        assertFalse( control.getCriticality() );
+        
+        assertEquals( "1.2.840.113556.1.4.789", control.getControlType() );
+        
+        assertEquals( "Some other text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
+    }
+    
+    /**
+     * Test parsing of a response with 3 (optional) Control elements without value
+     */
+    public void testResponseWith3ControlsWithoutValue()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_3_controls_without_value.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        assertEquals( 3, searchResultDone.getControls().size() );
+        
+        Control control = searchResultDone.getCurrentControl();
+        
+        assertTrue( control.getCriticality() );
+        
+        assertEquals( "1.2.840.113556.1.4.456", control.getControlType() );
+        
+        assertEquals( StringTools.EMPTY_BYTES, control.getControlValue() );
+    }
+    
+
+    /**
+     * Test parsing of a Response with the (optional) requestID attribute
+     */
+    public void testResponseWithRequestId()
+    {
+        Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+        
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        assertEquals( 456, searchResultDone.getMessageId() );
+    }
+       
+    
+    /**
+     * Test parsing of a response without Result Code element
+     */
+    public void testResponseWithoutResultCode()
+    {
+        testParsingFail( SearchResultDoneTest.class, "response_without_result_code.xml");
+    }
+    
+    /**
+     * Test parsing of a response with Result Code element but a not integer value
+     */
+    public void testResponseWithResultCodeNotInteger()
+    {
+        testParsingFail( SearchResultDoneTest.class, "response_with_result_code_not_integer.xml");
+    }
+    
+    /**
+     * Test parsing of a response with Result Code 
+     */
+    public void testResponseWithResultCode()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_result_code.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        LdapResult ldapResult = searchResultDone.getLdapResult();
+        
+        assertEquals( 2, ldapResult.getResultCode() );
+    }
+    
+    /**
+     * Test parsing of a response with Error Message
+     */
+    public void testResponseWithErrorMessage()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_error_message.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        LdapResult ldapResult = searchResultDone.getLdapResult();
+        
+        assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult.getErrorMessage() );
+    }
+    
+    /**
+     * Test parsing of a response with a Referral
+     */
+    public void testResponseWith1Referral()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_1_referral.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        LdapResult ldapResult = searchResultDone.getLdapResult();
+        
+        List referrals = ldapResult.getReferrals();
+        
+        assertEquals( 1, referrals.size() );
+        
+        Object referral = referrals.get( 0 );
+        
+        try 
+        {
+			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+		} 
+        catch (NamingException e)
+        {
+			fail();
+		}
+    }
+    
+    /**
+     * Test parsing of a response with 2 Referral elements
+     */
+    public void testResponseWith2Referrals()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_2_referrals.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        LdapResult ldapResult = searchResultDone.getLdapResult();
+        
+        List referrals = ldapResult.getReferrals();
+        
+        assertEquals( 2, referrals.size() );
+        
+        Object referral = referrals.get( 0 );
+        
+        try 
+        {
+			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+		} 
+        catch (NamingException e)
+        {
+			fail();
+		}
+        
+        Object referral2 = referrals.get( 1 );
+        
+        try 
+        {
+			assertEquals( new LdapURL( "ldap://www.apple.com/" ).toString(), referral2.toString() );
+		} 
+        catch (NamingException e)
+        {
+			fail();
+		}
+    }
+    
+    /**
+     * Test parsing of a response with a Referral and an Error Message
+     */
+    public void testResponseWith1ReferralAndAnErrorMessage()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_1_referral_and_error_message.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        LdapResult ldapResult = searchResultDone.getLdapResult();
+        
+        List referrals = ldapResult.getReferrals();
+        
+        assertEquals( 1, referrals.size() );
+        
+        Object referral = referrals.get( 0 );
+        
+        try 
+        {
+			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+		} 
+        catch (NamingException e)
+        {
+			fail();
+		}
+    }
+    
+    /**
+     * Test parsing of a response with MatchedDN attribute
+     */
+    public void testResponseWithMatchedDNAttribute()
+    {
+    	Dsmlv2ResponseParser parser = null;
+        try
+        {
+            parser = new Dsmlv2ResponseParser();
+            
+            parser.setInputFile( SearchResultDoneTest.class.getResource( "response_with_matchedDN_attribute.xml" ).getFile() );
+        
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        SearchResultDone searchResultDone = ( ( SearchResponse ) parser.getBatchResponse().getCurrentResponse() ).getSearchResultDone();
+        
+        LdapResult ldapResult = searchResultDone.getLdapResult();
+        
+        assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", ldapResult.getMatchedDN() );
+    }
+    
+    /**
+     * Test parsing of a response with wrong matched DN
+     */
+    public void testResponseWithWrongMatchedDN()
+    {
+        testParsingFail( SearchResultDoneTest.class, "response_with_wrong_matchedDN_attribute.xml");
+    }
+    
+    /**
+     * Test parsing of a response with wrong Descr attribute
+     */
+    public void testResponseWithWrongDescr()
+    {
+        testParsingFail( SearchResultDoneTest.class, "response_with_wrong_descr.xml");
+    }
+}



Mime
View raw message