Search in sources :

Example 31 with StandardHost

use of org.apache.catalina.core.StandardHost in project tomcat by apache.

the class TestMapper method createHost.

private synchronized Host createHost(String name) {
    Host host = hostMap.get(name);
    if (host == null) {
        host = new StandardHost();
        host.setName(name);
        hostMap.put(name, host);
    }
    return host;
}
Also used : StandardHost(org.apache.catalina.core.StandardHost) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host)

Example 32 with StandardHost

use of org.apache.catalina.core.StandardHost in project tomcat by apache.

the class TestTomcat method testGetCustomContextPerAddContextWithHost.

@Test
public void testGetCustomContextPerAddContextWithHost() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass(ReplicatedContext.class.getName());
    }
    // No file system docBase required
    Context ctx = tomcat.addContext(host, "", null);
    assertEquals(ReplicatedContext.class.getName(), ctx.getClass().getName());
}
Also used : ReplicatedContext(org.apache.catalina.ha.context.ReplicatedContext) InitialContext(javax.naming.InitialContext) Context(org.apache.catalina.Context) StandardContext(org.apache.catalina.core.StandardContext) StandardHost(org.apache.catalina.core.StandardHost) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) ReplicatedContext(org.apache.catalina.ha.context.ReplicatedContext) Test(org.junit.Test)

Example 33 with StandardHost

use of org.apache.catalina.core.StandardHost in project tomcat by apache.

the class TestTomcat method testGetCustomContextPerAddWebappWithNullHost.

@Test
public void testGetCustomContextPerAddWebappWithNullHost() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass(ReplicatedContext.class.getName());
    }
    File appFile = new File("test/deployment/context.war");
    Context context = tomcat.addWebapp(null, "/test", appFile.getAbsolutePath());
    assertEquals(ReplicatedContext.class.getName(), context.getClass().getName());
}
Also used : ReplicatedContext(org.apache.catalina.ha.context.ReplicatedContext) InitialContext(javax.naming.InitialContext) Context(org.apache.catalina.Context) StandardContext(org.apache.catalina.core.StandardContext) StandardHost(org.apache.catalina.core.StandardHost) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) ReplicatedContext(org.apache.catalina.ha.context.ReplicatedContext) File(java.io.File) Test(org.junit.Test)

Example 34 with StandardHost

use of org.apache.catalina.core.StandardHost in project tomcat by apache.

the class TestTomcat method testGetCustomContextPerAddWebappWithHost.

@Test
public void testGetCustomContextPerAddWebappWithHost() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass(ReplicatedContext.class.getName());
    }
    File appFile = new File("test/deployment/context.war");
    Context context = tomcat.addWebapp(host, "/test", appFile.getAbsolutePath());
    assertEquals(ReplicatedContext.class.getName(), context.getClass().getName());
}
Also used : ReplicatedContext(org.apache.catalina.ha.context.ReplicatedContext) InitialContext(javax.naming.InitialContext) Context(org.apache.catalina.Context) StandardContext(org.apache.catalina.core.StandardContext) StandardHost(org.apache.catalina.core.StandardHost) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) ReplicatedContext(org.apache.catalina.ha.context.ReplicatedContext) File(java.io.File) Test(org.junit.Test)

Example 35 with StandardHost

use of org.apache.catalina.core.StandardHost in project tomcat by apache.

the class TestTomcat method testGetBrokenContextPerAddWepapp.

@Test
public void testGetBrokenContextPerAddWepapp() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass("InvalidContextClassName");
    }
    try {
        File appFile = new File("test/deployment/context.war");
        tomcat.addWebapp(null, "/test", appFile.getAbsolutePath());
        fail();
    } catch (IllegalArgumentException e) {
    // OK
    }
}
Also used : StandardHost(org.apache.catalina.core.StandardHost) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) File(java.io.File) Test(org.junit.Test)

Aggregations

StandardHost (org.apache.catalina.core.StandardHost)45 File (java.io.File)26 Context (org.apache.catalina.Context)19 StandardContext (org.apache.catalina.core.StandardContext)16 Test (org.junit.Test)15 Host (org.apache.catalina.Host)13 Container (org.apache.catalina.Container)10 Tomcat (org.apache.catalina.startup.Tomcat)7 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)7 Service (org.apache.catalina.Service)5 StandardEngine (org.apache.catalina.core.StandardEngine)5 HostConfig (org.apache.catalina.startup.HostConfig)5 IOException (java.io.IOException)4 Engine (org.apache.catalina.Engine)4 URL (java.net.URL)3 JarFile (java.util.jar.JarFile)3 InitialContext (javax.naming.InitialContext)3 ReplicatedContext (org.apache.catalina.ha.context.ReplicatedContext)3 ByteChunk (org.apache.tomcat.util.buf.ByteChunk)3 Before (org.junit.Before)3