Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.commons.beanutils
Class PropertyUtilsTestCase  view PropertyUtilsTestCase download PropertyUtilsTestCase.java

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.apache.commons.beanutils.PropertyUtilsTestCase
All Implemented Interfaces:
junit.framework.Test

public class PropertyUtilsTestCase
extends junit.framework.TestCase

Test Case for the PropertyUtils class. The majority of these tests use instances of the TestBean class, so be sure to update the tests if you change the characteristics of that class.

So far, this test case has tests for the following methods of the PropertyUtils class:

Version:
$Revision: 1.34 $ $Date: 2004/02/28 13:18:36 $

Field Summary
protected  TestBean bean
          The basic test bean for each test.
protected  TestBeanPackageSubclass beanPackageSubclass
          The "package private subclass" test bean for each test.
protected  org.apache.commons.beanutils.priv.PrivateDirect beanPrivate
          The test bean for private access tests.
protected  org.apache.commons.beanutils.priv.PrivateDirect beanPrivateSubclass
          The test bean for private access tests of subclasses.
protected  TestBeanPublicSubclass beanPublicSubclass
          The "public subclass" test bean for each test.
protected  java.lang.String[] describes
          The set of properties that should be described.
private static java.lang.String PRIVATE_DIRECT_CLASS
          The fully qualified class name of our private directly implemented interface.
private static java.lang.String PRIVATE_INDIRECT_CLASS
          The fully qualified class name of our private indirectly implemented interface.
protected static java.lang.String[] properties
          The set of property names we expect to have returned when calling getPropertyDescriptors().
private static java.lang.String TEST_BEAN_CLASS
          The fully qualified class name of our test bean class.
 
Fields inherited from class junit.framework.TestCase
 
Constructor Summary
PropertyUtilsTestCase(java.lang.String name)
          Construct a new instance of this test case.
 
Method Summary
 void setUp()
          Set up instance variables required by this test case.
static junit.framework.Test suite()
          Return the tests included in this test suite.
 void tearDown()
          Tear down instance variables required by this test case.
 void testCopyPropertiesMap()
          Test copyProperties() when the origin is a a Map.
 void testDescribe()
          Test the describe() method.
 void testGetDescriptorArguments()
          Corner cases on getPropertyDescriptor invalid arguments.
protected  void testGetDescriptorBase(java.lang.String name, java.lang.String read, java.lang.String write)
          Base for testGetDescriptorXxxxx() series of tests.
 void testGetDescriptorBoolean()
          Positive getPropertyDescriptor on property booleanProperty.
 void testGetDescriptorDouble()
          Positive getPropertyDescriptor on property doubleProperty.
 void testGetDescriptorFloat()
          Positive getPropertyDescriptor on property floatProperty.
 void testGetDescriptorInt()
          Positive getPropertyDescriptor on property intProperty.
 void testGetDescriptorInvalidBoolean()
          Negative tests on an invalid property with two different boolean getters (which is fine, according to the JavaBeans spec) but a String setter instead of a boolean setter.
 void testGetDescriptorLong()
          Positive getPropertyDescriptor on property longProperty.
 void testGetDescriptorReadOnly()
          Positive getPropertyDescriptor on property readOnlyProperty.
 void testGetDescriptors()
          Positive test for getPropertyDescriptors().
 void testGetDescriptorsArguments()
          Corner cases on getPropertyDescriptors invalid arguments.
 void testGetDescriptorSecond()
          Positive getPropertyDescriptor on property booleanSecond that uses an "is" method as the getter.
 void testGetDescriptorShort()
          Positive getPropertyDescriptor on property shortProperty.
 void testGetDescriptorString()
          Positive getPropertyDescriptor on property stringProperty.
 void testGetDescriptorUnknown()
          Negative getPropertyDescriptor on property unknown.
 void testGetDescriptorWriteOnly()
          Positive getPropertyDescriptor on property writeOnlyProperty.
 void testGetIndexedArguments()
          Corner cases on getIndexedProperty invalid arguments.
 void testGetIndexedValues()
          Positive and negative tests on getIndexedProperty valid arguments.
 void testGetMappedArguments()
          Corner cases on getMappedProperty invalid arguments.
 void testGetMappedPeriods()
          Test getting mapped values with periods in the key.
 void testGetMappedSlashes()
          Test getting mapped values with slashes in the key.
 void testGetMappedValues()
          Positive and negative tests on getMappedProperty valid arguments.
 void testGetNestedArguments()
          Corner cases on getNestedProperty invalid arguments.
 void testGetNestedBoolean()
          Test getNestedProperty on a boolean property.
 void testGetNestedDouble()
          Test getNestedProperty on a double property.
 void testGetNestedFloat()
          Test getNestedProperty on a float property.
 void testGetNestedInt()
          Test getNestedProperty on an int property.
 void testGetNestedLong()
          Test getNestedProperty on a long property.
 void testGetNestedReadOnly()
          Test getNestedProperty on a read-only String property.
 void testGetNestedShort()
          Test getNestedProperty on a short property.
 void testGetNestedString()
          Test getNestedProperty on a String property.
 void testGetNestedUnknown()
          Negative test getNestedProperty on an unknown property.
 void testGetNestedWriteOnly()
          Test getNestedProperty on a write-only String property.
 void testGetPropertyType()
          Test getPropertyType() on all kinds of properties.
protected  void testGetReadMethod(java.lang.Object bean, java.lang.String[] properties, java.lang.String className)
          Base for testGetReadMethod() series of tests.
 void testGetReadMethodBasic()
          Test getting accessible property reader methods for a specified list of properties of our standard test bean.
 void testGetReadMethodPackageSubclass()
          Test getting accessible property reader methods for a specified list of properties of a package private subclass of our standard test bean.
 void testGetReadMethodPublicInterface()
          Test getting accessible property reader methods for a specified list of properties that are declared either directly or via implemented interfaces.
 void testGetReadMethodPublicSubclass()
          Test getting accessible property reader methods for a specified list of properties of a public subclass of our standard test bean.
 void testGetSetInnerBean()
          Text case for setting properties on inner classes
 void testGetSetParentBean()
          Text case for setting properties on parent
 void testGetSimpleArguments()
          Corner cases on getSimpleProperty invalid arguments.
 void testGetSimpleBoolean()
          Test getSimpleProperty on a boolean property.
 void testGetSimpleDouble()
          Test getSimpleProperty on a double property.
 void testGetSimpleFloat()
          Test getSimpleProperty on a float property.
 void testGetSimpleIndexed()
          Negative test getSimpleProperty on an indexed property.
 void testGetSimpleInt()
          Test getSimpleProperty on an int property.
 void testGetSimpleLong()
          Test getSimpleProperty on a long property.
 void testGetSimpleNested()
          Negative test getSimpleProperty on a nested property.
 void testGetSimpleReadOnly()
          Test getSimpleProperty on a read-only String property.
 void testGetSimpleShort()
          Test getSimpleProperty on a short property.
 void testGetSimpleString()
          Test getSimpleProperty on a String property.
 void testGetSimpleUnknown()
          Negative test getSimpleProperty on an unknown property.
 void testGetSimpleWriteOnly()
          Test getSimpleProperty on a write-only String property.
protected  void testGetWriteMethod(java.lang.Object bean, java.lang.String[] properties, java.lang.String className)
          Base for testGetWriteMethod() series of tests.
 void testGetWriteMethodBasic()
          Test getting accessible property writer methods for a specified list of properties of our standard test bean.
 void testGetWriteMethodPackageSubclass()
          Test getting accessible property writer methods for a specified list of properties of a package private subclass of our standard test bean.
 void testGetWriteMethodPublicSubclass()
          Test getting accessible property writer methods for a specified list of properties of a public subclass of our standard test bean.
 void testMappedPropertyType()
          Test the mappedPropertyType of MappedPropertyDescriptor.
 void testNestedWithIndex()
           
 void testSetIndexedArguments()
          Corner cases on setIndexedProperty invalid arguments.
 void testSetIndexedValues()
          Positive and negative tests on setIndexedProperty valid arguments.
 void testSetMapExtension()
          This tests to see that classes that implement Map can have their standard properties set.
 void testSetMappedArguments()
          Corner cases on getMappedProperty invalid arguments.
 void testSetMappedValues()
          Positive and negative tests on setMappedProperty valid arguments.
 void testSetNestedArguments()
          Corner cases on setNestedProperty invalid arguments.
 void testSetNestedBoolean()
          Test setNextedProperty on a boolean property.
 void testSetNestedDouble()
          Test setNestedProperty on a double property.
 void testSetNestedFloat()
          Test setNestedProperty on a float property.
 void testSetNestedInt()
          Test setNestedProperty on a int property.
 void testSetNestedLong()
          Test setNestedProperty on a long property.
 void testSetNestedReadOnly()
          Test setNestedProperty on a read-only String property.
 void testSetNestedShort()
          Test setNestedProperty on a short property.
 void testSetNestedString()
          Test setNestedProperty on a String property.
 void testSetNestedUnknown()
          Test setNestedProperty on an unknown property name.
 void testSetNestedWriteOnly()
          Test setNestedProperty on a write-only String property.
 void testSetNoGetter()
           
 void testSetSimpleArguments()
          Corner cases on setSimpleProperty invalid arguments.
 void testSetSimpleBoolean()
          Test setSimpleProperty on a boolean property.
 void testSetSimpleDouble()
          Test setSimpleProperty on a double property.
 void testSetSimpleFloat()
          Test setSimpleProperty on a float property.
 void testSetSimpleIndexed()
          Negative test setSimpleProperty on an indexed property.
 void testSetSimpleInt()
          Test setSimpleProperty on a int property.
 void testSetSimpleLong()
          Test setSimpleProperty on a long property.
 void testSetSimpleNested()
          Negative test setSimpleProperty on a nested property.
 void testSetSimpleReadOnly()
          Test setSimpleProperty on a read-only String property.
 void testSetSimpleShort()
          Test setSimpleProperty on a short property.
 void testSetSimpleString()
          Test setSimpleProperty on a String property.
 void testSetSimpleUnknown()
          Test setSimpleProperty on an unknown property name.
 void testSetSimpleWriteOnly()
          Test setSimpleProperty on a write-only String property.
 void testThrowNestedNull()
          When a bean has a null property which is reference by the standard access language, this should throw a NestedNullException.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PRIVATE_DIRECT_CLASS

private static final java.lang.String PRIVATE_DIRECT_CLASS
The fully qualified class name of our private directly implemented interface.

See Also:
Constant Field Values

PRIVATE_INDIRECT_CLASS

private static final java.lang.String PRIVATE_INDIRECT_CLASS
The fully qualified class name of our private indirectly implemented interface.

See Also:
Constant Field Values

TEST_BEAN_CLASS

private static final java.lang.String TEST_BEAN_CLASS
The fully qualified class name of our test bean class.

See Also:
Constant Field Values

bean

protected TestBean bean
The basic test bean for each test.


beanPackageSubclass

protected TestBeanPackageSubclass beanPackageSubclass
The "package private subclass" test bean for each test.


beanPrivate

protected org.apache.commons.beanutils.priv.PrivateDirect beanPrivate
The test bean for private access tests.


beanPrivateSubclass

protected org.apache.commons.beanutils.priv.PrivateDirect beanPrivateSubclass
The test bean for private access tests of subclasses.


beanPublicSubclass

protected TestBeanPublicSubclass beanPublicSubclass
The "public subclass" test bean for each test.


describes

protected java.lang.String[] describes
The set of properties that should be described.


properties

protected static final java.lang.String[] properties
The set of property names we expect to have returned when calling getPropertyDescriptors(). You should update this list when new properties are added to TestBean.

Constructor Detail

PropertyUtilsTestCase

public PropertyUtilsTestCase(java.lang.String name)
Construct a new instance of this test case.

Method Detail

setUp

public void setUp()
Set up instance variables required by this test case.


suite

public static junit.framework.Test suite()
Return the tests included in this test suite.


tearDown

public void tearDown()
Tear down instance variables required by this test case.


testCopyPropertiesMap

public void testCopyPropertiesMap()
Test copyProperties() when the origin is a a Map.


testDescribe

public void testDescribe()
Test the describe() method.


testGetDescriptorArguments

public void testGetDescriptorArguments()
Corner cases on getPropertyDescriptor invalid arguments.


testGetDescriptorBoolean

public void testGetDescriptorBoolean()
Positive getPropertyDescriptor on property booleanProperty.


testGetDescriptorDouble

public void testGetDescriptorDouble()
Positive getPropertyDescriptor on property doubleProperty.


testGetDescriptorFloat

public void testGetDescriptorFloat()
Positive getPropertyDescriptor on property floatProperty.


testGetDescriptorInt

public void testGetDescriptorInt()
Positive getPropertyDescriptor on property intProperty.


testGetDescriptorInvalidBoolean

public void testGetDescriptorInvalidBoolean()
                                     throws java.lang.Exception

Negative tests on an invalid property with two different boolean getters (which is fine, according to the JavaBeans spec) but a String setter instead of a boolean setter.

Although one could logically argue that this combination of method signatures should not identify a property at all, there is a sentence in Section 8.3.1 making it clear that the behavior tested for here is correct: "If we find only one of these methods, then we regard it as defining either a read-only or write-only property called <property-name>.


testGetDescriptorLong

public void testGetDescriptorLong()
Positive getPropertyDescriptor on property longProperty.


testGetDescriptorReadOnly

public void testGetDescriptorReadOnly()
Positive getPropertyDescriptor on property readOnlyProperty.


testGetDescriptorSecond

public void testGetDescriptorSecond()
Positive getPropertyDescriptor on property booleanSecond that uses an "is" method as the getter.


testGetDescriptorShort

public void testGetDescriptorShort()
Positive getPropertyDescriptor on property shortProperty.


testGetDescriptorString

public void testGetDescriptorString()
Positive getPropertyDescriptor on property stringProperty.


testGetDescriptorUnknown

public void testGetDescriptorUnknown()
Negative getPropertyDescriptor on property unknown.


testGetDescriptorWriteOnly

public void testGetDescriptorWriteOnly()
Positive getPropertyDescriptor on property writeOnlyProperty.


testGetDescriptors

public void testGetDescriptors()
Positive test for getPropertyDescriptors(). Each property name listed in properties should be returned exactly once.


testGetDescriptorsArguments

public void testGetDescriptorsArguments()
Corner cases on getPropertyDescriptors invalid arguments.


testGetIndexedArguments

public void testGetIndexedArguments()
Corner cases on getIndexedProperty invalid arguments.


testGetIndexedValues

public void testGetIndexedValues()
Positive and negative tests on getIndexedProperty valid arguments.


testGetMappedArguments

public void testGetMappedArguments()
Corner cases on getMappedProperty invalid arguments.


testGetMappedPeriods

public void testGetMappedPeriods()
Test getting mapped values with periods in the key.


testGetMappedSlashes

public void testGetMappedSlashes()
Test getting mapped values with slashes in the key. This is different from periods because slashes are not syntactically significant.


testGetMappedValues

public void testGetMappedValues()
Positive and negative tests on getMappedProperty valid arguments.


testGetNestedArguments

public void testGetNestedArguments()
Corner cases on getNestedProperty invalid arguments.


testGetNestedBoolean

public void testGetNestedBoolean()
Test getNestedProperty on a boolean property.


testGetNestedDouble

public void testGetNestedDouble()
Test getNestedProperty on a double property.


testGetNestedFloat

public void testGetNestedFloat()
Test getNestedProperty on a float property.


testGetNestedInt

public void testGetNestedInt()
Test getNestedProperty on an int property.


testGetNestedLong

public void testGetNestedLong()
Test getNestedProperty on a long property.


testGetNestedReadOnly

public void testGetNestedReadOnly()
Test getNestedProperty on a read-only String property.


testGetNestedShort

public void testGetNestedShort()
Test getNestedProperty on a short property.


testGetNestedString

public void testGetNestedString()
Test getNestedProperty on a String property.


testGetNestedUnknown

public void testGetNestedUnknown()
Negative test getNestedProperty on an unknown property.


testThrowNestedNull

public void testThrowNestedNull()
                         throws java.lang.Exception
When a bean has a null property which is reference by the standard access language, this should throw a NestedNullException.


testGetNestedWriteOnly

public void testGetNestedWriteOnly()
Test getNestedProperty on a write-only String property.


testGetPropertyType

public void testGetPropertyType()
Test getPropertyType() on all kinds of properties.


testGetReadMethodBasic

public void testGetReadMethodBasic()
Test getting accessible property reader methods for a specified list of properties of our standard test bean.


testGetReadMethodPackageSubclass

public void testGetReadMethodPackageSubclass()
Test getting accessible property reader methods for a specified list of properties of a package private subclass of our standard test bean.


testGetReadMethodPublicInterface

public void testGetReadMethodPublicInterface()
Test getting accessible property reader methods for a specified list of properties that are declared either directly or via implemented interfaces.


testGetReadMethodPublicSubclass

public void testGetReadMethodPublicSubclass()
Test getting accessible property reader methods for a specified list of properties of a public subclass of our standard test bean.


testGetSimpleArguments

public void testGetSimpleArguments()
Corner cases on getSimpleProperty invalid arguments.


testGetSimpleBoolean

public void testGetSimpleBoolean()
Test getSimpleProperty on a boolean property.


testGetSimpleDouble

public void testGetSimpleDouble()
Test getSimpleProperty on a double property.


testGetSimpleFloat

public void testGetSimpleFloat()
Test getSimpleProperty on a float property.


testGetSimpleIndexed

public void testGetSimpleIndexed()
Negative test getSimpleProperty on an indexed property.


testGetSimpleInt

public void testGetSimpleInt()
Test getSimpleProperty on an int property.


testGetSimpleLong

public void testGetSimpleLong()
Test getSimpleProperty on a long property.


testGetSimpleNested

public void testGetSimpleNested()
Negative test getSimpleProperty on a nested property.


testGetSimpleReadOnly

public void testGetSimpleReadOnly()
Test getSimpleProperty on a read-only String property.


testGetSimpleShort

public void testGetSimpleShort()
Test getSimpleProperty on a short property.


testGetSimpleString

public void testGetSimpleString()
Test getSimpleProperty on a String property.


testGetSimpleUnknown

public void testGetSimpleUnknown()
Negative test getSimpleProperty on an unknown property.


testGetSimpleWriteOnly

public void testGetSimpleWriteOnly()
Test getSimpleProperty on a write-only String property.


testGetWriteMethodBasic

public void testGetWriteMethodBasic()
Test getting accessible property writer methods for a specified list of properties of our standard test bean.


testGetWriteMethodPackageSubclass

public void testGetWriteMethodPackageSubclass()
Test getting accessible property writer methods for a specified list of properties of a package private subclass of our standard test bean.


testGetWriteMethodPublicSubclass

public void testGetWriteMethodPublicSubclass()
Test getting accessible property writer methods for a specified list of properties of a public subclass of our standard test bean.


testMappedPropertyType

public void testMappedPropertyType()
                            throws java.lang.Exception
Test the mappedPropertyType of MappedPropertyDescriptor.


testSetIndexedArguments

public void testSetIndexedArguments()
Corner cases on setIndexedProperty invalid arguments.


testSetIndexedValues

public void testSetIndexedValues()
Positive and negative tests on setIndexedProperty valid arguments.


testSetMappedArguments

public void testSetMappedArguments()
Corner cases on getMappedProperty invalid arguments.


testSetMappedValues

public void testSetMappedValues()
Positive and negative tests on setMappedProperty valid arguments.


testSetNestedArguments

public void testSetNestedArguments()
Corner cases on setNestedProperty invalid arguments.


testSetNestedBoolean

public void testSetNestedBoolean()
Test setNextedProperty on a boolean property.


testSetNestedDouble

public void testSetNestedDouble()
Test setNestedProperty on a double property.


testSetNestedFloat

public void testSetNestedFloat()
Test setNestedProperty on a float property.


testSetNestedInt

public void testSetNestedInt()
Test setNestedProperty on a int property.


testSetNestedLong

public void testSetNestedLong()
Test setNestedProperty on a long property.


testSetNestedReadOnly

public void testSetNestedReadOnly()
Test setNestedProperty on a read-only String property.


testSetNestedShort

public void testSetNestedShort()
Test setNestedProperty on a short property.


testSetNestedString

public void testSetNestedString()
Test setNestedProperty on a String property.


testSetNestedUnknown

public void testSetNestedUnknown()
Test setNestedProperty on an unknown property name.


testSetNestedWriteOnly

public void testSetNestedWriteOnly()
Test setNestedProperty on a write-only String property.


testSetSimpleArguments

public void testSetSimpleArguments()
Corner cases on setSimpleProperty invalid arguments.


testSetSimpleBoolean

public void testSetSimpleBoolean()
Test setSimpleProperty on a boolean property.


testSetSimpleDouble

public void testSetSimpleDouble()
Test setSimpleProperty on a double property.


testSetSimpleFloat

public void testSetSimpleFloat()
Test setSimpleProperty on a float property.


testSetSimpleIndexed

public void testSetSimpleIndexed()
Negative test setSimpleProperty on an indexed property.


testSetSimpleInt

public void testSetSimpleInt()
Test setSimpleProperty on a int property.


testSetSimpleLong

public void testSetSimpleLong()
Test setSimpleProperty on a long property.


testSetSimpleNested

public void testSetSimpleNested()
Negative test setSimpleProperty on a nested property.


testSetSimpleReadOnly

public void testSetSimpleReadOnly()
Test setSimpleProperty on a read-only String property.


testSetSimpleShort

public void testSetSimpleShort()
Test setSimpleProperty on a short property.


testSetSimpleString

public void testSetSimpleString()
Test setSimpleProperty on a String property.


testSetSimpleUnknown

public void testSetSimpleUnknown()
Test setSimpleProperty on an unknown property name.


testSetSimpleWriteOnly

public void testSetSimpleWriteOnly()
Test setSimpleProperty on a write-only String property.


testGetDescriptorBase

protected void testGetDescriptorBase(java.lang.String name,
                                     java.lang.String read,
                                     java.lang.String write)
Base for testGetDescriptorXxxxx() series of tests.


testGetReadMethod

protected void testGetReadMethod(java.lang.Object bean,
                                 java.lang.String[] properties,
                                 java.lang.String className)
Base for testGetReadMethod() series of tests.


testGetWriteMethod

protected void testGetWriteMethod(java.lang.Object bean,
                                  java.lang.String[] properties,
                                  java.lang.String className)
Base for testGetWriteMethod() series of tests.


testNestedWithIndex

public void testNestedWithIndex()
                         throws java.lang.Exception

testGetSetInnerBean

public void testGetSetInnerBean()
                         throws java.lang.Exception
Text case for setting properties on inner classes


testGetSetParentBean

public void testGetSetParentBean()
                          throws java.lang.Exception
Text case for setting properties on parent


testSetNoGetter

public void testSetNoGetter()
                     throws java.lang.Exception

testSetMapExtension

public void testSetMapExtension()
                         throws java.lang.Exception
This tests to see that classes that implement Map can have their standard properties set.