directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1065899 [2/2] - in /directory: apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/ apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ apacheds/trunk/core/src/main/java/org/apac...
Date Tue, 01 Feb 2011 02:46:13 GMT
Copied: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTest.java
(from r1065842, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTest.java?p2=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTest.java&p1=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java&r1=1065842&r2=1065899&rev=1065899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyTest.java
Tue Feb  1 02:46:12 2011
@@ -23,6 +23,7 @@ package org.apache.directory.shared.ldap
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.nio.ByteBuffer;
 
@@ -37,7 +38,7 @@ import org.junit.Test;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PasswordPolicyResponseControlTest
+public class PasswordPolicyTest
 {
     ILdapCodecService codec = new DefaultLdapCodecService();
     
@@ -48,22 +49,23 @@ public class PasswordPolicyResponseContr
 
         bb.put( new byte[]
             { 
-             0x30, 0x08,
-              (byte)0xA0, 0x03,         // timeBeforeExpiration
-                     (byte)0x80, 0x01, 0x01, 
-              (byte)0x81, 0x01, 0x01   // ppolicyError
+                      0x30, 0x08,
+             ( byte ) 0xA0, 0x03,         // timeBeforeExpiration
+             ( byte ) 0x80, 0x01, 0x01, 
+             ( byte ) 0x81, 0x01, 0x01    // ppolicyError
             } );
 
         bb.flip();
 
-        PasswordPolicyResponseDecorator control = new PasswordPolicyResponseDecorator( codec
);
+        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
+        IPasswordPolicy passwordPolicy = ( IPasswordPolicy ) control.decode( bb.array() );
 
-        IPasswordPolicyResponse passwordPolicyResponse = (IPasswordPolicyResponse)control.decode(
bb.array() );
+        assertTrue( passwordPolicy.hasResponse() );
+        assertEquals( 1, passwordPolicy.getResponse().getTimeBeforeExpiration() );
+        assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue()
);
         
-        assertEquals( 1, passwordPolicyResponse.getTimeBeforeExpiration() );
-        assertEquals( 1, passwordPolicyResponse.getPasswordPolicyError().getValue() );
-        
-        ByteBuffer encoded = ((PasswordPolicyResponseDecorator)passwordPolicyResponse).encode(
ByteBuffer.allocate( ((PasswordPolicyResponseDecorator)passwordPolicyResponse).computeLength()
) );
+        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode( 
+            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength()
) );
         assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array()
) );
     }
     
@@ -75,22 +77,23 @@ public class PasswordPolicyResponseContr
 
         bb.put( new byte[]
             { 
-             0x30, 0x08,
-              (byte)0xA0, 0x03,           // warning
-                (byte)0x81, 0x01, 0x01,   // graceAuthNsRemaining
-              (byte)0x81, 0x01, 0x01      // error
+                       0x30, 0x08,
+              ( byte ) 0xA0, 0x03,           // warning
+              ( byte ) 0x81, 0x01, 0x01,     // graceAuthNsRemaining
+              ( byte ) 0x81, 0x01, 0x01      // error
             } );
 
         bb.flip();
 
-        PasswordPolicyResponseDecorator control = new PasswordPolicyResponseDecorator( codec
);
-
-        IPasswordPolicyResponse passwordPolicyResponse = (IPasswordPolicyResponse)control.decode(
bb.array() );
+        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
+        IPasswordPolicy passwordPolicy = ( IPasswordPolicy ) control.decode( bb.array() );
         
-        assertEquals( 1, passwordPolicyResponse.getGraceAuthNsRemaining() );
-        assertEquals( 1, passwordPolicyResponse.getPasswordPolicyError().getValue() );
+        assertTrue( passwordPolicy.hasResponse() );
+        assertEquals( 1, passwordPolicy.getResponse().getGraceAuthNsRemaining() );
+        assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue()
);
         
-        ByteBuffer encoded = ((PasswordPolicyResponseDecorator)passwordPolicyResponse).encode(
ByteBuffer.allocate( ((PasswordPolicyResponseDecorator)passwordPolicyResponse).computeLength()
) );
+        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode( 
+            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength()
) );
         assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array())
 );
     }
 
@@ -102,20 +105,21 @@ public class PasswordPolicyResponseContr
 
         bb.put( new byte[]
             { 
-             0x30, 0x05,
-              (byte)0xA0, 0x03,
-                     (byte)0x80, 0x01, 0x01 //  timeBeforeExpiration
+                       0x30, 0x05,
+              ( byte ) 0xA0, 0x03,
+              ( byte ) 0x80, 0x01, 0x01 //  timeBeforeExpiration
             } );
 
         bb.flip();
 
-        PasswordPolicyResponseDecorator control = new PasswordPolicyResponseDecorator( codec
);
-
-        IPasswordPolicyResponse passwordPolicyResponse = (IPasswordPolicyResponse)control.decode(
bb.array() );
+        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
+        IPasswordPolicy passwordPolicy = ( IPasswordPolicy ) control.decode( bb.array() );
 
-        assertEquals( 1, passwordPolicyResponse.getTimeBeforeExpiration() );
+        assertTrue( passwordPolicy.hasResponse() );
+        assertEquals( 1, passwordPolicy.getResponse().getTimeBeforeExpiration() );
         
-        ByteBuffer encoded = ((PasswordPolicyResponseDecorator)passwordPolicyResponse).encode(
ByteBuffer.allocate( ((PasswordPolicyResponseDecorator)passwordPolicyResponse).computeLength()
) );
+        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode( 
+            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength()
) );
         assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array()
) );
     }
     
@@ -127,20 +131,21 @@ public class PasswordPolicyResponseContr
 
         bb.put( new byte[]
             { 
-             0x30, 0x05,
-              (byte)0xA0, 0x03,
-                     (byte)0x81, 0x01, 0x01 //  graceAuthNsRemaining
+                       0x30, 0x05,
+              ( byte ) 0xA0, 0x03,
+              ( byte ) 0x81, 0x01, 0x01 //  graceAuthNsRemaining
             } );
 
         bb.flip();
 
-        PasswordPolicyResponseDecorator control = new PasswordPolicyResponseDecorator( codec
);
-        
-        IPasswordPolicyResponse passwordPolicyResponse = (IPasswordPolicyResponse)control.decode(
bb.array() );
+        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
+        IPasswordPolicy passwordPolicy = ( IPasswordPolicy ) control.decode( bb.array() );
 
-        assertEquals( 1, passwordPolicyResponse.getGraceAuthNsRemaining() );
+        assertTrue( passwordPolicy.hasResponse() );
+        assertEquals( 1, passwordPolicy.getResponse().getGraceAuthNsRemaining() );
         
-        ByteBuffer encoded = ((PasswordPolicyResponseDecorator)passwordPolicyResponse).encode(
ByteBuffer.allocate( ((PasswordPolicyResponseDecorator)passwordPolicyResponse).computeLength()
) );
+        ByteBuffer encoded = ( ( PasswordPolicyDecorator) passwordPolicy ).encode( 
+            ByteBuffer.allocate( ( ( PasswordPolicyDecorator) passwordPolicy ).computeLength()
) );
         assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array()
) );
     }
     
@@ -152,19 +157,20 @@ public class PasswordPolicyResponseContr
 
         bb.put( new byte[]
             { 
-             0x30, 0x03,
-              (byte)0x81, 0x01, 0x01 //  error
+                       0x30, 0x03,
+              ( byte ) 0x81, 0x01, 0x01 //  error
             } );
 
         bb.flip();
 
-        PasswordPolicyResponseDecorator control = new PasswordPolicyResponseDecorator( codec
);
-        
-        IPasswordPolicyResponse passwordPolicyResponse = (IPasswordPolicyResponse)control.decode(
bb.array() );
+        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
+        IPasswordPolicy passwordPolicy = ( IPasswordPolicy ) control.decode( bb.array() );
         
-        assertEquals( 1, passwordPolicyResponse.getPasswordPolicyError().getValue() );
+        assertTrue( passwordPolicy.hasResponse() );
+        assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue()
);
         
-        ByteBuffer encoded = ((PasswordPolicyResponseDecorator)passwordPolicyResponse).encode(
ByteBuffer.allocate( ((PasswordPolicyResponseDecorator)passwordPolicyResponse).computeLength()
) );
+        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode( 
+            ByteBuffer.allocate( ( ( PasswordPolicyDecorator) passwordPolicy ).computeLength()
) );
         assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array()
) );
     }
 
@@ -181,13 +187,14 @@ public class PasswordPolicyResponseContr
 
         bb.flip();
 
-        PasswordPolicyResponseDecorator control = new PasswordPolicyResponseDecorator( codec
);
-
-        IPasswordPolicyResponse passwordPolicyResponse = (IPasswordPolicyResponse)control.decode(
bb.array() );
+        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
+        IPasswordPolicy passwordPolicy = ( IPasswordPolicy ) control.decode( bb.array() );
         
-        assertNotNull( passwordPolicyResponse );
+        assertNotNull( passwordPolicy );
+        assertTrue( passwordPolicy.hasResponse() );
         
-        ByteBuffer encoded = ((PasswordPolicyResponseDecorator)passwordPolicyResponse).encode(
ByteBuffer.allocate( ((PasswordPolicyResponseDecorator)passwordPolicyResponse).computeLength()
) );
+        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode( 
+            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength()
) );
         assertEquals( "", Strings.dumpBytes( encoded.array() ) );
     }
 }



Mime
View raw message