.
| Method from org.apache.cactus.integration.ant.deployment.application.TestApplicationXml Detail: |
public void setUp() throws ParserConfigurationException {
factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(false);
builder = factory.newDocumentBuilder();
builder.setEntityResolver(new EntityResolver()
{
public InputSource resolveEntity(String thePublicId,
String theSystemId) throws SAXException
{
return new InputSource(new StringReader(""));
}
});
}
|
public void testConstructionWithNullDocument() throws Exception {
try
{
new DefaultApplicationXml(null);
fail("Expected NullPointerException");
}
catch (NullPointerException npe)
{
// expected
}
}
Tests whether the construction of a ApplicationXml object with a
null parameter for the DOM document throws a
NullPointerException. |
public void testGetWebModuleContextRootMultipleWebModules() throws Exception {
String xml = "< application >"
+ " < module >"
+ " < web >"
+ " < web-uri >webmodule1.jar< /web-uri >"
+ " < context-root >/webmodule1< /context-root >"
+ " < /web >"
+ " < /module >"
+ " < module >"
+ " < web >"
+ " < web-uri >webmodule2.jar< /web-uri >"
+ " < context-root >/webmodule2< /context-root >"
+ " < /web >"
+ " < /module >"
+ " < module >"
+ " < web >"
+ " < web-uri >webmodule3.jar< /web-uri >"
+ " < context-root >/webmodule3< /context-root >"
+ " < /web >"
+ " < /module >"
+ "< /application >";
Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes()));
ApplicationXml applicationXml = new DefaultApplicationXml(doc);
assertEquals("/webmodule1",
applicationXml.getWebModuleContextRoot("webmodule1.jar"));
assertEquals("/webmodule2",
applicationXml.getWebModuleContextRoot("webmodule2.jar"));
assertEquals("/webmodule3",
applicationXml.getWebModuleContextRoot("webmodule3.jar"));
}
Verifies that the method getWebModuleContextRoot() returns
an the correct context roots for a descriptor with multiple web modules. |
public void testGetWebModuleContextRootSingleWebModule() throws Exception {
String xml = "< application >"
+ " < module >"
+ " < web >"
+ " < web-uri >webmodule.jar< /web-uri >"
+ " < context-root >/webmodule< /context-root >"
+ " < /web >"
+ " < /module >"
+ "< /application >";
Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes()));
ApplicationXml applicationXml = new DefaultApplicationXml(doc);
assertEquals("/webmodule",
applicationXml.getWebModuleContextRoot("webmodule.jar"));
}
Verifies that the method getWebModuleContextRoot() returns
an the correct context root for a descriptor with a single web module. |
public void testGetWebModuleContextRootUndefined() throws Exception {
String xml = "< application >"
+ " < module >"
+ " < java >javaclient.jar< /java >"
+ " < /module >"
+ "< /application >";
Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes()));
ApplicationXml applicationXml = new DefaultApplicationXml(doc);
try
{
applicationXml.getWebModuleContextRoot("webmodule.jar");
fail("IllegalArgumentException expected");
}
catch (IllegalArgumentException expected)
{
// expected
}
}
Verifies that the method getWebModuleContextRoot() throws an
IllegalARgumentException when the specified web module is
not defined. |
public void testGetWebModuleUrisWithEmptyDocument() throws Exception {
String xml = "< application >"
+ " < module >"
+ " < java >javaclient.jar< /java >"
+ " < /module >"
+ "< /application >";
Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes()));
ApplicationXml applicationXml = new DefaultApplicationXml(doc);
Iterator webUris = applicationXml.getWebModuleUris();
assertTrue("No web modules defined", !webUris.hasNext());
}
Verifies that the method getWebModuleUris() returns an empty
iterator for a descriptor with no web module definitions. |
public void testGetWebModuleUrisWithMultipleWebModules() throws Exception {
String xml = "< application >"
+ " < module >"
+ " < web >"
+ " < web-uri >webmodule1.jar< /web-uri >"
+ " < context-root >/webmodule1< /context-root >"
+ " < /web >"
+ " < /module >"
+ " < module >"
+ " < web >"
+ " < web-uri >webmodule2.jar< /web-uri >"
+ " < context-root >/webmodule2< /context-root >"
+ " < /web >"
+ " < /module >"
+ " < module >"
+ " < web >"
+ " < web-uri >webmodule3.jar< /web-uri >"
+ " < context-root >/webmodule3< /context-root >"
+ " < /web >"
+ " < /module >"
+ "< /application >";
Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes()));
ApplicationXml applicationXml = new DefaultApplicationXml(doc);
Iterator webUris = applicationXml.getWebModuleUris();
assertEquals("webmodule1.jar", webUris.next());
assertEquals("webmodule2.jar", webUris.next());
assertEquals("webmodule3.jar", webUris.next());
assertTrue(!webUris.hasNext());
}
Verifies that the method getWebModuleUris() returns an
iterator with the correct web-uris for a descriptor with multiple web
module definitions. |
public void testGetWebModuleUrisWithSingleWebModule() throws Exception {
String xml = "< application >"
+ " < module >"
+ " < web >"
+ " < web-uri >webmodule.jar< /web-uri >"
+ " < context-root >/webmodule< /context-root >"
+ " < /web >"
+ " < /module >"
+ "< /application >";
Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes()));
ApplicationXml applicationXml = new DefaultApplicationXml(doc);
Iterator webUris = applicationXml.getWebModuleUris();
assertEquals("webmodule.jar", webUris.next());
assertTrue(!webUris.hasNext());
}
Verifies that the method getWebModuleUris() returns an
iterator with the correct web-uri for a descriptor with a single web
module definition. |