Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/beans/XMLEncoder/Test7169395.java
38812 views
/*1* Copyright (c) 2012, 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 716939526* @summary Tests that array list initialized correctly27* @author Sergey Malenkov28*/2930import java.beans.ConstructorProperties;31import java.util.ArrayList;32import java.util.Collection;33import java.util.Map;34import java.util.TreeMap;3536public class Test7169395 extends AbstractTest {3738public static void main(String[] args) {39new Test7169395().test(true);40}4142protected Object getObject() {43Container container = new Container();44container.add("test-null", null);45container.add("test-value", "value");46container.add("test-other", "other");47return container;48}4950public static class Component {5152private final Container container;53private final String name;54private String value;5556@ConstructorProperties({ "container", "name" })57public Component(Container container, String name) {58this.container = container;59this.name = name;60}6162public Container getContainer() {63return this.container;64}6566public String getName() {67return this.name;68}6970public String getValue() {71return this.value;72}7374public void setValue(String value) {75this.value = value;76}77}7879public static class Container {8081private final Map<String, Component> map = new TreeMap<String, Component>();8283public Collection<Component> getComponents() {84return new ArrayList<Component>(this.map.values());85}8687public void setComponents(Collection<Component> components) {88this.map.clear();89for (Component component : components){90this.map.put(component.getName(), component);91}92}9394public void add(String name, String value) {95Component list = new Component(this, name);96list.setValue(value);97this.map.put(name, list);98}99}100}101102103