Index: modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java =================================================================== --- modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java (revision 0) +++ modules/awt/src/test/api/java/common/java/awt/image/ComponentSampleModelTest.java (revision 0) @@ -0,0 +1,49 @@ +package java.awt.image; + +import junit.framework.TestCase; + +public class ComponentSampleModelTest extends TestCase { + + public ComponentSampleModelTest(String name) { + super(name); + } + + public final void testSetDataElements(){ + // Checking ArrayIndexOutOfBoundsException when passes wrong x or y + int[] offsets = new int[4]; + ComponentSampleModel csm = new + ComponentSampleModel(DataBuffer.TYPE_USHORT,238,4,7,14,offsets); + ComponentSampleModel obj = new + ComponentSampleModel(DataBuffer.TYPE_USHORT,1,2,3,15, offsets); + + DataBufferFloat db = new DataBufferFloat(4); + try{ + csm.setDataElements(-1399, 2, obj, db); + fail("Expected ArrayIndexOutOfBoundsException didn't throw"); + }catch (ClassCastException e) { + fail("Unexpected ClassCastException was thrown"); + }catch (ArrayIndexOutOfBoundsException e) { + assertTrue(true); + } + } + + public final void testGetDataElements(){ + // Checking ArrayIndexOutOfBoundsException when passes wrong x or y + int[] offsets = new int[4]; + ComponentSampleModel csm = new + ComponentSampleModel(DataBuffer.TYPE_USHORT,238,4,7,14,offsets); + ComponentSampleModel obj = new + ComponentSampleModel(DataBuffer.TYPE_USHORT,1,2,3,15, offsets); + + DataBufferFloat db = new DataBufferFloat(4); + try{ + csm.getDataElements(-1399, 2, obj, db); + fail("Expected ArrayIndexOutOfBoundsException didn't throw"); + }catch (ClassCastException e) { + fail("Unexpected ClassCastException was thrown"); + }catch (ArrayIndexOutOfBoundsException e) { + assertTrue(true); + } + } + +}