1 7 8 package org.dom4j.dtd; 9 10 import junit.textui.TestRunner; 11 12 import org.dom4j.AbstractTestCase; 13 14 32 public class ExternalEntityDeclTest extends AbstractTestCase { 33 public static void main(String [] args) { 34 TestRunner.run(ExternalEntityDeclTest.class); 35 } 36 37 public void testToString() { 40 ExternalEntityDecl decl1 = new ExternalEntityDecl("name", null, 41 "systemID"); 42 ExternalEntityDecl decl2 = new ExternalEntityDecl("%name", null, 43 "systemID"); 44 45 assertEquals("<!ENTITY name SYSTEM \"systemID\" >", decl1.toString()); 46 assertEquals("<!ENTITY % name SYSTEM \"systemID\" >", decl2.toString()); 47 } 48 49 52 public void testSystemId() { 53 String expectedName = "anEntity"; 54 55 String expectedPublicID = null; 56 57 String expectedSystemID = "http://www.myorg.org/foo"; 58 59 String expectedText = "<!ENTITY anEntity " 60 + "SYSTEM \"http://www.myorg.org/foo\" >"; 61 62 ExternalEntityDecl actual = new ExternalEntityDecl(expectedName, 63 expectedPublicID, expectedSystemID); 64 65 assertEquals("name is correct", expectedName, actual.getName()); 66 67 assertEquals("publicID is correct", expectedPublicID, actual 68 .getPublicID()); 69 70 assertEquals("systemID is correct", expectedSystemID, actual 71 .getSystemID()); 72 73 assertEquals("toString() is correct", expectedText, actual.toString()); 74 } 75 76 80 public void testPublicIdSystemId() { 81 String expectedName = "anEntity"; 82 83 String expectedPublicID = "-//dom4j//DTD sample"; 84 85 String expectedSystemID = "http://www.myorg.org/foo"; 86 87 String expectedText = "<!ENTITY anEntity " 88 + "PUBLIC \"-//dom4j//DTD sample\" " 89 + "\"http://www.myorg.org/foo\" >"; 90 91 ExternalEntityDecl actual = new ExternalEntityDecl(expectedName, 92 expectedPublicID, expectedSystemID); 93 94 assertEquals("name is correct", expectedName, actual.getName()); 95 96 assertEquals("publicID is correct", expectedPublicID, actual 97 .getPublicID()); 98 99 assertEquals("systemID is correct", expectedSystemID, actual 100 .getSystemID()); 101 102 assertEquals("toString() is correct", expectedText, actual.toString()); 103 } 104 } 105 106 142 | Popular Tags |