1 /** 2 * Copyright (c) 2008, SnakeYAML 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package org.yaml.snakeyaml.constructor; 15 16 import java.util.Vector; 17 import junit.framework.TestCase; 18 import org.yaml.snakeyaml.Yaml; 19 20 public class VectorTest extends TestCase { 21 22 @SuppressWarnings("unchecked") testVector()23 public void testVector() throws ClassNotFoundException { 24 // Data to serialise 25 Vector<String> srcVector = new Vector<String>(); 26 srcVector.add("this"); 27 srcVector.add("is"); 28 srcVector.add("a"); 29 srcVector.add("test"); 30 // System.out.println("Source Vector: " + srcVector); 31 Yaml yaml = new Yaml(); 32 String instance = yaml.dump(srcVector); 33 // System.out.println("YAML String: " + instance); 34 yaml = new Yaml(new Constructor("java.util.Vector")); 35 // If I try to get a Vector I receive a class cast exception. 36 Vector<String> vector = yaml.load(instance); 37 // System.out.println("Vector: " + vector); 38 assertEquals(4, vector.size()); 39 assertEquals("this", vector.firstElement()); 40 assertEquals("test", vector.lastElement()); 41 } 42 } 43