directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r483066 [7/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/batchResponse/BatchResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/batchResponse/BatchResponseTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/batchResponse/BatchResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/batchResponse/BatchResponseTest.java Wed Dec  6 05:17:42 2006
@@ -20,6 +20,7 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.batchResponse;
 
+
 import org.apache.directory.ldapstudio.dsmlv2.AbstractResponseTest;
 import org.apache.directory.ldapstudio.dsmlv2.BatchResponse;
 import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
@@ -34,6 +35,7 @@
 import org.apache.directory.shared.ldap.codec.modify.ModifyResponse;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponse;
 
+
 /**
  * Tests for the Compare Response parsing
  */
@@ -48,21 +50,23 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( BatchResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser.setInputFile( BatchResponseTest.class.getResource( "response_with_requestID_attribute.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1234567890, batchResponse.getRequestID() );
     }
-    
+
+
     /**
      * Test parsing of a Response with 0 Response
      */
@@ -72,22 +76,22 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_0_response.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 0, batchResponse.getResponses().size() );
     }
-    
-    
+
+
     /**
      * Test parsing of a Response with the 1 AddResponse
      */
@@ -97,32 +101,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_AddResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof AddResponse ) 
+
+        if ( response instanceof AddResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 1 AuthResponse
      */
@@ -132,32 +137,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_AuthResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof BindResponse ) 
+
+        if ( response instanceof BindResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 1 CompareResponse
      */
@@ -167,32 +173,34 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_CompareResponse.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( BatchResponseTest.class.getResource( "response_with_1_CompareResponse.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof CompareResponse ) 
+
+        if ( response instanceof CompareResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 1 DelResponse
      */
@@ -202,32 +210,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_DelResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof DelResponse ) 
+
+        if ( response instanceof DelResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 1 ErrorResponse
      */
@@ -237,32 +246,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_ErrorResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof ErrorResponse ) 
+
+        if ( response instanceof ErrorResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 1 ExtendedResponse
      */
@@ -272,32 +282,34 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_ExtendedResponse.xml" ).getFile() );
-        
+
+            parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_ExtendedResponse.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof ExtendedResponse ) 
+
+        if ( response instanceof ExtendedResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 1 ModDNResponse
      */
@@ -307,32 +319,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_ModDNResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof ModifyDNResponse ) 
+
+        if ( response instanceof ModifyDNResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 1 ModifyResponse
      */
@@ -342,32 +355,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_ModifyResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof ModifyResponse ) 
+
+        if ( response instanceof ModifyResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 1 SearchResponse
      */
@@ -377,32 +391,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_1_SearchResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 1, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof SearchResponse ) 
+
+        if ( response instanceof SearchResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 AddResponse
      */
@@ -412,32 +427,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_AddResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof AddResponse ) 
+
+        if ( response instanceof AddResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 AuthResponse
      */
@@ -447,32 +463,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_AuthResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof BindResponse ) 
+
+        if ( response instanceof BindResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 CompareResponse
      */
@@ -482,32 +499,34 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_CompareResponse.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( BatchResponseTest.class.getResource( "response_with_2_CompareResponse.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof CompareResponse ) 
+
+        if ( response instanceof CompareResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 DelResponse
      */
@@ -517,32 +536,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_DelResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof DelResponse ) 
+
+        if ( response instanceof DelResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 ErrorResponse
      */
@@ -552,32 +572,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_ErrorResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof ErrorResponse ) 
+
+        if ( response instanceof ErrorResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 ExtendedResponse
      */
@@ -587,32 +608,34 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_ExtendedResponse.xml" ).getFile() );
-        
+
+            parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_ExtendedResponse.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof ExtendedResponse ) 
+
+        if ( response instanceof ExtendedResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 ModDNResponse
      */
@@ -622,32 +645,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_ModDNResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof ModifyDNResponse ) 
+
+        if ( response instanceof ModifyDNResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 ModifyResponse
      */
@@ -657,32 +681,33 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_ModifyResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof ModifyResponse ) 
+
+        if ( response instanceof ModifyResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
-    
+
+
     /**
      * Test parsing of a Response with the 2 SearchResponse
      */
@@ -692,29 +717,29 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( BatchResponseTest.class.getResource( "response_with_2_SearchResponse.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         BatchResponse batchResponse = parser.getBatchResponse();
-        
+
         assertEquals( 2, batchResponse.getResponses().size() );
-        
+
         LdapResponse response = batchResponse.getCurrentResponse();
-        
-        if ( response instanceof SearchResponse ) 
+
+        if ( response instanceof SearchResponse )
         {
-        	assertTrue( true );
-		}
+            assertTrue( true );
+        }
         else
         {
-        	fail();
+            fail();
         }
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareRequest/CompareRequestTest.java Wed Dec  6 05:17:42 2006
@@ -20,12 +20,14 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.compareRequest;
 
+
 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.compare.CompareRequest;
 import org.apache.directory.shared.ldap.util.StringTools;
 
+
 /**
  * Tests for the Compare Request parsing
  */
@@ -38,7 +40,8 @@
     {
         testParsingFail( CompareRequestTest.class, "request_without_dn_attribute.xml" );
     }
-    
+
+
     /**
      * Test parsing of a request with the dn attribute
      */
@@ -48,21 +51,22 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( CompareRequestTest.class.getResource( "request_with_dn_attribute.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", compareRequest.getEntry().toString() );
     }
-    
+
+
     /**
      * Test parsing of a request with the (optional) requestID attribute
      */
@@ -72,21 +76,22 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( CompareRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser.setInputFile( CompareRequestTest.class.getResource( "request_with_requestID_attribute.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 456, compareRequest.getMessageId() );
     }
-    
+
 
     /**
      * Test parsing of a request with a (optional) Control element
@@ -97,29 +102,63 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( CompareRequestTest.class.getResource( "request_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 1, compareRequest.getControls().size() );
-        
+
         Control control = compareRequest.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( CompareRequestTest.class.getResource( "request_with_1_control_empty_value.xml" )
+                .getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        assertEquals( 1, compareRequest.getControls().size() );
+
+        Control control = compareRequest.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
@@ -130,29 +169,30 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( CompareRequestTest.class.getResource( "request_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 2, compareRequest.getControls().size() );
-        
+
         Control control = compareRequest.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
      */
@@ -162,29 +202,31 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( CompareRequestTest.class.getResource( "request_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( CompareRequestTest.class.getResource( "request_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 3, compareRequest.getControls().size() );
-        
+
         Control control = compareRequest.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
      */
@@ -194,26 +236,57 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( CompareRequestTest.class.getResource( "request_with_1_complete_assertion.xml" ).getFile() );
-        
+
+            parser.setInputFile( CompareRequestTest.class.getResource( "request_with_1_complete_assertion.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
-        
 
-        assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", (String) compareRequest.getEntry().toString() );
+        assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", ( String ) compareRequest.getEntry().toString() );
 
-        assertEquals( "sn", (String) compareRequest.getAttributeDesc()  );
-        
-        assertEquals( "Johnson", (String) compareRequest.getAssertionValue() );
+        assertEquals( "sn", ( String ) compareRequest.getAttributeDesc() );
+
+        assertEquals( "Johnson", ( String ) compareRequest.getAssertionValue() );
     }
-    
+
+
+    /**
+     * Test parsing of a request with an Attr elements with empty value
+     */
+    public void testRequestWith1AssertionEmptyValue()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser.setInputFile( CompareRequestTest.class.getResource( "request_with_1_assertion_empty_value.xml" )
+                .getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        CompareRequest compareRequest = ( CompareRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", ( String ) compareRequest.getEntry().toString() );
+
+        assertEquals( "sn", ( String ) compareRequest.getAttributeDesc() );
+
+        assertNull( compareRequest.getAssertionValue() );
+    }
+
+
     /**
      * Test parsing of a request without the Assertion element
      */
@@ -221,7 +294,8 @@
     {
         testParsingFail( CompareRequestTest.class, "request_without_assertion.xml" );
     }
-    
+
+
     /**
      * Test parsing of a request with 2 complete Assertion element
      */
@@ -229,7 +303,8 @@
     {
         testParsingFail( CompareRequestTest.class, "request_with_2_complete_assertions.xml" );
     }
-    
+
+
     /**
      * Test parsing of a request with 1 Assertion element without the name attribute
      */
@@ -237,7 +312,8 @@
     {
         testParsingFail( CompareRequestTest.class, "request_with_1_assertion_without_name_attribute.xml" );
     }
-    
+
+
     /**
      * Test parsing of a request with 1 Assertion element without the Value element
      */
@@ -245,7 +321,8 @@
     {
         testParsingFail( CompareRequestTest.class, "request_with_1_assertion_without_value.xml" );
     }
-    
+
+
     /**
      * Test parsing of a request with 1 Assertion element with 2 Value elements
      */

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/compareResponse/CompareResponseTest.java Wed Dec  6 05:17:42 2006
@@ -20,6 +20,7 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.compareResponse;
 
+
 import java.util.List;
 
 import javax.naming.NamingException;
@@ -33,13 +34,13 @@
 
 import com.sun.jndi.ldap.LdapURL;
 
+
 /**
  * Tests for the Compare Response parsing
  */
 public class CompareResponseTest extends AbstractResponseTest
 {
-    
-    
+
     /**
      * Test parsing of a Response with the (optional) requestID attribute
      */
@@ -49,34 +50,35 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( CompareResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser.setInputFile( CompareResponseTest.class.getResource( "response_with_requestID_attribute.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 456, compareResponse.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( CompareResponseTest.class.getResource( "response_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -85,63 +87,65 @@
         }
 
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 1, compareResponse.getControls().size() );
-        
+
         Control control = compareResponse.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( CompareResponseTest.class.getResource( "response_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 2, compareResponse.getControls().size() );
-        
+
         Control control = compareResponse.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( CompareResponseTest.class.getResource( "response_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( CompareResponseTest.class.getResource( "response_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -150,46 +154,49 @@
         }
 
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 3, compareResponse.getControls().size() );
-        
+
         Control control = compareResponse.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( CompareResponseTest.class, "response_without_result_code.xml");
+        testParsingFail( CompareResponseTest.class, "response_without_result_code.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with Result Code element but a not integer value
      */
     public void testResponseWithResultCodeNotInteger()
     {
-        testParsingFail( CompareResponseTest.class, "response_with_result_code_not_integer.xml");
+        testParsingFail( CompareResponseTest.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( CompareResponseTest.class.getResource( "response_with_result_code.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -198,24 +205,25 @@
         }
 
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = compareResponse.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( CompareResponseTest.class.getResource( "response_with_error_message.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -224,24 +232,26 @@
         }
 
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = compareResponse.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( CompareResponseTest.class.getResource( "response_with_1_referral.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -250,37 +260,38 @@
         }
 
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = compareResponse.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( CompareResponseTest.class.getResource( "response_with_2_referrals.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -289,48 +300,50 @@
         }
 
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = compareResponse.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( CompareResponseTest.class.getResource( "response_with_1_referral_and_error_message.xml" ).getFile() );
-        
+
+            parser.setInputFile( CompareResponseTest.class.getResource(
+                "response_with_1_referral_and_error_message.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -339,37 +352,39 @@
         }
 
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = compareResponse.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( CompareResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).getFile() );
-        
+
+            parser.setInputFile( CompareResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -378,25 +393,27 @@
         }
 
         CompareResponse compareResponse = ( CompareResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = compareResponse.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( CompareResponseTest.class, "response_with_wrong_matchedDN_attribute.xml");
+        testParsingFail( CompareResponseTest.class, "response_with_wrong_matchedDN_attribute.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with wrong Descr attribute
      */
     public void testResponseWithWrongDescr()
     {
-        testParsingFail( CompareResponseTest.class, "response_with_wrong_descr.xml");
+        testParsingFail( CompareResponseTest.class, "response_with_wrong_descr.xml" );
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/delRequest/DelRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/delRequest/DelRequestTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/delRequest/DelRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/delRequest/DelRequestTest.java Wed Dec  6 05:17:42 2006
@@ -20,12 +20,14 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.delRequest;
 
+
 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.del.DelRequest;
 import org.apache.directory.shared.ldap.util.StringTools;
 
+
 /**
  * Tests for the Del Request parsing
  */
@@ -38,7 +40,8 @@
     {
         testParsingFail( DelRequestTest.class, "request_without_dn_attribute.xml" );
     }
-    
+
+
     /**
      * Test parsing of a request with the dn attribute
      */
@@ -48,21 +51,22 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( DelRequestTest.class.getResource( "request_with_dn_attribute.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         DelRequest delRequest = ( DelRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM", delRequest.getEntry().toString() );
     }
-    
+
+
     /**
      * Test parsing of a request with the (optional) requestID attribute
      */
@@ -72,21 +76,21 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( DelRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         DelRequest delRequest = ( DelRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 456, delRequest.getMessageId() );
     }
-    
+
 
     /**
      * Test parsing of a request with a (optional) Control element
@@ -97,29 +101,63 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( DelRequestTest.class.getResource( "request_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         DelRequest delRequest = ( DelRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 1, delRequest.getControls().size() );
-        
+
         Control control = delRequest.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( DelRequestTest.class.getResource( "request_with_1_control_empty_value.xml" ).getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        DelRequest delRequest = ( DelRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        assertEquals( 1, delRequest.getControls().size() );
+
+        Control control = delRequest.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
@@ -130,29 +168,30 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( DelRequestTest.class.getResource( "request_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         DelRequest delRequest = ( DelRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 2, delRequest.getControls().size() );
-        
+
         Control control = delRequest.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
      */
@@ -162,26 +201,27 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( DelRequestTest.class.getResource( "request_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( DelRequestTest.class.getResource( "request_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         DelRequest delRequest = ( DelRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 3, delRequest.getControls().size() );
-        
+
         Control control = delRequest.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/delResponse/DelResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/delResponse/DelResponseTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/delResponse/DelResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/delResponse/DelResponseTest.java Wed Dec  6 05:17:42 2006
@@ -20,6 +20,7 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.delResponse;
 
+
 import java.util.List;
 
 import javax.naming.NamingException;
@@ -33,13 +34,13 @@
 
 import com.sun.jndi.ldap.LdapURL;
 
+
 /**
  * Tests for the Del Response parsing
  */
 public class DelResponseTest extends AbstractResponseTest
 {
-    
-    
+
     /**
      * Test parsing of a Response with the (optional) requestID attribute
      */
@@ -49,34 +50,35 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( DelResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( DelResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 456, delResponse.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( DelResponseTest.class.getResource( "response_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -85,63 +87,65 @@
         }
 
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 1, delResponse.getControls().size() );
-        
+
         Control control = delResponse.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( DelResponseTest.class.getResource( "response_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 2, delResponse.getControls().size() );
-        
+
         Control control = delResponse.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( DelResponseTest.class.getResource( "response_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( DelResponseTest.class.getResource( "response_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -150,46 +154,49 @@
         }
 
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 3, delResponse.getControls().size() );
-        
+
         Control control = delResponse.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( DelResponseTest.class, "response_without_result_code.xml");
+        testParsingFail( DelResponseTest.class, "response_without_result_code.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with Result Code element but a not integer value
      */
     public void testResponseWithResultCodeNotInteger()
     {
-        testParsingFail( DelResponseTest.class, "response_with_result_code_not_integer.xml");
+        testParsingFail( DelResponseTest.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( DelResponseTest.class.getResource( "response_with_result_code.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -198,24 +205,25 @@
         }
 
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = delResponse.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( DelResponseTest.class.getResource( "response_with_error_message.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -224,24 +232,26 @@
         }
 
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = delResponse.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( DelResponseTest.class.getResource( "response_with_1_referral.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -250,37 +260,38 @@
         }
 
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = delResponse.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( DelResponseTest.class.getResource( "response_with_2_referrals.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
@@ -289,48 +300,50 @@
         }
 
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = delResponse.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( DelResponseTest.class.getResource( "response_with_1_referral_and_error_message.xml" ).getFile() );
-        
+
+            parser.setInputFile( DelResponseTest.class.getResource( "response_with_1_referral_and_error_message.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -339,37 +352,39 @@
         }
 
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = delResponse.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( DelResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( DelResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
@@ -378,25 +393,27 @@
         }
 
         DelResponse delResponse = ( DelResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         LdapResult ldapResult = delResponse.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( DelResponseTest.class, "response_with_wrong_matchedDN_attribute.xml");
+        testParsingFail( DelResponseTest.class, "response_with_wrong_matchedDN_attribute.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with wrong Descr attribute
      */
     public void testResponseWithWrongDescr()
     {
-        testParsingFail( DelResponseTest.class, "response_with_wrong_descr.xml");
+        testParsingFail( DelResponseTest.class, "response_with_wrong_descr.xml" );
     }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/errorResponse/ErrorResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/errorResponse/ErrorResponseTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/errorResponse/ErrorResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/errorResponse/ErrorResponseTest.java Wed Dec  6 05:17:42 2006
@@ -20,18 +20,19 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.errorResponse;
 
+
 import org.apache.directory.ldapstudio.dsmlv2.AbstractResponseTest;
 import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
 import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse;
 import org.apache.directory.ldapstudio.dsmlv2.reponse.ErrorResponse.ErrorResponseType;
 
+
 /**
  * Tests for the Error Response parsing
  */
 public class ErrorResponseTest extends AbstractResponseTest
 {
-    
-    
+
     /**
      * Test parsing of a Response with the (optional) requestID attribute
      */
@@ -41,259 +42,269 @@
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_requestID_attribute.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( 456, errorResponse.getMessageId() );
     }
-  
+
 
     /**
      * Test parsing of a response without Type attribute
      */
     public void testResponseWithoutType()
     {
-    	testParsingFail( ErrorResponseTest.class, "response_without_type.xml");
+        testParsingFail( ErrorResponseTest.class, "response_without_type.xml" );
     }
 
-    
+
     /**
      * Test parsing of a response with type == notAttempted
      */
     public void testResponseWithTypeNotAttempted()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_notAttempted.xml" ).getFile() );
-        
+
+            parser
+                .setInputFile( ErrorResponseTest.class.getResource( "response_with_type_notAttempted.xml" ).getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( ErrorResponseType.NOT_ATTEMPTED, errorResponse.getType() );
     }
-    
-    
+
+
     /**
      * Test parsing of a response with type == couldNotConnect
      */
     public void testResponseWithTypeCouldNotConnect()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_couldNotConnect.xml" ).getFile() );
-        
+
+            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_couldNotConnect.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( ErrorResponseType.COULD_NOT_CONNECT, errorResponse.getType() );
     }
-    
-    
+
+
     /**
      * Test parsing of a response with type == connectionClosed
      */
     public void testResponseWithTypeConnectionClosed()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_connectionClosed.xml" ).getFile() );
-        
+
+            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_connectionClosed.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( ErrorResponseType.CONNECTION_CLOSED, errorResponse.getType() );
     }
-    
-    
+
+
     /**
      * Test parsing of a response with type == malformedRequest
      */
     public void testResponseWithTypeMalformedRequest()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_malformedRequest.xml" ).getFile() );
-        
+
+            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_malformedRequest.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( ErrorResponseType.MALFORMED_REQUEST, errorResponse.getType() );
     }
-    
-    
+
+
     /**
      * Test parsing of a response with type == gatewayInternalError
      */
     public void testResponseWithTypeGatewayInternalError()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_gatewayInternalError.xml" ).getFile() );
-        
+
+            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_gatewayInternalError.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( ErrorResponseType.GATEWAY_INTERNAL_ERROR, errorResponse.getType() );
     }
-    
-    
+
+
     /**
      * Test parsing of a response with type == authenticationFailed
      */
     public void testResponseWithTypeAuthenticationFailed()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_authenticationFailed.xml" ).getFile() );
-        
+
+            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_authenticationFailed.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( ErrorResponseType.AUTHENTICATION_FAILED, errorResponse.getType() );
     }
-    
-    
+
+
     /**
      * Test parsing of a response with type == unresolvableURI
      */
     public void testResponseWithTypeUnresolvableURI()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
-            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_unresolvableURI.xml" ).getFile() );
-        
+
+            parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_unresolvableURI.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( ErrorResponseType.UNRESOLVABLE_URI, errorResponse.getType() );
     }
-    
-    
+
+
     /**
      * Test parsing of a response with type == other
      */
     public void testResponseWithTypeOther()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_type_other.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( ErrorResponseType.OTHER, errorResponse.getType() );
-    }    
-    
+    }
+
+
     /**
      * Test parsing of a response with type in error
      */
     public void testResponseWithTypeError()
     {
-    	testParsingFail( ErrorResponseTest.class, "response_with_type_inError.xml");
+        testParsingFail( ErrorResponseTest.class, "response_with_type_inError.xml" );
     }
-    
+
+
     /**
      * Test parsing of a response with Message
      */
     public void testResponseWithMessage()
     {
-    	Dsmlv2ResponseParser parser = null;
+        Dsmlv2ResponseParser parser = null;
         try
         {
             parser = new Dsmlv2ResponseParser();
-            
+
             parser.setInputFile( ErrorResponseTest.class.getResource( "response_with_message.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ErrorResponse errorResponse = ( ErrorResponse ) parser.getBatchResponse().getCurrentResponse();
-        
+
         assertEquals( "Connection refused", errorResponse.getMessage() );
-    }    
+    }
 }

Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/ExtendedRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/ExtendedRequestTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/ExtendedRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/extendedRequest/ExtendedRequestTest.java Wed Dec  6 05:17:42 2006
@@ -20,12 +20,14 @@
 
 package org.apache.directory.ldapstudio.dsmlv2.extendedRequest;
 
+
 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.extended.ExtendedRequest;
 import org.apache.directory.shared.ldap.util.StringTools;
 
+
 /**
  * Tests for the Extended Request parsing
  */
@@ -40,21 +42,22 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( ExtendedRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
-        
+
+            parser.setInputFile( ExtendedRequestTest.class.getResource( "request_with_requestID_attribute.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ExtendedRequest extendedRequest = ( ExtendedRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 456, extendedRequest.getMessageId() );
     }
-    
+
 
     /**
      * Test parsing of a request with a (optional) Control element
@@ -65,29 +68,63 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( ExtendedRequestTest.class.getResource( "request_with_1_control.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ExtendedRequest extendedRequest = ( ExtendedRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 1, extendedRequest.getControls().size() );
-        
+
         Control control = extendedRequest.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( ExtendedRequestTest.class.getResource( "request_with_1_control_empty_value.xml" )
+                .getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        ExtendedRequest extendedRequest = ( ExtendedRequest ) parser.getBatchRequest().getCurrentRequest();
+
+        assertEquals( 1, extendedRequest.getControls().size() );
+
+        Control control = extendedRequest.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
@@ -98,29 +135,30 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( ExtendedRequestTest.class.getResource( "request_with_2_controls.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ExtendedRequest extendedRequest = ( ExtendedRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 2, extendedRequest.getControls().size() );
-        
+
         Control control = extendedRequest.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
      */
@@ -130,29 +168,31 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
-            parser.setInputFile( ExtendedRequestTest.class.getResource( "request_with_3_controls_without_value.xml" ).getFile() );
-        
+
+            parser.setInputFile( ExtendedRequestTest.class.getResource( "request_with_3_controls_without_value.xml" )
+                .getFile() );
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ExtendedRequest extendedRequest = ( ExtendedRequest ) parser.getBatchRequest().getCurrentRequest();
-        
+
         assertEquals( 3, extendedRequest.getControls().size() );
-        
+
         Control control = extendedRequest.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 a RequestValue element
      */
@@ -162,27 +202,28 @@
         try
         {
             parser = new Dsmlv2Parser();
-            
+
             parser.setInputFile( ExtendedRequestTest.class.getResource( "request_with_requestValue.xml" ).getFile() );
-        
+
             parser.parse();
         }
         catch ( Exception e )
         {
             fail( e.getMessage() );
         }
-        
+
         ExtendedRequest extendedRequest = ( ExtendedRequest ) parser.getBatchRequest().getCurrentRequest();
-        
-        String s1 = StringTools.dumpBytes( StringTools.getBytesUtf8( "RFNNTHYyLjAgcm9ja3MhIQ==" ) );
-        String s2 = StringTools.dumpBytes( extendedRequest.getRequestValue() );
-        
+
+        //        String s1 = StringTools.dumpBytes( StringTools.getBytesUtf8( "RFNNTHYyLjAgcm9ja3MhIQ==" ) );
+        //        String s2 = StringTools.dumpBytes( extendedRequest.getRequestValue() );
+
         //assertTrue( Arrays.equals( StringTools.getBytesUtf8( "RFNNTHYyLjAgcm9ja3MhIQ==" ), extendedRequest.getRequestValue() ) );
-        
-//        assertEquals( s1, s2 );
+
+        //        assertEquals( s1, s2 );
         assertEquals( StringTools.getBytesUtf8( "RFNNTHYyLjAgcm9ja3MhIQ==" ), extendedRequest.getRequestValue() );
     }
-    
+
+
     /**
      * Test parsing of a request with 2 requestValue Elements
      */
@@ -190,12 +231,47 @@
     {
         testParsingFail( ExtendedRequestTest.class, "request_with_2_requestValue.xml" );
     }
-    
+
+
     /**
      * Test parsing of a request with 2 requestName Elements
      */
     public void testRequestWith2RequestName()
     {
         testParsingFail( ExtendedRequestTest.class, "request_with_2_requestName.xml" );
+    }
+
+
+    /**
+     * Test parsing of a request with an empty requestName
+     */
+    public void testRequestWithEmptyRequestName()
+    {
+        testParsingFail( ExtendedRequestTest.class, "request_with_empty_requestName.xml" );
+    }
+
+
+    /**
+     * Test parsing of a request with an empty RequestValue
+     */
+    public void testRequestWithEmptyRequestValue()
+    {
+        Dsmlv2Parser parser = null;
+        try
+        {
+            parser = new Dsmlv2Parser();
+
+            parser.setInputFile( ExtendedRequestTest.class.getResource( "request_with_empty_requestValue.xml" )
+                .getFile() );
+
+            parser.parse();
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+
+        ExtendedRequest extendedRequest = ( ExtendedRequest ) parser.getBatchRequest().getCurrentRequest();
+        assertNull( extendedRequest.getRequestValue() );
     }
 }



Mime
View raw message