Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
parent
d4f72256e7
commit
f1474a4a3f
|
@ -79,6 +79,65 @@ public class WebAppContextTest
|
|||
Configurations.cleanKnown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultContextPath() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
File webXml = MavenTestingUtils.getTestResourceFile("web-with-default-context-path.xml");
|
||||
File webXmlEmptyPath = MavenTestingUtils.getTestResourceFile("web-with-empty-default-context-path.xml");
|
||||
File webDefaultXml = MavenTestingUtils.getTestResourceFile("web-default-with-default-context-path.xml");
|
||||
File overrideWebXml = MavenTestingUtils.getTestResourceFile("override-web-with-default-context-path.xml");
|
||||
assertNotNull(webXml);
|
||||
assertNotNull(webDefaultXml);
|
||||
assertNotNull(overrideWebXml);
|
||||
assertNotNull(webXmlEmptyPath);
|
||||
|
||||
try
|
||||
{
|
||||
WebAppContext wac = new WebAppContext();
|
||||
wac.setResourceBase(MavenTestingUtils.getTargetTestingDir().getAbsolutePath());
|
||||
server.setHandler(wac);
|
||||
|
||||
//test that an empty default-context-path defaults to root
|
||||
wac.setDescriptor(webXmlEmptyPath.getAbsolutePath());
|
||||
server.start();
|
||||
assertEquals("/", wac.getContextPath());
|
||||
|
||||
server.stop();
|
||||
|
||||
//test web-default.xml value is used
|
||||
wac.setDescriptor(null);
|
||||
wac.setDefaultsDescriptor(webDefaultXml.getAbsolutePath());
|
||||
server.start();
|
||||
assertEquals("/one", wac.getContextPath());
|
||||
|
||||
server.stop();
|
||||
|
||||
//test web.xml value is used
|
||||
wac.setDescriptor(webXml.getAbsolutePath());
|
||||
server.start();
|
||||
assertEquals("/two", wac.getContextPath());
|
||||
|
||||
server.stop();
|
||||
|
||||
//test override-web.xml value is used
|
||||
wac.setOverrideDescriptor(overrideWebXml.getAbsolutePath());
|
||||
server.start();
|
||||
assertEquals("/three", wac.getContextPath());
|
||||
|
||||
server.stop();
|
||||
|
||||
//test that explicitly set context path is used instead
|
||||
wac.setContextPath("/foo");
|
||||
server.start();
|
||||
assertEquals("/foo", wac.getContextPath());
|
||||
}
|
||||
finally
|
||||
{
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionListeners()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee web-app_4_0.xsd"
|
||||
version="4.0">
|
||||
|
||||
<display-name>Test 4 WebApp</display-name>
|
||||
<default-context-path>/three</default-context-path>
|
||||
|
||||
</web-app>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee web-app_4_0.xsd"
|
||||
version="4.0">
|
||||
|
||||
<display-name>Test 4 WebApp</display-name>
|
||||
<default-context-path>/one</default-context-path>
|
||||
|
||||
</web-app>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee web-app_4_0.xsd"
|
||||
version="4.0">
|
||||
|
||||
<display-name>Test 4 WebApp</display-name>
|
||||
<default-context-path>/two</default-context-path>
|
||||
|
||||
</web-app>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee web-app_4_0.xsd"
|
||||
version="4.0">
|
||||
|
||||
<display-name>Test 4 WebApp</display-name>
|
||||
<default-context-path></default-context-path>
|
||||
|
||||
</web-app>
|
Loading…
Reference in New Issue