|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.api.convertor; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.InputStream; import org.netbeans.junit.*; import junit.textui.TestRunner; import org.netbeans.api.convertor.dvd.DVD; import org.netbeans.modules.convertor.PropertiesConvertor; import org.netbeans.spi.convertor.Convertor; import org.openide.filesystems.Repository; import org.openide.modules.ModuleInfo; import org.openide.util.Lookup; import org.w3c.dom.Document; /** * * @author David Konecny */ public class DVDConvertorTest extends NbTestCase { public DVDConvertorTest(String name) { super (name); } public static void main(String[] args) { TestRunner.run(new NbTestSuite(DVDConvertorTest.class)); } protected void setUp () throws Exception { Lookup.getDefault().lookup(ModuleInfo.class); Repository.getDefault ().getDefaultFileSystem ().getRoot (); } private static Convertor conv; public static void setupConvertor() throws Exception { ModuleUtils.DEFAULT.install(); ModuleUtils.DEFAULT.enableDVDConvertorModule(true); } public static void removeConvertor() throws Exception { ModuleUtils.DEFAULT.enableDVDConvertorModule(false); ModuleUtils.DEFAULT.uninstall(); } public void testDVDConvertor() throws Exception { assertFalse(Convertors.canRead("http://www.netbeans.org/ns/dvd", "dvd")); assertFalse(Convertors.canWrite(new DVD())); setupConvertor(); assertTrue(Convertors.canRead("http://www.netbeans.org/ns/dvd", "dvd")); assertTrue(Convertors.canWrite(new DVD())); // assertEquals(Convertors.getConvertorDescriptor(new DVD()), new ConvertorDescriptor("http://www.netbeans.org/ns/dvd", "org.netbeans.api.convertor.dvd.DVD")); String name = DVDConvertorTest.class.getResource("dvd").getFile() + "/data/DVD.xml"; InputStream is = new FileInputStream(name); DVD d = (DVD)Convertors.read(is); assertEquals(d.ID, 125); assertEquals(d.title, "Tetsuo"); assertEquals(d.publisher, "TartanTerror"); assertEquals(d.price, 19); is.close(); ByteArrayOutputStream os = new ByteArrayOutputStream(); DVD dvd = new DVD(698, "Zentropa", "TartanClassic", 65); Convertors.write(os, dvd); byte[] ba = os.toByteArray(); os.close(); ByteArrayInputStream bis = new ByteArrayInputStream(ba); Object o = Convertors.read(bis); assertEquals(dvd, o); removeConvertor(); assertFalse(Convertors.canRead("http://www.netbeans.org/ns/dvd", "dvd")); assertFalse(Convertors.canWrite(new DVD())); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.