commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1366010 [2/2] - in /commons/sandbox/beanutils2/trunk/src: changes/ main/java/org/apache/commons/beanutils2/ test/java/org/apache/commons/beanutils2/ test/java/org/apache/commons/beanutils2/testbeans/
Date Thu, 26 Jul 2012 14:17:08 GMT
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterNotAccessibleException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterNotAccessibleException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterNotAccessibleException.java
(added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterNotAccessibleException.java
Thu Jul 26 14:17:06 2012
@@ -0,0 +1,42 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.
+ */
+
+public class PropertyGetterNotAccessibleException
+    extends MethodNotAccessibleException
+{
+
+    private static final long serialVersionUID = 201207151513L;
+
+    private final String propertyName;
+
+    public PropertyGetterNotAccessibleException( String propertyName, String getterMethodName,
Class<?> target,
+                                                 Throwable cause )
+    {
+        super( getterMethodName, target, cause );
+        this.propertyName = propertyName;
+    }
+
+    public String getPropertyName()
+    {
+        return propertyName;
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterNotAccessibleException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterNotAccessibleException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterNotAccessibleException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotReadableException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotReadableException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotReadableException.java
(added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotReadableException.java
Thu Jul 26 14:17:06 2012
@@ -0,0 +1,51 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.
+ */
+
+/**
+ * An exception that indicates that a property is not readable (that there is not getter
method).
+ */
+public class PropertyNotReadableException
+    extends BeanReflectionException
+{
+
+    private static final long serialVersionUID = 201206192234L;
+
+    private final String propertyName;
+
+    /**
+     * Constructs a new instance of PropertyNotReadableFoundException.
+     *
+     * @param propertyName the name of the property that isn't readable
+     * @param beanType the class the property was searched for
+     * @param cause the cause of this exception
+     */
+    public PropertyNotReadableException( String propertyName, Class<?> beanType, Throwable
cause )
+    {
+        super( cause, beanType, "Property %s in type %s is not readable", propertyName, beanType.getName()
);
+        this.propertyName = propertyName;
+    }
+
+    public String getPropertyName()
+    {
+        return this.propertyName;
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotReadableException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotReadableException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotReadableException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotWritableException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotWritableException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotWritableException.java
(added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotWritableException.java
Thu Jul 26 14:17:06 2012
@@ -0,0 +1,51 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.
+ */
+
+/**
+ * An exception that indiactes that a property is not writable (that there is not setter
method)
+ */
+public class PropertyNotWritableException
+    extends BeanReflectionException
+{
+
+    private static final long serialVersionUID = 201206192234L;
+
+    private final String propertyName;
+
+    /**
+     * Constructs a new instance of PropertyNotWritableFoundException.
+     *
+     * @param propertyName the name of the property that isn't readable
+     * @param beanType the class the property was searched for
+     * @param cause the cause of this exception
+     */
+    public PropertyNotWritableException( String propertyName, Class<?> beanType, Throwable
cause )
+    {
+        super( cause, beanType, "Property %s in type %s is not writable", propertyName, beanType.getName()
);
+        this.propertyName = propertyName;
+    }
+
+    public String getPropertyName()
+    {
+        return this.propertyName;
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotWritableException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotWritableException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotWritableException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterInvocationException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterInvocationException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterInvocationException.java
(added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterInvocationException.java
Thu Jul 26 14:17:06 2012
@@ -0,0 +1,45 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.
+ */
+
+/**
+ * An exception indicating that calling the setter of a property caused an exception.
+ */
+public class PropertySetterInvocationException
+    extends MethodInvocationException
+{
+
+    private static final long serialVersionUID = 201206192258L;
+
+    private final String propertyName;
+
+    public PropertySetterInvocationException( String propertyName, String setterMethodName,
Class<?> target,
+                                              Throwable cause )
+    {
+        super( setterMethodName, target, cause );
+        this.propertyName = propertyName;
+    }
+
+    public String getPropertyName()
+    {
+        return propertyName;
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterInvocationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterInvocationException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterInvocationException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterNotAccessibleException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterNotAccessibleException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterNotAccessibleException.java
(added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterNotAccessibleException.java
Thu Jul 26 14:17:06 2012
@@ -0,0 +1,42 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.
+ */
+
+public class PropertySetterNotAccessibleException
+    extends MethodNotAccessibleException
+{
+
+    private static final long serialVersionUID = 201207151513L;
+
+    private final String propertyName;
+
+    public PropertySetterNotAccessibleException( String propertyName, String setterMethodName,
Class<?> target,
+                                                 Throwable cause )
+    {
+        super( setterMethodName, target, cause );
+        this.propertyName = propertyName;
+    }
+
+    public String getPropertyName()
+    {
+        return propertyName;
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterNotAccessibleException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterNotAccessibleException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterNotAccessibleException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java
Thu Jul 26 14:17:06 2012
@@ -24,9 +24,9 @@ import static org.apache.commons.beanuti
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-import org.junit.Rule;
+import org.apache.commons.beanutils2.testbeans.AbstractTestBean;
+import org.apache.commons.beanutils2.testbeans.ThrowingExceptionBean;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 /**
  * <p>
@@ -35,9 +35,6 @@ import org.junit.rules.ExpectedException
  */
 public class ConstructorsTestCase
 {
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
-
     // ------------------------------------------------ Individual Test Methods
 
     @Test
@@ -56,13 +53,10 @@ public class ConstructorsTestCase
         }
     }
 
-    @Test
+    @Test( expected = NoSuchConstructorException.class )
     public void invokeConstructorWithInvalidArgument()
         throws Exception
     {
-        thrown.expect( NoSuchMethodException.class );
-        thrown.expectMessage( "No such accessible constructor on class:" );
-        thrown.expectMessage( TestBean.class.getName() );
         on( TestBean.class ).invokeConstructor( argument( (byte) 6 ) ).get();
     }
 
@@ -83,13 +77,10 @@ public class ConstructorsTestCase
         assertEquals( "TEST", obj.getStringProperty() );
     }
 
-    @Test
+    @Test( expected = NoSuchConstructorException.class )
     public void invokeConstrucotrWithInvalidArgArray()
         throws Exception
     {
-        thrown.expect( NoSuchMethodException.class );
-        thrown.expectMessage( "No such accessible constructor on class:" );
-        thrown.expectMessage( TestBean.class.getName() );
         on( TestBean.class ).invokeConstructor( argument( (byte) 17 ), argument( "TEST" )
).get();
     }
 
@@ -120,12 +111,9 @@ public class ConstructorsTestCase
         }
     }
 
-    @Test
+    @Test( expected = NoSuchConstructorException.class )
     public void invokeConstructorWithInvalidTypeArray() throws Exception
     {
-        thrown.expect( NoSuchMethodException.class );
-        thrown.expectMessage( "No such accessible constructor on class:" );
-        thrown.expectMessage( TestBean.class.getName() );
         on( TestBean.class ).invokeConstructor( argument( String.class, "TEST" ),
                                                 argument( Boolean.TYPE, Boolean.TRUE )).get();
     }
@@ -147,13 +135,10 @@ public class ConstructorsTestCase
         }
     }
 
-    @Test
+    @Test( expected = NoSuchConstructorException.class )
     public void invokeExactConstructorWithInvalidArgument()
         throws Exception
     {
-        thrown.expect( NoSuchMethodException.class );
-        thrown.expectMessage( "No such accessible constructor on class:" );
-        thrown.expectMessage( TestBean.class.getName() );
         on( TestBean.class ).invokeExactConstructor( argument( new Float( 17.3f ) ) ).get();
     }
 
@@ -175,12 +160,9 @@ public class ConstructorsTestCase
         assertEquals( "TEST", obj.getStringProperty() );
     }
 
-    @Test
+    @Test( expected = NoSuchConstructorException.class )
     public void invokeExactConstructorWithInvalidArgArray() throws Exception
     {
-        thrown.expect( NoSuchMethodException.class );
-        thrown.expectMessage( "No such accessible constructor on class:" );
-        thrown.expectMessage( TestBean.class.getName() );
         on( TestBean.class ).invokeExactConstructor( argument( new Float( 17.3f ) ),argument(
"TEST" ) ).get();
     }
 
@@ -219,14 +201,59 @@ public class ConstructorsTestCase
         }
     }
 
-    @Test
-    public void invokeExactConstructorWithInvalidTypeArray() throws Exception
+    @Test( expected = NoSuchConstructorException.class )
+    public void invokeExactConstructorWithInvalidTypeArray()
+        throws Exception
     {
-        thrown.expect( NoSuchMethodException.class );
-        thrown.expectMessage( "No such accessible constructor on class:" );
-        thrown.expectMessage( TestBean.class.getName() );
         on( TestBean.class ).invokeExactConstructor( argument( Float.class, new Float( 17.3f
) ),
                                                      argument( String.class, "TEST" ) ).get();
     }
 
+    @Test( expected = ConstructorInvocationException.class )
+    public void invokeConstructorThatThrowsException()
+        throws Exception
+    {
+        on( ThrowingExceptionBean.class ).invokeConstructor( argument( RuntimeException.class,
+                                                                           new RuntimeException()
) );
+    }
+
+    @Test( expected = ConstructorInvocationException.class )
+    public void invokeExactConstructorThatThrowsException()
+        throws Exception
+    {
+        on( ThrowingExceptionBean.class ).invokeExactConstructor( argument( RuntimeException.class,
+                                                                                new RuntimeException()
) );
+    }
+
+    // FIXME Why don't we see a ConstructorNotAccessibleException?
+    @Test( expected = NoSuchConstructorException.class )
+    public void invokePrivateConstructor()
+        throws Exception
+    {
+        on( ThrowingExceptionBean.class ).invokeConstructor( argument( Integer.class, Integer.valueOf(
4711 ) ) );
+    }
+
+    // FIXME Why don't we see a ConstructorNotAccessibleException?
+    @Test( expected = NoSuchConstructorException.class )
+    public void invokeProtectedConstructor()
+        throws Exception
+    {
+        on( ThrowingExceptionBean.class ).invokeConstructor( argument( Short.class, Short.valueOf(
(short) 4711 ) ) );
+    }
+
+    // FIXME Why don't we see a ConstructorNotAccessibleException?
+    @Test( expected = NoSuchConstructorException.class )
+    public void invokeDefaultConstructor()
+        throws Exception
+    {
+        on( ThrowingExceptionBean.class ).invokeConstructor( argument( Byte.class, Byte.valueOf(
(byte) 4711 ) ) );
+    }
+
+    @Test( expected = BeanInstantiationException.class )
+    public void invokeConstructorOnAbstract()
+        throws Exception
+    {
+        on( AbstractTestBean.class ).invokeConstructor();
+    }
+
 }

Added: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetIndexedPropertyTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetIndexedPropertyTestCase.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetIndexedPropertyTestCase.java
(added)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetIndexedPropertyTestCase.java
Thu Jul 26 14:17:06 2012
@@ -0,0 +1,101 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+
+import static org.apache.commons.beanutils2.BeanUtils.on;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.commons.beanutils2.testbeans.ThrowingExceptionBean;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GetIndexedPropertyTestCase
+{
+
+    private TestBean testBean;
+
+    private ThrowingExceptionBean exceptionBean;
+
+    @Before
+    public void setUp()
+    {
+        testBean = new TestBean();
+        exceptionBean = new ThrowingExceptionBean();
+    }
+
+    @After
+    public void tearDown()
+    {
+        testBean = null;
+        exceptionBean = null;
+    }
+
+    @Test( expected = NullPointerException.class )
+    public void getIndexedNull()
+    {
+        on( testBean ).getIndexed( null );
+    }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void getIndexedUnknown()
+    {
+        on( testBean ).getIndexed( "unknown" );
+    }
+
+    @Test( expected = IllegalArgumentException.class )
+    public void getIndexedNegative()
+    {
+        on( testBean ).getIndexed( "intIndexed" ).at( -1 );
+    }
+
+    @Test
+    public void getIndexed()
+    {
+        int expected = testBean.getIntIndexed( 0 );
+        BeanAccessor<?> accessor = on( testBean ).getIndexed( "intIndexed" ).at( 0
);
+        assertNotNull( accessor );
+        assertEquals( expected, accessor.get() );
+    }
+
+    @Test( expected = PropertyGetterInvocationException.class )
+    public void getExceptionIndexed()
+    {
+        on( exceptionBean ).getIndexed( "exceptionIndexed" ).at( 0 );
+    }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void getPrivateIndexed()
+    {
+        on( exceptionBean ).getIndexed( "privateIndexed" );
+    }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void getProtectedIndexed()
+    {
+        on( exceptionBean ).getIndexed( "protecedIndexed" );
+    }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void getDefaultIndexed()
+    {
+        on( exceptionBean ).getIndexed( "defaultIndexed" );
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetIndexedPropertyTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetIndexedPropertyTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetIndexedPropertyTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetPropertyTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetPropertyTestCase.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetPropertyTestCase.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetPropertyTestCase.java
Thu Jul 26 14:17:06 2012
@@ -23,8 +23,7 @@ import static org.apache.commons.beanuti
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import java.beans.IntrospectionException;
-
+import org.apache.commons.beanutils2.testbeans.ThrowingExceptionBean;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -33,17 +32,20 @@ public final class GetPropertyTestCase
 {
 
     private TestBean bean;
+    private ThrowingExceptionBean exceptionBean;
 
     @Before
     public void setUp()
     {
         bean = new TestBean();
+        exceptionBean = new ThrowingExceptionBean();
     }
 
     @After
     public void tearDown()
     {
         bean = null;
+        exceptionBean = null;
     }
 
     /**
@@ -59,14 +61,14 @@ public final class GetPropertyTestCase
         assertTrue( "Got an incorrect value", ( (Boolean) value ).booleanValue() == bean.getBooleanProperty()
);
     }
 
-    @Test( expected = NoSuchMethodException.class )
+    @Test( expected = PropertyNotReadableException.class )
     public void getWirteOnlyProperty()
         throws Exception
     {
         on( bean ).get( "writeOnlyProperty" ).get();
     }
 
-    @Test( expected = IntrospectionException.class )
+    @Test( expected = NoSuchPropertyException.class )
     public void getUnknownProperty()
         throws Exception
     {
@@ -80,4 +82,28 @@ public final class GetPropertyTestCase
         on( bean ).get( null );
     }
 
+    @Test( expected = NoSuchPropertyException.class )
+    public void getPrivateProperty()
+    {
+        on( exceptionBean ).get( "privateProperty" );
+    }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void getProtectedProperty()
+    {
+        on( exceptionBean ).get( "protectedProperty" );
+    }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void getDefaultProperty()
+    {
+        on( exceptionBean ).get( "defaultProperty" );
+    }
+
+    @Test( expected = PropertyGetterInvocationException.class )
+    public void getExcpetionProperty()
+    {
+        on( exceptionBean ).get( "exceptionProperty" );
+    }
+
 }

Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/MethodsTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/MethodsTestCase.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/MethodsTestCase.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/MethodsTestCase.java
Thu Jul 26 14:17:06 2012
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import org.apache.commons.beanutils2.testbeans.ThrowingExceptionBean;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,17 +36,20 @@ public class MethodsTestCase
 {
 
     private TestBean testBean;
+    private ThrowingExceptionBean exceptionBean;
 
     @Before
     public void setUp()
     {
         testBean = new TestBean();
+        exceptionBean = new ThrowingExceptionBean();
     }
 
     @After
     public void tearDown()
     {
         testBean = null;
+        exceptionBean = null;
     }
 
     @Test
@@ -107,7 +111,7 @@ public class MethodsTestCase
         on( testBean ).invoke( null );
     }
 
-    @Test( expected = NoSuchMethodException.class )
+    @Test( expected = NoSuchBeanMethodException.class )
     public void invokeMethodNonExistent()
         throws Exception
     {
@@ -132,7 +136,7 @@ public class MethodsTestCase
         assertFalse( testBean.getBooleanProperty() );
     }
 
-    @Test( expected = NoSuchMethodException.class )
+    @Test( expected = NoSuchBeanMethodException.class )
     public void invokeExactMethodSetBooleanPropertyWithWrapper()
         throws Exception
     {
@@ -166,7 +170,7 @@ public class MethodsTestCase
         assertEquals( testBean.getIntProperty(), 47 );
     }
 
-    @Test( expected = NoSuchMethodException.class )
+    @Test( expected = NoSuchBeanMethodException.class )
     public void invokeExactMethodSetIntPropertyWithWrapper()
         throws Exception
     {
@@ -188,11 +192,25 @@ public class MethodsTestCase
         on( testBean ).invokeExact( null );
     }
 
-    @Test( expected = NoSuchMethodException.class )
+    @Test( expected = NoSuchBeanMethodException.class )
     public void invokeExactMethodNonExistent()
         throws Exception
     {
         on( testBean ).invokeExact( "nonExistent" ).withArguments();
     }
 
+    @Test(expected = MethodInvocationException.class)
+    public void invokeExceptionMethod()
+        throws Exception
+    {
+        on( exceptionBean ).invoke( "setExceptionProperty" ).withArguments( argument( "Exception"
) );
+    }
+
+    @Test( expected = MethodInvocationException.class )
+    public void invokeExactExceptionMethod()
+        throws Exception
+    {
+        on( exceptionBean ).invokeExact( "setExceptionProperty" ).withArguments( argument(
"Exception" ) );
+    }
+
 }

Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java
Thu Jul 26 14:17:06 2012
@@ -32,7 +32,7 @@ public class OnClassNameTestCase
         onClassName( null );
     }
 
-    @Test( expected = ClassNotFoundException.class )
+    @Test( expected = BeanClassNotFoundException.class )
     public void onClassNameUnknown()
         throws Exception
     {

Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetIndexedPropertyTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetIndexedPropertyTestCase.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetIndexedPropertyTestCase.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetIndexedPropertyTestCase.java
Thu Jul 26 14:17:06 2012
@@ -20,8 +20,6 @@ package org.apache.commons.beanutils2;
 import static org.apache.commons.beanutils2.BeanUtils.on;
 import static org.junit.Assert.assertTrue;
 
-import java.beans.IntrospectionException;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -50,7 +48,7 @@ public class SetIndexedPropertyTestCase
         on( testBean ).setIndexed( "intIndexed" ).at( -1 );
     }
 
-    @Test( expected = IntrospectionException.class )
+    @Test( expected = NoSuchPropertyException.class )
     public void setIndexedUnknown()
         throws Exception
     {

Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetPropertyTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetPropertyTestCase.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetPropertyTestCase.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetPropertyTestCase.java
Thu Jul 26 14:17:06 2012
@@ -24,8 +24,7 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 
-import java.beans.IntrospectionException;
-
+import org.apache.commons.beanutils2.testbeans.ThrowingExceptionBean;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -34,17 +33,20 @@ public class SetPropertyTestCase
 {
 
     private TestBean testBean;
+    private ThrowingExceptionBean exceptionBean;
 
     @Before
     public void setUp()
     {
         testBean = new TestBean();
+        exceptionBean = new ThrowingExceptionBean();
     }
 
     @After
     public void tearDown()
     {
         testBean = null;
+        exceptionBean = null;
     }
 
     @Test
@@ -79,11 +81,11 @@ public class SetPropertyTestCase
     /**
      * Tests if trying to set a nonexistent property causes an NPE.
      */
-    @Test( expected = IntrospectionException.class )
+    @Test( expected = NoSuchPropertyException.class )
     public void setNonExistentProperty()
         throws Exception
     {
-        on( testBean ).set( "nonExistent" ).with( null );
+        on( testBean ).set( "nonExistent" );
     }
 
     /**
@@ -109,11 +111,11 @@ public class SetPropertyTestCase
     /**
      * Test if trying to set a read only property causes a NoSuchMethodException.
      */
-    @Test( expected = NoSuchMethodException.class )
+    @Test( expected = PropertyNotWritableException.class )
     public void setReadOnlyProperty()
         throws Exception
     {
-        on( testBean ).set( "readOnlyProperty" ).with( 15 );
+        on( testBean ).set( "readOnlyProperty" );
     }
 
     /**
@@ -125,4 +127,29 @@ public class SetPropertyTestCase
     {
         on( testBean ).set( null );
     }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void setPrivateProperty()
+    {
+        on( exceptionBean ).set( "privateProperty" );
+    }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void setProtectedProperty()
+    {
+        on( exceptionBean ).set( "protectedProperty" );
+    }
+
+    @Test( expected = NoSuchPropertyException.class )
+    public void setDefaultProperty()
+    {
+        on( exceptionBean ).set( "defaultProperty" );
+    }
+
+    @Test( expected = PropertySetterInvocationException.class )
+    public void setExcpetionProperty()
+    {
+        on( exceptionBean ).set( "exceptionProperty" ).with( "Throw Exception!" );
+    }
+
 }

Modified: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/StaticMethodsTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/StaticMethodsTestCase.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/StaticMethodsTestCase.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/StaticMethodsTestCase.java
Thu Jul 26 14:17:06 2012
@@ -23,18 +23,15 @@ import static org.apache.commons.beanuti
 import static org.apache.commons.beanutils2.BeanUtils.on;
 import static org.junit.Assert.assertEquals;
 
+import org.apache.commons.beanutils2.testbeans.ThrowingExceptionBean;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 public final class StaticMethodsTestCase
 {
-    private int oldValue;
 
-    @Rule
-    public ExpectedException thrown = ExpectedException.none();
+    private int oldValue;
 
     @Before
     public void setUp()
@@ -99,15 +96,11 @@ public final class StaticMethodsTestCase
         assertEquals( oldValue + 8 * 2, TestBean.currentCounter() );
     }
 
-    @Test
+    @Test(expected = NoSuchBeanMethodException.class)
     public void invokeStaticMethodWithInvalidArgument()
         throws Exception
     {
         String methodName = "incrementCounter";
-        thrown.expect( NoSuchMethodException.class );
-        thrown.expectMessage( "No such accessible method:" );
-        thrown.expectMessage( methodName );
-        thrown.expectMessage( TestBean.class.getName() );
         on( TestBean.class ).invokeStatic( methodName ).withArguments( argument( 'x' ) );
     }
 
@@ -126,7 +119,7 @@ public final class StaticMethodsTestCase
         assertEquals( oldValue + 8, TestBean.currentCounter() );
     }
 
-    @Test( expected = NoSuchMethodException.class )
+    @Test( expected = NoSuchBeanMethodException.class )
     public void invokeExactStaticMethodIncrementIntegerWrapper()
         throws Exception
     {
@@ -143,4 +136,18 @@ public final class StaticMethodsTestCase
         assertEquals( oldValue + 2 * 8, TestBean.currentCounter() );
     }
 
+    @Test(expected = MethodInvocationException.class)
+    public void invokeStaticExceptionMethod()
+        throws Exception
+    {
+        on( ThrowingExceptionBean.class ).invokeStatic( "staticException" ).withArguments(
argument( "Exception" ) );
+    }
+
+    @Test( expected = MethodInvocationException.class )
+    public void invokeExactStaticExceptionMethod()
+        throws Exception
+    {
+        on( ThrowingExceptionBean.class ).invokeExactStatic( "staticException" ).withArguments(
argument( "Exception" ) );
+    }
+
 }

Added: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java
(added)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java
Thu Jul 26 14:17:06 2012
@@ -0,0 +1,30 @@
+package org.apache.commons.beanutils2.testbeans;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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.
+ */
+
+/**
+ * Abstract test bean for testing Instantiation Exceptions.
+ */
+public abstract class AbstractTestBean
+{
+
+    public AbstractTestBean() {
+        // do nothing
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message