Path: blob/master/test/jdk/java/beans/XMLEncoder/Test4935607.java
41152 views
/*1* Copyright (c) 2007, 2008, 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* @test %I% %G%25* @bug 493560726* @summary Tests transient properties27* @run main/othervm -Djava.security.manager=allow Test493560728* @author Sergey Malenkov29*/3031import java.beans.Transient;3233public class Test4935607 extends AbstractTest<Test4935607.TransientBean> {34public static void main(String[] args) {35new Test4935607().test(true);36}3738@Override39protected TransientBean getObject() {40TransientBean bean = new TransientBean();41bean.setName("some string"); // NON-NLS: some string42return bean;43}4445@Override46protected TransientBean getAnotherObject() {47TransientBean bean = new TransientBean();48bean.setName("another string"); // NON-NLS: another string49bean.setComment("some comment"); // NON-NLS: some comment50return bean;51}5253@Override54protected void validate(TransientBean before, TransientBean after) {55if (!before.getName().equals(after.getName()))56throw new Error("the name property incorrectly encoded");5758if (null != after.getComment())59throw new Error("the comment property should be encoded");60}6162public static class TransientBean {63private String name;64private String comment;6566public String getName() {67return this.name;68}6970public void setName(String name) {71this.name = name;72}7374@Transient75public String getComment() {76return this.comment;77}7879public void setComment(String comment) {80this.comment = comment;81}82}83}848586