commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1235012 - in /commons/sandbox/beanutils2/trunk/src: changes/changes.xml test/java/org/apache/commons/beanutils2/ArgumentTest.java
Date Mon, 23 Jan 2012 21:49:36 GMT
Author: simonetripodi
Date: Mon Jan 23 21:49:35 2012
New Revision: 1235012

URL: http://svn.apache.org/viewvc?rev=1235012&view=rev
Log:
[SANDBOX-362] Create basic unit tests for all classes - patch provided by Benedikt Ritter

Modified:
    commons/sandbox/beanutils2/trunk/src/changes/changes.xml
    commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ArgumentTest.java

Modified: commons/sandbox/beanutils2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/changes/changes.xml?rev=1235012&r1=1235011&r2=1235012&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/changes/changes.xml (original)
+++ commons/sandbox/beanutils2/trunk/src/changes/changes.xml Mon Jan 23 21:49:35 2012
@@ -29,6 +29,9 @@
     <action dev="simonetripodi" type="update" issue="SANDBOX-363" due-to="Benedikt Ritter">
       Check if value is of the correct type in Argument.argument( Class&lt;T&gt;
type, V value )
     </action>
+    <action dev="simonetripodi" type="update" issue="SANDBOX-362" due-to="Benedikt Ritter">
+      Create basic unit tests for all classes
+    </action>
     <action dev="simonetripodi" type="update" issue="SANDBOX-360" due-to="Benedikt Ritter">
       Rename Converter&lt;T, S&gt; to Transformer&lt;T, S&gt;.
     </action>

Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ArgumentTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ArgumentTest.java?rev=1235012&r1=1235011&r2=1235012&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ArgumentTest.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ArgumentTest.java
Mon Jan 23 21:49:35 2012
@@ -19,63 +19,126 @@ package org.apache.commons.beanutils2;
 
 import static org.apache.commons.beanutils2.Argument.argument;
 import static org.apache.commons.beanutils2.Argument.getParameterTypes;
+import static org.apache.commons.beanutils2.Argument.getParameters;
 import static org.apache.commons.beanutils2.Argument.nullArgument;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import org.junit.Test;
 
 public class ArgumentTest
 {
 
+    private static byte fByte = 7;
+
+    private static short fShort = 39;
+
+    private static int fInt = 96;
+
+    private static long fLong = 1569875l;
+
+    private static float fFloat = 47.11f;
+
+    private static double fDouble = 0.345e-36d;
+
+    private static char fChar = 'X';
+
+    private static String fString = "Testing is important!";
+
+    private static Object fObject = new Object();
+
+    private static TestBean fTestBean = new TestBean( true, fString );
+
     @Test
-    public void argumentA()
+    public void argumentBoolean()
     {
         Argument<Boolean> booleanArg = argument( true );
         assertTrue( booleanArg.getValue().booleanValue() );
         assertEquals( Boolean.class, booleanArg.getType() );
+    }
 
-        Argument<Byte> byteArg = argument( new Byte( (byte) 7 ) );
-        assertEquals( (byte) 7, byteArg.getValue().byteValue() );
+    @Test
+    public void argumentByte()
+    {
+        Argument<Byte> byteArg = argument( new Byte( fByte ) );
+        assertEquals( fByte, byteArg.getValue().byteValue() );
         assertEquals( Byte.class, byteArg.getType() );
+    }
 
-        Argument<Short> shortArg = argument( new Short( (short) 16 ) );
-        assertEquals( (short) 16, shortArg.getValue().shortValue() );
+    @Test
+    public void argumentShort()
+    {
+        Argument<Short> shortArg = argument( new Short( fShort ) );
+        assertEquals( fShort, shortArg.getValue().shortValue() );
         assertEquals( Short.class, shortArg.getType() );
+    }
 
-        Argument<Integer> intArg = argument( 2 );
-        assertEquals( 2, intArg.getValue().intValue() );
+    @Test
+    public void argumentInt()
+    {
+        Argument<Integer> intArg = argument( fInt );
+        assertEquals( fInt, intArg.getValue().intValue() );
         assertEquals( Integer.class, intArg.getType() );
+    }
 
-        Argument<Long> longArg = argument( 76l );
-        assertEquals( 76l, longArg.getValue().longValue() );
+    @Test
+    public void argumentLong()
+    {
+        Argument<Long> longArg = argument( fLong );
+        assertEquals( fLong, longArg.getValue().longValue() );
         assertEquals( Long.class, longArg.getType() );
+    }
 
-        Argument<Float> floatArg = argument( 23.7f );
-        assertEquals( 23.7f, floatArg.getValue().floatValue(), 0.0d );
+    @Test
+    public void argumentFloat()
+    {
+        Argument<Float> floatArg = argument( fFloat );
+        assertEquals( fFloat, floatArg.getValue().floatValue(), 0.0d );
         assertEquals( Float.class, floatArg.getType() );
+    }
 
-        Argument<Double> doubleArg = argument( 289.6d );
-        assertEquals( 289.6d, doubleArg.getValue().doubleValue(), 0.0d );
+    @Test
+    public void argumentDouble()
+    {
+        Argument<Double> doubleArg = argument( fDouble );
+        assertEquals( fDouble, doubleArg.getValue().doubleValue(), 0.0d );
         assertEquals( Double.class, doubleArg.getType() );
+    }
 
-        Argument<Character> charArg = argument( 'X' );
-        assertEquals( 'X', charArg.getValue().charValue() );
+    @Test
+    public void argumentChar()
+    {
+        Argument<Character> charArg = argument( fChar );
+        assertEquals( fChar, charArg.getValue().charValue() );
         assertEquals( Character.class, charArg.getType() );
+    }
 
-        Argument<String> stringArg = argument( "Hello World!" );
-        assertEquals( "Hello World!", stringArg.getValue() );
+    @Test
+    public void argumentString()
+    {
+        Argument<String> stringArg = argument( fString );
+        assertEquals( fString, stringArg.getValue() );
         assertEquals( String.class, stringArg.getType() );
+    }
 
-        Object valueObj = new Object();
-        Argument<Object> objArg = argument( valueObj );
-        assertEquals( valueObj, objArg.getValue() );
+    @Test
+    public void argumentObject()
+    {
+        Argument<Object> objArg = argument( fObject );
+        assertEquals( fObject, objArg.getValue() );
         assertEquals( Object.class, objArg.getType() );
     }
 
+    @Test
+    public void argumentTestBean()
+    {
+        Argument<TestBean> testBeanArg = argument( fTestBean );
+        assertEquals( fTestBean, testBeanArg.getValue() );
+        assertEquals( TestBean.class, testBeanArg.getType() );
+    }
+
     @Test( expected = NullPointerException.class )
     public void argumentNull()
     {
@@ -83,81 +146,158 @@ public class ArgumentTest
     }
 
     @Test
-    public void nullArgumentClassOfA()
+    public void nullArgumentClassOfBooleanClass()
     {
         Argument<Boolean> booleanArg = nullArgument( Boolean.class );
         assertNull( booleanArg.getValue() );
         assertEquals( Boolean.class, booleanArg.getType() );
 
-        booleanArg = nullArgument( Boolean.TYPE );
+    }
+
+    @Test
+    public void nullArgumentClassOfBooleanType()
+    {
+        Argument<Boolean> booleanArg = nullArgument( Boolean.TYPE );
         assertNull( booleanArg.getValue() );
         assertEquals( Boolean.TYPE, booleanArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfByteClass()
+    {
         Argument<Byte> byteArg = nullArgument( Byte.class );
         assertNull( byteArg.getValue() );
         assertEquals( Byte.class, byteArg.getType() );
+    }
 
-        byteArg = nullArgument( Byte.TYPE );
+    @Test
+    public void nullArgumentClassOfByteType()
+    {
+        Argument<Byte> byteArg = nullArgument( Byte.TYPE );
         assertNull( byteArg.getValue() );
         assertEquals( Byte.TYPE, byteArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfShortClass()
+    {
         Argument<Short> shortArg = nullArgument( Short.class );
         assertNull( shortArg.getValue() );
         assertEquals( Short.class, shortArg.getType() );
+    }
 
-        shortArg = nullArgument( Short.TYPE );
+    @Test
+    public void nullArgumentClassOfShortType()
+    {
+        Argument<Short> shortArg = nullArgument( Short.TYPE );
         assertNull( shortArg.getValue() );
         assertEquals( Short.TYPE, shortArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfIntegerClass()
+    {
         Argument<Integer> intArg = nullArgument( Integer.class );
         assertNull( intArg.getValue() );
         assertEquals( Integer.class, intArg.getType() );
+    }
 
-        intArg = nullArgument( Integer.TYPE );
+    @Test
+    public void nullArgumentClassOfIntegerType()
+    {
+        Argument<Integer> intArg = nullArgument( Integer.TYPE );
         assertNull( intArg.getValue() );
         assertEquals( Integer.TYPE, intArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfLongClass()
+    {
         Argument<Long> longArg = nullArgument( Long.class );
         assertNull( longArg.getValue() );
         assertEquals( Long.class, longArg.getType() );
+    }
 
-        longArg = nullArgument( Long.TYPE );
+    @Test
+    public void nullArgumentClassOfLongType()
+    {
+        Argument<Long> longArg = nullArgument( Long.TYPE );
         assertNull( longArg.getValue() );
         assertEquals( Long.TYPE, longArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfFloatClass()
+    {
         Argument<Float> floatArg = nullArgument( Float.class );
         assertNull( floatArg.getValue() );
         assertEquals( Float.class, floatArg.getType() );
+    }
 
-        floatArg = nullArgument( Float.TYPE );
+    @Test
+    public void nullArgumentClassOfFloatType()
+    {
+        Argument<Float> floatArg = nullArgument( Float.TYPE );
         assertNull( floatArg.getValue() );
         assertEquals( Float.TYPE, floatArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfDoubleClass()
+    {
         Argument<Double> doubleArg = nullArgument( Double.class );
         assertNull( doubleArg.getValue() );
         assertEquals( Double.class, doubleArg.getType() );
+    }
 
-        doubleArg = nullArgument( Double.TYPE );
+    @Test
+    public void nullArgumentClassOfDoubleType()
+    {
+        Argument<Double> doubleArg = nullArgument( Double.TYPE );
         assertNull( doubleArg.getValue() );
         assertEquals( Double.TYPE, doubleArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfCharacterClass()
+    {
         Argument<Character> charArg = nullArgument( Character.class );
         assertNull( charArg.getValue() );
         assertEquals( Character.class, charArg.getType() );
+    }
 
-        charArg = nullArgument( Character.TYPE );
+    @Test
+    public void nullArgumentClassOfCharacterType()
+    {
+        Argument<Character> charArg = nullArgument( Character.TYPE );
         assertNull( charArg.getValue() );
         assertEquals( Character.TYPE, charArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfStringClass()
+    {
         Argument<String> stringArg = nullArgument( String.class );
         assertNull( stringArg.getValue() );
         assertEquals( String.class, stringArg.getType() );
+    }
 
+    @Test
+    public void nullArgumentClassOfObjectClass()
+    {
         Argument<Object> objArg = nullArgument( Object.class );
         assertNull( objArg.getValue() );
         assertEquals( Object.class, objArg.getType() );
     }
 
+    @Test
+    public void nullArgumentClassOfTestBeanClass()
+    {
+        Argument<TestBean> testBeanArg = nullArgument( TestBean.class );
+        assertNull( testBeanArg.getValue() );
+        assertEquals( TestBean.class, testBeanArg.getType() );
+    }
+
     @Test( expected = NullPointerException.class )
     public void nullArgumentClassOfANull()
     {
@@ -165,108 +305,171 @@ public class ArgumentTest
     }
 
     @Test
-    public void argumentClassOfTV()
+    public void argumentClassOfBooleanClass()
     {
         Argument<Boolean> booleanArg = argument( Boolean.class, Boolean.TRUE );
         assertTrue( booleanArg.getValue().booleanValue() );
         assertEquals( Boolean.class, booleanArg.getType() );
+    }
 
-        booleanArg = argument( Boolean.TYPE, Boolean.TRUE );
+    @Test
+    public void argumentClassOfBooleanType()
+    {
+        Argument<Boolean> booleanArg = argument( Boolean.TYPE, Boolean.TRUE );
         assertTrue( booleanArg.getValue().booleanValue() );
         assertEquals( Boolean.TYPE, booleanArg.getType() );
+    }
 
-        Argument<Byte> byteArg = argument( Byte.class, new Byte( (byte) 7 ) );
-        assertEquals( (byte) 7, byteArg.getValue().byteValue() );
+    @Test
+    public void argumentClassOfByteClass()
+    {
+        Argument<Byte> byteArg = argument( Byte.class, new Byte( fByte ) );
+        assertEquals( fByte, byteArg.getValue().byteValue() );
         assertEquals( Byte.class, byteArg.getType() );
+    }
 
-        byteArg = argument( Byte.TYPE, new Byte( (byte) 7 ) );
-        assertEquals( (byte) 7, byteArg.getValue().byteValue() );
+    @Test
+    public void argumentClassOfByteType()
+    {
+        Argument<Byte> byteArg = argument( Byte.TYPE, new Byte( fByte ) );
+        assertEquals( fByte, byteArg.getValue().byteValue() );
         assertEquals( Byte.TYPE, byteArg.getType() );
+    }
 
-        Argument<Short> shortArg = argument( Short.class, new Short( (short) 16 ) );
-        assertEquals( (short) 16, shortArg.getValue().shortValue() );
+    @Test
+    public void argumentClassOfShortClass()
+    {
+        Argument<Short> shortArg = argument( Short.class, new Short( fShort ) );
+        assertEquals( fShort, shortArg.getValue().shortValue() );
         assertEquals( Short.class, shortArg.getType() );
+    }
 
-        shortArg = argument( Short.TYPE, new Short( (short) 16 ) );
-        assertEquals( (short) 16, shortArg.getValue().shortValue() );
+    @Test
+    public void argumentClassOfShortType()
+    {
+        Argument<Short> shortArg = argument( Short.TYPE, new Short( fShort ) );
+        assertEquals( fShort, shortArg.getValue().shortValue() );
         assertEquals( Short.TYPE, shortArg.getType() );
+    }
 
-        Argument<Integer> intArg = argument( Integer.class, 2 );
-        assertEquals( 2, intArg.getValue().intValue() );
+    @Test
+    public void argumentClassOfIntegerClass()
+    {
+        Argument<Integer> intArg = argument( Integer.class, fInt );
+        assertEquals( fInt, intArg.getValue().intValue() );
         assertEquals( Integer.class, intArg.getType() );
+    }
 
-        intArg = argument( Integer.TYPE, 2 );
-        assertEquals( 2, intArg.getValue().intValue() );
+    @Test
+    public void argumentClassOfIntegerType()
+    {
+        Argument<Integer> intArg = argument( Integer.TYPE, fInt );
+        assertEquals( fInt, intArg.getValue().intValue() );
         assertEquals( Integer.TYPE, intArg.getType() );
+    }
 
-        Argument<Long> longArg = argument( Long.class, 76l );
-        assertEquals( 76l, longArg.getValue().longValue() );
+    @Test
+    public void argumentClassOfLongClass()
+    {
+        Argument<Long> longArg = argument( Long.class, fLong );
+        assertEquals( fLong, longArg.getValue().longValue() );
         assertEquals( Long.class, longArg.getType() );
+    }
 
-        longArg = argument( Long.TYPE, 76l );
-        assertEquals( 76l, longArg.getValue().longValue() );
+    @Test
+    public void argumentClassOfLongType()
+    {
+        Argument<Long> longArg = argument( Long.TYPE, fLong );
+        assertEquals( fLong, longArg.getValue().longValue() );
         assertEquals( Long.TYPE, longArg.getType() );
+    }
 
-        Argument<Float> floatArg = argument( Float.class, 23.7f );
-        assertEquals( 23.7f, floatArg.getValue().floatValue(), 0.0d );
+    @Test
+    public void argumentClassOfFloatClass()
+    {
+        Argument<Float> floatArg = argument( Float.class, fFloat );
+        assertEquals( fFloat, floatArg.getValue().floatValue(), 0.0d );
         assertEquals( Float.class, floatArg.getType() );
+    }
 
-        floatArg = argument( Float.TYPE, 23.7f );
-        assertEquals( 23.7f, floatArg.getValue().floatValue(), 0.0d );
+    @Test
+    public void argumentClassOfFloatType()
+    {
+        Argument<Float> floatArg = argument( Float.TYPE, fFloat );
+        assertEquals( fFloat, floatArg.getValue().floatValue(), 0.0d );
         assertEquals( Float.TYPE, floatArg.getType() );
+    }
 
-        Argument<Double> doubleArg = argument( Double.class, 289.6d );
-        assertEquals( 289.6d, doubleArg.getValue().doubleValue(), 0.0d );
+    @Test
+    public void argumentClassOfDoubleClass()
+    {
+        Argument<Double> doubleArg = argument( Double.class, fDouble );
+        assertEquals( fDouble, doubleArg.getValue().doubleValue(), 0.0d );
         assertEquals( Double.class, doubleArg.getType() );
+    }
 
-        doubleArg = argument( Double.TYPE, 289.6d );
-        assertEquals( 289.6d, doubleArg.getValue().doubleValue(), 0.0d );
+    @Test
+    public void argumentClassOfDoubleType()
+    {
+        Argument<Double> doubleArg = argument( Double.TYPE, fDouble );
+        assertEquals( fDouble, doubleArg.getValue().doubleValue(), 0.0d );
         assertEquals( Double.TYPE, doubleArg.getType() );
+    }
 
-        Argument<Character> charArg = argument( Character.class, 'X' );
-        assertEquals( 'X', charArg.getValue().charValue() );
+    @Test
+    public void argumentOfClassCharacterClass()
+    {
+        Argument<Character> charArg = argument( Character.class, fChar );
+        assertEquals( fChar, charArg.getValue().charValue() );
         assertEquals( Character.class, charArg.getType() );
+    }
 
-        charArg = argument( Character.TYPE, 'X' );
-        assertEquals( 'X', charArg.getValue().charValue() );
+    @Test
+    public void argumentOfClassCharacterType()
+    {
+        Argument<Character> charArg = argument( Character.TYPE, fChar );
+        assertEquals( fChar, charArg.getValue().charValue() );
         assertEquals( Character.TYPE, charArg.getType() );
+    }
 
-        Argument<String> stringArg = argument( String.class, "Hello World!" );
-        assertEquals( "Hello World!", stringArg.getValue() );
+    @Test
+    public void argumentOfClassStringClass()
+    {
+        Argument<String> stringArg = argument( String.class, fString );
+        assertEquals( fString, stringArg.getValue() );
         assertEquals( String.class, stringArg.getType() );
+    }
 
-        Object valueObj = new Object();
-        Argument<Object> objArg = argument( Object.class, valueObj );
-        assertEquals( valueObj, objArg.getValue() );
+    @Test
+    public void argumentClassOfObjectClass()
+    {
+        Argument<Object> objArg = argument( Object.class, fObject );
+        assertEquals( fObject, objArg.getValue() );
         assertEquals( Object.class, objArg.getType() );
     }
 
     @Test
-    public void argumentClassOfTVNull()
+    public void argumentClassOfTestBeanClass()
+    {
+        Argument<TestBean> testBeanArg = argument( TestBean.class, fTestBean );
+        assertEquals( fTestBean, testBeanArg.getValue() );
+        assertEquals( TestBean.class, testBeanArg.getType() );
+    }
+
+    @Test( expected = NullPointerException.class )
+    public void argumentClassOfNullNull()
     {
-        try
-        {
-            argument( null, null );
-            fail( "NullPointerException was not thrown!" );
-        }
-        catch ( NullPointerException e )
-        {
-            // do nothing here, we want this exception to be thrown!
-        }
-
-        try
-        {
-            argument( null, 25 );
-            fail( "NullPointerException was not thrown!" );
-        }
-        catch ( NullPointerException e )
-        {
-            // do nothing here, we want this exception to be thrown!
-        }
+        argument( null, null );
+    }
+
+    @Test( expected = NullPointerException.class )
+    public void argumentClassOfNullInt()
+    {
+        argument( null, 25 );
     }
 
     @Test
-    public void getParameterTypesArgumentsOfQ()
+    public void getParameterTypesArgumentsOfWrapperClasses()
     {
         Argument<Boolean> booleanArg = nullArgument( Boolean.class );
         Argument<Byte> byteArg = nullArgument( Byte.class );
@@ -278,10 +481,11 @@ public class ArgumentTest
         Argument<Character> charArg = nullArgument( Character.class );
         Argument<String> stringArg = nullArgument( String.class );
         Argument<Object> objArg = nullArgument( Object.class );
+        Argument<TestBean> testBeanArg = nullArgument( TestBean.class );
 
         Class<?>[] types =
-            getParameterTypes( booleanArg, byteArg, shortArg, intArg, longArg, 
-                               floatArg, doubleArg, charArg, stringArg, objArg );
+            getParameterTypes( booleanArg, byteArg, shortArg, intArg, longArg, floatArg,
doubleArg, charArg, stringArg,
+                               objArg, testBeanArg );
         assertNotNull( types );
         assertEquals( Boolean.class, types[0] );
         assertEquals( Byte.class, types[1] );
@@ -293,20 +497,23 @@ public class ArgumentTest
         assertEquals( Character.class, types[7] );
         assertEquals( String.class, types[8] );
         assertEquals( Object.class, types[9] );
+        assertEquals( TestBean.class, types[10] );
+    }
 
-        // do the same for simple types
-        booleanArg = nullArgument( Boolean.TYPE );
-        byteArg = nullArgument( Byte.TYPE );
-        shortArg = nullArgument( Short.TYPE );
-        intArg = nullArgument( Integer.TYPE );
-        longArg = nullArgument( Long.TYPE );
-        floatArg = nullArgument( Float.TYPE );
-        doubleArg = nullArgument( Double.TYPE );
-        charArg = nullArgument( Character.TYPE );
-
-        types =
-            getParameterTypes( booleanArg, byteArg, shortArg, intArg, longArg, 
-                               floatArg, doubleArg, charArg, stringArg, objArg );
+    @Test
+    public void getParameterTypesOfPrimitiveClasses()
+    {
+        Argument<Boolean> booleanArg = nullArgument( Boolean.TYPE );
+        Argument<Byte> byteArg = nullArgument( Byte.TYPE );
+        Argument<Short> shortArg = nullArgument( Short.TYPE );
+        Argument<Integer> intArg = nullArgument( Integer.TYPE );
+        Argument<Long> longArg = nullArgument( Long.TYPE );
+        Argument<Float> floatArg = nullArgument( Float.TYPE );
+        Argument<Double> doubleArg = nullArgument( Double.TYPE );
+        Argument<Character> charArg = nullArgument( Character.TYPE );
+
+        Class<?>[] types =
+            getParameterTypes( booleanArg, byteArg, shortArg, intArg, longArg, floatArg,
doubleArg, charArg );
         assertNotNull( types );
         assertEquals( Boolean.TYPE, types[0] );
         assertEquals( Byte.TYPE, types[1] );
@@ -318,37 +525,74 @@ public class ArgumentTest
         assertEquals( Character.TYPE, types[7] );
     }
 
+    @Test( expected = NullPointerException.class )
+    public void getParameterTypesArgumentsOfNull()
+    {
+        getParameterTypes( (Argument<?>) null );
+    }
+
+    @Test( expected = NullPointerException.class )
+    public void getParameterTypesArgumentsOfArgumentIntNull()
+    {
+        getParameterTypes( argument( 15 ), (Argument<?>) null );
+    }
+
+    @Test( expected = NullPointerException.class )
+    public void getParameterTypesArgumentsOfNullNull()
+    {
+        getParameterTypes( (Argument<?>) null, (Argument<?>) null );
+    }
+
     @Test
-    public void getParameterTypesArgumentsOfQNull()
+    public void getParametersArguments()
     {
-        try
-        {
-            getParameterTypes( (Argument<?>) null );
-            fail( "No exception has been thrown!" );
-        }
-        catch ( NullPointerException e )
-        {
-            // do nothing here, we want this exception to be thrown!
-        }
-
-        try
-        {
-            getParameterTypes( argument( 15 ), (Argument<?>) null );
-            fail( "No exception has been thrown!" );
-        }
-        catch ( NullPointerException e )
-        {
-            // do nothing here, we want this exception to be thrown!
-        }
-
-        try
-        {
-            getParameterTypes( (Argument<?>) null, (Argument<?>) null );
-            fail( "No exception has been thrown!" );
-        }
-        catch ( NullPointerException e )
-        {
-            // do nothing here, we want this exception to be thrown!
-        }
+        Argument<Boolean> booleanArg = argument( true );
+        Argument<Byte> byteArg = argument( fByte );
+        Argument<Short> shortArg = argument( fShort );
+        Argument<Integer> intArg = argument( fInt );
+        Argument<Long> longArg = argument( fLong );
+        Argument<Float> floatArg = argument( fFloat );
+        Argument<Double> doubleArg = argument( fDouble );
+        Argument<Character> charArg = argument( fChar );
+        Argument<String> stringArg = argument( fString );
+        Argument<Object> objArg = argument( fObject );
+        Argument<TestBean> testBeanArg = argument( fTestBean );
+        Argument<Object> nullArg = nullArgument( Object.class );
+
+        Object[] parameters =
+            getParameters( booleanArg, byteArg, shortArg, intArg, longArg, floatArg, doubleArg,
charArg, stringArg,
+                           objArg, testBeanArg, nullArg );
+
+        assertEquals( true, parameters[0] );
+        assertEquals( fByte, parameters[1] );
+        assertEquals( fShort, parameters[2] );
+        assertEquals( fInt, parameters[3] );
+        assertEquals( fLong, parameters[4] );
+        assertEquals( fFloat, parameters[5] );
+        assertEquals( fDouble, parameters[6] );
+        assertEquals( fChar, parameters[7] );
+        assertEquals( fString, parameters[8] );
+        assertEquals( fObject, parameters[9] );
+        assertEquals( fTestBean, parameters[10] );
+        assertNull( parameters[11] );
     }
+
+    @Test( expected = NullPointerException.class )
+    public void getParametersNull()
+    {
+        getParameters( (Argument<?>) null );
+    }
+
+    @Test( expected = NullPointerException.class )
+    public void getParametersIntNull()
+    {
+        getParameters( argument( fInt ), null );
+    }
+
+    @Test( expected = NullPointerException.class )
+    public void getParametersNullNull()
+    {
+        getParameters( null, null );
+    }
+
 }



Mime
View raw message