1/* 2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/* 25 * @test 26 * @summary Tests <int> element 27 * @author Sergey Malenkov 28 */ 29 30import java.beans.XMLDecoder; 31 32public final class TestInt extends AbstractTest { 33 public static final String XML 34 = "<java>\n" 35 + " <int>0</int>\n" 36 + " <int>127</int>\n" 37 + " <int>-128</int>\n" 38 + " <int>32767</int>\n" 39 + " <int>-32768</int>\n" 40 + " <int>2147483647</int>\n" 41 + " <int>-2147483648</int>\n" 42 + "</java>"; 43 44 public static void main(String[] args) { 45 new TestInt().test(true); 46 } 47 48 @Override 49 protected void validate(XMLDecoder decoder) { 50 validate(0, decoder.readObject()); 51 validate((int) Byte.MAX_VALUE, decoder.readObject()); 52 validate((int) Byte.MIN_VALUE, decoder.readObject()); 53 validate((int) Short.MAX_VALUE, decoder.readObject()); 54 validate((int) Short.MIN_VALUE, decoder.readObject()); 55 validate(Integer.MAX_VALUE, decoder.readObject()); 56 validate(Integer.MIN_VALUE, decoder.readObject()); 57 } 58 59 private static void validate(int value, Object object) { 60 if (!object.equals(Integer.valueOf(value))) { 61 throw new Error("int " + value + " expected"); 62 } 63 } 64} 65