1 19 package org.enhydra.zeus.source; 20 21 import java.io.File ; 22 import java.io.FileInputStream ; 23 import java.io.FileNotFoundException ; 24 import java.io.InputStream ; 25 import java.io.InputStreamReader ; 26 import java.io.IOException ; 27 import java.io.Reader ; 28 import java.io.StringReader ; 29 30 import org.enhydra.zeus.Source; 32 33 import com.wutka.dtd.DTD; 35 36 import junit.framework.Test; 38 import junit.framework.TestCase; 39 import junit.framework.TestSuite; 40 41 49 public class StreamDTDSourceTest extends TestCase { 50 51 60 public StreamDTDSourceTest(String testName) { 61 super(testName); 62 } 63 64 73 public static Test suite() { 74 return new TestSuite(StreamDTDSourceTest.class); 75 } 76 77 83 public void testConstructors() { 84 String systemID = "file:///test/system/ID.xml"; 85 FileInputStream in = null; 86 try { 87 in = new FileInputStream (new File ("bin/build.sh")); 88 } catch (FileNotFoundException neverHappens) { } 89 StreamDTDSource ss = new StreamDTDSource(in, systemID); 90 ss = new StreamDTDSource(in); 91 92 StringReader reader = new StringReader ("Test Input Reader"); 93 ss = new StreamDTDSource(reader, systemID); 94 95 ss = new StreamDTDSource(reader); 96 } 97 98 106 public void testGetDTDNegative() { 107 boolean caught = false; 108 try { 109 String systemID = "file:///test/system/ID.dtd"; 110 FileInputStream in = null; 111 try { 112 in = new FileInputStream (new File ("bin/build.sh")); 113 } catch (FileNotFoundException neverHappens) { } 114 StreamDTDSource ss = new StreamDTDSource(in, systemID); 115 DTD dtd = ss.getDTD(); 116 } catch (IOException e) { 117 caught = true; 118 } finally { 119 assertTrue(caught); 120 } 121 } 122 123 130 public void testGetDTDPositive() { 131 } 134 135 136 142 public void testGetSystemID() { 143 String systemID = "file:///test/system/ID.xml"; 144 FileInputStream in = null; 145 try { 146 in = new FileInputStream (new File ("bin/build.sh")); 147 } catch (FileNotFoundException neverHappens) { } 148 StreamDTDSource ss = new StreamDTDSource(in, systemID); 149 assertEquals(systemID, ss.getSystemID()); 150 151 ss = new StreamDTDSource(in); 152 assertNull(ss.getSystemID()); 153 154 StringReader reader = new StringReader ("Test Input Reader"); 155 ss = new StreamDTDSource(reader, systemID); 156 assertEquals(systemID, ss.getSystemID()); 157 158 ss = new StreamDTDSource(reader); 159 assertNull(ss.getSystemID()); 160 161 } 162 163 169 public void testSetSystemID() { 170 String systemID = "file:///test/system/ID.xml"; 171 FileInputStream in = null; 172 try { 173 in = new FileInputStream (new File ("bin/build.sh")); 174 } catch (FileNotFoundException neverHappens) { } 175 StreamDTDSource ss = new StreamDTDSource(in); 176 assertNull(ss.getSystemID()); 177 178 ss.setSystemID(systemID); 179 assertEquals(systemID, ss.getSystemID()); 180 181 ss = new StreamDTDSource(in, systemID); 182 assertEquals(systemID, ss.getSystemID()); 183 184 StringReader reader = new StringReader ("Test Input Reader"); 185 ss = new StreamDTDSource(reader); 186 assertNull(ss.getSystemID()); 187 ss.setSystemID(systemID); 188 assertEquals(systemID, ss.getSystemID()); 189 } 190 } 191 | Popular Tags |