Path: blob/master/test/jdk/java/beans/XMLEncoder/Test4950122.java
41152 views
/*1* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 495012226* @summary Tests DefaultPersistenceDelegate with boolean and integer property27* @author Sergey Malenkov28*/2930import java.beans.DefaultPersistenceDelegate;31import java.beans.Encoder;32import java.beans.ExceptionListener;33import java.beans.Expression;3435public final class Test4950122 {36public static void main(String[] args) {37TestBean bean = new TestBean(true, 11);38Encoder encoder = new Encoder();39encoder.setExceptionListener(bean);40new TestDPD().instantiate(bean, encoder);41}4243public static class TestDPD extends DefaultPersistenceDelegate {44public TestDPD() {45super(new String[] {"boolean", "integer"});46}4748public Expression instantiate(Object oldInstance, Encoder out) {49return super.instantiate(oldInstance, out);50}51}5253public static class TestBean implements ExceptionListener {54private boolean b;55private int i;5657public TestBean(boolean b, int i) {58this.b = b;59this.i = i;60}6162public boolean isBoolean() {63return this.b;64}6566public int getInteger() {67return this.i;68}6970public void exceptionThrown(Exception exception) {71throw new Error("unexpected exception", exception);72}73}74}757677