}
public void testNullParameterForRequiredBeanArray() throws Exception
{
final Element element = this.getRootElement( "/incorrect/test9.xml" );
final NullParameterForRequiredBeanArray cfg = XML2Java.bind( element, NullParameterForRequiredBeanArray.class );
this.assertArrayValues( cfg );
try
{
cfg.setProperties( null );
Assert.fail( "This test method had to fail!" );
}
catch ( Exception e )
{
final String[] expectedSubstrings = new String[]
{
"Cannot accept null value for bean",
"marked as required",
};
Helper.assertContains( e, expectedSubstrings );
}
this.assertArrayValues( cfg );
try
{
cfg.setProperties( new Integer[] {} );
Assert.fail( "This test method had to fail!" );
}
catch ( Exception e )
{
final String[] expectedSubstrings = new String[]
{
"Cannot accept zero length array for bean",
"marked as required. Array size have to be at least 1",
};
Helper.assertContains( e, expectedSubstrings );
}
this.assertArrayValues( cfg );
try
{
final Integer[] newValues = new Integer[]
{
1, null,
};
cfg.setProperties( newValues );
Assert.fail( "This test method had to fail!" );
}
catch ( Exception e )
{
final String[] expectedSubstrings = new String[]