directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r483066 [6/10] - in /directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src: main/java/org/apache/directory/ldapstudio/dsmlv2/ main/java/org/apache/directory/ldapstudio/dsmlv2/engine/ main/java/org/apache/directory/ldapstudio/ds...
Date Wed, 06 Dec 2006 13:17:46 GMT
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addRequest/AddRequestTest.java Wed Dec  6 05:17:42 2006
@@ -20,6 +20,7 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.addRequest;
 
+
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
@@ -31,6 +32,7 @@
 import org.apache.directory.shared.ldap.codec.add.AddRequest;
 import org.apache.directory.shared.ldap.util.StringTools;
 
+
 /**
  * Tests for the Add Request parsing
  */
@@ -43,7 +45,8 @@
     {
         testParsingFail( AddRequestTest.class, "request_without_dn_attribute.xml" );
     }
-    
+
+
     /**
      * Test parsing of a request with the dn attribute
      */
@@ -53,21 +56,22 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AddRequestTest.class.getResource( "request_with_dn_attribute.xml" ).getFile() );
-      
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", addRequest.getEntry().toString() );
     }
-    
+
+
     /**
      * Test parsing of a request with the (optional) requestID attribute
      */
@@ -77,21 +81,21 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AddRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 456, addRequest.getMessageId() );
     }
-    
+
 
     /**
      * Test parsing of a request with a (optional) Control element
@@ -102,29 +106,63 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AddRequestTest.class.getResource( "request_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 1, addRequest.getControls().size() );
-        
+
         Control control = addRequest.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 a (optional) Control element with empty value
+     */
+    public void testRequestWith1ControlEmptyValue()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser
+                .setInputFile( AddRequestTest.class.getResource( "request_with_1_control_empty_value.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        assertEquals( 1, addRequest.getControls().size() );
+
+        Control control = addRequest.getCurrentControl();
+
+        assertTrue( control.getCriticality() );
+
+        assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
+
+        assertEquals( StringTools.EMPTY_BYTES, control.getControlValue() );
+    }
+
 
     /**
      * Test parsing of a request with 2 (optional) Control elements
@@ -135,29 +173,30 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AddRequestTest.class.getResource( "request_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 2, addRequest.getControls().size() );
-        
+
         Control control = addRequest.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
      */
@@ -167,29 +206,31 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( AddRequestTest.class.getResource( "request_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( AddRequestTest.class.getResource( "request_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 3, addRequest.getControls().size() );
-        
+
         Control control = addRequest.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 with an Attr elements with value
      */
@@ -199,25 +240,25 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( AddRequestTest.class.getResource( "request_with_1_attr_with_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( AddRequestTest.class.getResource( "request_with_1_attr_without_value.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         Attributes attributes = addRequest.getAttributes();
-        
+
         assertEquals( 1, attributes.size() );
-        
+
         // Getting the Attribute       
         NamingEnumeration ne = attributes.getAll();
-        
+
         Attribute attribute = null;
         try
         {
@@ -227,10 +268,79 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "objectclass", attribute.getID() );
+
+        // Getting the Value
+        NamingEnumeration ne2 = null;
+        try
+        {
+            ne2 = attribute.getAll();
+        }
+        catch ( NamingException e )
+        {
+            fail( e.getMessage() );
+        }
+
+        assertFalse( ne2.hasMoreElements() );
     }
-    
+
+
+    /**
+     * Test parsing of a request with an Attr elements with empty value
+     */
+    public void testRequestWith1AttrEmptyValue()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser.setInputFile( AddRequestTest.class.getResource( "request_with_1_attr_empty_value.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        Attributes attributes = addRequest.getAttributes();
+
+        assertEquals( 1, attributes.size() );
+
+        // Getting the Attribute       
+        NamingEnumeration ne = attributes.getAll();
+
+        Attribute attribute = null;
+        try
+        {
+            attribute = ( Attribute ) ne.next();
+        }
+        catch ( NamingException e )
+        {
+            fail( e.getMessage() );
+        }
+
+        assertEquals( "objectclass", attribute.getID() );
+
+        // Getting the Value
+        NamingEnumeration ne2 = null;
+        try
+        {
+            ne2 = attribute.getAll();
+        }
+        catch ( NamingException e )
+        {
+            fail( e.getMessage() );
+        }
+
+        assertFalse( ne2.hasMoreElements() );
+    }
+
+
     /**
      * Test parsing of a request with an Attr elements without value
      */
@@ -240,25 +350,25 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( AddRequestTest.class.getResource( "request_with_1_attr_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( AddRequestTest.class.getResource( "request_with_1_attr_with_value.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         Attributes attributes = addRequest.getAttributes();
-        
+
         assertEquals( 1, attributes.size() );
-        
+
         // Getting the Attribute       
         NamingEnumeration ne = attributes.getAll();
-        
+
         Attribute attribute = null;
         try
         {
@@ -268,9 +378,9 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "objectclass", attribute.getID() );
-        
+
         // Getting the Value
         NamingEnumeration ne2 = null;
         try
@@ -281,7 +391,7 @@
         {
             fail( e.getMessage() );
         }
-        
+
         String value = null;
         try
         {
@@ -291,10 +401,11 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "top", value );
     }
-    
+
+
     /**
      * Test parsing of a request with 2 Attr elements with value
      */
@@ -304,25 +415,25 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AddRequestTest.class.getResource( "request_with_2_attr_with_value.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         Attributes attributes = addRequest.getAttributes();
-        
+
         assertEquals( 1, attributes.size() );
-        
+
         // Getting the Attribute       
         NamingEnumeration ne = attributes.getAll();
-        
+
         Attribute attribute = null;
         try
         {
@@ -332,9 +443,9 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "objectclass", attribute.getID() );
-        
+
         // Getting the Value
         NamingEnumeration ne2 = null;
         try
@@ -345,7 +456,7 @@
         {
             fail( e.getMessage() );
         }
-        
+
         String value = null;
         try
         {
@@ -355,9 +466,9 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "top", value );
-        
+
         try
         {
             value = ( String ) ne2.next();
@@ -366,18 +477,19 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "person", value );
     }
-    
+
+
     /**
      * Test parsing of a request with 1 Attr element without attribute value
      */
     public void testRequestWith1AttrWithoutNameAttribute()
     {
-        testParsingFail( AddRequestTest.class, "request_with_1_attr_without_name_attribute.xml");
+        testParsingFail( AddRequestTest.class, "request_with_1_attr_without_name_attribute.xml" );
     }
-    
+
 
     /**
      * Test parsing of a request with 1 Attr element with 2 Values
@@ -388,25 +500,25 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AddRequestTest.class.getResource( "request_with_1_attr_with_2_values.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddRequest addRequest = ( AddRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         Attributes attributes = addRequest.getAttributes();
-        
+
         assertEquals( 1, attributes.size() );
-        
+
         // Getting the Attribute       
         NamingEnumeration ne = attributes.getAll();
-        
+
         Attribute attribute = null;
         try
         {
@@ -416,9 +528,9 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "objectclass", attribute.getID() );
-        
+
         // Getting the Value
         NamingEnumeration ne2 = null;
         try
@@ -429,7 +541,7 @@
         {
             fail( e.getMessage() );
         }
-        
+
         String value = null;
         try
         {
@@ -439,9 +551,9 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "top", value );
-        
+
         try
         {
             value = ( String ) ne2.next();
@@ -450,7 +562,7 @@
         {
             fail( e.getMessage() );
         }
-        
+
         assertEquals( "person", value );
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/addResponse/AddResponseTest.java Wed Dec  6 05:17:42 2006
@@ -20,6 +20,7 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.addResponse;
 
+
 import java.util.List;
 
 import javax.naming.NamingException;
@@ -33,13 +34,13 @@
 
 import com.sun.jndi.ldap.LdapURL;
 
+
 /**
  * Tests for the Add Response parsing
  */
 public class AddResponseTest extends AbstractResponseTest
 {
-    
-    
+
     /**
      * Test parsing of a Response with the (optional) requestID attribute
      */
@@ -49,34 +50,35 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( AddResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( AddResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 456, addResponse.getMessageId() );
     }
-    
+
 
     /**
      * Test parsing of a response with a (optional) Control element
      */
     public void testResponseWith1Control()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AddResponseTest.class.getResource( "response_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -85,63 +87,65 @@
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 1, addResponse.getControls().size() );
-        
+
         Control control = addResponse.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;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AddResponseTest.class.getResource( "response_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 2, addResponse.getControls().size() );
-        
+
         Control control = addResponse.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;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( AddResponseTest.class.getResource( "response_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( AddResponseTest.class.getResource( "response_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -150,46 +154,49 @@
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 3, addResponse.getControls().size() );
-        
+
         Control control = addResponse.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 without Result Code element
      */
     public void testResponseWithoutResultCode()
     {
-        testParsingFail( AddResponseTest.class, "response_without_result_code.xml");
+        testParsingFail( AddResponseTest.class, "response_without_result_code.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with Result Code element but a not integer value
      */
     public void testResponseWithResultCodeNotInteger()
     {
-        testParsingFail( AddResponseTest.class, "response_with_result_code_not_integer.xml");
+        testParsingFail( AddResponseTest.class, "response_with_result_code_not_integer.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with Result Code 
      */
     public void testResponseWithResultCode()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AddResponseTest.class.getResource( "response_with_result_code.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -198,24 +205,25 @@
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = addResponse.getLdapResult();
-        
+
         assertEquals( 2, ldapResult.getResultCode() );
     }
-    
+
+
     /**
      * Test parsing of a response with Error Message
      */
     public void testResponseWithErrorMessage()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AddResponseTest.class.getResource( "response_with_error_message.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -224,63 +232,66 @@
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = addResponse.getLdapResult();
-        
-        assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult.getErrorMessage() );
+
+        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;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AddResponseTest.class.getResource( "response_with_1_referral.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
-        	fail( e.getMessage() );
+            fail( e.getMessage() );
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = addResponse.getLdapResult();
-        
+
         List referrals = ldapResult.getReferrals();
-        
+
         assertEquals( 1, referrals.size() );
-        
+
         Object referral = referrals.get( 0 );
-        
-        try 
+
+        try
         {
-			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
-		} 
-        catch (NamingException e)
+            assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+        }
+        catch ( NamingException e )
         {
-			fail();
-		}
+            fail();
+        }
     }
-    
+
+
     /**
      * Test parsing of a response with 2 Referral elements
      */
     public void testResponseWith2Referrals()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AddResponseTest.class.getResource( "response_with_2_referrals.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -289,48 +300,50 @@
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = addResponse.getLdapResult();
-        
+
         List referrals = ldapResult.getReferrals();
-        
+
         assertEquals( 2, referrals.size() );
-        
+
         Object referral = referrals.get( 0 );
-        
-        try 
+
+        try
+        {
+            assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+        }
+        catch ( NamingException e )
         {
-			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
-		} 
-        catch (NamingException e)
-        {
-			fail();
-		}
-        
+            fail();
+        }
+
         Object referral2 = referrals.get( 1 );
-        
-        try 
+
+        try
         {
-			assertEquals( new LdapURL( "ldap://www.apple.com/" ).toString(), referral2.toString() );
-		} 
-        catch (NamingException e)
+            assertEquals( new LdapURL( "ldap://www.apple.com/" ).toString(), referral2.toString() );
+        }
+        catch ( NamingException e )
         {
-			fail();
-		}
+            fail();
+        }
     }
-    
+
+
     /**
      * Test parsing of a response with a Referral and an Error Message
      */
     public void testResponseWith1ReferralAndAnErrorMessage()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( AddResponseTest.class.getResource( "response_with_1_referral_and_error_message.xml" ).getFile() );
-        
+
+            parser.setInputFile( AddResponseTest.class.getResource( "response_with_1_referral_and_error_message.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -339,37 +352,39 @@
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = addResponse.getLdapResult();
-        
+
         List referrals = ldapResult.getReferrals();
-        
+
         assertEquals( 1, referrals.size() );
-        
+
         Object referral = referrals.get( 0 );
-        
-        try 
+
+        try
         {
-			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
-		} 
-        catch (NamingException e)
+            assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+        }
+        catch ( NamingException e )
         {
-			fail();
-		}
+            fail();
+        }
     }
-    
+
+
     /**
      * Test parsing of a response with MatchedDN attribute
      */
     public void testResponseWithMatchedDNAttribute()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( AddResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( AddResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -378,25 +393,27 @@
         }
 
         AddResponse addResponse = ( AddResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = addResponse.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( AddResponseTest.class, "response_with_wrong_matchedDN_attribute.xml");
+        testParsingFail( AddResponseTest.class, "response_with_wrong_matchedDN_attribute.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with wrong Descr attribute
      */
     public void testResponseWithWrongDescr()
     {
-        testParsingFail( AddResponseTest.class, "response_with_wrong_descr.xml");
+        testParsingFail( AddResponseTest.class, "response_with_wrong_descr.xml" );
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authRequest/AuthRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authRequest/AuthRequestTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authRequest/AuthRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authRequest/AuthRequestTest.java Wed Dec  6 05:17:42 2006
@@ -20,25 +20,27 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.authRequest;
 
+
 import org.apache.directory.ldapstudio.dsmlv2.AbstractTest;
 import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2Parser;
 import org.apache.directory.shared.ldap.codec.Control;
 import org.apache.directory.shared.ldap.codec.bind.BindRequest;
 import org.apache.directory.shared.ldap.util.StringTools;
 
+
 /**
  * Tests for the Auth Request parsing
  */
 public class AuthRequestTest extends AbstractTest
-{ 
+{
     /**
      * Test parsing of a request without the principal attribute
      */
     public void testRequestWithoutPrincipal()
     {
-        testParsingFail( AuthRequestTest.class,"request_without_principal_attribute.xml" );
+        testParsingFail( AuthRequestTest.class, "request_without_principal_attribute.xml" );
     }
-    
+
 
     /**
      * Test parsing of a request with the principal attribute
@@ -49,21 +51,21 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AuthRequestTest.class.getResource( "request_with_principal_attribute.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BindRequest bindRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", bindRequest.getName().toString() );
     }
-    
+
 
     /**
      * Test parsing of a request with the (optional) requestID attribute
@@ -74,18 +76,18 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AuthRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 456, abandonRequest.getMessageId() );
     }
 
@@ -99,29 +101,63 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AuthRequestTest.class.getResource( "request_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 1, abandonRequest.getControls().size() );
-        
+
         Control control = abandonRequest.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 a (optional) Control element with empty value
+     */
+    public void testRequestWith1ControlEmptyValue()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser.setInputFile( AuthRequestTest.class.getResource( "request_with_1_control_empty_value.xml" )
+                .getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        assertEquals( 1, abandonRequest.getControls().size() );
+
+        Control control = abandonRequest.getCurrentControl();
+
+        assertTrue( control.getCriticality() );
+
+        assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
+
+        assertEquals( StringTools.EMPTY_BYTES, control.getControlValue() );
+    }
+
 
     /**
      * Test parsing of a request with 2 (optional) Control elements
@@ -132,29 +168,30 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( AuthRequestTest.class.getResource( "request_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 2, abandonRequest.getControls().size() );
-        
+
         Control control = abandonRequest.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
      */
@@ -164,26 +201,27 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( AuthRequestTest.class.getResource( "request_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( AuthRequestTest.class.getResource( "request_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 3, abandonRequest.getControls().size() );
-        
+
         Control control = abandonRequest.getCurrentControl();
-        
+
         assertTrue( control.getCriticality() );
-        
+
         assertEquals( "1.2.840.113556.1.4.456", control.getControlType() );
-        
+
         assertEquals( StringTools.EMPTY_BYTES, control.getControlValue() );
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/authResponse/AuthResponseTest.java Wed Dec  6 05:17:42 2006
@@ -20,6 +20,7 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.authResponse;
 
+
 import java.util.List;
 
 import javax.naming.NamingException;
@@ -33,13 +34,13 @@
 
 import com.sun.jndi.ldap.LdapURL;
 
+
 /**
  * Tests for the Auth Response parsing
  */
 public class AuthResponseTest extends AbstractResponseTest
 {
-    
-    
+
     /**
      * Test parsing of a Response with the (optional) requestID attribute
      */
@@ -49,34 +50,35 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_requestID_attribute.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 456, bindResponse.getMessageId() );
     }
-    
+
 
     /**
      * Test parsing of a response with a (optional) Control element
      */
     public void testResponseWith1Control()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AuthResponseTest.class.getResource( "response_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -85,63 +87,65 @@
         }
 
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 1, bindResponse.getControls().size() );
-        
+
         Control control = bindResponse.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;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AuthResponseTest.class.getResource( "response_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 2, bindResponse.getControls().size() );
-        
+
         Control control = bindResponse.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;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -150,46 +154,49 @@
         }
 
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 3, bindResponse.getControls().size() );
-        
+
         Control control = bindResponse.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 without Result Code element
      */
     public void testResponseWithoutResultCode()
     {
-        testParsingFail( AuthResponseTest.class, "response_without_result_code.xml");
+        testParsingFail( AuthResponseTest.class, "response_without_result_code.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with Result Code element but a not integer value
      */
     public void testResponseWithResultCodeNotInteger()
     {
-        testParsingFail( AuthResponseTest.class, "response_with_result_code_not_integer.xml");
+        testParsingFail( AuthResponseTest.class, "response_with_result_code_not_integer.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with Result Code 
      */
     public void testResponseWithResultCode()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AuthResponseTest.class.getResource( "response_with_result_code.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -198,24 +205,25 @@
         }
 
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = bindResponse.getLdapResult();
-        
+
         assertEquals( 2, ldapResult.getResultCode() );
     }
-    
+
+
     /**
      * Test parsing of a response with Error Message
      */
     public void testResponseWithErrorMessage()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AuthResponseTest.class.getResource( "response_with_error_message.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -224,24 +232,26 @@
         }
 
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = bindResponse.getLdapResult();
-        
-        assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult.getErrorMessage() );
+
+        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;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AuthResponseTest.class.getResource( "response_with_1_referral.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -250,37 +260,38 @@
         }
 
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = bindResponse.getLdapResult();
-        
+
         List referrals = ldapResult.getReferrals();
-        
+
         assertEquals( 1, referrals.size() );
-        
+
         Object referral = referrals.get( 0 );
-        
-        try 
+
+        try
         {
-			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
-		} 
-        catch (NamingException e)
+            assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+        }
+        catch ( NamingException e )
         {
-			fail();
-		}
+            fail();
+        }
     }
-    
+
+
     /**
      * Test parsing of a response with 2 Referral elements
      */
     public void testResponseWith2Referrals()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( AuthResponseTest.class.getResource( "response_with_2_referrals.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -289,48 +300,50 @@
         }
 
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = bindResponse.getLdapResult();
-        
+
         List referrals = ldapResult.getReferrals();
-        
+
         assertEquals( 2, referrals.size() );
-        
+
         Object referral = referrals.get( 0 );
-        
-        try 
+
+        try
+        {
+            assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+        }
+        catch ( NamingException e )
         {
-			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
-		} 
-        catch (NamingException e)
-        {
-			fail();
-		}
-        
+            fail();
+        }
+
         Object referral2 = referrals.get( 1 );
-        
-        try 
+
+        try
         {
-			assertEquals( new LdapURL( "ldap://www.apple.com/" ).toString(), referral2.toString() );
-		} 
-        catch (NamingException e)
+            assertEquals( new LdapURL( "ldap://www.apple.com/" ).toString(), referral2.toString() );
+        }
+        catch ( NamingException e )
         {
-			fail();
-		}
+            fail();
+        }
     }
-    
+
+
     /**
      * Test parsing of a response with a Referral and an Error Message
      */
     public void testResponseWith1ReferralAndAnErrorMessage()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_1_referral_and_error_message.xml" ).getFile() );
-        
+
+            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_1_referral_and_error_message.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -339,37 +352,39 @@
         }
 
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = bindResponse.getLdapResult();
-        
+
         List referrals = ldapResult.getReferrals();
-        
+
         assertEquals( 1, referrals.size() );
-        
+
         Object referral = referrals.get( 0 );
-        
-        try 
+
+        try
         {
-			assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
-		} 
-        catch (NamingException e)
+            assertEquals( new LdapURL( "ldap://www.apache.org/" ).toString(), referral.toString() );
+        }
+        catch ( NamingException e )
         {
-			fail();
-		}
+            fail();
+        }
     }
-    
+
+
     /**
      * Test parsing of a response with MatchedDN attribute
      */
     public void testResponseWithMatchedDNAttribute()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).getFile() );
-        
+
+            parser.setInputFile( AuthResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -378,25 +393,27 @@
         }
 
         BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = bindResponse.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( AuthResponseTest.class, "response_with_wrong_matchedDN_attribute.xml");
+        testParsingFail( AuthResponseTest.class, "response_with_wrong_matchedDN_attribute.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with wrong Descr attribute
      */
     public void testResponseWithWrongDescr()
     {
-        testParsingFail( AuthResponseTest.class, "response_with_wrong_matchedDN_attribute.xml");
+        testParsingFail( AuthResponseTest.class, "response_with_wrong_matchedDN_attribute.xml" );
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/batchRequest/BatchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/batchRequest/BatchRequestTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/batchRequest/BatchRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/batchRequest/BatchRequestTest.java Wed Dec  6 05:17:42 2006
@@ -20,6 +20,7 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.batchRequest;
 
+
 import java.util.List;
 
 import org.apache.directory.ldapstudio.dsmlv2.AbstractTest;
@@ -36,6 +37,7 @@
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequest;
 import org.apache.directory.shared.ldap.codec.search.SearchRequest;
 
+
 /**
  * Tests for the Compare Response parsing
  */
@@ -46,693 +48,715 @@
      */
     public void testResponseWithRequestId()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( BatchRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( BatchRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1234567890, batchRequest.getRequestID() );
     }
-    
+
+
     /**
      * Test parsing of a Request with the (optional) requestID attribute
      */
     public void testResponseWith0Request()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( BatchRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( BatchRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 0, batchRequest.getRequests().size() );
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 AuthRequest
      */
     public void testResponseWith1AuthRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_AuthRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof BindRequest ) 
+
+        if ( request instanceof BindRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 AddRequest
      */
     public void testResponseWith1AddRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_AddRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof AddRequest ) 
+
+        if ( request instanceof AddRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 CompareRequest
      */
     public void testResponseWith1CompareRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_CompareRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof CompareRequest ) 
+
+        if ( request instanceof CompareRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 AbandonRequest
      */
     public void testResponseWith1AbandonRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_AbandonRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof AbandonRequest ) 
+
+        if ( request instanceof AbandonRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 DelRequest
      */
     public void testResponseWith1DelRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_DelRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof DelRequest ) 
+
+        if ( request instanceof DelRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 ExtendedRequest
      */
     public void testResponseWith1ExtendedRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_ExtendedRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof ExtendedRequest ) 
+
+        if ( request instanceof ExtendedRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 ModDNRequest
      */
     public void testResponseWith1ModDNRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_ModDNRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof ModifyDNRequest ) 
+
+        if ( request instanceof ModifyDNRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 ModifyRequest
      */
     public void testResponseWith1ModifyRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_ModifyRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof ModifyRequest ) 
+
+        if ( request instanceof ModifyRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 SearchRequest
      */
     public void testResponseWith1SearchRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_SearchRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 1, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof SearchRequest ) 
+
+        if ( request instanceof SearchRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
-    
+
+
     /**
      * Test parsing of a Request with 2 AddRequest
      */
     public void testResponseWith2AddRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_2_AddRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 2, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof AddRequest ) 
+
+        if ( request instanceof AddRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 2 CompareRequest
      */
     public void testResponseWith2CompareRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_2_CompareRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 2, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof CompareRequest ) 
+
+        if ( request instanceof CompareRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 2 AbandonRequest
      */
     public void testResponseWith2AbandonRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_2_AbandonRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 2, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof AbandonRequest ) 
+
+        if ( request instanceof AbandonRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 2 DelRequest
      */
     public void testResponseWith2DelRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_2_DelRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 2, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof DelRequest ) 
+
+        if ( request instanceof DelRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 2 ExtendedRequest
      */
     public void testResponseWith2ExtendedRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_2_ExtendedRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 2, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof ExtendedRequest ) 
+
+        if ( request instanceof ExtendedRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 2 ModDNRequest
      */
     public void testResponseWith2ModDNRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_2_ModDNRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 2, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof ModifyDNRequest ) 
+
+        if ( request instanceof ModifyDNRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 2 ModifyRequest
      */
     public void testResponseWith2ModifyRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_2_ModifyRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 2, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof ModifyRequest ) 
+
+        if ( request instanceof ModifyRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 2 SearchRequest
      */
     public void testResponseWith2SearchRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( BatchRequestTest.class.getResource( "request_with_2_SearchRequest.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         assertEquals( 2, batchRequest.getRequests().size() );
-        
+
         LdapMessage request = batchRequest.getCurrentRequest();
-        
-        if ( request instanceof SearchRequest ) 
+
+        if ( request instanceof SearchRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Request with 1 AuthRequest and 1 AddRequest
      */
     public void testResponseWith1AuthRequestAnd1AddRequest()
     {
-    	Dsmlv2Parser parser = null;
+        Dsmlv2Parser parser = null;
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_AuthRequest_1_AddRequest.xml" ).getFile() );
-        
+
+            parser.setInputFile( BatchRequestTest.class.getResource( "request_with_1_AuthRequest_1_AddRequest.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchRequest batchRequest = parser.getBatchRequest();
-        
+
         List requests = batchRequest.getRequests();
-        
+
         assertEquals( 2, requests.size() );
-        
-        LdapMessage request = (LdapMessage) requests.get( 0 );
-        
-        if ( request instanceof BindRequest ) 
+
+        LdapMessage request = ( LdapMessage ) requests.get( 0 );
+
+        if ( request instanceof BindRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
-        
-        request = (LdapMessage) requests.get( 1 );
-        
-        if ( request instanceof AddRequest ) 
+
+        request = ( LdapMessage ) requests.get( 1 );
+
+        if ( request instanceof AddRequest )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a request with 1 wrong placed AuthRequest
      */



Mime
View raw message