org.apache.commons.beanutils
Class BeanUtilsTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.beanutils.BeanUtilsTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
BeanUtils2TestCase

public class BeanUtilsTestCase
extends junit.framework.TestCase

Test Case for the BeanUtils 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.

Template for this stolen from Craigs PropertyUtilsTestCase

Note that the tests are dependant upon the static aspects (such as array sizes...) of the TestBean.java class, so ensure than all changes to TestBean are reflected here.

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

Version:
$Revision: 658830 $
Author:
Geir Magnusson Jr.

Field Summary
protected  TestBean bean
          The test bean for each test.
protected  String[] describes
          The set of properties that should be described.
protected  Calendar testCalendar
          Test Calendar value
protected  String testStringDate
          Test String Date value
protected  Date testUtilDate
          Test java.util.Date value
 
Constructor Summary
BeanUtilsTestCase(String name)
          Construct a new instance of this test case.
 
Method Summary
protected  void checkIntArray(int[] actual, int[] expected)
           
protected  void checkMap(Map actual, Map expected)
           
 void setUp()
          Set up instance variables required by this test case.
protected  void setUpShared()
          Shared Set up.
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 testArrayPropertyConversion()
           
 void testCopyPropertiesDynaBean()
          Test the copyProperties() method from a DynaBean.
 void testCopyPropertiesMap()
          Test copyProperties() when the origin is a a Map.
 void testCopyPropertiesStandard()
          Test the copyProperties() method from a standard JavaBean.
 void testCopyPropertyByte()
          Test narrowing and widening conversions on byte.
 void testCopyPropertyConvert()
          Test copyProperty() conversion.
 void testCopyPropertyConvertFromString()
          Test copyProperty() converting from a String.
 void testCopyPropertyConvertToString()
          Test copyProperty() converting to a String.
 void testCopyPropertyConvertToStringArray()
          Test copyProperty() converting to a String.
 void testCopyPropertyConvertToStringIndexed()
          Test copyProperty() converting to a String on indexed property
 void testCopyPropertyDouble()
          Test narrowing and widening conversions on double.
 void testCopyPropertyFloat()
          Test narrowing and widening conversions on float.
 void testCopyPropertyInteger()
          Test narrowing and widening conversions on int.
 void testCopyPropertyLong()
          Test narrowing and widening conversions on long.
 void testCopyPropertyNestedIndexedArray()
          Test copying a property using a nested indexed array expression, with and without conversions.
 void testCopyPropertyNestedMappedMap()
          Test copying a property using a nested mapped map property.
 void testCopyPropertyNestedSimple()
          Test copying a property using a nested simple expression, with and without conversions.
 void testCopyPropertyNull()
          Test copying a null property value.
 void testCopyPropertyShort()
          Test narrowing and widening conversions on short.
 void testCopyPropertyWriteOnly()
          Test copying a new value to a write-only property, with and without conversions.
 void testDescribe()
          Test the describe() method.
 void testGetArrayProperty()
          tests the string and int arrays of TestBean
 void testGetArrayPropertyDate()
          Test getArrayProperty() converting to a String.
 void testGetGeneralProperty()
          tests getting a 'whatever' property
 void testGetIndexedProperty1()
          tests getting an indexed property
 void testGetIndexedProperty2()
          tests getting an indexed property
 void testGetIndexedPropertyDate()
          Test getArrayProperty() converting to a String.
 void testGetNestedProperty()
          tests getting a nested property
 void testGetSimpleProperty()
          tests getting a 'whatever' property
 void testGetSimplePropertyDate()
          Test getSimpleProperty() converting to a String.
 void testInitCause()
          Test for BeanUtilsBean.initCause(Throwable, Throwable) method.
 void testMappedProperty()
           
 void testPopulateArrayElements()
          Test populate() method on individual array elements.
 void testPopulateArrayProperties()
          Test populate() method on array properties as a whole.
 void testPopulateMapped()
          Test populate() on mapped properties.
 void testPopulateNested()
          Test populate() method on nested properties.
 void testPopulateScalar()
          Test populate() method on scalar properties.
 void testSeparateInstances()
          Tests that separate instances can register separate instances
 void testSetMappedMap()
          Test setting a value out of a mapped Map
 void testSetPropertyByte()
          Test narrowing and widening conversions on byte.
 void testSetPropertyConvert()
          Test setProperty() conversion.
 void testSetPropertyConvertFromString()
          Test setProperty() converting from a String.
 void testSetPropertyConvertToString()
          Test setProperty() converting to a String.
 void testSetPropertyConvertToStringArray()
          Test setProperty() converting to a String array.
 void testSetPropertyConvertToStringIndexed()
          Test setProperty() converting to a String on indexed property
 void testSetPropertyDouble()
          Test narrowing and widening conversions on double.
 void testSetPropertyFloat()
          Test narrowing and widening conversions on float.
 void testSetPropertyInteger()
          Test narrowing and widening conversions on int.
 void testSetPropertyLong()
          Test narrowing and widening conversions on long.
 void testSetPropertyNull()
          Test setting a null property value.
 void testSetPropertyNullValues()
          Test calling setProperty() with null property values.
 void testSetPropertyOnPrimitiveWrappers()
          Test converting to and from primitive wrapper types.
 void testSetPropertyShort()
          Test narrowing and widening conversions on short.
 void testSetPropertyStringToArray()
          Test setting a String value to a String array property
 void testSetPropertyWriteOnly()
          Test setting a new value to a write-only property, with and without conversions.
 
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

bean

protected TestBean bean
The test bean for each test.


describes

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


testCalendar

protected Calendar testCalendar
Test Calendar value


testUtilDate

protected Date testUtilDate
Test java.util.Date value


testStringDate

protected String testStringDate
Test String Date value

Constructor Detail

BeanUtilsTestCase

public BeanUtilsTestCase(String name)
Construct a new instance of this test case.

Parameters:
name - Name of the test case
Method Detail

setUp

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

Overrides:
setUp in class junit.framework.TestCase

setUpShared

protected void setUpShared()
Shared Set up.


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.

Overrides:
tearDown in class junit.framework.TestCase

testCopyPropertiesDynaBean

public void testCopyPropertiesDynaBean()
Test the copyProperties() method from a DynaBean.


testCopyPropertiesMap

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


testCopyPropertiesStandard

public void testCopyPropertiesStandard()
Test the copyProperties() method from a standard JavaBean.


testDescribe

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


testGetArrayProperty

public void testGetArrayProperty()
tests the string and int arrays of TestBean


testGetArrayPropertyDate

public void testGetArrayPropertyDate()
Test getArrayProperty() converting to a String.


testGetIndexedProperty1

public void testGetIndexedProperty1()
tests getting an indexed property


testGetIndexedPropertyDate

public void testGetIndexedPropertyDate()
Test getArrayProperty() converting to a String.


testGetIndexedProperty2

public void testGetIndexedProperty2()
tests getting an indexed property


testGetNestedProperty

public void testGetNestedProperty()
tests getting a nested property


testGetGeneralProperty

public void testGetGeneralProperty()
tests getting a 'whatever' property


testGetSimpleProperty

public void testGetSimpleProperty()
tests getting a 'whatever' property


testGetSimplePropertyDate

public void testGetSimplePropertyDate()
Test getSimpleProperty() converting to a String.


testPopulateArrayElements

public void testPopulateArrayElements()
Test populate() method on individual array elements.


testPopulateArrayProperties

public void testPopulateArrayProperties()
Test populate() method on array properties as a whole.


testPopulateMapped

public void testPopulateMapped()
Test populate() on mapped properties.


testPopulateNested

public void testPopulateNested()
Test populate() method on nested properties.


testPopulateScalar

public void testPopulateScalar()
Test populate() method on scalar properties.


testSetPropertyNullValues

public void testSetPropertyNullValues()
                               throws Exception
Test calling setProperty() with null property values.

Throws:
Exception

testSetPropertyOnPrimitiveWrappers

public void testSetPropertyOnPrimitiveWrappers()
                                        throws Exception
Test converting to and from primitive wrapper types.

Throws:
Exception

testSetPropertyByte

public void testSetPropertyByte()
                         throws Exception
Test narrowing and widening conversions on byte.

Throws:
Exception

testSetPropertyConvert

public void testSetPropertyConvert()
Test setProperty() conversion.


testSetPropertyConvertFromString

public void testSetPropertyConvertFromString()
Test setProperty() converting from a String.


testSetPropertyConvertToString

public void testSetPropertyConvertToString()
Test setProperty() converting to a String.


testSetPropertyConvertToStringArray

public void testSetPropertyConvertToStringArray()
Test setProperty() converting to a String array.


testSetPropertyConvertToStringIndexed

public void testSetPropertyConvertToStringIndexed()
Test setProperty() converting to a String on indexed property


testSetPropertyDouble

public void testSetPropertyDouble()
                           throws Exception
Test narrowing and widening conversions on double.

Throws:
Exception

testSetPropertyFloat

public void testSetPropertyFloat()
                          throws Exception
Test narrowing and widening conversions on float.

Throws:
Exception

testSetPropertyInteger

public void testSetPropertyInteger()
                            throws Exception
Test narrowing and widening conversions on int.

Throws:
Exception

testSetPropertyLong

public void testSetPropertyLong()
                         throws Exception
Test narrowing and widening conversions on long.

Throws:
Exception

testSetPropertyNull

public void testSetPropertyNull()
                         throws Exception
Test setting a null property value.

Throws:
Exception

testSetPropertyShort

public void testSetPropertyShort()
                          throws Exception
Test narrowing and widening conversions on short.

Throws:
Exception

testSetPropertyStringToArray

public void testSetPropertyStringToArray()
                                  throws Exception
Test setting a String value to a String array property

Throws:
Exception

testCopyPropertyByte

public void testCopyPropertyByte()
                          throws Exception
Test narrowing and widening conversions on byte.

Throws:
Exception

testCopyPropertyConvert

public void testCopyPropertyConvert()
Test copyProperty() conversion.


testCopyPropertyConvertFromString

public void testCopyPropertyConvertFromString()
Test copyProperty() converting from a String.


testCopyPropertyConvertToString

public void testCopyPropertyConvertToString()
Test copyProperty() converting to a String.


testCopyPropertyConvertToStringArray

public void testCopyPropertyConvertToStringArray()
Test copyProperty() converting to a String.


testCopyPropertyConvertToStringIndexed

public void testCopyPropertyConvertToStringIndexed()
Test copyProperty() converting to a String on indexed property


testCopyPropertyDouble

public void testCopyPropertyDouble()
                            throws Exception
Test narrowing and widening conversions on double.

Throws:
Exception

testCopyPropertyFloat

public void testCopyPropertyFloat()
                           throws Exception
Test narrowing and widening conversions on float.

Throws:
Exception

testCopyPropertyInteger

public void testCopyPropertyInteger()
                             throws Exception
Test narrowing and widening conversions on int.

Throws:
Exception

testCopyPropertyLong

public void testCopyPropertyLong()
                          throws Exception
Test narrowing and widening conversions on long.

Throws:
Exception

testCopyPropertyShort

public void testCopyPropertyShort()
                           throws Exception
Test narrowing and widening conversions on short.

Throws:
Exception

testCopyPropertyNestedIndexedArray

public void testCopyPropertyNestedIndexedArray()
                                        throws Exception
Test copying a property using a nested indexed array expression, with and without conversions.

Throws:
Exception

testCopyPropertyNestedMappedMap

public void testCopyPropertyNestedMappedMap()
                                     throws Exception
Test copying a property using a nested mapped map property.

Throws:
Exception

testCopyPropertyNestedSimple

public void testCopyPropertyNestedSimple()
                                  throws Exception
Test copying a property using a nested simple expression, with and without conversions.

Throws:
Exception

testCopyPropertyNull

public void testCopyPropertyNull()
                          throws Exception
Test copying a null property value.

Throws:
Exception

testCopyPropertyWriteOnly

public void testCopyPropertyWriteOnly()
                               throws Exception
Test copying a new value to a write-only property, with and without conversions.

Throws:
Exception

testSetPropertyWriteOnly

public void testSetPropertyWriteOnly()
                              throws Exception
Test setting a new value to a write-only property, with and without conversions.

Throws:
Exception

testSetMappedMap

public void testSetMappedMap()
Test setting a value out of a mapped Map


testSeparateInstances

public void testSeparateInstances()
                           throws Exception
Tests that separate instances can register separate instances

Throws:
Exception

testArrayPropertyConversion

public void testArrayPropertyConversion()
                                 throws Exception
Throws:
Exception

checkIntArray

protected void checkIntArray(int[] actual,
                             int[] expected)

checkMap

protected void checkMap(Map actual,
                        Map expected)

testMappedProperty

public void testMappedProperty()
                        throws Exception
Throws:
Exception

testInitCause

public void testInitCause()
Test for BeanUtilsBean.initCause(Throwable, Throwable) method.



Copyright © 2000-2010 The Apache Software Foundation. All Rights Reserved.