jdk/test/java/beans/XMLEncoder/Test7169395.java
author lana
Tue, 23 May 2017 21:11:42 +0000
changeset 45187 331a6542b5b8
parent 13653 012c6f8f0279
permissions -rw-r--r--
Added tag jdk-10+7 for changeset d554736d963e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13653
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     1
/*
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     4
 *
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     8
 *
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    13
 * accompanied this code).
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    14
 *
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    18
 *
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    21
 * questions.
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    22
 */
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    23
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    24
/*
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    25
 * @test
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    26
 * @bug 7169395
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    27
 * @summary Tests that array list initialized correctly
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    29
 */
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    30
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    31
import java.beans.ConstructorProperties;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    32
import java.util.ArrayList;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    33
import java.util.Collection;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    34
import java.util.Map;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    35
import java.util.TreeMap;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    36
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    37
public class Test7169395 extends AbstractTest {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    38
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    39
    public static void main(String[] args) {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    40
        new Test7169395().test(true);
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    41
    }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    42
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    43
    protected Object getObject() {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    44
        Container container = new Container();
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    45
        container.add("test-null", null);
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    46
        container.add("test-value", "value");
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    47
        container.add("test-other", "other");
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    48
        return container;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    49
    }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    50
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    51
    public static class Component {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    52
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    53
        private final Container container;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    54
        private final String name;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    55
        private String value;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    56
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    57
        @ConstructorProperties({ "container", "name" })
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    58
        public Component(Container container, String name) {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    59
            this.container = container;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    60
            this.name = name;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    61
        }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    62
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    63
        public Container getContainer() {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    64
            return this.container;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    65
        }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    66
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    67
        public String getName() {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    68
            return this.name;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    69
        }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    70
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    71
        public String getValue() {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    72
            return this.value;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    73
        }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    74
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    75
        public void setValue(String value) {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    76
            this.value = value;
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    77
        }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    78
    }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    79
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    80
    public static class Container {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    81
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    82
        private final Map<String, Component> map = new TreeMap<String, Component>();
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    83
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    84
        public Collection<Component> getComponents() {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    85
            return new ArrayList<Component>(this.map.values());
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    86
        }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    87
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    88
        public void setComponents(Collection<Component> components) {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    89
            this.map.clear();
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    90
            for (Component component : components){
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    91
                this.map.put(component.getName(), component);
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    92
            }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    93
        }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    94
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    95
        public void add(String name, String value) {
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    96
            Component list = new Component(this, name);
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    97
            list.setValue(value);
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    98
            this.map.put(name, list);
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
    99
        }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
   100
    }
012c6f8f0279 7169395: Exception throws due to the changes in JDK 7 object tranversal and break backward compatibility
malenkov
parents:
diff changeset
   101
}