2849N/A/*
2849N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2849N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2849N/A *
2849N/A * This code is free software; you can redistribute it and/or modify it
2849N/A * under the terms of the GNU General Public License version 2 only, as
2849N/A * published by the Free Software Foundation.
2849N/A *
2849N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2849N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2849N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2849N/A * version 2 for more details (a copy is included in the LICENSE file that
2849N/A * accompanied this code).
2849N/A *
2849N/A * You should have received a copy of the GNU General Public License version
2849N/A * 2 along with this work; if not, write to the Free Software Foundation,
2849N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2849N/A *
2849N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2849N/A * or visit www.oracle.com if you need additional information or have any
2849N/A * questions.
2849N/A */
2849N/A
2849N/A/*
2849N/A * @test
2849N/A * @bug 6773022
2849N/A * @summary Test verifies that SampleModel.getDataElements() throws an appropriate
2849N/A * exception if coordinates are not in bounds.
2849N/A *
2849N/A * @run main GetDataElementsTest
2849N/A */
2849N/A
2849N/Aimport java.awt.image.ComponentSampleModel;
2849N/Aimport java.awt.image.DataBuffer;
2849N/Aimport java.awt.image.SampleModel;
2849N/A
2849N/Apublic class GetDataElementsTest {
2849N/A
2849N/A public static int width = 100;
2849N/A public static int height = 100;
2849N/A public static int dataType = DataBuffer.TYPE_BYTE;
2849N/A public static int numBands = 4;
2849N/A
2849N/A public static void main(String[] args) {
2849N/A SampleModel sm = new ComponentSampleModel(dataType, width, height, 4, width * 4, new int[] { 0, 1, 2, 3 } );
2849N/A
2849N/A DataBuffer db = sm.createDataBuffer();
2849N/A Object o = null;
2849N/A
2849N/A boolean testPassed = false;
2849N/A try {
2849N/A o = sm.getDataElements(Integer.MAX_VALUE, 0, 1, 1, o, db);
2849N/A } catch (ArrayIndexOutOfBoundsException e) {
2849N/A System.out.println(e.getMessage());
2849N/A testPassed = true;
2849N/A }
2849N/A
2849N/A if (!testPassed) {
2849N/A throw new RuntimeException("Excpected excprion was not thrown.");
2849N/A }
2849N/A }
2849N/A}