Search in sources :

Example 71 with StandardHost

use of org.apache.catalina.core.StandardHost in project fess by codelibs.

the class FessBoot method main.

// ===================================================================================
// main
// ============
public static void main(final String[] args) {
    // update java.io.tmpdir
    final String tempPath = System.getProperty(FESS_TEMP_PATH);
    if (tempPath != null) {
        System.setProperty(JAVA_IO_TMPDIR, tempPath);
    }
    final TomcatBoot tomcatBoot = // 
    new FessBoot(getPort(), getContextPath()).useTldDetect();
    if (tempPath != null) {
        tomcatBoot.atBaseDir(new File(tempPath, "webapp").getAbsolutePath());
    }
    final String tomcatConfigPath = getTomcatConfigPath();
    if (tomcatConfigPath != null) {
        // e.g. URIEncoding
        tomcatBoot.configure(tomcatConfigPath);
    }
    tomcatBoot.logging(LOGGING_PROPERTIES, op -> {
        op.ignoreNoFile();
        String fessLogPath = System.getProperty("fess.log.path");
        if (fessLogPath == null) {
            fessLogPath = "../../logs";
        }
        op.replace("fess.log.path", fessLogPath.replace("\\", "/"));
    }).asYouLikeIt(resource -> {
        final Host host = resource.getHost();
        if (host instanceof StandardHost) {
            ((StandardHost) host).setErrorReportValveClass(SuppressErrorReportValve.class.getName());
        }
    }).useTldDetect(jarName -> (jarName.contains("jstl") || jarName.contains("lasta-taglib"))).asDevelopment(isNoneEnv()).bootAwait();
}
Also used : TomcatBoot(org.dbflute.tomcat.TomcatBoot) Host(org.apache.catalina.Host) FessWebResourceRoot(org.codelibs.fess.tomcat.webresources.FessWebResourceRoot) StringUtil(org.codelibs.core.lang.StringUtil) SuppressErrorReportValve(org.codelibs.fess.tomcat.valve.SuppressErrorReportValve) Context(org.apache.catalina.Context) StandardHost(org.apache.catalina.core.StandardHost) TomcatBoot(org.dbflute.tomcat.TomcatBoot) File(java.io.File) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) StandardHost(org.apache.catalina.core.StandardHost) File(java.io.File)

Example 72 with StandardHost

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

the class TesterDigestAuthenticatorPerformance method setUp.

@Before
public void setUp() throws Exception {
    ConcurrentMessageDigest.init("MD5");
    // Configure the Realm
    TesterMapRealm realm = new TesterMapRealm();
    realm.addUser(USER, PWD);
    realm.addUserRole(USER, ROLE);
    // Add the Realm to the Context
    Context context = new StandardContext();
    context.setName(CONTEXT_PATH);
    context.setRealm(realm);
    Host host = new StandardHost();
    context.setParent(host);
    Engine engine = new StandardEngine();
    host.setParent(engine);
    Service service = new StandardService();
    engine.setService(service);
    // Configure the Login config
    LoginConfig config = new LoginConfig();
    config.setRealmName(REALM);
    context.setLoginConfig(config);
    // Make the Context and Realm visible to the Authenticator
    authenticator.setContainer(context);
    authenticator.setNonceCountWindowSize(8 * 1024);
    authenticator.start();
}
Also used : Context(org.apache.catalina.Context) StandardContext(org.apache.catalina.core.StandardContext) TesterMapRealm(org.apache.catalina.startup.TesterMapRealm) StandardEngine(org.apache.catalina.core.StandardEngine) StandardHost(org.apache.catalina.core.StandardHost) StandardContext(org.apache.catalina.core.StandardContext) LoginConfig(org.apache.tomcat.util.descriptor.web.LoginConfig) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) StandardService(org.apache.catalina.core.StandardService) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine) Before(org.junit.Before)

Example 73 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());
        Assert.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)

Example 74 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());
    Assert.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 75 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());
    Assert.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)

Aggregations

StandardHost (org.apache.catalina.core.StandardHost)90 File (java.io.File)48 Context (org.apache.catalina.Context)38 StandardContext (org.apache.catalina.core.StandardContext)36 Host (org.apache.catalina.Host)29 Test (org.junit.Test)26 Tomcat (org.apache.catalina.startup.Tomcat)16 Container (org.apache.catalina.Container)12 StandardEngine (org.apache.catalina.core.StandardEngine)12 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)12 IOException (java.io.IOException)10 URL (java.net.URL)8 Service (org.apache.catalina.Service)8 HostConfig (org.apache.catalina.startup.HostConfig)8 InitialContext (javax.naming.InitialContext)7 Engine (org.apache.catalina.Engine)7 InputStream (java.io.InputStream)6 ObjectName (javax.management.ObjectName)6 ReplicatedContext (org.apache.catalina.ha.context.ReplicatedContext)6 ArrayList (java.util.ArrayList)5