1 20 package org.apache.cactus.integration.ant.deployment.application; 21 22 23 import javax.xml.parsers.DocumentBuilderFactory ; 24 import javax.xml.parsers.ParserConfigurationException ; 25 26 import junit.framework.TestCase; 27 28 import org.w3c.dom.DOMImplementation ; 29 import org.w3c.dom.DocumentType ; 30 31 36 public final class TestApplicationXmlVersion extends TestCase 37 { 38 41 private DOMImplementation domImpl; 42 43 46 public void setUp() throws ParserConfigurationException 47 { 48 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 49 factory.setValidating(false); 50 factory.setNamespaceAware(false); 51 52 this.domImpl = factory.newDocumentBuilder().getDOMImplementation(); 53 } 54 55 60 public void testCompare12To12() throws Exception 61 { 62 assertTrue(ApplicationXmlVersion.V1_2.compareTo( 63 ApplicationXmlVersion.V1_2) == 0); 64 } 65 66 72 public void testCompare12To13() throws Exception 73 { 74 assertTrue(ApplicationXmlVersion.V1_2.compareTo( 75 ApplicationXmlVersion.V1_3) < 0); 76 } 77 78 83 public void testCompare13To13() throws Exception 84 { 85 assertTrue(ApplicationXmlVersion.V1_3.compareTo( 86 ApplicationXmlVersion.V1_3) == 0); 87 } 88 89 95 public void testCompare13To12() throws Exception 96 { 97 assertTrue(ApplicationXmlVersion.V1_3.compareTo( 98 ApplicationXmlVersion.V1_2) > 0); 99 } 100 101 107 public void testValueOfNull() throws Exception 108 { 109 try 110 { 111 ApplicationXmlVersion.valueOf((DocumentType ) null); 112 fail("Expected NullPointerException"); 113 } 114 catch (NullPointerException expected) 115 { 116 } 118 } 119 120 126 public void testValueOfUnknownDocType() throws Exception 127 { 128 DocumentType docType = domImpl.createDocumentType("application", 129 "foo", "bar"); 130 assertNull(ApplicationXmlVersion.valueOf(docType)); 131 } 132 133 139 public void testValueOfDocType12() throws Exception 140 { 141 DocumentType docType = domImpl.createDocumentType("application", 142 ApplicationXmlVersion.V1_2.getPublicId(), 143 ApplicationXmlVersion.V1_2.getSystemId()); 144 assertEquals(ApplicationXmlVersion.V1_2, 145 ApplicationXmlVersion.valueOf(docType)); 146 } 147 148 154 public void testValueOfDocType13() throws Exception 155 { 156 DocumentType docType = domImpl.createDocumentType("application", 157 ApplicationXmlVersion.V1_3.getPublicId(), 158 ApplicationXmlVersion.V1_3.getSystemId()); 159 assertEquals(ApplicationXmlVersion.V1_3, 160 ApplicationXmlVersion.valueOf(docType)); 161 } 162 163 } 164 | Popular Tags |