@@ -0,0 +1,2663 @@
+/**%0A * Copyright (c) 2008-2011, http://www.snakeyaml.org%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.yaml.snakeyaml.issues.issue114;%0A%0Aimport java.util.LinkedHashMap;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport junit.framework.TestCase;%0A%0Aimport org.yaml.snakeyaml.Yaml;%0A%0Apublic class PreserveTypeTest extends TestCase %7B%0A%0A    public static class MyBean %7B%0A%0A        private int dummy;%0A%0A        public int getDummy() %7B%0A            return dummy;%0A        %7D%0A%0A        public void setDummy(int dummy) %7B%0A            this.dummy = dummy;%0A        %7D%0A    %7D%0A%0A    public static class ReferencingBean %7B%0A%0A        private List%3CMyBean%3E myBeans = new LinkedList%3CPreserveTypeTest.MyBean%3E();%0A%0A        public List%3CMyBean%3E getMyBeans() %7B%0A            return myBeans;%0A        %7D%0A%0A        public void setMyBeans(List%3CMyBean%3E myBeans) %7B%0A            this.myBeans = myBeans;%0A        %7D%0A    %7D%0A%0A    private Map%3CString, Object%3E createData(boolean collectionFirst) %7B%0A        MyBean myBean = new MyBean();%0A        ReferencingBean referencingBean = new ReferencingBean();%0A        referencingBean.getMyBeans().add(myBean);%0A%0A        LinkedHashMap%3CString, Object%3E map = new LinkedHashMap%3CString, Object%3E();%0A        if (collectionFirst) %7B%0A            map.put(%22referencingBean%22, referencingBean);%0A            map.put(%22myBean%22, myBean);%0A        %7D else %7B%0A            map.put(%22myBean%22, myBean);%0A            map.put(%22referencingBean%22, referencingBean);%0A        %7D%0A        return map;%0A    %7D%0A%0A    private void check(String doc) %7B%0A        System.err.println(doc);%0A        Yaml yaml = new Yaml();%0A        @SuppressWarnings(%22unchecked%22)%0A        Map%3CString, Object%3E loaded = (Map%3CString, Object%3E) yaml.load(doc);%0A        Object myBean2 = loaded.get(%22myBean%22);%0A        assertTrue(myBean2.getClass().toString(), myBean2 instanceof MyBean);%0A    %7D%0A%0A    public void testPreserveType1() %7B%0A        Yaml yaml = new Yaml();%0A        String s = yaml.dump(createData(true));%0A        check(s);%0A    %7D%0A%0A    public void testPreserveType2() %7B%0A        Yaml yaml = new Yaml();%0A        String s = yaml.dump(createData(false));%0A        // TODO issue 114 check(s);%0A    %7D%0A%7D%0A

Add test for issue 114