malenkov | 61c45de | 2008-05-07 23:20:32 +0400 | [diff] [blame] | 1 | /* |
xdono | d10b8cf | 2008-07-02 12:55:45 -0700 | [diff] [blame] | 2 | * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. |
malenkov | 61c45de | 2008-05-07 23:20:32 +0400 | [diff] [blame] | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 21 | * have any questions. |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * @test %I% %G% |
| 26 | * @bug 4935607 |
| 27 | * @summary Tests transient properties |
| 28 | * @author Sergey Malenkov |
| 29 | */ |
| 30 | |
| 31 | import java.beans.Transient; |
| 32 | |
| 33 | public class Test4935607 extends AbstractTest<Test4935607.TransientBean> { |
| 34 | public static void main(String[] args) { |
| 35 | new Test4935607().test(true); |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | protected TransientBean getObject() { |
| 40 | TransientBean bean = new TransientBean(); |
| 41 | bean.setName("some string"); // NON-NLS: some string |
| 42 | return bean; |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | protected TransientBean getAnotherObject() { |
| 47 | TransientBean bean = new TransientBean(); |
| 48 | bean.setName("another string"); // NON-NLS: another string |
| 49 | bean.setComment("some comment"); // NON-NLS: some comment |
| 50 | return bean; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | protected void validate(TransientBean before, TransientBean after) { |
| 55 | if (!before.getName().equals(after.getName())) |
| 56 | throw new Error("the name property incorrectly encoded"); |
| 57 | |
| 58 | if (null != after.getComment()) |
| 59 | throw new Error("the comment property should be encoded"); |
| 60 | } |
| 61 | |
| 62 | public static class TransientBean { |
| 63 | private String name; |
| 64 | private String comment; |
| 65 | |
| 66 | public String getName() { |
| 67 | return this.name; |
| 68 | } |
| 69 | |
| 70 | public void setName(String name) { |
| 71 | this.name = name; |
| 72 | } |
| 73 | |
| 74 | @Transient |
| 75 | public String getComment() { |
| 76 | return this.comment; |
| 77 | } |
| 78 | |
| 79 | public void setComment(String comment) { |
| 80 | this.comment = comment; |
| 81 | } |
| 82 | } |
| 83 | } |