directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1068124 [19/19] - in /directory/apacheds/branches/m1/kerberos-codec/src: main/java/org/apache/directory/server/kerberos/shared/crypto/checksum/ main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/ main/java/org/apache/d...
Date Mon, 07 Feb 2011 20:49:13 GMT
Modified: directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlagsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlagsTest.java?rev=1068124&r1=1068123&r2=1068124&view=diff
==============================================================================
--- directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlagsTest.java
(original)
+++ directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/messages/value/flags/AbstractKerberosFlagsTest.java
Mon Feb  7 20:49:04 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.server.kerberos.shared.messages.value.flags;
 
@@ -34,7 +34,7 @@ import org.junit.runner.RunWith;
 
 /**
  * Test for AbstractKerberosFlags
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(ConcurrentJunitRunner.class)
@@ -46,8 +46,8 @@ public class AbstractKerberosFlagsTest
     {
         // Flags 1, 2, 4, 8 set
         AbstractKerberosFlags akf = new AbstractKerberosFlags(
-            ( int ) ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) )
-                  + ( 1 << ( 31 - TicketFlag.FORWARDED.getValue() ) ) 
+            ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) )
+                  + ( 1 << ( 31 - TicketFlag.FORWARDED.getValue() ) )
                   + ( 1 << ( 31 - TicketFlag.PROXY.getValue() ) )
                   + ( 1 << ( 31 - TicketFlag.RENEWABLE.getValue() ) ) )
         {
@@ -58,7 +58,7 @@ public class AbstractKerberosFlagsTest
         akf.clearFlag( TicketFlag.PROXY );
         assertEquals(
             "clear(KerberosFlag)",
-            ( int ) ( 
+            (
                   ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) )
                 + ( 1 << ( 31 - TicketFlag.FORWARDED.getValue() ) )
                 + ( 1 << ( 31 - TicketFlag.RENEWABLE.getValue() ) ) ),
@@ -68,7 +68,7 @@ public class AbstractKerberosFlagsTest
         akf.clearFlag( TicketFlag.FORWARDED.getValue() );
         assertEquals(
             "clear(int)",
-            ( int ) ( ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) )
+            ( ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) )
                 + ( 1 << ( 31 - TicketFlag.RENEWABLE.getValue() ) ) ), akf.getIntValue()
);
     }
 
@@ -77,10 +77,10 @@ public class AbstractKerberosFlagsTest
     public void testValue() throws Exception
     {
         // Flags 1, 2, 4, 8 set
-        AbstractKerberosFlags akfIntConstructor = new AbstractKerberosFlags( 
-            ( int ) ( ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) )
+        AbstractKerberosFlags akfIntConstructor = new AbstractKerberosFlags(
+            ( ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) )
             + ( 1 << ( 31 - TicketFlag.FORWARDED.getValue() ) )
-            + ( 1 << ( 31 - TicketFlag.PROXY.getValue() ) ) 
+            + ( 1 << ( 31 - TicketFlag.PROXY.getValue() ) )
             + ( 1 << ( 31 - TicketFlag.RENEWABLE.getValue() ) ) ) )
         {
             private static final long serialVersionUID = 1L;
@@ -95,7 +95,7 @@ public class AbstractKerberosFlagsTest
         assertEquals( "intValue", 0, akfEmptyConstructor.getIntValue() );
         assertEquals(
             "intValue",
-            ( int ) ( ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) ) )
+            ( ( 1 << ( 31 - TicketFlag.FORWARDABLE.getValue() ) ) )
                 + ( 1 << ( 31 - TicketFlag.FORWARDED.getValue() ) )
                 + ( 1 << ( 31 - TicketFlag.PROXY.getValue() ) )
                 + ( 1 << ( 31 - TicketFlag.RENEWABLE.getValue() ) ), akfIntConstructor.getIntValue()
);
@@ -115,19 +115,19 @@ public class AbstractKerberosFlagsTest
         TicketFlag[] ticketFlags = new TicketFlag[TicketFlag.values().length - 1];
         int i = 0;
         int flagsValue = 0;
-        
+
         for ( TicketFlag tf : TicketFlag.values() )
         {
             if ( tf != TicketFlag.MAX_VALUE )
             {
                 ticketFlags[i] = tf;
             }
-            
+
             i++;
         }
 
         boolean setFlag = true;
-        
+
         for ( TicketFlag ticketFlag : ticketFlags )
         {
             // Only set every 2nd ticket flag
@@ -136,12 +136,12 @@ public class AbstractKerberosFlagsTest
                 akf.setFlag( ticketFlag.getValue() );
                 flagsValue += ( 1 << ( 31 - ticketFlag.getValue() ) );
             }
-            
+
             setFlag = !setFlag;
         }
 
         setFlag = true;
-        
+
         for ( TicketFlag ticketFlag : ticketFlags )
         {
             // Only every 2nd ticket flag is set
@@ -159,25 +159,8 @@ public class AbstractKerberosFlagsTest
                 assertFalse( "isFlagSet(int,int): " + ticketFlag.toString(),
                     AbstractKerberosFlags.isFlagSet( flagsValue, ticketFlag.getValue() )
);
             }
-            
+
             setFlag = !setFlag;
         }
     }
-
-
-    /**
-         * 
-         * Get the byte array representation of an int
-         *
-         * @param flags The flags as int
-         * @return The Flags as byte array
-         */
-    private byte[] getBytes( int flags )
-    {
-        return new byte[]
-            {
-                ( byte ) ( 0 ), // unused bits
-                ( byte ) ( flags >>> 24 ), ( byte ) ( ( flags >> 16 ) &
0x00ff ), ( byte ) ( ( flags >> 8 ) & 0x00ff ),
-                ( byte ) ( flags & 0x00ff ) };
-    }
 }

Modified: directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java?rev=1068124&r1=1068123&r2=1068124&view=diff
==============================================================================
--- directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
(original)
+++ directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
Mon Feb  7 20:49:04 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.server.kerberos.shared.replay;
 
@@ -43,7 +43,7 @@ import org.junit.runner.RunWith;
 
 /**
  * Test the InMemory replay cache
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(ConcurrentJunitRunner.class)
@@ -57,7 +57,7 @@ public class ReplayCacheImplTest
     /**
      * Test that the cache is working well. We will create a new entry
      * every 500 ms, with 4 different serverPrincipals.
-     * 
+     *
      * After this period of time, we should only have 2 entries in the cache
      */
     @Test
@@ -78,7 +78,7 @@ public class ReplayCacheImplTest
 
         int i = 0;
 
-        // Inject 4 entries 
+        // Inject 4 entries
         while ( i < 4 )
         {
             KerberosPrincipal serverPrincipal = new KerberosPrincipal( "server" + i + "@APACHE.ORG",
@@ -91,12 +91,12 @@ public class ReplayCacheImplTest
             i++;
         }
 
-        List keys = ehCache.getKeys();
+        List<?> keys = ehCache.getKeys();
 
         // We should have 4 entries
         assertTrue( keys.size() != 0 );
 
-        // Wait till the timetolive time exceeds 
+        // Wait till the timetolive time exceeds
         Thread.sleep( 1200 );
 
         // then access the cache so that the objects present in the cache will be expired

Modified: directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java?rev=1068124&r1=1068123&r2=1068124&view=diff
==============================================================================
--- directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java
(original)
+++ directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java
Mon Feb  7 20:49:04 2011
@@ -21,6 +21,8 @@
 package org.apache.directory.shared.kerberos.codec;
 
 
+import static org.junit.Assert.assertTrue;
+
 import java.lang.reflect.Field;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
@@ -45,15 +47,14 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.kerberos.flags.TicketFlags;
 import org.junit.Before;
 import org.junit.Test;
-import static org.junit.Assert.*;
 
 
 /**
  * Test cases for KrbCredInfo codec.
- * 
+ *
  * This test class assumes that the encoding of KrbCredInfo class is correct and highly relies
on its functionality
  * to generate test PDUs instead of generating them by hand. Also note that the accuracy
of this test case depends on
- * the accuracy of the encoding done by the components constituted in KrbCredInfo ASN.1 structure

+ * the accuracy of the encoding done by the components constituted in KrbCredInfo ASN.1 structure
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -140,11 +141,12 @@ public class KrbCredInfoDecoderTest
     public void testKrbCredInfo() throws Exception
     {
         // algorithm:
-        // start from the first mandatory element and then add one of the subsequent OPTIONAL
elements(in order) then 
+        // start from the first mandatory element and then add one of the subsequent OPTIONAL
elements(in order) then
         // start adding/removing subsequent OPTIONAL elements(those which fall after the
above OPTIONAL element)
         // one by one and then test decoding
 
         int size = optionalFieldValueList.size();
+
         for ( int i = 0; i < size; i++ )
         {
             KrbCredInfo expected = new KrbCredInfo();
@@ -242,13 +244,14 @@ public class KrbCredInfoDecoderTest
     /**
      * compare the values that are inserted into the KrbCredInfo objects before encoding
to
      * those that are obtained from decoded KrbCredInfo
-     * 
+     *
      * @param presentFieldList the list of values that were inserted in the KrbCredInfo class
before encoding
-     * @param decoded the decoded KrbCredInfo object 
+     * @param decoded the decoded KrbCredInfo object
      */
     private void assertValues( List<FieldValueHolder> presentFieldList, KrbCredInfo
decoded ) throws Exception
     {
         Map<String, Field> krbCredInfoFieldNameMap = getFieldMap( decoded );
+
         for ( FieldValueHolder fh : presentFieldList )
         {
             Field actualField = krbCredInfoFieldNameMap.get( fh.fieldName.toLowerCase() );
@@ -263,7 +266,7 @@ public class KrbCredInfoDecoderTest
 
     /**
      * create a map with the field's name and field objects of the KrbCreInfo
-     * 
+     *
      * @param source the KrbCredInfo object
      */
     private Map<String, Field> getFieldMap( KrbCredInfo source )

Modified: directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java?rev=1068124&r1=1068123&r2=1068124&view=diff
==============================================================================
--- directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java
(original)
+++ directory/apacheds/branches/m1/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java
Mon Feb  7 20:49:04 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.kerberos.codec.options;
 
@@ -28,11 +28,12 @@ import org.junit.Test;
 
 /**
  * Test the Options class
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class OptionsTest
 {
+    @SuppressWarnings("serial")
     private class MyOptions extends Options
     {
         private MyOptions()
@@ -40,19 +41,19 @@ public class OptionsTest
             super( 22 );
         }
     }
-    
+
     @Test
     public void testAddBytes()
     {
-        MyOptions myOptions = new MyOptions(); 
-        
+        MyOptions myOptions = new MyOptions();
+
         // Set the bits 10-0100 1010-1100 0000-0110
         myOptions.setBytes( new byte[]{ 0x02, (byte)0x92, (byte)0xB0, 0x18} );
 
         assertEquals( "1001001010110000000110", myOptions.toString() );
         assertFalse( myOptions.get( 21 ) );
         assertTrue( myOptions.get( 20 ) );
-        
+
         try
         {
             myOptions.get( 22 );



Mime
View raw message