Java Code Examples for org.apache.catalina.core.StandardHost#getConfigBaseFile()

The following examples show how to use org.apache.catalina.core.StandardHost#getConfigBaseFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHostConfigAutomaticDeployment.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private void doTestCopyXML(boolean copyXmlHost, boolean copyXmlWar,
        boolean external, boolean resultXml) throws Exception {

    Tomcat tomcat = getTomcatInstance();
    StandardHost host = (StandardHost) tomcat.getHost();

    host.setCopyXML(copyXmlHost);

    tomcat.start();

    File war;
    if (copyXmlWar) {
        war = createWar(WAR_XML_COPYXML_TRUE_SOURCE, !external);
    } else {
        war = createWar(WAR_XML_COPYXML_FALSE_SOURCE, !external);
    }
    if (external) {
        createXmlInConfigBaseForExternal(war);
    }

    host.backgroundProcess();

    File xml = new File(host.getConfigBaseFile(),
            APP_NAME.getBaseName() + ".xml");
    Assert.assertEquals(
            Boolean.valueOf(resultXml), Boolean.valueOf(xml.isFile()));

    Context context = (Context) host.findChild(APP_NAME.getName());
    if (external) {
        Assert.assertEquals(XML_COOKIE_NAME,
                context.getSessionCookieName());
    } else {
        Assert.assertEquals(WAR_COOKIE_NAME,
                context.getSessionCookieName());
    }
}
 
Example 2
Source File: TestHostConfigAutomaticDeployment.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
private void doTestDeployment(boolean deployXML, boolean copyXML,
        boolean unpackWARs, LifecycleState resultState, String cookieName,
        boolean resultXml, boolean resultWar, boolean resultDir)
        throws Exception {

    Tomcat tomcat = getTomcatInstance();

    // Start the instance
    tomcat.start();

    // Set the attributes
    StandardHost host = (StandardHost) tomcat.getHost();
    host.setDeployXML(deployXML);
    host.setCopyXML(copyXML);
    host.setUnpackWARs(unpackWARs);

    // Trigger automatic deployment
    host.backgroundProcess();

    // Test the results
    Context ctxt = (Context) tomcat.getHost().findChild(APP_NAME.getPath());
    if (resultState == null) {
        Assert.assertNull(ctxt);
    } else {
        Assert.assertNotNull(ctxt);
        Assert.assertEquals(resultState, ctxt.getState());
        Assert.assertEquals(cookieName, ctxt.getSessionCookieName());
    }

    File xml = new File(
            host.getConfigBaseFile(), APP_NAME.getBaseName() + ".xml");
    Assert.assertEquals(
            Boolean.valueOf(resultXml), Boolean.valueOf(xml.isFile()));

    File war = new File(
            host.getAppBaseFile(), APP_NAME.getBaseName() + ".war");
    Assert.assertEquals(
            Boolean.valueOf(resultWar), Boolean.valueOf(war.isFile()));

    File dir = new File(host.getAppBase(), APP_NAME.getBaseName());
    Assert.assertEquals(
            Boolean.valueOf(resultDir), Boolean.valueOf(dir.isDirectory()));
}