KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > convertor > xmlinstance > XMLInstanceConvertorTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.convertor.xmlinstance;
21
22 import java.io.FileInputStream JavaDoc;
23 import java.io.FileReader JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.io.InputStream JavaDoc;
26 import java.io.Reader JavaDoc;
27 import junit.textui.TestRunner;
28 import org.netbeans.api.convertor.Convertors;
29 import org.netbeans.junit.NbTestCase;
30 import org.netbeans.junit.NbTestSuite;
31 import org.openide.filesystems.Repository;
32 import org.openide.modules.ModuleInfo;
33 import org.openide.util.Lookup;
34
35 /**
36  *
37  * @author David Konecny
38  */

39 public class XMLInstanceConvertorTest extends NbTestCase {
40     
41     public XMLInstanceConvertorTest(String JavaDoc name) {
42         super (name);
43     }
44     
45     public static void main(String JavaDoc[] args) {
46         TestRunner.run(new NbTestSuite(XMLInstanceConvertorTest.class));
47     }
48     
49     protected void setUp () throws Exception JavaDoc {
50         Lookup.getDefault().lookup(ModuleInfo.class);
51     }
52
53     public void testConvertor() throws Exception JavaDoc {
54         String JavaDoc name = XMLInstanceConvertorTest.class.getResource("data").getFile() + "/CD1.xml";
55         InputStream JavaDoc is = new FileInputStream JavaDoc(name);
56         CD c = (CD)Convertors.read(is);
57         assertNotNull(c);
58         assertEquals(c, new CD());
59         is.close();
60         
61         name = XMLInstanceConvertorTest.class.getResource("data").getFile() + "/CD2.xml";
62         is = new FileInputStream JavaDoc(name);
63         c = (CD)Convertors.read(is);
64         assertNotNull(c);
65         assertEquals(c, new CD("V.A.", "Radio 1 Essential Mixes"));
66         is.close();
67         
68         name = XMLInstanceConvertorTest.class.getResource("data").getFile() + "/CD3.xml";
69         is = new FileInputStream JavaDoc(name);
70         c = (CD)Convertors.read(is);
71         assertNotNull(c);
72         assertEquals(c, new CD("The Hafler Trio", "Cleave: 9 Great Openings"));
73         is.close();
74         
75     }
76     
77 }
78
Popular Tags