Author: mcucchiara
Date: Thu Oct 13 10:30:50 2011
New Revision: 1182769

URL: http://svn.apache.org/viewvc?rev=1182769&view=rev
Log:
Added new test get method

Modified:
    
commons/proper/ognl/branches/new-cache-approach/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java

Modified: 
commons/proper/ognl/branches/new-cache-approach/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
URL: 
http://svn.apache.org/viewvc/commons/proper/ognl/branches/new-cache-approach/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java?rev=1182769&r1=1182768&r2=1182769&view=diff
==============================================================================
--- 
commons/proper/ognl/branches/new-cache-approach/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
 (original)
+++ 
commons/proper/ognl/branches/new-cache-approach/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
 Thu Oct 13 10:30:50 2011
@@ -20,6 +20,7 @@
 package org.apache.commons.ognl;
 
 import org.apache.commons.ognl.test.objects.BaseGeneric;
+import org.apache.commons.ognl.test.objects.Bean1;
 import org.apache.commons.ognl.test.objects.Bean2;
 import org.apache.commons.ognl.test.objects.FormImpl;
 import org.apache.commons.ognl.test.objects.GameGeneric;
@@ -38,6 +39,7 @@ import org.apache.commons.ognl.test.obje
 import org.apache.commons.ognl.test.objects.SubclassSyntheticObject;
 import org.junit.Test;
 
+import java.beans.IntrospectionException;
 import java.beans.PropertyDescriptor;
 import java.io.Serializable;
 import java.lang.reflect.Field;
@@ -54,123 +56,123 @@ public class TestOgnlRuntime
 {
 
     @Test
-    public void test_Get_Super_Or_Interface_Class()
+    public void test_Get_Super_Or_Interface_Class( )
         throws Exception
     {
-        ListSource list = new ListSourceImpl();
+        ListSource list = new ListSourceImpl( );
 
-        Method m = OgnlRuntime.getReadMethod( list.getClass(), "total" );
+        Method m = OgnlRuntime.getReadMethod( list.getClass( ), "total" );
         assertNotNull( m );
 
-        assertEquals( ListSource.class, 
OgnlRuntime.getCompiler().getSuperOrInterfaceClass( m, list.getClass() ) );
+        assertEquals( ListSource.class, OgnlRuntime.getCompiler( 
).getSuperOrInterfaceClass( m, list.getClass( ) ) );
     }
 
     @Test
-    public void test_Get_Private_Class()
+    public void test_Get_Private_Class( )
         throws Exception
     {
         List list = Arrays.asList( "hello", "world" );
 
-        Method m = OgnlRuntime.getReadMethod( list.getClass(), "iterator" );
+        Method m = OgnlRuntime.getReadMethod( list.getClass( ), "iterator" );
         assertNotNull( m );
 
-        assertEquals( Iterable.class, 
OgnlRuntime.getCompiler().getSuperOrInterfaceClass( m, list.getClass() ) );
+        assertEquals( Iterable.class, OgnlRuntime.getCompiler( 
).getSuperOrInterfaceClass( m, list.getClass( ) ) );
     }
 
     @Test
-    public void test_Complicated_Inheritance()
+    public void test_Complicated_Inheritance( )
         throws Exception
     {
-        IForm form = new FormImpl();
+        IForm form = new FormImpl( );
 
-        Method m = OgnlRuntime.getWriteMethod( form.getClass(), "clientId" );
+        Method m = OgnlRuntime.getWriteMethod( form.getClass( ), "clientId" );
         assertNotNull( m );
 
-        assertEquals( IComponent.class, 
OgnlRuntime.getCompiler().getSuperOrInterfaceClass( m, form.getClass() ) );
+        assertEquals( IComponent.class, OgnlRuntime.getCompiler( 
).getSuperOrInterfaceClass( m, form.getClass( ) ) );
     }
 
     @Test
-    public void test_Get_Read_Method()
+    public void test_Get_Read_Method( )
         throws Exception
     {
         Method m = OgnlRuntime.getReadMethod( Bean2.class, "pageBreakAfter" );
         assertNotNull( m );
 
-        assertEquals( "isPageBreakAfter", m.getName() );
+        assertEquals( "isPageBreakAfter", m.getName( ) );
     }
 
     class TestGetters
     {
-        public boolean isEditorDisabled()
+        public boolean isEditorDisabled( )
         {
             return false;
         }
 
-        public boolean isDisabled()
+        public boolean isDisabled( )
         {
             return true;
         }
 
-        public boolean isNotAvailable()
+        public boolean isNotAvailable( )
         {
             return false;
         }
 
-        public boolean isAvailable()
+        public boolean isAvailable( )
         {
             return true;
         }
     }
 
     @Test
-    public void test_Get_Read_Method_Multiple()
+    public void test_Get_Read_Method_Multiple( )
         throws Exception
     {
         Method m = OgnlRuntime.getReadMethod( TestGetters.class, "disabled" );
         assertNotNull( m );
 
-        assertEquals( "isDisabled", m.getName() );
+        assertEquals( "isDisabled", m.getName( ) );
     }
 
     @Test
-    public void test_Get_Read_Method_Multiple_Boolean_Getters()
+    public void test_Get_Read_Method_Multiple_Boolean_Getters( )
         throws Exception
     {
         Method m = OgnlRuntime.getReadMethod( TestGetters.class, "available" );
         assertNotNull( m );
 
-        assertEquals( "isAvailable", m.getName() );
+        assertEquals( "isAvailable", m.getName( ) );
 
         m = OgnlRuntime.getReadMethod( TestGetters.class, "notAvailable" );
         assertNotNull( m );
 
-        assertEquals( "isNotAvailable", m.getName() );
+        assertEquals( "isNotAvailable", m.getName( ) );
     }
 
     @Test
-    public void test_Find_Method_Mixed_Boolean_Getters()
+    public void test_Find_Method_Mixed_Boolean_Getters( )
         throws Exception
     {
         Method m = OgnlRuntime.getReadMethod( GetterMethods.class, 
"allowDisplay" );
         assertNotNull( m );
 
-        assertEquals( "getAllowDisplay", m.getName() );
+        assertEquals( "getAllowDisplay", m.getName( ) );
     }
 
     @Test
-    public void test_Get_Appropriate_Method()
+    public void test_Get_Appropriate_Method( )
         throws Exception
     {
-        ListSource list = new ListSourceImpl();
+        ListSource list = new ListSourceImpl( );
         OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
 
-        Object ret = OgnlRuntime.callMethod( context, list, "addValue", new 
String[] { null } );
+        Object ret = OgnlRuntime.callMethod( context, list, "addValue", new 
String[]{ null } );
 
         assert ret != null;
     }
 
     @Test
-    public void test_Call_Static_Method_Invalid_Class()
+    public void test_Call_Static_Method_Invalid_Class( )
     {
 
         try
@@ -185,18 +187,18 @@ public class TestOgnlRuntime
         {
 
             assertTrue( MethodFailedException.class.isInstance( et ) );
-            assertTrue( et.getMessage().contains( "made.up.Name" ) );
+            assertTrue( et.getMessage( ).contains( "made.up.Name" ) );
         }
     }
 
     @Test
-    public void test_Setter_Returns()
+    public void test_Setter_Returns( )
         throws Exception
     {
         OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-        SetterReturns root = new SetterReturns();
+        SetterReturns root = new SetterReturns( );
 
-        Method m = OgnlRuntime.getWriteMethod( root.getClass(), "value" );
+        Method m = OgnlRuntime.getWriteMethod( root.getClass( ), "value" );
         assertTrue( m != null );
 
         Ognl.setValue( "value", context, root, "12__" );
@@ -204,47 +206,47 @@ public class TestOgnlRuntime
     }
 
     @Test
-    public void test_Call_Method_VarArgs()
+    public void test_Call_Method_VarArgs( )
         throws Exception
     {
         OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
-        GenericService service = new GenericServiceImpl();
+        GenericService service = new GenericServiceImpl( );
 
-        GameGenericObject argument = new GameGenericObject();
+        GameGenericObject argument = new GameGenericObject( );
 
-        Object[] args = OgnlRuntime.getObjectArrayPool().create( 2 );
+        Object[] args = OgnlRuntime.getObjectArrayPool( ).create( 2 );
         args[0] = argument;
 
         assertEquals( "Halo 3", OgnlRuntime.callMethod( context, service, 
"getFullMessageFor", args ) );
     }
 
     @Test
-    public void test_Class_Cache_Inspector()
+    public void test_Class_Cache_Inspector( )
         throws Exception
     {
-        OgnlRuntime.clearCache();
-        assertEquals( 0, OgnlRuntime._propertyDescriptorCache.getSize() );
+        OgnlRuntime.clearCache( );
+        assertEquals( 0, OgnlRuntime._propertyDescriptorCache.getSize( ) );
 
-        Root root = new Root();
+        Root root = new Root( );
         OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
         Node expr = Ognl.compileExpression( context, root, 
"property.bean3.value != null" );
 
-        assertTrue( (Boolean) expr.getAccessor().get( context, root ) );
+        assertTrue( (Boolean) expr.getAccessor( ).get( context, root ) );
 
-        int size = OgnlRuntime._propertyDescriptorCache.getSize();
+        int size = OgnlRuntime._propertyDescriptorCache.getSize( );
         assertTrue( size > 0 );
 
-        OgnlRuntime.clearCache();
-        assertEquals( 0, OgnlRuntime._propertyDescriptorCache.getSize() );
+        OgnlRuntime.clearCache( );
+        assertEquals( 0, OgnlRuntime._propertyDescriptorCache.getSize( ) );
 
         // now register class cache prevention
 
-        OgnlRuntime.setClassCacheInspector( new TestCacheInspector() );
+        OgnlRuntime.setClassCacheInspector( new TestCacheInspector( ) );
 
         expr = Ognl.compileExpression( context, root, "property.bean3.value != 
null" );
-        assertTrue( (Boolean) expr.getAccessor().get( context, root ) );
+        assertTrue( (Boolean) expr.getAccessor( ).get( context, root ) );
 
-        assertEquals( ( size - 1 ), 
OgnlRuntime._propertyDescriptorCache.getSize() );
+        assertEquals( ( size - 1 ), 
OgnlRuntime._propertyDescriptorCache.getSize( ) );
     }
 
     class TestCacheInspector
@@ -258,7 +260,7 @@ public class TestOgnlRuntime
     }
 
     @Test
-    public void test_Set_Generic_Parameter_Types()
+    public void test_Set_Generic_Parameter_Types( )
         throws Exception
     {
         OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
@@ -266,13 +268,13 @@ public class TestOgnlRuntime
         Method m = OgnlRuntime.getSetMethod( context, GenericCracker.class, 
"param" );
         assertNotNull( m );
 
-        Class[] types = m.getParameterTypes();
+        Class[] types = m.getParameterTypes( );
         assertEquals( 1, types.length );
         assertEquals( Integer.class, types[0] );
     }
 
     @Test
-    public void test_Get_Generic_Parameter_Types()
+    public void test_Get_Generic_Parameter_Types( )
         throws Exception
     {
         OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
@@ -280,11 +282,11 @@ public class TestOgnlRuntime
         Method m = OgnlRuntime.getGetMethod( context, GenericCracker.class, 
"param" );
         assertNotNull( m );
 
-        assertEquals( Integer.class, m.getReturnType() );
+        assertEquals( Integer.class, m.getReturnType( ) );
     }
 
     @Test
-    public void test_Find_Parameter_Types()
+    public void test_Find_Parameter_Types( )
         throws Exception
     {
         OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
@@ -298,7 +300,7 @@ public class TestOgnlRuntime
     }
 
     @Test
-    public void test_Find_Parameter_Types_Superclass()
+    public void test_Find_Parameter_Types_Superclass( )
         throws Exception
     {
         OgnlContext context = (OgnlContext) Ognl.createDefaultContext( null );
@@ -312,7 +314,7 @@ public class TestOgnlRuntime
     }
 
     @Test
-    public void test_Get_Declared_Methods_With_Synthetic_Methods()
+    public void test_Get_Declared_Methods_With_Synthetic_Methods( )
         throws Exception
     {
         List result = OgnlRuntime.getDeclaredMethods( 
SubclassSyntheticObject.class, "list", false );
@@ -321,17 +323,17 @@ public class TestOgnlRuntime
         // "public volatile java.util.List 
org.ognl.test.objects.SubclassSyntheticObject.getList()",
         // causing method return size to be 3
 
-        assertEquals( 2, result.size() );
+        assertEquals( 2, result.size( ) );
     }
 
     @Test
-    public void test_Get_Property_Descriptors_With_Synthetic_Methods()
+    public void test_Get_Property_Descriptors_With_Synthetic_Methods( )
         throws Exception
     {
         PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor( 
SubclassSyntheticObject.class, "list" );
 
         assert pd != null;
-        assert OgnlRuntime.isMethodCallable( pd.getReadMethod() );
+        assert OgnlRuntime.isMethodCallable( pd.getReadMethod( ) );
     }
 
     private static class GenericParent<T>
@@ -358,7 +360,7 @@ public class TestOgnlRuntime
      * Tests OGNL parameter discovery.
      */
     @Test
-    public void testOGNLParameterDiscovery()
+    public void testOGNLParameterDiscovery( )
         throws NoSuchMethodException
     {
         Method saveMethod = GenericParent.class.getMethod( "save", 
Object.class );
@@ -378,7 +380,16 @@ public class TestOgnlRuntime
         throws OgnlException
     {
         Field field = OgnlRuntime.getField( OtherObjectIndexed.class, 
"attributes" );
-        assertNotNull( "Field is null", field);
+        assertNotNull( "Field is null", field );
     }
 
+    @Test
+    public void testGetSetMethod( )
+        throws IntrospectionException, OgnlException
+    {
+        Method setter = OgnlRuntime.getSetMethod( null, Bean1.class, "bean2" );
+        Method getter = OgnlRuntime.getGetMethod( null, Bean1.class, "bean2" );
+        assertNotNull( getter );
+        assertNull( setter );
+    }
 }


Reply via email to