1 19 20 package org.netbeans.api.convertor.xmlinstance; 21 22 import java.io.FileInputStream ; 23 import java.io.FileReader ; 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 import java.io.Reader ; 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 39 public class XMLInstanceConvertorTest extends NbTestCase { 40 41 public XMLInstanceConvertorTest(String name) { 42 super (name); 43 } 44 45 public static void main(String [] args) { 46 TestRunner.run(new NbTestSuite(XMLInstanceConvertorTest.class)); 47 } 48 49 protected void setUp () throws Exception { 50 Lookup.getDefault().lookup(ModuleInfo.class); 51 } 52 53 public void testConvertor() throws Exception { 54 String name = XMLInstanceConvertorTest.class.getResource("data").getFile() + "/CD1.xml"; 55 InputStream is = new FileInputStream (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 (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 (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 |