moved back to sandbox
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1036 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
b5dee0c6d7
commit
0c415b3a47
|
@ -1,9 +0,0 @@
|
|||
target/
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
*.swp
|
||||
*.patch
|
||||
*.diff
|
||||
*.log
|
||||
cobertura.ser
|
|
@ -1,168 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-project</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp-logging</artifactId>
|
||||
<name>Jetty :: Centralized WebApp Logging</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>always</forkMode>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>package-config</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>config.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>package-boot</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/boot.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-centralized-logging</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-deploy</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jxr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>copy-test-webapps</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>testwarcopy</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>dummy-webapp-logging-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>dummy-webapp-logging-java</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>dummy-webapp-logging-log4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>dummy-webapp-logging-slf4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${basedir}/src/test/resources/webapps</outputDirectory>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
<stripVersion>true</stripVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly>
|
||||
<id>boot</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>jar</format>
|
||||
</formats>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.build.outputDirectory}</directory>
|
||||
<outputDirectory></outputDirectory>
|
||||
<includes>
|
||||
<include>**/*Formatter.class</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Enable Centralized Logging in the Jetty Server -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.webapp.logging.CentralizedLogging">
|
||||
<Set name="server"><Ref id="Server" /></Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -1,75 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
/**
|
||||
* Jetty Centralized Logging bean.
|
||||
*/
|
||||
public class CentralizedLogging extends AbstractLifeCycle
|
||||
{
|
||||
private Server server;
|
||||
private CentralizedWebAppLoggingConfiguration webAppConfiguration;
|
||||
private String configurationFilename;
|
||||
|
||||
public String getConfigurationFilename()
|
||||
{
|
||||
return configurationFilename;
|
||||
}
|
||||
|
||||
public void setConfigurationFilename(String filename)
|
||||
{
|
||||
this.configurationFilename = filename;
|
||||
}
|
||||
|
||||
public Server getServer()
|
||||
{
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(Server server)
|
||||
{
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
if (configurationFilename != null)
|
||||
{
|
||||
CentralizedWebAppLoggingConfiguration.setLoggerConfigurationFilename(configurationFilename);
|
||||
}
|
||||
webAppConfiguration = new CentralizedWebAppLoggingConfiguration();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Configuration> config = (List<Configuration>)server.getAttribute(WebAppContext.SERVER_CONFIG);
|
||||
if (config == null)
|
||||
{
|
||||
config = new ArrayList<Configuration>();
|
||||
}
|
||||
config.add(webAppConfiguration);
|
||||
server.setAttribute(WebAppContext.SERVER_CONFIG,config);
|
||||
|
||||
super.doStart();
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.logging.impl.CentralLoggerConfig;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Slf4jLog;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
|
||||
/**
|
||||
* WebAppContext {@link Configuration} for Centralized Logging.
|
||||
*/
|
||||
public class CentralizedWebAppLoggingConfiguration implements Configuration
|
||||
{
|
||||
private static boolean loggerConfigured = false;
|
||||
|
||||
public static CentralLoggerConfig getLoggerRoot()
|
||||
{
|
||||
loggerConfigured = true;
|
||||
return org.slf4j.impl.StaticLoggerBinder.getSingleton().getRoot();
|
||||
}
|
||||
|
||||
public static boolean isLoggerConfigured()
|
||||
{
|
||||
return loggerConfigured;
|
||||
}
|
||||
|
||||
public static void setConfiguredLoggerRoot(CentralLoggerConfig root)
|
||||
{
|
||||
loggerConfigured = true;
|
||||
org.slf4j.impl.StaticLoggerBinder.getSingleton().setRoot(root);
|
||||
try
|
||||
{
|
||||
// Reset jetty logger.
|
||||
Slf4jLog jettyLogger = new Slf4jLog();
|
||||
Log.setLog(jettyLogger);
|
||||
}
|
||||
catch (Exception ignore)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLoggerConfigurationFilename(String filename) throws IOException
|
||||
{
|
||||
FileInputStream stream = null;
|
||||
try
|
||||
{
|
||||
stream = new FileInputStream(filename);
|
||||
CentralLoggerConfig root = CentralLoggerConfig.load(stream);
|
||||
setConfiguredLoggerRoot(root);
|
||||
loggerConfigured = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IO.close(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void configure(WebAppContext context) throws Exception
|
||||
{
|
||||
context.addSystemClass("org.apache.log4j.");
|
||||
context.addSystemClass("org.slf4j.");
|
||||
context.addSystemClass("org.apache.commons.logging.");
|
||||
}
|
||||
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
public void preConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.Principal;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.MDC;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
|
||||
/**
|
||||
* Adds Logging specific MDC information about the incoming request information.
|
||||
*/
|
||||
public class ContextLogHandler extends HandlerWrapper
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
// Collect Info for NDC/MDC
|
||||
MDC.put("target",target);
|
||||
String contextPath = request.getContextPath();
|
||||
if (contextPath != null)
|
||||
{
|
||||
MDC.put("contextPath",contextPath);
|
||||
}
|
||||
MDC.put("remoteAddr",request.getRemoteAddr());
|
||||
String remoteUser = request.getRemoteUser();
|
||||
if (remoteUser != null)
|
||||
{
|
||||
MDC.put("remoteUser",remoteUser);
|
||||
}
|
||||
Principal principal = request.getUserPrincipal();
|
||||
if (principal != null)
|
||||
{
|
||||
MDC.put("principal",principal.getName());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
super.handle(target,baseRequest,request,response);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Pop info out / clear the NDC/MDC
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.jetty.logging.impl.Formatter;
|
||||
import org.eclipse.jetty.logging.impl.Severity;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
public class WebappContextLogFormatter implements Formatter
|
||||
{
|
||||
private String dateFormat = "yyyy-MM-dd HH:mm:ss.SSS";
|
||||
|
||||
public String format(Date date, Severity severity, String name, String message)
|
||||
{
|
||||
// Take the information out of the NDC/MDC and log it, along with the standard log message
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append(severity.name()).append(' ');
|
||||
buf.append(new SimpleDateFormat(dateFormat).format(date)).append(' ');
|
||||
buf.append('[').append(name).append("] ");
|
||||
|
||||
String target = MDC.get("target");
|
||||
String userAddr = MDC.get("remoteAddr");
|
||||
String userName = MDC.get("remoteUser");
|
||||
String principal = MDC.get("principal");
|
||||
String contextPath = MDC.get("contextPath");
|
||||
if ((target != null) || (contextPath != null) || (userAddr != null) || (userName != null) || (principal != null))
|
||||
{
|
||||
buf.append('[');
|
||||
// The user info
|
||||
if (principal != null)
|
||||
{
|
||||
buf.append(principal).append(':');
|
||||
}
|
||||
if (userName != null)
|
||||
{
|
||||
buf.append(userName).append(':');
|
||||
}
|
||||
if (userAddr != null)
|
||||
{
|
||||
buf.append(userAddr).append(':');
|
||||
}
|
||||
// The path requested
|
||||
if (contextPath != null)
|
||||
{
|
||||
buf.append(contextPath);
|
||||
}
|
||||
buf.append(target).append("] ");
|
||||
}
|
||||
|
||||
buf.append(message);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String getDateFormat()
|
||||
{
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat)
|
||||
{
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
target/
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
*.swp
|
||||
*.patch
|
||||
*.diff
|
||||
*.log
|
||||
cobertura.ser
|
|
@ -1,51 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>dummy-webapp-logging-commons</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<name>Jetty :: Centralized Logging :: Dummy Webapp for Commons Logging</name>
|
||||
<packaging>war</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging-api</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,65 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.tests.webapp;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Servlet implementation class LoggingServlet
|
||||
*/
|
||||
public class LoggingServlet extends HttpServlet
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String LOGID = "LoggingServlet(commons-logging)";
|
||||
private Log log = LogFactory.getLog(LoggingServlet.class);
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public LoggingServlet()
|
||||
{
|
||||
log.debug(LOGID + " initialized");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
|
||||
* response)
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
log.info(LOGID + " GET requested");
|
||||
|
||||
log.warn(LOGID + " Slightly warn, with a chance of log events");
|
||||
|
||||
log.error(LOGID + " Nothing is (intentionally) being output by this Servlet");
|
||||
|
||||
IOException severe = new FileNotFoundException("A file cannot be found");
|
||||
|
||||
log.fatal(LOGID + " Whoops (intentionally) causing a Throwable",severe);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
|
||||
<display-name>logging-commons-webapp</display-name>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.htm</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
<welcome-file>default.html</welcome-file>
|
||||
<welcome-file>default.htm</welcome-file>
|
||||
<welcome-file>default.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
<servlet>
|
||||
<description></description>
|
||||
<display-name>LoggingServlet</display-name>
|
||||
<servlet-name>LoggingServlet</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.tests.webapp.LoggingServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>LoggingServlet</servlet-name>
|
||||
<url-pattern>/logging</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
|
@ -1,9 +0,0 @@
|
|||
target/
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
*.swp
|
||||
*.patch
|
||||
*.diff
|
||||
*.log
|
||||
cobertura.ser
|
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>dummy-webapp-logging-java</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<name>Jetty :: Centralized Logging :: Dummy Webapp for Java Util Logging</name>
|
||||
<packaging>war</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,63 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.tests.webapp;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class LoggingServlet
|
||||
*/
|
||||
public class LoggingServlet extends HttpServlet
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String LOGID = "LoggingServlet(java)";
|
||||
private Logger log = Logger.getLogger(LoggingServlet.class.getName());
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public LoggingServlet()
|
||||
{
|
||||
log.log(Level.FINE,LOGID + " initialized");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
log.log(Level.INFO,LOGID + " GET requested");
|
||||
|
||||
log.log(Level.WARNING,LOGID + " Slightly warn, with a chance of log events");
|
||||
|
||||
log.log(Level.WARNING,LOGID + " Nothing is (intentionally) being output by this Servlet");
|
||||
|
||||
IOException severe = new FileNotFoundException("A file cannot be found");
|
||||
|
||||
log.log(Level.SEVERE,LOGID + " Whoops (intentionally) causing a Throwable",severe);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
|
||||
<display-name>logging-java-webapp</display-name>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.htm</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
<welcome-file>default.html</welcome-file>
|
||||
<welcome-file>default.htm</welcome-file>
|
||||
<welcome-file>default.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
<servlet>
|
||||
<description></description>
|
||||
<display-name>LoggingServlet</display-name>
|
||||
<servlet-name>LoggingServlet</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.tests.webapp.LoggingServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>LoggingServlet</servlet-name>
|
||||
<url-pattern>/logging</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
|
@ -1,9 +0,0 @@
|
|||
target/
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
*.swp
|
||||
*.patch
|
||||
*.diff
|
||||
*.log
|
||||
cobertura.ser
|
|
@ -1,69 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>dummy-webapp-logging-log4j</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<name>Jetty :: Centralized Logging :: Dummy Webapp for Log4J Logging</name>
|
||||
<packaging>war</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.15</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.jms</groupId>
|
||||
<artifactId>jms</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jdmk</groupId>
|
||||
<artifactId>jmxtools</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jmx</groupId>
|
||||
<artifactId>jmxri</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,62 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.tests.webapp;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Servlet implementation class LoggingServlet
|
||||
*/
|
||||
public class LoggingServlet extends HttpServlet
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String LOGID = "LoggingServlet(log4j)";
|
||||
private Logger log = Logger.getLogger(LoggingServlet.class);
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public LoggingServlet()
|
||||
{
|
||||
log.debug(LOGID + " initialized");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
|
||||
* response)
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
log.info(LOGID + " GET requested");
|
||||
|
||||
log.warn(LOGID + " Slightly warn, with a chance of log events");
|
||||
|
||||
log.error(LOGID + " Nothing is (intentionally) being output by this Servlet");
|
||||
|
||||
IOException severe = new FileNotFoundException("A file cannot be found");
|
||||
|
||||
log.fatal(LOGID + " Whoops (intentionally) causing a Throwable",severe);
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
|
||||
<display-name>logging-log4j-webapp</display-name>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.htm</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
<welcome-file>default.html</welcome-file>
|
||||
<welcome-file>default.htm</welcome-file>
|
||||
<welcome-file>default.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
<servlet>
|
||||
<description></description>
|
||||
<display-name>LoggingServlet</display-name>
|
||||
<servlet-name>LoggingServlet</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.tests.webapp.LoggingServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>LoggingServlet</servlet-name>
|
||||
<url-pattern>/logging</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
|
@ -1,9 +0,0 @@
|
|||
target/
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
*.swp
|
||||
*.patch
|
||||
*.diff
|
||||
*.log
|
||||
cobertura.ser
|
|
@ -1,51 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>dummy-webapp-logging-slf4j</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
<name>Jetty :: Centralized Logging :: Dummy Webapp for Slf4J Logging</name>
|
||||
<packaging>war</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.5.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,64 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.tests.webapp;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Servlet implementation class LoggingServlet
|
||||
*/
|
||||
public class LoggingServlet extends HttpServlet
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String LOGID = "LoggingServlet(slf4j)";
|
||||
private Logger log = LoggerFactory.getLogger(LoggingServlet.class);
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public LoggingServlet()
|
||||
{
|
||||
log.debug(LOGID + " initialized");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
|
||||
* response)
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
log.info(LOGID + " GET requested");
|
||||
|
||||
log.warn(LOGID + " Slightly warn, with a chance of log events");
|
||||
|
||||
log.error(LOGID + " Nothing is (intentionally) being output by this Servlet");
|
||||
|
||||
IOException severe = new FileNotFoundException("A file cannot be found");
|
||||
|
||||
log.error(LOGID + " Whoops (intentionally) causing a Throwable",severe);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
|
||||
<display-name>logging-slf4j-webapp</display-name>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.htm</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
<welcome-file>default.html</welcome-file>
|
||||
<welcome-file>default.htm</welcome-file>
|
||||
<welcome-file>default.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
<servlet>
|
||||
<description></description>
|
||||
<display-name>LoggingServlet</display-name>
|
||||
<servlet-name>LoggingServlet</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.tests.webapp.LoggingServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>LoggingServlet</servlet-name>
|
||||
<url-pattern>/logging</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
//
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-project</artifactId>
|
||||
<version>7.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
<artifactId>centralized-logging-test-artifacts-parent</artifactId>
|
||||
<name>Jetty :: Centralized Logging :: Dummy Webapps Parent</name>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>dummy-webapp-logging-commons</module>
|
||||
<module>dummy-webapp-logging-log4j</module>
|
||||
<module>dummy-webapp-logging-java</module>
|
||||
<module>dummy-webapp-logging-slf4j</module>
|
||||
</modules>
|
||||
</project>
|
|
@ -1,113 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.logging.impl.CentralLoggerConfig;
|
||||
import org.eclipse.jetty.logging.impl.Severity;
|
||||
import org.eclipse.jetty.webapp.logging.TestAppender.LogEvent;
|
||||
|
||||
public class CentralizedLoggingTest extends TestCase
|
||||
{
|
||||
private static final String LOGGING_SERVLET_ID = "org.eclipse.jetty.tests.webapp.LoggingServlet";
|
||||
private XmlConfiguredJetty jetty;
|
||||
|
||||
private void assertContainsLogEvents(TestAppender capturedEvents, List<LogEvent> expectedLogs)
|
||||
{
|
||||
for (LogEvent expectedEvent : expectedLogs)
|
||||
{
|
||||
if (!capturedEvents.contains(expectedEvent))
|
||||
{
|
||||
capturedEvents.dump();
|
||||
fail("LogEvent not found: " + expectedEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
jetty = new XmlConfiguredJetty(this);
|
||||
jetty.addConfiguration("jetty.xml");
|
||||
jetty.addConfiguration("jetty-webapp-logging.xml");
|
||||
|
||||
jetty.load();
|
||||
|
||||
jetty.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
jetty.stop();
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testAllRouting() throws IOException
|
||||
{
|
||||
CentralLoggerConfig root = CentralizedWebAppLoggingConfiguration.getLoggerRoot();
|
||||
TestAppender testAppender = (TestAppender)root.findAppender(TestAppender.class);
|
||||
assertNotNull("Should have found TestAppender in configuration",testAppender);
|
||||
|
||||
SimpleRequest.get(jetty,"/dummy-webapp-logging-log4j/logging");
|
||||
SimpleRequest.get(jetty,"/dummy-webapp-logging-commons/logging");
|
||||
SimpleRequest.get(jetty,"/dummy-webapp-logging-slf4j/logging");
|
||||
SimpleRequest.get(jetty,"/dummy-webapp-logging-java/logging");
|
||||
|
||||
String prefix = "LoggingServlet(commons-logging)";
|
||||
List<LogEvent> expectedLogs = new ArrayList<LogEvent>();
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
prefix = "LoggingServlet(log4j)";
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
prefix = "LoggingServlet(java)";
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
prefix = "LoggingServlet(slf4j)";
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
|
||||
assertContainsLogEvents(testAppender,expectedLogs);
|
||||
|
||||
assertContainsLogEvents(testAppender,expectedLogs);
|
||||
}
|
||||
}
|
|
@ -1,272 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.logging.impl.CentralLoggerConfig;
|
||||
import org.eclipse.jetty.logging.impl.Severity;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.webapp.logging.TestAppender.LogEvent;
|
||||
|
||||
/**
|
||||
* Test centralized logging in an embedded scenario
|
||||
*/
|
||||
public class EmbeddedCentralizedLoggingTest extends TestCase
|
||||
{
|
||||
private static final String LOGGING_SERVLET_ID = "org.eclipse.jetty.tests.webapp.LoggingServlet";
|
||||
private TestAppender testAppender;
|
||||
|
||||
private void assertContainsLogEvents(TestAppender capturedEvents, List<LogEvent> expectedLogs)
|
||||
{
|
||||
for (LogEvent expectedEvent : expectedLogs)
|
||||
{
|
||||
if (!capturedEvents.contains(expectedEvent))
|
||||
{
|
||||
capturedEvents.dump();
|
||||
fail("LogEvent not found: " + expectedEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Handler createWebapp(String contextPath, String webappName)
|
||||
{
|
||||
File webappFile = MavenTestingUtils.getTestResourceFile("webapps/" + webappName);
|
||||
|
||||
WebAppContext webapp = new WebAppContext();
|
||||
webapp.setContextPath(contextPath);
|
||||
webapp.setWar(webappFile.getAbsolutePath());
|
||||
|
||||
return webapp;
|
||||
}
|
||||
|
||||
protected Server createWebAppServer(String contextPath, String webappName) throws Exception
|
||||
{
|
||||
if (!CentralizedWebAppLoggingConfiguration.isLoggerConfigured())
|
||||
{
|
||||
String loggerConfigFilename = MavenTestingUtils.getTestResourceFile("logger/testing.properties").getAbsolutePath();
|
||||
CentralizedWebAppLoggingConfiguration.setLoggerConfigurationFilename(loggerConfigFilename);
|
||||
}
|
||||
|
||||
CentralLoggerConfig root = CentralizedWebAppLoggingConfiguration.getLoggerRoot();
|
||||
testAppender = (TestAppender)root.findAppender(TestAppender.class);
|
||||
testAppender.reset();
|
||||
|
||||
Server server = new Server();
|
||||
List<Configuration> serverConfigs = new ArrayList<Configuration>();
|
||||
serverConfigs.add(new CentralizedWebAppLoggingConfiguration());
|
||||
server.setAttribute(WebAppContext.SERVER_CONFIG,serverConfigs);
|
||||
|
||||
Connector connector = new SelectChannelConnector();
|
||||
connector.setPort(0);
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
||||
File webappFile = MavenTestingUtils.getTestResourceFile("webapps/" + webappName);
|
||||
|
||||
WebAppContext webapp = new WebAppContext();
|
||||
webapp.setContextPath(contextPath);
|
||||
webapp.setWar(webappFile.getAbsolutePath());
|
||||
|
||||
server.setHandler(webapp);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
File testTmpDir = new File(MavenTestingUtils.getTargetTestingDir(this),"workdir");
|
||||
testTmpDir.mkdirs();
|
||||
System.setProperty("java.io.tmpdir",testTmpDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
public void testEmbeddedAll() throws Exception
|
||||
{
|
||||
if (!CentralizedWebAppLoggingConfiguration.isLoggerConfigured())
|
||||
{
|
||||
String loggerConfigFilename = MavenTestingUtils.getTestResourceFile("logger/testing.properties").getAbsolutePath();
|
||||
CentralizedWebAppLoggingConfiguration.setLoggerConfigurationFilename(loggerConfigFilename);
|
||||
}
|
||||
|
||||
CentralLoggerConfig root = CentralizedWebAppLoggingConfiguration.getLoggerRoot();
|
||||
testAppender = (TestAppender)root.findAppender(TestAppender.class);
|
||||
testAppender.reset();
|
||||
|
||||
Server server = new Server();
|
||||
List<Configuration> serverConfigs = new ArrayList<Configuration>();
|
||||
serverConfigs.add(new CentralizedWebAppLoggingConfiguration());
|
||||
server.setAttribute(WebAppContext.SERVER_CONFIG,serverConfigs);
|
||||
|
||||
Connector connector = new SelectChannelConnector();
|
||||
connector.setPort(0);
|
||||
server.setConnectors(new Connector[]
|
||||
{ connector });
|
||||
|
||||
ContextHandlerCollection handlers = new ContextHandlerCollection();
|
||||
handlers.addHandler(createWebapp("/log4j","dummy-webapp-logging-log4j.war"));
|
||||
handlers.addHandler(createWebapp("/slf4j","dummy-webapp-logging-slf4j.war"));
|
||||
handlers.addHandler(createWebapp("/clogging","dummy-webapp-logging-commons.war"));
|
||||
handlers.addHandler(createWebapp("/javalogging","dummy-webapp-logging-java.war"));
|
||||
|
||||
ContextLogHandler loghandler = new ContextLogHandler();
|
||||
loghandler.setHandler(handlers);
|
||||
|
||||
server.setHandler(loghandler);
|
||||
|
||||
server.start();
|
||||
|
||||
SimpleRequest.get(server,"/log4j/logging");
|
||||
SimpleRequest.get(server,"/slf4j/logging");
|
||||
SimpleRequest.get(server,"/clogging/logging");
|
||||
SimpleRequest.get(server,"/javalogging/logging");
|
||||
|
||||
server.stop();
|
||||
|
||||
String prefix = "LoggingServlet(commons-logging)";
|
||||
List<LogEvent> expectedLogs = new ArrayList<LogEvent>();
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
prefix = "LoggingServlet(log4j)";
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
prefix = "LoggingServlet(java)";
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
prefix = "LoggingServlet(slf4j)";
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
|
||||
assertContainsLogEvents(testAppender,expectedLogs);
|
||||
}
|
||||
|
||||
public void testEmbeddedWebappCommonsLogging() throws Exception
|
||||
{
|
||||
Server server = createWebAppServer("/clogging","dummy-webapp-logging-commons.war");
|
||||
|
||||
server.start();
|
||||
|
||||
SimpleRequest.get(server,"/clogging/logging");
|
||||
|
||||
server.stop();
|
||||
|
||||
String prefix = "LoggingServlet(commons-logging)";
|
||||
List<LogEvent> expectedLogs = new ArrayList<LogEvent>();
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
|
||||
assertContainsLogEvents(testAppender,expectedLogs);
|
||||
}
|
||||
|
||||
public void testEmbeddedWebappJavaUtil() throws Exception
|
||||
{
|
||||
Server server = createWebAppServer("/javalogging","dummy-webapp-logging-java.war");
|
||||
|
||||
server.start();
|
||||
|
||||
SimpleRequest.get(server,"/javalogging/logging");
|
||||
|
||||
server.stop();
|
||||
|
||||
String prefix = "LoggingServlet(java)";
|
||||
List<LogEvent> expectedLogs = new ArrayList<LogEvent>();
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
|
||||
assertContainsLogEvents(testAppender,expectedLogs);
|
||||
}
|
||||
|
||||
public void testEmbeddedWebappLog4j() throws Exception
|
||||
{
|
||||
Server server = createWebAppServer("/log4j","dummy-webapp-logging-log4j.war");
|
||||
|
||||
server.start();
|
||||
|
||||
SimpleRequest.get(server,"/log4j/logging");
|
||||
|
||||
server.stop();
|
||||
|
||||
String prefix = "LoggingServlet(log4j)";
|
||||
List<LogEvent> expectedLogs = new ArrayList<LogEvent>();
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
|
||||
assertContainsLogEvents(testAppender,expectedLogs);
|
||||
}
|
||||
|
||||
public void testEmbeddedWebappSlf4j() throws Exception
|
||||
{
|
||||
Server server = createWebAppServer("/slf4j","dummy-webapp-logging-slf4j.war");
|
||||
|
||||
server.start();
|
||||
|
||||
SimpleRequest.get(server,"/slf4j/logging");
|
||||
|
||||
server.stop();
|
||||
|
||||
String prefix = "LoggingServlet(slf4j)";
|
||||
List<LogEvent> expectedLogs = new ArrayList<LogEvent>();
|
||||
// expectedLogs.add(new LogEvent(Severity.DEBUG,LOGGING_SERVLET_ID,prefix + " initialized"));
|
||||
expectedLogs.add(new LogEvent(Severity.INFO,LOGGING_SERVLET_ID,prefix + " GET requested"));
|
||||
expectedLogs.add(new LogEvent(Severity.WARN,LOGGING_SERVLET_ID,prefix + " Slightly warn, with a chance of log events"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Nothing is (intentionally) being output by this Servlet"));
|
||||
expectedLogs.add(new LogEvent(Severity.ERROR,LOGGING_SERVLET_ID,prefix + " Whoops (intentionally) causing a Throwable")
|
||||
.expectedThrowable(new FileNotFoundException("A file cannot be found")));
|
||||
|
||||
assertContainsLogEvents(testAppender,expectedLogs);
|
||||
}
|
||||
}
|
|
@ -1,200 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
||||
/**
|
||||
* Common utility methods for working with JUnit tests cases in a maven friendly way.
|
||||
*/
|
||||
public class MavenTestingUtils
|
||||
{
|
||||
private static File basedir;
|
||||
private static File testResourcesDir;
|
||||
private static File targetDir;
|
||||
|
||||
// private static Boolean surefireRunning;
|
||||
|
||||
public static File getBasedir()
|
||||
{
|
||||
if (basedir == null)
|
||||
{
|
||||
String cwd = System.getProperty("basedir");
|
||||
|
||||
if (cwd == null)
|
||||
{
|
||||
cwd = System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
basedir = new File(cwd);
|
||||
}
|
||||
|
||||
return basedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the /target directory for this project.
|
||||
*
|
||||
* @return the directory path to the target directory.
|
||||
*/
|
||||
public static File getTargetDir()
|
||||
{
|
||||
if (targetDir == null)
|
||||
{
|
||||
targetDir = new File(basedir,"target");
|
||||
PathAssert.assertDirExists("Target Dir",targetDir);
|
||||
}
|
||||
return targetDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link File} object for a path in the /target directory.
|
||||
*
|
||||
* @param path
|
||||
* the path desired, no validation of existence is performed.
|
||||
* @return the File to the path.
|
||||
*/
|
||||
public static File getTargetFile(String path)
|
||||
{
|
||||
return new File(getTargetDir(),path.replace("/",File.separator));
|
||||
}
|
||||
|
||||
public static File getTargetTestingDir()
|
||||
{
|
||||
File dir = new File(getTargetDir(),"testing");
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkdirs();
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
public static File getTargetTestingDir(TestCase test)
|
||||
{
|
||||
File dir = new File(getTargetDir(),"test-" + test.getName());
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkdirs();
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a dir from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a dir)
|
||||
* @return the dir in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceDir(String name)
|
||||
{
|
||||
File dir = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertDirExists("Test Resource Dir",dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist as a file)
|
||||
* @return the file in src/test/resource
|
||||
*/
|
||||
public static File getTestResourceFile(String name)
|
||||
{
|
||||
File file = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertFileExists("Test Resource File",file);
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a path resource (File or Dir) from the src/test/resource directory.
|
||||
*
|
||||
* @param name
|
||||
* the name of the path to get (it must exist)
|
||||
* @return the path in src/test/resource
|
||||
*/
|
||||
public static File getTestResourcePath(String name)
|
||||
{
|
||||
File path = new File(getTestResourcesDir(),name);
|
||||
PathAssert.assertExists("Test Resource Path",path);
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory to the src/test/resource directory
|
||||
*
|
||||
* @return the directory {@link File} to the src/test/resources directory
|
||||
*/
|
||||
public static File getTestResourcesDir()
|
||||
{
|
||||
if (testResourcesDir == null)
|
||||
{
|
||||
testResourcesDir = new File(basedir,"src/test/resources".replace("/",File.separator));
|
||||
PathAssert.assertDirExists("Test Resources Dir",testResourcesDir);
|
||||
}
|
||||
return testResourcesDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the contents of a file into a String and return it.
|
||||
*
|
||||
* @param file
|
||||
* the file to read.
|
||||
* @return the contents of the file.
|
||||
* @throws IOException
|
||||
* if unable to read the file.
|
||||
*/
|
||||
public static String readToString(File file) throws IOException
|
||||
{
|
||||
FileReader reader = null;
|
||||
try
|
||||
{
|
||||
reader = new FileReader(file);
|
||||
return IO.toString(reader);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IO.close(reader);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static boolean isSurefireExecuting()
|
||||
{
|
||||
if (surefireRunning == null)
|
||||
{
|
||||
String val = System.getProperty("surefire.test.class.path");
|
||||
if (val != null)
|
||||
{
|
||||
surefireRunning = Boolean.TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
surefireRunning = Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return surefireRunning;
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class PathAssert
|
||||
{
|
||||
public static void assertDirExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a Dir : " + path.getAbsolutePath(),path.isDirectory());
|
||||
}
|
||||
|
||||
public static void assertFileExists(String msg, File path)
|
||||
{
|
||||
assertExists(msg,path);
|
||||
Assert.assertTrue(msg + " path should be a File : " + path.getAbsolutePath(),path.isFile());
|
||||
}
|
||||
|
||||
public static void assertExists(String msg, File path)
|
||||
{
|
||||
Assert.assertTrue(msg + " path should exist: " + path.getAbsolutePath(),path.exists());
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
||||
/**
|
||||
* Utility class for performing simple requests.
|
||||
*/
|
||||
public class SimpleRequest
|
||||
{
|
||||
private static final boolean CONN_TRACE = false;
|
||||
|
||||
/**
|
||||
* Issue an HTTP GET to the server, on the path specified.
|
||||
*
|
||||
* @param jetty
|
||||
* @param path
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String get(XmlConfiguredJetty jetty, String path) throws IOException
|
||||
{
|
||||
URI fullUri = jetty.getServerURI().resolve(path);
|
||||
return get(fullUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue an HTTP GET to the server, on the path specified.
|
||||
*
|
||||
* @param jetty
|
||||
* @param path
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String get(Server server, String path) throws IOException
|
||||
{
|
||||
// Find the active server port.
|
||||
int serverPort = (-1);
|
||||
Connector connectors[] = server.getConnectors();
|
||||
for (int i = 0; i < connectors.length; i++)
|
||||
{
|
||||
Connector connector = connectors[i];
|
||||
if (connector.getLocalPort() > 0)
|
||||
{
|
||||
serverPort = connector.getLocalPort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuffer uri = new StringBuffer();
|
||||
uri.append("http://");
|
||||
uri.append(InetAddress.getLocalHost().getHostAddress());
|
||||
uri.append(":").append(serverPort);
|
||||
|
||||
URI fullUri = URI.create(uri.toString()).resolve(path);
|
||||
return get(fullUri);
|
||||
}
|
||||
|
||||
private static String get(URI fullUri) throws IOException
|
||||
{
|
||||
System.out.println("GET: " + fullUri.toASCIIString());
|
||||
|
||||
trace("Opening Connection ...");
|
||||
HttpURLConnection conn = (HttpURLConnection)fullUri.toURL().openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setUseCaches(false);
|
||||
conn.setAllowUserInteraction(false);
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.setReadTimeout(5000);
|
||||
|
||||
trace("Connecting ...");
|
||||
conn.connect();
|
||||
trace("Connected.");
|
||||
|
||||
InputStream in = null;
|
||||
InputStreamReader reader = null;
|
||||
try
|
||||
{
|
||||
trace("Getting InputStream ...");
|
||||
in = conn.getInputStream();
|
||||
trace("Got InputStream.");
|
||||
reader = new InputStreamReader(in);
|
||||
|
||||
trace("Reading InputStream to String ...");
|
||||
String response = IO.toString(reader);
|
||||
|
||||
trace("Checking Response Code ...");
|
||||
if (conn.getResponseCode() != 200)
|
||||
{
|
||||
System.out.printf("Got HTTP Response %d, expecting %d.%n",conn.getResponseCode(),200);
|
||||
System.out.println(response);
|
||||
}
|
||||
else if ((response != null) && (response.trim().length() > 0))
|
||||
{
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
trace("Returning response.");
|
||||
return response;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IO.close(reader);
|
||||
IO.close(in);
|
||||
}
|
||||
}
|
||||
|
||||
private static void trace(String format, Object... args)
|
||||
{
|
||||
if (CONN_TRACE)
|
||||
{
|
||||
System.out.printf(format,args);
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,282 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.eclipse.jetty.logging.impl.Appender;
|
||||
import org.eclipse.jetty.logging.impl.Formatter;
|
||||
import org.eclipse.jetty.logging.impl.Severity;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
/**
|
||||
* Test Appender, records the logging events.
|
||||
*/
|
||||
public class TestAppender implements Appender
|
||||
{
|
||||
public static class LogEvent
|
||||
{
|
||||
Date date;
|
||||
Severity severity;
|
||||
String name;
|
||||
String message;
|
||||
Throwable t;
|
||||
String mdc;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public LogEvent(Date date, Severity severity, String name, String message, Throwable t)
|
||||
{
|
||||
super();
|
||||
this.date = date;
|
||||
this.severity = severity;
|
||||
this.name = name;
|
||||
this.message = message;
|
||||
this.t = t;
|
||||
this.mdc = "";
|
||||
|
||||
Map<String, String> mdcMap = MDC.getCopyOfContextMap();
|
||||
if (mdcMap != null)
|
||||
{
|
||||
Set<String> keys = new TreeSet<String>();
|
||||
keys.addAll(mdcMap.keySet());
|
||||
boolean delim = false;
|
||||
for (String key : keys)
|
||||
{
|
||||
if (delim)
|
||||
{
|
||||
mdc += ", ";
|
||||
}
|
||||
mdc += key + "=" + mdcMap.get(key);
|
||||
delim = true;
|
||||
}
|
||||
if (mdc.length() > 0)
|
||||
{
|
||||
System.out.println("mdc: " + mdc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LogEvent(Severity severity, String name, String message)
|
||||
{
|
||||
this(null,severity,name,message,null);
|
||||
}
|
||||
|
||||
public LogEvent expectedThrowable(Throwable t)
|
||||
{
|
||||
this.t = t;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((message == null)?0:message.hashCode());
|
||||
result = prime * result + ((name == null)?0:name.hashCode());
|
||||
result = prime * result + ((severity == null)?0:severity.hashCode());
|
||||
if (t != null)
|
||||
{
|
||||
result = prime * result + t.getClass().hashCode();
|
||||
if (t.getMessage() != null)
|
||||
{
|
||||
result = prime * result + t.getMessage().hashCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = prime * result + 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = prime * result + 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
LogEvent other = (LogEvent)obj;
|
||||
if (message == null)
|
||||
{
|
||||
if (other.message != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!message.equals(other.message))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (name == null)
|
||||
{
|
||||
if (other.name != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!name.equals(other.name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (severity == null)
|
||||
{
|
||||
if (other.severity != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!severity.equals(other.severity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Throwable
|
||||
if (t == null)
|
||||
{
|
||||
if (other.t != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!t.getClass().equals(other.t.getClass()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (t.getMessage() == null)
|
||||
{
|
||||
if (other.t.getMessage() != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!t.getMessage().equals(other.t.getMessage()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(severity.name()).append("|");
|
||||
buf.append(name).append("|");
|
||||
buf.append(message);
|
||||
if (t != null)
|
||||
{
|
||||
buf.append("|").append(t.getClass().getName());
|
||||
buf.append("(\"").append(t.getMessage()).append("\")");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private List<LogEvent> events = new ArrayList<LogEvent>();
|
||||
private String id;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void append(Date date, Severity severity, String name, String message, Throwable t)
|
||||
{
|
||||
if (name.equals("org.eclipse.jetty.util.log")) // standard jetty logger
|
||||
{
|
||||
if (t != null)
|
||||
{
|
||||
// Still interested in seeing throwables (HACK)
|
||||
t.printStackTrace(System.err);
|
||||
}
|
||||
return; // skip storing it.
|
||||
}
|
||||
events.add(new LogEvent(date,severity,name,message,t));
|
||||
}
|
||||
|
||||
public void close() throws IOException
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
public boolean contains(LogEvent expectedEvent)
|
||||
{
|
||||
return events.contains(expectedEvent);
|
||||
}
|
||||
|
||||
public List<LogEvent> getEvents()
|
||||
{
|
||||
return events;
|
||||
}
|
||||
|
||||
public void open() throws IOException
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
events.clear();
|
||||
}
|
||||
|
||||
public void setProperty(String key, String value) throws Exception
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
public void dump()
|
||||
{
|
||||
System.out.printf("Captured %s event(s)%n",events.size());
|
||||
for (LogEvent event : events)
|
||||
{
|
||||
System.out.println(event);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFormatter(Formatter formatter)
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
}
|
|
@ -1,210 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) Webtide LLC
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.webapp.logging;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.http.HttpSchemes;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
/**
|
||||
* Allows for setting up a Jetty server for testing based on XML configuration files.
|
||||
*/
|
||||
public class XmlConfiguredJetty
|
||||
{
|
||||
private List<URL> xmlConfigurations;
|
||||
private Properties properties = new Properties();
|
||||
private Server server;
|
||||
private int serverPort;
|
||||
private String scheme = HttpSchemes.HTTP;
|
||||
|
||||
public XmlConfiguredJetty(TestCase test) throws IOException
|
||||
{
|
||||
xmlConfigurations = new ArrayList<URL>();
|
||||
properties = new Properties();
|
||||
|
||||
File jettyHome = MavenTestingUtils.getTargetTestingDir(test);
|
||||
// Prepare Jetty.Home (Test) dir
|
||||
jettyHome.mkdirs();
|
||||
|
||||
File logsDir = new File(jettyHome,"logs");
|
||||
logsDir.mkdirs();
|
||||
|
||||
File etcDir = new File(jettyHome,"etc");
|
||||
etcDir.mkdirs();
|
||||
IO.copyFile(MavenTestingUtils.getTestResourceFile("etc/realm.properties"),new File(etcDir,"realm.properties"));
|
||||
|
||||
File webappsDir = new File(jettyHome,"webapps");
|
||||
webappsDir.mkdirs();
|
||||
File tmpDir = new File(MavenTestingUtils.getTargetTestingDir(test),"tmp");
|
||||
tmpDir.mkdirs();
|
||||
|
||||
// Setup properties
|
||||
System.setProperty("java.io.tmpdir",tmpDir.getAbsolutePath());
|
||||
properties.setProperty("jetty.home",jettyHome.getAbsolutePath());
|
||||
System.setProperty("jetty.home",jettyHome.getAbsolutePath());
|
||||
properties.setProperty("test.basedir",MavenTestingUtils.getBasedir().getAbsolutePath());
|
||||
properties.setProperty("test.resourcesdir",MavenTestingUtils.getTestResourcesDir().getAbsolutePath());
|
||||
properties.setProperty("test.webapps",MavenTestingUtils.getTestResourceDir("webapps").getAbsolutePath());
|
||||
properties.setProperty("test.targetdir",MavenTestingUtils.getTargetDir().getAbsolutePath());
|
||||
|
||||
// Write out configuration for use by ConfigurationManager.
|
||||
File testConfig = MavenTestingUtils.getTargetFile("xml-configured-jetty.properties");
|
||||
FileOutputStream out = new FileOutputStream(testConfig);
|
||||
properties.store(out,"Generated by " + XmlConfiguredJetty.class.getName());
|
||||
}
|
||||
|
||||
public void addConfiguration(URL xmlConfig)
|
||||
{
|
||||
xmlConfigurations.add(xmlConfig);
|
||||
}
|
||||
|
||||
public void addConfiguration(File xmlConfigFile) throws MalformedURLException
|
||||
{
|
||||
xmlConfigurations.add(xmlConfigFile.toURI().toURL());
|
||||
}
|
||||
|
||||
public void addConfiguration(String testConfigName) throws MalformedURLException
|
||||
{
|
||||
addConfiguration(MavenTestingUtils.getTestResourceFile(testConfigName));
|
||||
}
|
||||
|
||||
public void setProperty(String key, String value)
|
||||
{
|
||||
properties.setProperty(key,value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load() throws Exception
|
||||
{
|
||||
XmlConfiguration last = null;
|
||||
Object[] obj = new Object[this.xmlConfigurations.size()];
|
||||
|
||||
// Configure everything
|
||||
for (int i = 0; i < this.xmlConfigurations.size(); i++)
|
||||
{
|
||||
URL configURL = this.xmlConfigurations.get(i);
|
||||
XmlConfiguration configuration = new XmlConfiguration(configURL);
|
||||
if (last != null)
|
||||
{
|
||||
configuration.getIdMap().putAll(last.getIdMap());
|
||||
}
|
||||
configuration.setProperties(properties);
|
||||
obj[i] = configuration.configure();
|
||||
last = configuration;
|
||||
}
|
||||
|
||||
// Test for Server Instance.
|
||||
Server foundServer = null;
|
||||
int serverCount = 0;
|
||||
for (int i = 0; i < this.xmlConfigurations.size(); i++)
|
||||
{
|
||||
if (obj[i] instanceof Server)
|
||||
{
|
||||
if (obj[i].equals(foundServer))
|
||||
{
|
||||
// Identical server instance found
|
||||
break;
|
||||
}
|
||||
foundServer = (Server)obj[i];
|
||||
serverCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (serverCount <= 0)
|
||||
{
|
||||
throw new Exception("Load failed to configure a " + Server.class.getName());
|
||||
}
|
||||
|
||||
Assert.assertEquals("Server load count",1,serverCount);
|
||||
|
||||
this.server = foundServer;
|
||||
this.server.setGracefulShutdown(10);
|
||||
|
||||
}
|
||||
|
||||
public String getScheme()
|
||||
{
|
||||
return scheme;
|
||||
}
|
||||
|
||||
public void setScheme(String scheme)
|
||||
{
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
public void start() throws Exception
|
||||
{
|
||||
Assert.assertNotNull("Server should not be null (failed load?)",server);
|
||||
|
||||
server.start();
|
||||
|
||||
// Find the active server port.
|
||||
this.serverPort = (-1);
|
||||
Connector connectors[] = server.getConnectors();
|
||||
for (int i = 0; i < connectors.length; i++)
|
||||
{
|
||||
Connector connector = connectors[i];
|
||||
if (connector.getLocalPort() > 0)
|
||||
{
|
||||
this.serverPort = connector.getLocalPort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue("Server Port is between 1 and 65535. Actually <" + serverPort + ">",(1 <= this.serverPort) && (this.serverPort <= 65535));
|
||||
|
||||
// Uncomment to have server start and continue to run (without exiting)
|
||||
// System.out.printf("Listening to port %d%n",this.serverPort);
|
||||
// server.join();
|
||||
}
|
||||
|
||||
public int getServerPort()
|
||||
{
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
public void stop() throws Exception
|
||||
{
|
||||
server.stop();
|
||||
}
|
||||
|
||||
public URI getServerURI() throws UnknownHostException
|
||||
{
|
||||
StringBuffer uri = new StringBuffer();
|
||||
uri.append(this.scheme).append("://");
|
||||
uri.append(InetAddress.getLocalHost().getHostAddress());
|
||||
uri.append(":").append(this.serverPort);
|
||||
return URI.create(uri.toString());
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">/commons</Set>
|
||||
<Set name="war">
|
||||
<Property name="test.webapps" default="." />/dummy-webapp-logging-commons.war
|
||||
</Set>
|
||||
</Configure>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">/java</Set>
|
||||
<Set name="war">
|
||||
<Property name="test.webapps" default="." />/dummy-webapp-logging-java.war
|
||||
</Set>
|
||||
</Configure>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">/log4j</Set>
|
||||
<Set name="war">
|
||||
<Property name="test.webapps" default="." />/dummy-webapp-logging-log4j.war
|
||||
</Set>
|
||||
</Configure>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Set name="contextPath">/slf4j</Set>
|
||||
<Set name="war">
|
||||
<Property name="test.webapps" default="." />/dummy-webapp-logging-slf4j.war
|
||||
</Set>
|
||||
</Configure>
|
|
@ -1,21 +0,0 @@
|
|||
#
|
||||
# This file defines users passwords and roles for a HashUserRealm
|
||||
#
|
||||
# The format is
|
||||
# <username>: <password>[,<rolename> ...]
|
||||
#
|
||||
# Passwords may be clear text, obfuscated or checksummed. The class
|
||||
# org.eclipse.util.Password should be used to generate obfuscated
|
||||
# passwords or password checksums
|
||||
#
|
||||
# If DIGEST Authentication is used, the password must be in a recoverable
|
||||
# format, either plain text or OBF:.
|
||||
#
|
||||
jetty: MD5:164c88b302622e17050af52c89945d44,user
|
||||
admin: CRYPT:adpexzg3FUZAk,server-administrator,content-administrator,admin
|
||||
other: OBF:1xmk1w261u9r1w1c1xmq,user
|
||||
plain: plain,user
|
||||
user: password,user
|
||||
|
||||
# This entry is for digest auth. The credential is a MD5 hash of username:realmname:password
|
||||
digest: MD5:6e120743ad67abfbc385bc2bb754e297,user
|
|
@ -1,404 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<!-- ===================================================================== -->
|
||||
<!-- This file contains the default descriptor for web applications. -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- The intent of this descriptor is to include jetty specific or common -->
|
||||
<!-- configuration for all webapps. If a context has a webdefault.xml -->
|
||||
<!-- descriptor, it is applied before the contexts own web.xml file -->
|
||||
<!-- -->
|
||||
<!-- A context may be assigned a default descriptor by: -->
|
||||
<!-- + Calling WebApplicationContext.setDefaultsDescriptor -->
|
||||
<!-- + Passed an arg to addWebApplications -->
|
||||
<!-- -->
|
||||
<!-- This file is used both as the resource within the jetty.jar (which is -->
|
||||
<!-- used as the default if no explicit defaults descriptor is set) and it -->
|
||||
<!-- is copied to the etc directory of the Jetty distro and explicitly -->
|
||||
<!-- by the jetty.xml file. -->
|
||||
<!-- -->
|
||||
<!-- ===================================================================== -->
|
||||
<web-app
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
metadata-complete="true"
|
||||
version="2.5">
|
||||
|
||||
<description>
|
||||
Default web.xml file.
|
||||
This file is applied to a Web application before it's own WEB_INF/web.xml file
|
||||
</description>
|
||||
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<!-- Context params to control Session Cookies -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- UNCOMMENT TO ACTIVATE
|
||||
<context-param>
|
||||
<param-name>org.eclipse.jetty.servlet.SessionDomain</param-name>
|
||||
<param-value>127.0.0.1</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>org.eclipse.jetty.servlet.SessionPath</param-name>
|
||||
<param-value>/</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>org.eclipse.jetty.servlet.MaxAge</param-name>
|
||||
<param-value>-1</param-value>
|
||||
</context-param>
|
||||
-->
|
||||
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<!-- The default servlet. -->
|
||||
<!-- This servlet, normally mapped to /, provides the handling for static -->
|
||||
<!-- content, OPTIONS and TRACE methods for the context. -->
|
||||
<!-- The following initParameters are supported: -->
|
||||
<!-- -->
|
||||
<!-- acceptRanges If true, range requests and responses are -->
|
||||
<!-- supported -->
|
||||
<!-- -->
|
||||
<!-- dirAllowed If true, directory listings are returned if no -->
|
||||
<!-- welcome file is found. Else 403 Forbidden. -->
|
||||
<!-- -->
|
||||
<!-- welcomeServlets If true, attempt to dispatch to welcome files -->
|
||||
<!-- that are servlets, if no matching static -->
|
||||
<!-- resources can be found. -->
|
||||
<!-- -->
|
||||
<!-- redirectWelcome If true, redirect welcome file requests -->
|
||||
<!-- else use request dispatcher forwards -->
|
||||
<!-- -->
|
||||
<!-- gzip If set to true, then static content will be served-->
|
||||
<!-- as gzip content encoded if a matching resource is -->
|
||||
<!-- found ending with ".gz" -->
|
||||
<!-- -->
|
||||
<!-- resoureBase Can be set to replace the context resource base -->
|
||||
<!-- -->
|
||||
<!-- relativeResourceBase -->
|
||||
<!-- Set with a pathname relative to the base of the -->
|
||||
<!-- servlet context root. Useful for only serving -->
|
||||
<!-- static content from only specific subdirectories. -->
|
||||
<!-- -->
|
||||
<!-- useFileMappedBuffer -->
|
||||
<!-- If set to true (the default), a memory mapped -->
|
||||
<!-- file buffer will be used to serve static content -->
|
||||
<!-- when using an NIO connector. Setting this value -->
|
||||
<!-- to false means that a direct buffer will be used -->
|
||||
<!-- instead. If you are having trouble with Windows -->
|
||||
<!-- file locking, set this to false. -->
|
||||
<!-- -->
|
||||
<!-- cacheControl If set, all static content will have this value -->
|
||||
<!-- set as the cache-control header. -->
|
||||
<!-- -->
|
||||
<!-- maxCacheSize Maximum size of the static resource cache -->
|
||||
<!-- -->
|
||||
<!-- maxCachedFileSize Maximum size of any single file in the cache -->
|
||||
<!-- -->
|
||||
<!-- maxCachedFiles Maximum number of files in the cache -->
|
||||
<!-- -->
|
||||
<!-- cacheType "nio", "bio" or "both" to determine the type(s) -->
|
||||
<!-- of resource cache. A bio cached buffer may be used-->
|
||||
<!-- by nio but is not as efficient as a nio buffer. -->
|
||||
<!-- An nio cached buffer may not be used by bio. -->
|
||||
<!-- -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<servlet>
|
||||
<servlet-name>default</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>acceptRanges</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>dirAllowed</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>welcomeServlets</param-name>
|
||||
<param-value>false</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>redirectWelcome</param-name>
|
||||
<param-value>false</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxCacheSize</param-name>
|
||||
<param-value>256000000</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxCachedFileSize</param-name>
|
||||
<param-value>10000000</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxCachedFiles</param-name>
|
||||
<param-value>1000</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>cacheType</param-name>
|
||||
<param-value>both</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>gzip</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>useFileMappedBuffer</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
<!--
|
||||
<init-param>
|
||||
<param-name>cacheControl</param-name>
|
||||
<param-value>max-age=3600,public</param-value>
|
||||
</init-param>
|
||||
-->
|
||||
<load-on-startup>0</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
|
||||
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<!-- JSP Servlet -->
|
||||
<!-- This is the jasper JSP servlet from the jakarta project -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- The JSP page compiler and execution servlet, which is the mechanism -->
|
||||
<!-- used by Glassfish to support JSP pages. Traditionally, this servlet -->
|
||||
<!-- is mapped to URL patterh "*.jsp". This servlet supports the -->
|
||||
<!-- following initialization parameters (default values are in square -->
|
||||
<!-- brackets): -->
|
||||
<!-- -->
|
||||
<!-- checkInterval If development is false and reloading is true, -->
|
||||
<!-- background compiles are enabled. checkInterval -->
|
||||
<!-- is the time in seconds between checks to see -->
|
||||
<!-- if a JSP page needs to be recompiled. [300] -->
|
||||
<!-- -->
|
||||
<!-- compiler Which compiler Ant should use to compile JSP -->
|
||||
<!-- pages. See the Ant documenation for more -->
|
||||
<!-- information. [javac] -->
|
||||
<!-- -->
|
||||
<!-- classdebuginfo Should the class file be compiled with -->
|
||||
<!-- debugging information? [true] -->
|
||||
<!-- -->
|
||||
<!-- classpath What class path should I use while compiling -->
|
||||
<!-- generated servlets? [Created dynamically -->
|
||||
<!-- based on the current web application] -->
|
||||
<!-- Set to ? to make the container explicitly set -->
|
||||
<!-- this parameter. -->
|
||||
<!-- -->
|
||||
<!-- development Is Jasper used in development mode (will check -->
|
||||
<!-- for JSP modification on every access)? [true] -->
|
||||
<!-- -->
|
||||
<!-- enablePooling Determines whether tag handler pooling is -->
|
||||
<!-- enabled [true] -->
|
||||
<!-- -->
|
||||
<!-- fork Tell Ant to fork compiles of JSP pages so that -->
|
||||
<!-- a separate JVM is used for JSP page compiles -->
|
||||
<!-- from the one Tomcat is running in. [true] -->
|
||||
<!-- -->
|
||||
<!-- ieClassId The class-id value to be sent to Internet -->
|
||||
<!-- Explorer when using <jsp:plugin> tags. -->
|
||||
<!-- [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93] -->
|
||||
<!-- -->
|
||||
<!-- javaEncoding Java file encoding to use for generating java -->
|
||||
<!-- source files. [UTF-8] -->
|
||||
<!-- -->
|
||||
<!-- keepgenerated Should we keep the generated Java source code -->
|
||||
<!-- for each page instead of deleting it? [true] -->
|
||||
<!-- -->
|
||||
<!-- logVerbosityLevel The level of detailed messages to be produced -->
|
||||
<!-- by this servlet. Increasing levels cause the -->
|
||||
<!-- generation of more messages. Valid values are -->
|
||||
<!-- FATAL, ERROR, WARNING, INFORMATION, and DEBUG. -->
|
||||
<!-- [WARNING] -->
|
||||
<!-- -->
|
||||
<!-- mappedfile Should we generate static content with one -->
|
||||
<!-- print statement per input line, to ease -->
|
||||
<!-- debugging? [false] -->
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
<!-- reloading Should Jasper check for modified JSPs? [true] -->
|
||||
<!-- -->
|
||||
<!-- suppressSmap Should the generation of SMAP info for JSR45 -->
|
||||
<!-- debugging be suppressed? [false] -->
|
||||
<!-- -->
|
||||
<!-- dumpSmap Should the SMAP info for JSR45 debugging be -->
|
||||
<!-- dumped to a file? [false] -->
|
||||
<!-- False if suppressSmap is true -->
|
||||
<!-- -->
|
||||
<!-- scratchdir What scratch directory should we use when -->
|
||||
<!-- compiling JSP pages? [default work directory -->
|
||||
<!-- for the current web application] -->
|
||||
<!-- -->
|
||||
<!-- tagpoolMaxSize The maximum tag handler pool size [5] -->
|
||||
<!-- -->
|
||||
<!-- xpoweredBy Determines whether X-Powered-By response -->
|
||||
<!-- header is added by generated servlet [false] -->
|
||||
<!-- -->
|
||||
<!-- If you wish to use Jikes to compile JSP pages: -->
|
||||
<!-- Set the init parameter "compiler" to "jikes". Define -->
|
||||
<!-- the property "-Dbuild.compiler.emacs=true" when starting Jetty -->
|
||||
<!-- to cause Jikes to emit error messages in a format compatible with -->
|
||||
<!-- Jasper. -->
|
||||
<!-- If you get an error reporting that jikes can't use UTF-8 encoding, -->
|
||||
<!-- try setting the init parameter "javaEncoding" to "ISO-8859-1". -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<servlet id="jsp">
|
||||
<servlet-name>jsp</servlet-name>
|
||||
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>logVerbosityLevel</param-name>
|
||||
<param-value>DEBUG</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>fork</param-name>
|
||||
<param-value>false</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>xpoweredBy</param-name>
|
||||
<param-value>false</param-value>
|
||||
</init-param>
|
||||
<!--
|
||||
<init-param>
|
||||
<param-name>classpath</param-name>
|
||||
<param-value>?</param-value>
|
||||
</init-param>
|
||||
-->
|
||||
<load-on-startup>0</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>jsp</servlet-name>
|
||||
<url-pattern>*.jsp</url-pattern>
|
||||
<url-pattern>*.jspf</url-pattern>
|
||||
<url-pattern>*.jspx</url-pattern>
|
||||
<url-pattern>*.xsp</url-pattern>
|
||||
<url-pattern>*.JSP</url-pattern>
|
||||
<url-pattern>*.JSPF</url-pattern>
|
||||
<url-pattern>*.JSPX</url-pattern>
|
||||
<url-pattern>*.XSP</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<!-- Dynamic Servlet Invoker. -->
|
||||
<!-- This servlet invokes anonymous servlets that have not been defined -->
|
||||
<!-- in the web.xml or by other means. The first element of the pathInfo -->
|
||||
<!-- of a request passed to the envoker is treated as a servlet name for -->
|
||||
<!-- an existing servlet, or as a class name of a new servlet. -->
|
||||
<!-- This servlet is normally mapped to /servlet/* -->
|
||||
<!-- This servlet support the following initParams: -->
|
||||
<!-- -->
|
||||
<!-- nonContextServlets If false, the invoker can only load -->
|
||||
<!-- servlets from the contexts classloader. -->
|
||||
<!-- This is false by default and setting this -->
|
||||
<!-- to true may have security implications. -->
|
||||
<!-- -->
|
||||
<!-- verbose If true, log dynamic loads -->
|
||||
<!-- -->
|
||||
<!-- * All other parameters are copied to the -->
|
||||
<!-- each dynamic servlet as init parameters -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- Uncomment for dynamic invocation
|
||||
<servlet>
|
||||
<servlet-name>invoker</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.servlet.Invoker</servlet-class>
|
||||
<init-param>
|
||||
<param-name>verbose</param-name>
|
||||
<param-value>false</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>nonContextServlets</param-name>
|
||||
<param-value>false</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>dynamicParam</param-name>
|
||||
<param-value>anyValue</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>0</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<session-config>
|
||||
<session-timeout>30</session-timeout>
|
||||
</session-config>
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<!-- Default MIME mappings -->
|
||||
<!-- The default MIME mappings are provided by the mime.properties -->
|
||||
<!-- resource in the org.eclipse.jetty.server.jar file. Additional or modified -->
|
||||
<!-- mappings may be specified here -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- UNCOMMENT TO ACTIVATE
|
||||
<mime-mapping>
|
||||
<extension>mysuffix</extension>
|
||||
<mime-type>mymime/type</mime-type>
|
||||
</mime-mapping>
|
||||
-->
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.htm</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
<!-- ==================================================================== -->
|
||||
<locale-encoding-mapping-list>
|
||||
<locale-encoding-mapping><locale>ar</locale><encoding>ISO-8859-6</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>be</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>bg</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>ca</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>cs</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>da</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>de</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>el</locale><encoding>ISO-8859-7</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>en</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>es</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>et</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>fi</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>fr</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>hr</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>hu</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>is</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>it</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>iw</locale><encoding>ISO-8859-8</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>ja</locale><encoding>Shift_JIS</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>ko</locale><encoding>EUC-KR</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>lt</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>lv</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>mk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>nl</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>no</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>pl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>pt</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>ro</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>ru</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>sh</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>sk</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>sl</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>sq</locale><encoding>ISO-8859-2</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>sr</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>sv</locale><encoding>ISO-8859-1</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>tr</locale><encoding>ISO-8859-9</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>uk</locale><encoding>ISO-8859-5</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>zh</locale><encoding>GB2312</encoding></locale-encoding-mapping>
|
||||
<locale-encoding-mapping><locale>zh_TW</locale><encoding>Big5</encoding></locale-encoding-mapping>
|
||||
</locale-encoding-mapping-list>
|
||||
|
||||
<security-constraint>
|
||||
<web-resource-collection>
|
||||
<web-resource-name>Disable TRACE</web-resource-name>
|
||||
<url-pattern>/</url-pattern>
|
||||
<http-method>TRACE</http-method>
|
||||
</web-resource-collection>
|
||||
<auth-constraint/>
|
||||
</security-constraint>
|
||||
|
||||
</web-app>
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Enable Centralized Logging in the Jetty Server -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.webapp.logging.CentralizedLogging">
|
||||
<Set name="server"><Ref id="Server" /></Set>
|
||||
<Set name="configurationFilename"><SystemProperty name="test.resourcesdir" default="src/test/resources"/>/logger/testing.properties</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -1,219 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure the Jetty Server -->
|
||||
<!-- -->
|
||||
<!-- Documentation of this file format can be found at: -->
|
||||
<!-- http://docs.codehaus.org/display/JETTY/jetty.xml -->
|
||||
<!-- -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
<!-- =========================================================== -->
|
||||
<!-- Server Thread Pool -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="ThreadPool">
|
||||
<!-- Default queued blocking threadpool
|
||||
-->
|
||||
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
|
||||
<Set name="minThreads">10</Set>
|
||||
<Set name="maxThreads">200</Set>
|
||||
</New>
|
||||
|
||||
<!-- Optional Java 5 bounded threadpool with job queue
|
||||
<New class="org.eclipse.thread.concurrent.ThreadPool">
|
||||
<Set name="corePoolSize">50</Set>
|
||||
<Set name="maximumPoolSize">50</Set>
|
||||
</New>
|
||||
-->
|
||||
</Set>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set connectors -->
|
||||
<!-- =========================================================== -->
|
||||
|
||||
<Call name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
|
||||
<Set name="host"></Set>
|
||||
<Set name="port">0</Set>
|
||||
<Set name="maxIdleTime">300000</Set>
|
||||
<Set name="Acceptors">2</Set>
|
||||
<Set name="statsOn">false</Set>
|
||||
<Set name="confidentialPort">8443</Set>
|
||||
<Set name="lowResourcesConnections">20000</Set>
|
||||
<Set name="lowResourcesMaxIdleTime">5000</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- To add a HTTPS SSL connector -->
|
||||
<!-- mixin jetty-ssl.xml: -->
|
||||
<!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- To add a HTTP blocking connector -->
|
||||
<!-- mixin jetty-bio.xml: -->
|
||||
<!-- java -jar start.jar etc/jetty.xml etc/jetty-bio.xml -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- To allow Jetty to be started from xinetd -->
|
||||
<!-- mixin jetty-xinetd.xml: -->
|
||||
<!-- java -jar start.jar etc/jetty.xml etc/jetty-xinetd.xml -->
|
||||
<!-- -->
|
||||
<!-- See jetty-xinetd.xml for further instructions. -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="handler">
|
||||
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||
<Set name="handlers">
|
||||
<Array type="org.eclipse.jetty.server.Handler">
|
||||
<Item>
|
||||
<New id="WebappContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
|
||||
</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
|
||||
<Call name="addLifeCycle">
|
||||
<Arg>
|
||||
<New id="ContextDeployer" class="org.eclipse.jetty.deploy.ContextDeployer">
|
||||
<Set name="contexts"><Ref id="WebappContexts" /></Set>
|
||||
<Set name="configurationDir">
|
||||
<Property name="test.resourcesdir" default="src/test/resources" />/contexts
|
||||
</Set>
|
||||
<Set name="scanInterval">0</Set>
|
||||
<Set name="configurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.FileConfigurationManager">
|
||||
<Set name="file">
|
||||
<Property name="test.targetdir" default="target" />/xml-configured-jetty.properties
|
||||
</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Configure the context deployer -->
|
||||
<!-- A context deployer will deploy contexts described in -->
|
||||
<!-- configuration files discovered in a directory. -->
|
||||
<!-- The configuration directory can be scanned for hot -->
|
||||
<!-- deployments at the configured scanInterval. -->
|
||||
<!-- -->
|
||||
<!-- This deployer is configured to deploy contexts configured -->
|
||||
<!-- in the $JETTY_HOME/contexts directory -->
|
||||
<!-- -->
|
||||
<!-- =========================================================== -->
|
||||
<!--
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.deploy.ContextDeployer">
|
||||
<Set name="contexts"><Ref id="Contexts"/></Set>
|
||||
<Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
|
||||
<Set name="scanInterval">5</Set>
|
||||
<Call name="setAttribute">
|
||||
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
|
||||
<Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Configure the webapp deployer. -->
|
||||
<!-- A webapp deployer will deploy standard webapps discovered -->
|
||||
<!-- in a directory at startup, without the need for additional -->
|
||||
<!-- configuration files. It does not support hot deploy or -->
|
||||
<!-- non standard contexts (see ContextDeployer above). -->
|
||||
<!-- -->
|
||||
<!-- This deployer is configured to deploy webapps from the -->
|
||||
<!-- $JETTY_HOME/webapps directory -->
|
||||
<!-- -->
|
||||
<!-- Normally only one type of deployer need be used. -->
|
||||
<!-- -->
|
||||
<!-- =========================================================== -->
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.deploy.WebAppDeployer">
|
||||
<Set name="contexts"><Ref id="Contexts"/></Set>
|
||||
<Set name="webAppDir"><SystemProperty name="test.resourcesdir" default="src/test/resources"/>/webapps</Set>
|
||||
<Set name="parentLoaderPriority">false</Set>
|
||||
<Set name="extract">true</Set>
|
||||
<Set name="allowDuplicates">false</Set>
|
||||
<Set name="defaultsDescriptor"><SystemProperty name="test.resourcesdir" default="src/test/resources"/>/etc/webdefault.xml</Set>
|
||||
<Call name="setAttribute">
|
||||
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
|
||||
<Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Configure Authentication Login Service -->
|
||||
<!-- Realms may be configured for the entire server here, or -->
|
||||
<!-- they can be configured for a specific web app in a context -->
|
||||
<!-- configuration (see $(jetty.home)/contexts/test.xml for an -->
|
||||
<!-- example). -->
|
||||
<!-- =========================================================== -->
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.security.HashLoginService">
|
||||
<Set name="name">Test Realm</Set>
|
||||
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
|
||||
<Set name="refreshInterval">0</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Configure Request Log -->
|
||||
<!-- Request logs may be configured for the entire server here, -->
|
||||
<!-- or they can be configured for a specific web app in a -->
|
||||
<!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
|
||||
<!-- for an example). -->
|
||||
<!-- =========================================================== -->
|
||||
<Ref id="RequestLog">
|
||||
<Set name="requestLog">
|
||||
<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
|
||||
<Set name="filename"><SystemProperty name="jetty.home" default="."/>/logs/yyyy_mm_dd.request.log</Set>
|
||||
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
|
||||
<Set name="retainDays">90</Set>
|
||||
<Set name="append">true</Set>
|
||||
<Set name="extended">false</Set>
|
||||
<Set name="logCookies">false</Set>
|
||||
<Set name="LogTimeZone">GMT</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</Ref>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- extra options -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="stopAtShutdown">true</Set>
|
||||
<Set name="sendServerVersion">true</Set>
|
||||
<Set name="sendDateHeader">true</Set>
|
||||
<Set name="gracefulShutdown">1000</Set>
|
||||
|
||||
</Configure>
|
|
@ -1,4 +0,0 @@
|
|||
root.level=DEBUG
|
||||
root.appenders=stdout
|
||||
|
||||
appenders.stdout.class=org.eclipse.jetty.logging.impl.ConsoleAppender
|
|
@ -1,6 +0,0 @@
|
|||
# Intentionally NOT get DEBUG messages
|
||||
root.level=INFO
|
||||
root.appenders=testing
|
||||
|
||||
appender.console.class=org.eclipse.jetty.logging.impl.ConsoleAppender
|
||||
appender.testing.class=org.eclipse.jetty.webapp.logging.TestAppender
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue