271535 Adding integration tests, and enabling RFC2616 tests.

Adding /tests/test-integration/ tree, along with new RedirectRegexRule.



git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@496 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Joakim Erdfelt 2009-07-08 19:28:16 +00:00
parent 74fd882da2
commit 3a7cc3809f
69 changed files with 6132 additions and 0 deletions

View File

@ -4,6 +4,7 @@ jetty-7.0.0.RC0-SNAPSHOT
+ JETTY-1056 update jetty-ant module for Jetty 7 at codehaus trunk
+ JETTY-1058 Handle trailing / with aliases
+ 280843 Buffer pool uses isHeader
+ 271535 Adding integration tests, and enabling RFC2616 tests
jetty-7.0.0.M4 1 June 2009
+ 281059 NPE in QTP with debug on

View File

@ -0,0 +1,63 @@
// ========================================================================
// 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.rewrite.handler;
import java.io.IOException;
import java.util.regex.Matcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Redirects the response by matching with a regular expression.
* The replacement string may use $n" to replace the nth capture group.
*/
public class RedirectRegexRule extends RegexRule
{
private String _replacement;
public RedirectRegexRule()
{
_handling = true;
_terminating = true;
}
/**
* Whenever a match is found, it replaces with this value.
*
* @param replacement the replacement string.
*/
public void setReplacement(String replacement)
{
_replacement = replacement;
}
@Override
protected String apply(String target, HttpServletRequest request, HttpServletResponse response, Matcher matcher)
throws IOException
{
target=_replacement;
for (int g=1;g<=matcher.groupCount();g++)
{
String group = matcher.group(g);
target=target.replaceAll("\\$"+g,group);
}
response.sendRedirect(target);
return target;
}
}

View File

@ -0,0 +1,68 @@
// ========================================================================
// 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.rewrite.handler;
import java.io.IOException;
import org.eclipse.jetty.http.HttpHeaders;
public class RedirectRegexRuleTest extends AbstractRuleTestCase
{
private RedirectRegexRule _rule;
public void setUp() throws Exception
{
super.setUp();
_rule = new RedirectRegexRule();
}
public void tearDown()
{
_rule = null;
}
public void testLocationWithReplacementGroupEmpty() throws IOException
{
_rule.setRegex("/my/dir/file/(.*)$");
_rule.setReplacement("http://www.mortbay.org/$1");
// Resource is dir
_rule.matchAndApply("/my/dir/file/", _request, _response);
assertEquals("http://www.mortbay.org/", _response.getHeader(HttpHeaders.LOCATION));
}
public void testLocationWithReplacmentGroupSimple() throws IOException
{
_rule.setRegex("/my/dir/file/(.*)$");
_rule.setReplacement("http://www.mortbay.org/$1");
// Resource is an image
_rule.matchAndApply("/my/dir/file/image.png", _request, _response);
assertEquals("http://www.mortbay.org/image.png", _response.getHeader(HttpHeaders.LOCATION));
}
public void testLocationWithReplacementGroupDeepWithParams() throws IOException
{
_rule.setRegex("/my/dir/file/(.*)$");
_rule.setReplacement("http://www.mortbay.org/$1");
// Resource is api with parameters
_rule.matchAndApply("/my/dir/file/api/rest/foo?id=100&sort=date", _request, _response);
assertEquals("http://www.mortbay.org/api/rest/foo?id=100&sort=date", _response.getHeader(HttpHeaders.LOCATION));
}
}

36
tests/pom.xml Normal file
View File

@ -0,0 +1,36 @@
<?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.0.M4-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>tests-parent</artifactId>
<name>Jetty Tests :: Parent</name>
<packaging>pom</packaging>
<build>
</build>
<modules>
<module>test-integration</module>
<module>test-webapps</module>
</modules>
</project>

View File

@ -0,0 +1,84 @@
<?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">
<parent>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>tests-parent</artifactId>
<version>7.0.0.M4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration</artifactId>
<packaging>jar</packaging>
<name>Jetty Tests :: Integrations</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-wars-for-testing</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>test</includeScope>
<includeTypes>war</includeTypes>
<overwriteSnapshots>true</overwriteSnapshots>
<overwriteReleases>true</overwriteReleases>
<stripVersion>true</stripVersion>
<outputDirectory>${project.build.directory}/webapps</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<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>org.eclipse.jetty</groupId>
<artifactId>jetty-rewrite</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>test-webapp-rfc2616</artifactId>
<version>7.0.0.M4-SNAPSHOT</version>
<type>war</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,90 @@
// ========================================================================
// 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.test;
import java.io.File;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
public abstract class AbstractJettyTestCase extends TestCase
{
private File baseDir;
public File getBaseDir()
{
if (baseDir == null)
{
String baseDirPath = System.getProperty("basedir");
if (baseDirPath == null)
{
baseDirPath = System.getProperty("user.dir",".");
}
baseDir = new File(baseDirPath);
}
return baseDir;
}
public File getTestResourcesDir()
{
File path = new File(getBaseDir(),"src/test/resources");
assertDirExists("test resources dir",path);
return path;
}
public File getDocRootBase()
{
File path = new File(getTestResourcesDir(),"docroots");
assertDirExists("docroot base dir",path);
return path;
}
public void assertDirExists(String msg, File path)
{
assertNotNull(msg + " should not be null",path);
assertTrue(msg + " should exist",path.exists());
assertTrue(msg + " should be a directory",path.isDirectory());
}
/**
* Return the port that the server is listening on.
*
* Assumes 1 connector, and that server is started already.
*
* @param server
* the server port.
* @return the port that the server is listening on.
*/
public int findServerPort(Server server)
{
Connector connectors[] = server.getConnectors();
for (int i = 0; i < connectors.length; i++)
{
Connector connector = connectors[i];
if (connector.getLocalPort() > 0)
{
return connector.getLocalPort();
}
}
throw new AssertionFailedError("No valid connector port found.");
}
}

View File

@ -0,0 +1,168 @@
// ========================================================================
// 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.test;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import org.eclipse.jetty.http.HttpSchemes;
import org.eclipse.jetty.test.support.TestableJettyServer;
import org.eclipse.jetty.test.support.rawhttp.HttpRequestTester;
import org.eclipse.jetty.test.support.rawhttp.HttpResponseTester;
import org.eclipse.jetty.test.support.rawhttp.HttpSocketImpl;
import org.eclipse.jetty.test.support.rawhttp.HttpTesting;
import org.eclipse.jetty.util.IO;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* Tests against the facilities within the TestSuite to ensure that the various
* org.eclipse.jetty.test.support.* classes do what they are supposed to.
*/
public class DefaultHandlerTest extends AbstractJettyTestCase
{
private boolean debug = true;
private TestableJettyServer server;
private int serverPort;
@Before
public void setUp() throws Exception
{
super.setUp();
server = new TestableJettyServer();
server.setScheme(HttpSchemes.HTTP);
server.addConfiguration("DefaultHandler.xml");
server.load();
server.start();
serverPort = server.getServerPort();
}
@After
public void tearDown() throws Exception
{
server.stop();
super.tearDown();
}
@Test
public void testGET_URL() throws Exception
{
URL url = new URL("http://localhost:" + serverPort + "/tests/alpha.txt");
URLConnection conn = url.openConnection();
conn.connect();
InputStream in = conn.getInputStream();
String response = IO.toString(in);
assertEquals("Response","ABCDEFGHIJKLMNOPQRSTUVWXYZ\n",response);
}
@Test
public void testGET_Raw() throws Exception
{
StringBuffer rawRequest = new StringBuffer();
rawRequest.append("GET /tests/alpha.txt HTTP/1.1\r\n");
rawRequest.append("Host: localhost\r\n");
rawRequest.append("Connection: close\r\n");
rawRequest.append("\r\n");
Socket sock = new Socket(InetAddress.getLocalHost(),serverPort);
sock.setSoTimeout(5000); // 5 second timeout;
DEBUG("--raw-request--\n" + rawRequest);
InputStream in = new ByteArrayInputStream(rawRequest.toString().getBytes());
// Send request
IO.copy(in,sock.getOutputStream());
// Collect response
String rawResponse = IO.toString(sock.getInputStream());
DEBUG("--raw-response--\n" + rawResponse);
HttpResponseTester response = new HttpResponseTester();
response.parse(rawResponse);
response.assertStatusOK();
response.assertBody("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
}
@Test
public void testMultiGET_Raw() throws Exception
{
StringBuffer rawRequests = new StringBuffer();
rawRequests.append("GET /tests/alpha.txt HTTP/1.1\r\n");
rawRequests.append("Host: localhost\r\n");
rawRequests.append("\r\n");
rawRequests.append("GET /tests/R1.txt HTTP/1.1\r\n");
rawRequests.append("Host: localhost\r\n");
rawRequests.append("\r\n");
rawRequests.append("GET /tests/R1.txt HTTP/1.1\r\n");
rawRequests.append("Host: localhost\r\n");
rawRequests.append("Connection: close\r\n");
rawRequests.append("\r\n");
HttpTesting http = new HttpTesting(new HttpSocketImpl(),serverPort);
List<HttpResponseTester> responses = http.requests(rawRequests);
HttpResponseTester response = responses.get(0);
response.assertStatusOK();
response.assertBody("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
response = responses.get(1);
response.assertStatusOK();
response.assertBody("Host=Default\nResource=R1\n");
response = responses.get(2);
response.assertStatusOK();
response.assertBody("Host=Default\nResource=R1\n");
}
@Test
public void testGET_HttpTesting() throws Exception
{
HttpRequestTester request = new HttpRequestTester();
request.setMethod("GET");
request.setURI("/tests/alpha.txt");
request.addHeader("Host","localhost");
request.addHeader("Connection","close");
// request.setContent(null);
HttpTesting testing = new HttpTesting(new HttpSocketImpl(),serverPort);
HttpResponseTester response = testing.request(request);
response.assertStatusOK();
response.assertContentType("text/plain");
response.assertBody("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
}
private void DEBUG(String msg)
{
if (debug)
{
System.out.println(msg);
}
}
}

View File

@ -0,0 +1,168 @@
// ========================================================================
// 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.test;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
public class StringAssert
{
/**
* Asserts that the string (<code>haystack</code>) starts with the string (
* <code>expected</code>)
*
* @param msg
* the assertion message
* @param haystack
* the text to search in
* @param expected
* the expected starts with text
*/
public static void assertStartsWith(String msg, String haystack, String expected)
{
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
Assert.assertNotNull(msg + ": expected should not be null",expected);
if (!haystack.startsWith(expected))
{
StringBuffer buf = new StringBuffer();
buf.append(msg).append(": String \"");
int len = Math.min(expected.length() + 4,haystack.length());
buf.append(haystack.substring(0,len));
buf.append("\" does not start with expected \"").append(expected).append("\"");
System.err.println(buf);
throw new AssertionFailedError(buf.toString());
}
}
/**
* Asserts that string (<code>haystack</code>) contains specified text (
* <code>needle</code>).
*
* @param msg
* the assertion message
* @param haystack
* the text to search in
* @param needle
* the text to search for
*/
public static void assertContains(String msg, String haystack, String needle)
{
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
Assert.assertNotNull(msg + ": needle should not be null",needle);
int idx = haystack.indexOf(needle);
if (idx == (-1))
{
StringBuffer buf = new StringBuffer();
buf.append(msg).append(": ");
buf.append("Unable to find \"").append(needle).append("\" in \"");
buf.append(haystack).append("\"");
System.err.println(buf);
throw new AssertionFailedError(buf.toString());
}
}
/**
* Asserts that string (<code>haystack</code>) contains specified text (
* <code>needle</code>), starting at offset (in <code>haystack</code>).
*
* @param msg
* the assertion message
* @param haystack
* the text to search in
* @param needle
* the text to search for
* @param offset
* the offset in (haystack) to perform search from
*/
public static void assertContains(String msg, String haystack, String needle, int offset)
{
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
Assert.assertNotNull(msg + ": needle should not be null",needle);
int idx = haystack.indexOf(needle,offset);
if (idx == (-1))
{
StringBuffer buf = new StringBuffer();
buf.append(msg).append(": ");
buf.append("Unable to find \"").append(needle).append("\" in \"");
buf.append(haystack.substring(offset)).append("\"");
System.err.println(buf);
throw new AssertionFailedError(buf.toString());
}
}
/**
* Asserts that string (<code>haystack</code>) does <u>not</u> contain
* specified text (<code>needle</code>).
*
* @param msg
* the assertion message
* @param haystack
* the text to search in
* @param needle
* the text to search for
*/
public static void assertNotContains(String msg, String haystack, String needle)
{
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
Assert.assertNotNull(msg + ": needle should not be null",needle);
int idx = haystack.indexOf(needle);
if (idx != (-1))
{
StringBuffer buf = new StringBuffer();
buf.append(msg).append(": ");
buf.append("Should not have found \"").append(needle).append("\" at offset ");
buf.append(idx).append(" in \"").append(haystack).append("\"");
System.err.println(buf);
throw new AssertionFailedError(buf.toString());
}
}
/**
* Asserts that string (<code>haystack</code>) does <u>not</u> contain
* specified text (<code>needle</code>), starting at offset (in
* <code>haystack</code>).
*
* @param msg
* the assertion message
* @param haystack
* the text to search in
* @param needle
* the text to search for
* @param offset
* the offset in (haystack) to perform search from
*/
public static void assertNotContains(String msg, String haystack, String needle, int offset)
{
Assert.assertNotNull(msg + ": haystack should not be null",haystack);
Assert.assertNotNull(msg + ": needle should not be null",needle);
int idx = haystack.indexOf(needle,offset);
if (idx != (-1))
{
StringBuffer buf = new StringBuffer();
buf.append(msg).append(": ");
buf.append("Should not have found \"").append(needle).append("\" at offset ");
buf.append(idx).append(" in \"").append(haystack.substring(offset)).append("\"");
System.err.println(buf);
throw new AssertionFailedError(buf.toString());
}
}
}

View File

@ -0,0 +1,48 @@
// ========================================================================
// 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.test.rfcs;
import java.io.IOException;
import org.eclipse.jetty.http.HttpSchemes;
import org.eclipse.jetty.test.support.TestableJettyServer;
import org.eclipse.jetty.test.support.rawhttp.HttpSocket;
import org.eclipse.jetty.test.support.rawhttp.HttpSocketImpl;
/**
* Perform the RFC2616 tests against a server running with the Jetty BIO Connector and listening on standard HTTP.
*/
public class RFC2616BIOHttpTest extends RFC2616BaseTest
{
@Override
public TestableJettyServer getJettyServer() throws IOException
{
TestableJettyServer server = new TestableJettyServer();
server.setScheme(HttpSchemes.HTTP);
server.addConfiguration("RFC2616Base.xml");
server.addConfiguration("RFC2616_Redirects.xml");
server.addConfiguration("RFC2616_Filters.xml");
server.addConfiguration("BIOHttp.xml");
return server;
}
@Override
public HttpSocket getHttpClientSocket()
{
return new HttpSocketImpl();
}
}

View File

@ -0,0 +1,48 @@
// ========================================================================
// 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.test.rfcs;
import java.io.IOException;
import org.eclipse.jetty.http.HttpSchemes;
import org.eclipse.jetty.test.support.TestableJettyServer;
import org.eclipse.jetty.test.support.rawhttp.HttpSocket;
import org.eclipse.jetty.test.support.rawhttp.HttpsSocketImpl;
/**
* Perform the RFC2616 tests against a server running with the Jetty BIO Connector and listening on HTTPS (HTTP over SSL).
*/
public class RFC2616BIOHttpsTest extends RFC2616BaseTest
{
@Override
public TestableJettyServer getJettyServer() throws IOException
{
TestableJettyServer server = new TestableJettyServer();
server.setScheme(HttpSchemes.HTTPS);
server.addConfiguration("RFC2616Base.xml");
server.addConfiguration("RFC2616_Redirects.xml");
server.addConfiguration("RFC2616_Filters.xml");
server.addConfiguration("BIOHttps.xml");
return server;
}
@Override
public HttpSocket getHttpClientSocket() throws Exception
{
return new HttpsSocketImpl();
}
}

View File

@ -0,0 +1,48 @@
// ========================================================================
// 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.test.rfcs;
import java.io.IOException;
import org.eclipse.jetty.http.HttpSchemes;
import org.eclipse.jetty.test.support.TestableJettyServer;
import org.eclipse.jetty.test.support.rawhttp.HttpSocket;
import org.eclipse.jetty.test.support.rawhttp.HttpSocketImpl;
/**
* Perform the RFC2616 tests against a server running with the Jetty NIO Connector and listening on standard HTTP.
*/
public class RFC2616NIOHttpTest extends RFC2616BaseTest
{
@Override
public TestableJettyServer getJettyServer() throws IOException
{
TestableJettyServer server = new TestableJettyServer();
server.setScheme(HttpSchemes.HTTP);
server.addConfiguration("RFC2616Base.xml");
server.addConfiguration("RFC2616_Redirects.xml");
server.addConfiguration("RFC2616_Filters.xml");
server.addConfiguration("NIOHttp.xml");
return server;
}
@Override
public HttpSocket getHttpClientSocket()
{
return new HttpSocketImpl();
}
}

View File

@ -0,0 +1,48 @@
// ========================================================================
// 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.test.rfcs;
import java.io.IOException;
import org.eclipse.jetty.http.HttpSchemes;
import org.eclipse.jetty.test.support.TestableJettyServer;
import org.eclipse.jetty.test.support.rawhttp.HttpSocket;
import org.eclipse.jetty.test.support.rawhttp.HttpsSocketImpl;
/**
* Perform the RFC2616 tests against a server running with the Jetty NIO Connector and listening on HTTPS (HTTP over SSL).
*/
public class RFC2616NIOHttpsTest extends RFC2616BaseTest
{
@Override
public TestableJettyServer getJettyServer() throws IOException
{
TestableJettyServer server = new TestableJettyServer();
server.setScheme(HttpSchemes.HTTPS);
server.addConfiguration("RFC2616Base.xml");
server.addConfiguration("RFC2616_Redirects.xml");
server.addConfiguration("RFC2616_Filters.xml");
server.addConfiguration("NIOHttps.xml");
return server;
}
@Override
public HttpSocket getHttpClientSocket() throws Exception
{
return new HttpsSocketImpl();
}
}

View File

@ -0,0 +1,64 @@
// ========================================================================
// 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.test.support;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.HttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
public class EchoHandler extends AbstractHandler
{
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
Request base_request = (request instanceof Request)?(Request)request:HttpConnection.getCurrentConnection().getRequest();
base_request.setHandled(true);
if (request.getContentType() != null)
response.setContentType(request.getContentType());
if (request.getParameter("charset") != null)
response.setCharacterEncoding(request.getParameter("charset"));
else if (request.getCharacterEncoding() != null)
response.setCharacterEncoding(request.getCharacterEncoding());
PrintWriter writer = response.getWriter();
BufferedReader reader = request.getReader();
int count = 0;
String line;
while ((line = reader.readLine()) != null)
{
writer.print(line);
writer.print("\n");
count += line.length();
}
// just to be difficult
reader.close();
writer.close();
if (reader.read() >= 0)
throw new IllegalStateException("Not closed");
}
}

View File

@ -0,0 +1,104 @@
// ========================================================================
// 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.test.support;
public class StringUtil
{
public static boolean isBlank(String str)
{
if (str == null)
{
return true;
}
int len = str.length();
if (len == 0)
{
return true;
}
char c;
for (int i = 0; i < str.length(); i++)
{
c = str.charAt(i);
if (Character.isWhitespace(c) == false)
{
return false;
}
}
return true;
}
public static boolean isNotBlank(String str)
{
return !StringUtil.isBlank(str);
}
public static String[] split(String s, char delim)
{
if (s == null)
{
return null;
}
if (s.length() <= 0)
{
return new String[] {}; // empty array
}
String ret[];
int count = 0;
int offset = 0;
int idx;
// Calculate entry length to not waste memory.
while ((idx = s.indexOf(delim,offset)) != (-1))
{
if (idx > offset)
{
count++;
}
offset = idx + 1;
}
if (s.length() > offset)
{
count++;
}
// Create return array.
offset = 0;
ret = new String[count];
int retIdx = 0;
while ((idx = s.indexOf(delim,offset)) != (-1))
{
if (idx > offset)
{
ret[retIdx] = s.substring(offset,idx);
retIdx++;
}
offset = idx + 1;
}
if (s.length() > offset)
{
ret[retIdx] = s.substring(offset);
}
return ret;
}
}

View File

@ -0,0 +1,202 @@
// ========================================================================
// 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.test.support;
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 org.eclipse.jetty.http.HttpSchemes;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.xml.XmlConfiguration;
import org.junit.Assert;
import org.junit.Ignore;
/**
* Allows for setting up a Jetty server for testing based on XML configuration files.
*/
@Ignore
public class TestableJettyServer
{
private List<URL> xmlConfigurations;
private Properties properties = new Properties();
private Server server;
private int serverPort;
private String scheme = HttpSchemes.HTTP;
/* Popular Directories */
private File baseDir;
private File testResourcesDir;
public TestableJettyServer() throws IOException
{
xmlConfigurations = new ArrayList<URL>();
properties = new Properties();
/* Establish Popular Directories */
String baseDirPath = System.getProperty("basedir");
if (baseDirPath == null)
{
baseDirPath = System.getProperty("user.dir",".");
}
baseDir = new File(baseDirPath);
properties.setProperty("test.basedir",baseDir.getAbsolutePath());
testResourcesDir = new File(baseDirPath,"src/test/resources".replace('/',File.separatorChar));
properties.setProperty("test.resourcesdir",testResourcesDir.getAbsolutePath());
File testDocRoot = new File(testResourcesDir,"docroots");
properties.setProperty("test.docroot.base",testDocRoot.getAbsolutePath());
File targetDir = new File(baseDir,"target");
properties.setProperty("test.targetdir",targetDir.getAbsolutePath());
File webappsDir = new File(targetDir,"webapps");
properties.setProperty("test.webapps",webappsDir.getAbsolutePath());
// Write out configuration for use by ConfigurationManager.
File testConfig = new File(targetDir,"testable-jetty-server-config.properties");
FileOutputStream out = new FileOutputStream(testConfig);
properties.store(out,"Generated by " + TestableJettyServer.class.getName());
}
public void addConfiguration(URL xmlConfig)
{
xmlConfigurations.add(xmlConfig);
}
public void addConfiguration(File xmlConfigFile) throws MalformedURLException
{
xmlConfigurations.add(xmlConfigFile.toURL());
}
public void addConfiguration(String testConfigName) throws MalformedURLException
{
addConfiguration(new File(testResourcesDir,testConfigName));
}
public void setProperty(String key, String value)
{
properties.setProperty(key,value);
}
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;
}
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));
}
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());
}
}

View File

@ -0,0 +1,226 @@
// ========================================================================
// 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.test.support.rawhttp;
import java.io.IOException;
import javax.servlet.http.Cookie;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpGenerator;
import org.eclipse.jetty.http.HttpHeaders;
import org.eclipse.jetty.http.HttpVersions;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.SimpleBuffers;
import org.eclipse.jetty.io.View;
import org.eclipse.jetty.io.bio.StringEndPoint;
/**
* Assist in Generating Proper Raw HTTP Requests. If you want ultimate control
* over the Raw HTTP Request, to test non-standard behavior, or partial HTTP
* Requests, do not use this class.
*
* <pre>
* HttpRequestTester request = new HttpRequestTester();
*
* request.setMethod(&quot;GET&quot;);
* request.setURI(&quot;/uri&quot;);
* request.setHost(&quot;fakehost&quot;);
* request.setConnectionClosed();
*
* String rawRequest = request.generate();
*
* System.out.println(&quot;--raw-request--\n&quot; + rawRequest);
* </pre>
*
* <pre>
* --raw-request--
* GET /uri HTTP/1.1
* Host: fakehost
* Connection: close
* </pre>
*/
public class HttpRequestTester
{
private HttpFields fields = new HttpFields();
private String method;
private String uri;
private String version;
private byte[] content;
private String charset;
private String defaultCharset;
private String contentType;
public HttpRequestTester()
{
this("UTF-8");
}
public HttpRequestTester(String defCharset)
{
this.defaultCharset = defCharset;
}
public String getMethod()
{
return method;
}
public void setHost(String host)
{
addHeader("Host",host);
}
public void setMethod(String method)
{
this.method = method;
}
public String getURI()
{
return uri;
}
public void setURI(String uri)
{
this.uri = uri;
}
public String getVersion()
{
return version;
}
public void setVersion(String version)
{
this.version = version;
}
public String getCharset()
{
return charset;
}
public void setCharset(String charset)
{
this.charset = charset;
}
public String getContentType()
{
return contentType;
}
public void setContentType(String contentType)
{
this.contentType = contentType;
}
public void setConnectionClosed()
{
fields.add("Connection","close");
}
/**
* @param name
* @param value
* @throws IllegalArgumentException
* @see org.eclipse.jetty.http.HttpFields#add(java.lang.String,
* java.lang.String)
*/
public void addHeader(String name, String value) throws IllegalArgumentException
{
fields.add(name,value);
}
/**
* @param name
* @param date
* @see org.eclipse.jetty.http.HttpFields#addDateField(java.lang.String,
* long)
*/
public void addDateHeader(String name, long date)
{
fields.addDateField(name,date);
}
/**
* @param name
* @param value
* @see org.eclipse.jetty.http.HttpFields#addLongField(java.lang.String,
* long)
*/
public void addLongHeader(String name, long value)
{
fields.addLongField(name,value);
}
/**
* @param cookie
* @see org.eclipse.jetty.http.HttpFields#addSetCookie(javax.servlet.http.Cookie)
*/
public void addSetCookie(Cookie cookie)
{
fields.addSetCookie(cookie.getName(),cookie.getValue(),cookie.getDomain(),cookie.getPath(),cookie.getMaxAge(),cookie.getComment(),cookie.getSecure(),
false,cookie.getVersion());
}
public String generate() throws IOException
{
charset = defaultCharset;
Buffer contentTypeBuffer = fields.get(HttpHeaders.CONTENT_TYPE_BUFFER);
if (contentTypeBuffer != null)
{
String calcCharset = MimeTypes.getCharsetFromContentType(contentTypeBuffer);
if (calcCharset != null)
{
this.charset = calcCharset;
}
}
Buffer bb = new ByteArrayBuffer(32 * 1024 + (content != null?content.length:0));
Buffer sb = new ByteArrayBuffer(4 * 1024);
StringEndPoint endp = new StringEndPoint(charset);
HttpGenerator generator = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
if (method != null)
{
generator.setRequest(getMethod(),getURI());
if (version == null)
{
generator.setVersion(HttpVersions.HTTP_1_1_ORDINAL);
}
else
{
generator.setVersion(HttpVersions.CACHE.getOrdinal(HttpVersions.CACHE.lookup(version)));
}
generator.completeHeader(fields,false);
if (content != null)
{
generator.addContent(new View(new ByteArrayBuffer(content)),false);
}
}
generator.complete();
generator.flushBuffer();
return endp.getOutput();
}
}

View File

@ -0,0 +1,64 @@
// ========================================================================
// 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.test.support.rawhttp;
import java.io.IOException;
import org.eclipse.jetty.test.AbstractJettyTestCase;
public class HttpRequestTesterTest extends AbstractJettyTestCase
{
public void testBasicHttp10Request() throws IOException
{
HttpRequestTester request = new HttpRequestTester();
request.setMethod("GET");
request.setURI("/uri");
request.setVersion("HTTP/1.0");
request.setHost("fakehost");
String rawRequest = request.generate();
StringBuffer expectedRequest = new StringBuffer();
expectedRequest.append("GET /uri HTTP/1.0\r\n");
expectedRequest.append("Host: fakehost\r\n");
expectedRequest.append("\r\n");
assertEquals("Basic Request",expectedRequest.toString(),rawRequest);
}
public void testBasicHttp11Request() throws IOException
{
HttpRequestTester request = new HttpRequestTester();
request.setMethod("GET");
request.setURI("/uri");
request.setHost("fakehost");
request.setConnectionClosed();
String rawRequest = request.generate();
StringBuffer expectedRequest = new StringBuffer();
expectedRequest.append("GET /uri HTTP/1.1\r\n");
expectedRequest.append("Host: fakehost\r\n");
expectedRequest.append("Connection: close\r\n");
expectedRequest.append("Transfer-Encoding: chunked\r\n");
expectedRequest.append("\r\n");
expectedRequest.append("0\r\n");
expectedRequest.append("\r\n");
assertEquals("Basic Request",expectedRequest.toString(),rawRequest);
}
}

View File

@ -0,0 +1,451 @@
// ========================================================================
// 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.test.support.rawhttp;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeaders;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.View;
import org.eclipse.jetty.test.StringAssert;
import org.eclipse.jetty.test.support.StringUtil;
import org.eclipse.jetty.util.ByteArrayOutputStream2;
/**
* Assists in testing of HTTP Responses.
*/
public class HttpResponseTester
{
private class PH extends HttpParser.EventHandler
{
public void content(Buffer ref) throws IOException
{
if (content == null)
content = new ByteArrayOutputStream2();
content.write(ref.asArray());
}
public void headerComplete() throws IOException
{
contentType = fields.get(HttpHeaders.CONTENT_TYPE_BUFFER);
if (contentType != null)
{
String calcCharset = MimeTypes.getCharsetFromContentType(contentType);
if (calcCharset != null)
{
charset = calcCharset;
}
}
}
public void messageComplete(long contextLength) throws IOException
{
}
public void parsedHeader(Buffer name, Buffer value) throws IOException
{
fields.add(name,value);
}
public void startRequest(Buffer method, Buffer url, Buffer version) throws IOException
{
reset();
HttpResponseTester.this.method = getString(method);
HttpResponseTester.this.uri = getString(url);
HttpResponseTester.this.version = getString(version);
}
public void startResponse(Buffer version, int status, Buffer reason) throws IOException
{
reset();
HttpResponseTester.this.version = getString(version);
HttpResponseTester.this.status = status;
HttpResponseTester.this.reason = getString(reason);
}
}
public static List<HttpResponseTester> parseMulti(CharSequence rawHTTP) throws IOException
{
List<HttpResponseTester> responses = new ArrayList<HttpResponseTester>();
String parse = rawHTTP.toString();
while (StringUtil.isNotBlank(parse))
{
HttpResponseTester response = new HttpResponseTester();
parse = response.parse(parse);
responses.add(response);
}
return responses;
}
private HttpFields fields = new HttpFields();
private CharSequence rawResponse;
private String method;
private String uri;
private String version;
private int status;
private String reason;
private Buffer contentType;
private ByteArrayOutputStream2 content;
private String charset;
private String defaultCharset;
public HttpResponseTester()
{
this("UTF-8");
}
public HttpResponseTester(String defCharset)
{
this.defaultCharset = defCharset;
}
public String getMethod()
{
return method;
}
public String getURI()
{
return uri;
}
public String getVersion()
{
return version;
}
public int getStatus()
{
return status;
}
public CharSequence getRawResponse()
{
return rawResponse;
}
public String getReason()
{
return reason;
}
public String getContentType()
{
if (contentType == null)
{
return null;
}
return contentType.toString();
}
public ByteArrayOutputStream2 getContentBytes()
{
return content;
}
public String getContent()
{
return content.toString();
}
public String getBody()
{
return content.toString();
}
private byte[] getByteArray(CharSequence str)
{
if (charset == null)
{
return str.toString().getBytes();
}
try
{
return str.toString().getBytes(charset);
}
catch (Exception e)
{
return str.toString().getBytes();
}
}
private String getString(Buffer buffer)
{
return getString(buffer.asArray());
}
private String getString(byte[] b)
{
if (charset == null)
{
return new String(b);
}
try
{
return new String(b,charset);
}
catch (Exception e)
{
return new String(b);
}
}
/**
* @param name
* @return
* @see org.eclipse.jetty.http.HttpFields#getDateField(java.lang.String)
*/
public long getDateHeader(String name)
{
return fields.getDateField(name);
}
/**
* @param name
* @return
* @throws NumberFormatException
* @see org.eclipse.jetty.http.HttpFields#getLongField(java.lang.String)
*/
public long getLongHeader(String name) throws NumberFormatException
{
return fields.getLongField(name);
}
/**
* @param name
* @return
* @see org.eclipse.jetty.http.HttpFields#getStringField(java.lang.String)
*/
public String getHeader(String name)
{
return fields.getStringField(name);
}
public boolean hasHeader(String headerKey)
{
return fields.containsKey(headerKey);
}
/**
* Parse on HTTP Response
*
* @param rawHTTP
* Raw HTTP to parse
* @return Any unparsed data in the rawHTTP (eg pipelined requests)
* @throws IOException
*/
public String parse(CharSequence rawHTTP) throws IOException
{
this.charset = defaultCharset;
this.rawResponse = rawHTTP;
ByteArrayBuffer buf = new ByteArrayBuffer(getByteArray(rawHTTP));
View view = new View(buf);
HttpParser parser = new HttpParser(view,new PH());
parser.parse();
return getString(view.asArray());
}
public void reset()
{
fields.clear();
method = null;
uri = null;
version = null;
status = 0;
reason = null;
content = null;
}
/**
* Make sure that status code is "OK"
*/
public void assertStatusOK()
{
assertStatus(HttpStatus.OK_200,"OK");
}
public void assertStatusOK(String msg)
{
assertStatus(msg,HttpStatus.OK_200,"OK");
}
public void assertStatus(int expectedStatus, String expectedReason)
{
Assert.assertEquals("Response.status",expectedStatus,this.status);
Assert.assertEquals("Response.reason",expectedReason,this.reason);
}
public void assertStatus(String msg, int expectedStatus, String expectedReason)
{
Assert.assertEquals(msg + ": Response.status",expectedStatus,this.status);
Assert.assertEquals(msg + ": Response.reason",expectedReason,this.reason);
}
public void assertStatus(String msg, int expectedStatus)
{
assertStatus(msg,expectedStatus,HttpStatus.getMessage(expectedStatus));
}
public void assertContentType(String expectedType)
{
assertHeader("Content-Type",expectedType);
}
private void assertHeader(String headerKey, String expectedValue)
{
String actual = fields.getStringField(headerKey);
Assert.assertNotNull("Response[" + headerKey + "] should not be null",actual);
Assert.assertEquals("Response[" + headerKey + "]",expectedValue,actual);
}
public void assertHeader(String msg, String headerKey, String expectedValue)
{
String actual = fields.getStringField(headerKey);
Assert.assertNotNull(msg + ": Response[" + headerKey + "] should not be null, expecting <" + expectedValue + ">",actual);
Assert.assertEquals(msg + ": Response[" + headerKey + "]",expectedValue,actual);
}
public void assertBody(String expected)
{
Assert.assertNotNull("Response.content should not be null",this.content);
Assert.assertEquals("Response.content",expected,this.content.toString());
}
public void assertBody(String msg, String expected)
{
Assert.assertNotNull(msg + ": Response.content should not be null",this.content);
Assert.assertEquals(msg + ": Response.content",expected,this.content.toString());
}
public void assertNoBody(String msg)
{
Assert.assertNull(msg + ": Response.content should be null",this.content);
}
public void assertBodyContains(String msg, String expectedNeedle)
{
StringAssert.assertContains(msg + ": Response Content",this.content.toString(),expectedNeedle);
}
public void assertHeaderExists(String msg, String expectedHeaderKey)
{
Assert.assertTrue(msg + ": header <" + expectedHeaderKey + "> should exist",fields.containsKey(expectedHeaderKey));
}
public void assertHeaderNotPresent(String msg, String headerKey)
{
Assert.assertFalse(msg + ": header <" + headerKey + "> should NOT exist",fields.containsKey(headerKey));
}
public List<HttpResponseTester> findBodyMultiparts(String boundary) throws IOException
{
List<HttpResponseTester> multiparts = new ArrayList<HttpResponseTester>();
BufferedReader buf = new BufferedReader(new StringReader(getBody()));
String line;
String startBoundary = "--" + boundary;
String endBoundary = "--" + boundary + "--";
HttpResponseTester resp = null;
boolean parsingHeader = true;
boolean previousBodyLine = false;
while ((line = buf.readLine()) != null)
{
if (line.equals(startBoundary))
{
// end of multipart, start a new one.
if (resp != null)
{
multiparts.add(resp);
}
resp = new HttpResponseTester();
parsingHeader = true;
previousBodyLine = false;
continue;
}
if (line.equals(endBoundary))
{
if (resp != null)
{
multiparts.add(resp);
}
break;
}
if (parsingHeader)
{
if (line.equals(""))
{
parsingHeader = false;
continue;
}
resp.parseHeader(line);
}
else
{
if (previousBodyLine)
{
resp.appendBody("\n");
}
resp.appendBody(line);
previousBodyLine = true;
}
}
return multiparts;
}
public void parseHeader(String line)
{
int idx = line.indexOf(":");
String key = line.substring(0,idx).trim();
String val = line.substring(idx + 1).trim();
fields.add(key,val);
}
public void appendBody(String s) throws IOException
{
appendBody(s.getBytes());
}
public void appendBody(byte buf[]) throws IOException
{
if (content == null)
{
content = new ByteArrayOutputStream2();
}
content.write(buf);
}
}

View File

@ -0,0 +1,113 @@
// ========================================================================
// 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.test.support.rawhttp;
import java.io.IOException;
import java.util.List;
import org.eclipse.jetty.test.AbstractJettyTestCase;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.junit.Test;
public class HttpResponseTesterTest extends AbstractJettyTestCase
{
@Test
public void testHttp11Response() throws IOException
{
StringBuffer rawResponse = new StringBuffer();
rawResponse.append("HTTP/1.1 200 OK\n");
rawResponse.append("Date: Mon, 08 Jun 2009 22:56:04 GMT\n");
rawResponse.append("Content-Type: text/plain\n");
rawResponse.append("Content-Length: 28\n");
rawResponse.append("Last-Modified: Mon, 08 Jun 2009 17:06:22 GMT\n");
rawResponse.append("Connection: close\n");
rawResponse.append("Server: Jetty(7.0.y.z-SNAPSHOT\n");
rawResponse.append("\n");
rawResponse.append("ABCDEFGHIJKLMNOPQRSTTUVWXYZ\n");
rawResponse.append("\n");
HttpResponseTester response = new HttpResponseTester();
response.parse(rawResponse);
assertEquals("Response.version","HTTP/1.1",response.getVersion());
assertEquals("Response.status",200,response.getStatus());
assertEquals("Response.reason","OK",response.getReason());
assertEquals("Response[Content-Type]","text/plain",response.getContentType());
assertEquals("Response[Content-Length]",28,response.getLongHeader("Content-Length"));
assertEquals("Response[Connection]","close",response.getHeader("Connection"));
assertEquals("Response.content","ABCDEFGHIJKLMNOPQRSTTUVWXYZ\n",response.getContent().toString());
}
@Test
public void testMultHttp11Response() throws IOException
{
StringBuffer rawResponse = new StringBuffer();
rawResponse.append("HTTP/1.1 200 OK\n");
rawResponse.append("Date: Mon, 08 Jun 2009 23:05:26 GMT\n");
rawResponse.append("Content-Type: text/plain\n");
rawResponse.append("Content-Length: 28\n");
rawResponse.append("Last-Modified: Mon, 08 Jun 2009 17:06:22 GMT\n");
rawResponse.append("Server: Jetty(7.0.y.z-SNAPSHOT)\n");
rawResponse.append("\n");
rawResponse.append("ABCDEFGHIJKLMNOPQRSTTUVWXYZ\n");
rawResponse.append("HTTP/1.1 200 OK\n");
rawResponse.append("Date: Mon, 08 Jun 2009 23:05:26 GMT\n");
rawResponse.append("Content-Type: text/plain\n");
rawResponse.append("Content-Length: 25\n");
rawResponse.append("Last-Modified: Mon, 08 Jun 2009 17:06:22 GMT\n");
rawResponse.append("Server: Jetty(7.0.y.z-SNAPSHOT)\n");
rawResponse.append("\n");
rawResponse.append("Host=Default\n");
rawResponse.append("Resource=R1\n");
rawResponse.append("HTTP/1.1 200 OK\n");
rawResponse.append("Date: Mon, 08 Jun 2009 23:05:26 GMT\n");
rawResponse.append("Content-Type: text/plain\n");
rawResponse.append("Content-Length: 25\n");
rawResponse.append("Last-Modified: Mon, 08 Jun 2009 17:06:22 GMT\n");
rawResponse.append("Connection: close\n");
rawResponse.append("Server: Jetty(7.0.y.z-SNAPSHOT)\n");
rawResponse.append("\n");
rawResponse.append("Host=Default\n");
rawResponse.append("Resource=R2\n");
rawResponse.append("\n");
List<HttpResponseTester> responses = HttpResponseTester.parseMulti(rawResponse);
assertNotNull("Responses should not be null",responses);
assertEquals("Responses.size",3,responses.size());
HttpResponseTester resp1 = responses.get(0);
resp1.assertStatusOK();
resp1.assertContentType("text/plain");
resp1.assertBody("ABCDEFGHIJKLMNOPQRSTTUVWXYZ\n");
assertThat(resp1.getHeader("Connection"),is(not("close")));
HttpResponseTester resp2 = responses.get(1);
resp2.assertStatusOK();
resp2.assertContentType("text/plain");
resp2.assertBody("Host=Default\nResource=R1\n");
assertThat(resp2.getHeader("Connection"),is(not("close")));
HttpResponseTester resp3 = responses.get(2);
resp3.assertStatusOK();
resp3.assertContentType("text/plain");
resp3.assertBody("Host=Default\nResource=R2\n");
assertThat(resp3.getHeader("Connection"),is("close"));
}
}

View File

@ -0,0 +1,29 @@
// ========================================================================
// 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.test.support.rawhttp;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
/**
* A Raw HTTP Socket connection interface.
*/
public interface HttpSocket
{
Socket connect(InetAddress host, int port) throws IOException;
}

View File

@ -0,0 +1,32 @@
// ========================================================================
// 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.test.support.rawhttp;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
/**
* Standard HTTP Socket Impl
*/
public class HttpSocketImpl implements HttpSocket
{
public Socket connect(InetAddress host, int port) throws IOException
{
return new Socket(host,port);
}
}

View File

@ -0,0 +1,298 @@
// ========================================================================
// 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.test.support.rawhttp;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.List;
import org.eclipse.jetty.test.StringAssert;
import org.eclipse.jetty.test.support.StringUtil;
import org.eclipse.jetty.util.IO;
/**
* Testing utility for performing RAW HTTP request/response.
*/
public class HttpTesting
{
private boolean debug = false;
private HttpSocket httpSocket;
private InetAddress serverHost;
private int serverPort;
private int timeoutMillis = 5000;
public HttpTesting(HttpSocket httpSocket, InetAddress host, int port)
{
this.httpSocket = httpSocket;
this.serverHost = host;
this.serverPort = port;
}
public HttpTesting(HttpSocket socket, int port) throws UnknownHostException
{
this(socket,InetAddress.getLocalHost(),port);
}
public HttpTesting(HttpSocket socket, String host, int port) throws UnknownHostException
{
this(socket,InetAddress.getByName(host),port);
}
public void close(Socket sock)
{
if (sock != null)
{
try
{
sock.close();
}
catch (IOException e)
{
System.err.println("Unable to close socket: " + sock);
e.printStackTrace(System.err);
}
}
}
private void DEBUG(String msg)
{
if (debug)
{
System.out.println(msg);
}
}
public void enableDebug()
{
this.debug = true;
}
public int getTimeoutMillis()
{
return timeoutMillis;
}
/**
* Open a socket.
*
* @return the open socket.
* @throws IOException
*/
public Socket open() throws IOException
{
Socket sock = httpSocket.connect(serverHost,serverPort);
sock.setSoTimeout(timeoutMillis);
return sock;
}
/**
* Read a response from a socket.
*
* @param sock
* the socket to read from.
* @return the response object
* @throws IOException
*/
public HttpResponseTester read(Socket sock) throws IOException
{
HttpResponseTester response = new HttpResponseTester();
response.parse(readRaw(sock));
return response;
}
/**
* Read any available response from a socket.
*
* @param sock
* the socket to read from.
* @return the response object
* @throws IOException
*/
public HttpResponseTester readAvailable(Socket sock) throws IOException
{
HttpResponseTester response = new HttpResponseTester();
String rawResponse = readRawAvailable(sock);
if (StringUtil.isBlank(rawResponse))
{
return null;
}
response.parse(rawResponse);
return response;
}
/**
* Read the raw response from the socket.
*
* @param sock
* @return
* @throws IOException
*/
public String readRaw(Socket sock) throws IOException
{
sock.setSoTimeout(timeoutMillis);
// Collect response
String rawResponse = IO.toString(sock.getInputStream());
DEBUG("--raw-response--\n" + rawResponse);
return rawResponse;
}
/**
* Read the raw response from the socket, reading whatever is available. Any SocketTimeoutException is consumed and just stops the reading.
*
* @param sock
* @return
* @throws IOException
*/
public String readRawAvailable(Socket sock) throws IOException
{
sock.setSoTimeout(timeoutMillis);
// Collect response
StringWriter writer = new StringWriter();
InputStreamReader reader = new InputStreamReader(sock.getInputStream());
try
{
IO.copy(reader,writer);
}
catch (SocketTimeoutException e)
{
/* ignore */
}
String rawResponse = writer.toString();
DEBUG("--raw-response--\n" + rawResponse);
return rawResponse;
}
/**
* Initiate a standard HTTP request, parse the response.
*
* Note: not for HTTPS requests.
*
* @param request
* the request
* @return the response
* @throws IOException
*/
public HttpResponseTester request(CharSequence rawRequest) throws IOException
{
Socket sock = open();
try
{
send(sock,rawRequest);
return read(sock);
}
finally
{
close(sock);
}
}
/**
* Initiate a standard HTTP request, parse the response.
*
* Note: not for HTTPS requests.
*
* @param request
* the request
* @return the response
* @throws IOException
*/
public HttpResponseTester request(HttpRequestTester request) throws IOException
{
String rawRequest = request.generate();
return request(rawRequest);
}
/**
* Initiate multiple raw HTTP requests, parse the responses.
*
* @param rawRequests
* the raw HTTP requests.
* @return the responses.
* @throws IOException
*/
public List<HttpResponseTester> requests(CharSequence rawRequests) throws IOException
{
Socket sock = open();
try
{
send(sock,rawRequests);
// Collect response
String rawResponses = IO.toString(sock.getInputStream());
DEBUG("--raw-response--\n" + rawResponses);
return HttpResponseTester.parseMulti(rawResponses);
}
finally
{
close(sock);
}
}
/**
* Initiate a multiple HTTP requests, parse the responses
*
* @param requests
* the request objects.
* @return the response objects.
* @throws IOException
*/
public List<HttpResponseTester> requests(List<HttpRequestTester> requests) throws IOException
{
StringBuffer rawRequest = new StringBuffer();
for (HttpRequestTester request : requests)
{
rawRequest.append(request.generate());
}
return requests(rawRequest);
}
/**
* Send a data (as request) to open socket.
*
* @param sock
* the socket to send the request to
* @param rawData
* the raw data to send.
* @throws IOException
*/
public void send(Socket sock, CharSequence rawData) throws IOException
{
sock.setSoTimeout(timeoutMillis);
DEBUG("--raw-request--\n" + rawData.toString());
InputStream in = new ByteArrayInputStream(rawData.toString().getBytes());
// Send request
IO.copy(in,sock.getOutputStream());
}
public void setTimeoutMillis(int timeoutMillis)
{
this.timeoutMillis = timeoutMillis;
}
}

View File

@ -0,0 +1,95 @@
// ========================================================================
// 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.test.support.rawhttp;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.eclipse.jetty.util.log.Log;
/**
* An HTTPS Socket Impl
*/
public class HttpsSocketImpl implements HttpSocket
{
private SSLContext sslContext;
private SSLSocketFactory sslfactory;
public HttpsSocketImpl() throws Exception
{
// Create loose SSL context.
// Create a trust manager that does not validate certificate
// chains
TrustManager[] trustAllCerts = new TrustManager[]
{ new X509TrustManager()
{
public java.security.cert.X509Certificate[] getAcceptedIssuers()
{
return null;
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
{
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
{
}
} };
HostnameVerifier hostnameVerifier = new HostnameVerifier()
{
public boolean verify(String urlHostName, SSLSession session)
{
Log.warn("Warning: URL Host: " + urlHostName + " vs." + session.getPeerHost());
return true;
}
};
// Install the all-trusting trust manager
try
{
// TODO real trust manager
this.sslContext = SSLContext.getInstance("SSL");
sslContext.init(null,trustAllCerts,new java.security.SecureRandom());
}
catch (Exception e)
{
throw new IOException("issue ignoring certs");
}
sslfactory = sslContext.getSocketFactory();
}
public Socket connect(InetAddress host, int port) throws IOException
{
Socket sslsock = sslfactory.createSocket();
SocketAddress address = new InetSocketAddress(host,port);
sslsock.connect(address);
return sslsock;
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.bio.SocketConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
</New>
</Arg>
</Call>
</Configure>

View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSocketConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="keystore"><Property name="test.resourcesdir" default="src/test/resources" />/keystore</Set>
<Set name="password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
<Set name="keyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
<!--
<Set name="truststore"><Property name="test.resourcesdir" default="src/test/resources" />/keystore</Set>
<Set name="trustPassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
-->
</New>
</Arg>
</Call>
</Configure>

View File

@ -0,0 +1,72 @@
<?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">
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="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>
<!-- =========================================================== -->
<!-- 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="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/tests</Set>
<Set name="ResourceBase"><Property name="test.docroot.base"/>/default</Set>
<Set name="Handler"><New id="reshandler" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
<Set name="DisplayName">default</Set>
</New>
</Item>
</Array>
</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
</Configure>

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
</Configure>

View File

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
<Set name="keystore"><Property name="test.resourcesdir" default="src/test/resources" />/keystore</Set>
<Set name="password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
<Set name="keyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
</New>
</Arg>
</Call>
</Configure>

View File

@ -0,0 +1,148 @@
<?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">
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- No connectors Set Here. -->
<!-- See: -->
<!-- BIOHttp.xml -->
<!-- BIOHttps.xml -->
<!-- NIOHttp.xml -->
<!-- NIOHttps.xml -->
<!-- =========================================================== -->
<!--
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="0"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
-->
<!-- =========================================================== -->
<!-- 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="vcontexts" class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/tests</Set>
<Set name="VirtualHosts">
<Array type="java.lang.String">
<Item>VirtualHost</Item>
</Array>
</Set>
<Set name="ResourceBase"><Property name="test.docroot.base"/>/virtualhost</Set>
<Set name="Handler"><New id="reshandler" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
<Set name="DisplayName">virtual</Set>
</New>
</Item>
<Item>
<New id="defcontext" class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/tests</Set>
<Set name="ResourceBase"><Property name="test.docroot.base"/>/default</Set>
<Set name="Handler"><New id="reshandler" class="org.eclipse.jetty.server.handler.ResourceHandler"/></Set>
<Set name="DisplayName">default</Set>
</New>
</Item>
<Item>
<New id="echocontext" class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/echo</Set>
<Set name="Handler"><New id="echohandler" class="org.eclipse.jetty.test.support.EchoHandler"/></Set>
<Set name="DisplayName">echo</Set>
</New>
</Item>
</Array>
</Set>
</New>
</Set>
<Call name="addLifeCycle">
<Arg>
<New class="org.eclipse.jetty.deploy.ContextDeployer">
<Set name="contexts"><Ref id="WebappContexts"/></Set>
<Set name="configurationDir"><Property name="test.resourcesdir" default="src/test/resources"/>/webapp-contexts/RFC2616</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"/>/testable-jetty-server-config.properties</Set>
</New>
</Set>
</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="WebappContexts"/></Set>
<Set name="webAppDir"><Property name="test.targetdir" default="target"/>/webapps</Set>
<Set name="parentLoaderPriority">false</Set>
<Set name="extract">true</Set>
<Set name="allowDuplicates">false</Set>
<Set name="defaultsDescriptor"><Property name="test.resourcesdir" default="src/test/resources"/>/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>
-->
<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
</Configure>

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
</Configure>

View File

@ -0,0 +1,54 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Configure Rewrite Handler -->
<!-- =========================================================== -->
<Get id="oldhandler" name="handler"/>
<Set name="handler">
<New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
<Set name="handler"><Ref id="oldhandler"/></Set>
<Set name="rewriteRequestURI">true</Set>
<Set name="rewritePathInfo">false</Set>
<Set name="originalPathAttribute">requestedPath</Set>
<Set name="rules">
<Array type="org.eclipse.jetty.rewrite.handler.Rule">
<!-- add a response rule -->
<!--
<Item>
<New id="response" class="org.eclipse.jetty.rewrite.handler.ResponsePatternRule">
<Set name="pattern">/rewrite/session/</Set>
<Set name="code">401</Set>
<Set name="reason">Setting error code 401</Set>
</New>
</Item>
-->
<!-- add a simple redirect -->
<!--
<Item>
<New id="redirect" class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
<Set name="pattern">/redirect/*</Set>
<Set name="location">/tests/</Set>
</New>
</Item>
-->
<!-- add a regex rewrite redirect -->
<Item>
<New id="redirect" class="org.eclipse.jetty.rewrite.handler.RedirectRegexRule">
<Set name="regex">/redirect/(.*)</Set>
<Set name="replacement">/tests/$1</Set>
</New>
</Item>
</Array>
</Set>
</New>
</Set>
</Configure>

View File

@ -0,0 +1,2 @@
Host=Default
Resource=R1

View File

@ -0,0 +1,2 @@
Host=Default
Resource=R2

View File

@ -0,0 +1,2 @@
Host=Default
Resource=R3

View File

@ -0,0 +1 @@
ABCDEFGHIJKLMNOPQRSTUVWXYZ

View File

@ -0,0 +1,8 @@
<html>
<head>
<title>Default DOCRoot</title>
</head>
<body>
<h1>Default DOCRoot</h1>
</body>
</html>

View File

@ -0,0 +1,14 @@
"The scientist. He will
spend thirty years in
building up a mountain
range of facts with
the intent to prove a
certain theory; then
he is so happy in his
achievement that as a
rule he overlooks the
main chief fact of all
-- that his accumulation
proves an entirely different
thing."
- Mark Twain

View File

@ -0,0 +1,2 @@
Host=Virtual
Resource=R1

View File

@ -0,0 +1,2 @@
Host=Virtual
Resource=R2

View File

@ -0,0 +1,2 @@
Host=Virtual
Resource=R3

View File

@ -0,0 +1,8 @@
<html>
<head>
<title>VirtualHost DOCRoot</title>
</head>
<body>
<h1>VirtualHost DOCRoot</h1>
</body>
</html>

Binary file not shown.

View File

@ -0,0 +1,8 @@
<?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">/rfc2616-webapp</Set>
<Set name="war">
<Property name="test.webapps" default="." />/test-webapp-rfc2616.war
</Set>
</Configure>

View File

@ -0,0 +1,404 @@
<?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
tests/test-webapps/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*/src/main/webapp/META-INF

View File

@ -0,0 +1,38 @@
<?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.tests</groupId>
<artifactId>tests-parent</artifactId>
<version>7.0.0.M4-SNAPSHOT</version>
</parent>
<artifactId>test-webapps-parent</artifactId>
<name>Jetty Tests :: WebApps :: Parent</name>
<packaging>pom</packaging>
<build>
</build>
<modules>
<module>test-webapp-rfc2616</module>
<module>test-webapp-logging-commons</module>
<module>test-webapp-logging-java</module>
<module>test-webapp-logging-log4j</module>
<module>test-webapp-logging-slf4j</module>
</modules>
</project>

View File

@ -0,0 +1,44 @@
<?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.tests</groupId>
<artifactId>test-webapps-parent</artifactId>
<version>7.0.0.M4-SNAPSHOT</version>
</parent>
<artifactId>test-webapp-logging-commons</artifactId>
<name>Jetty Tests :: WebApp :: Commons Logging</name>
<packaging>war</packaging>
<build>
</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>

View File

@ -0,0 +1,54 @@
// ========================================================================
// 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.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 Log log = LogFactory.getLog(LoggingServlet.class);
/**
* @see HttpServlet#HttpServlet()
*/
public LoggingServlet()
{
log.debug("LoggingServlet(commons-logging) initialized");
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
log.info("LoggingServlet(commons-logging) GET requested");
}
}

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -0,0 +1,22 @@
<?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>

View File

@ -0,0 +1,39 @@
<?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.tests</groupId>
<artifactId>test-webapps-parent</artifactId>
<version>7.0.0.M4-SNAPSHOT</version>
</parent>
<artifactId>test-webapp-logging-java</artifactId>
<name>Jetty Tests :: WebApp :: JavaSE Logging</name>
<packaging>war</packaging>
<build>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,53 @@
// ========================================================================
// 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.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 Logger log = Logger.getLogger(LoggingServlet.class.getName());
/**
* @see HttpServlet#HttpServlet()
*/
public LoggingServlet()
{
log.log(Level.FINE,"LoggingServlet(java) initialized");
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
log.log(Level.INFO,"LoggingServlet(log4j) initialized");
}
}

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -0,0 +1,22 @@
<?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>

View File

@ -0,0 +1,62 @@
<?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.tests</groupId>
<artifactId>test-webapps-parent</artifactId>
<version>7.0.0.M4-SNAPSHOT</version>
</parent>
<artifactId>test-webapp-logging-log4j</artifactId>
<name>Jetty Tests :: WebApp :: Log4J Logging</name>
<packaging>war</packaging>
<build>
</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>

View File

@ -0,0 +1,51 @@
// ========================================================================
// 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.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 Logger log = Logger.getLogger(LoggingServlet.class);
/**
* @see HttpServlet#HttpServlet()
*/
public LoggingServlet()
{
log.debug("LoggingServlet(log4j) initialized");
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
log.info("LoggingServlet(log4j) GET requested");
}
}

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -0,0 +1,22 @@
<?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>

View File

@ -0,0 +1,44 @@
<?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.tests</groupId>
<artifactId>test-webapps-parent</artifactId>
<version>7.0.0.M4-SNAPSHOT</version>
</parent>
<artifactId>test-webapp-logging-slf4j</artifactId>
<name>Jetty Tests :: WebApp :: Slf4J Logging</name>
<packaging>war</packaging>
<build>
</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>

View File

@ -0,0 +1,53 @@
// ========================================================================
// 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.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 Logger log = LoggerFactory.getLogger(LoggingServlet.class);
/**
* Default constructor.
*/
public LoggingServlet()
{
log.debug("LoggingServlet(slf4j) initialized");
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
log.info("LoggingServlet(slf4j) GET requested");
}
}

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -0,0 +1,22 @@
<?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>

View File

@ -0,0 +1,44 @@
<?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.tests</groupId>
<artifactId>test-webapps-parent</artifactId>
<version>7.0.0.M4-SNAPSHOT</version>
</parent>
<artifactId>test-webapp-rfc2616</artifactId>
<name>Jetty Tests :: WebApp :: RFC2616</name>
<packaging>war</packaging>
<build>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,114 @@
// ========================================================================
// 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.IOException;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet declaring the various do* methods.
*
* The Jetty internals for OPTIONS should detect the declared do* methods and
* return an appropriate listing of available OPTIONS on an OPTIONS request.
*/
public class HttpMethodsServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public HttpMethodsServlet()
{
super();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
/* do nothing */
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
/* do nothing */
}
/**
* @see HttpServlet#doPut(HttpServletRequest, HttpServletResponse)
*/
protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
/* do nothing */
}
/**
* @see HttpServlet#doDelete(HttpServletRequest, HttpServletResponse)
*/
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
/* do nothing */
}
/**
* @see HttpServlet#doHead(HttpServletRequest, HttpServletResponse)
*/
protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
/* do nothing */
}
/**
* @see HttpServlet#doTrace(HttpServletRequest, HttpServletResponse)
*/
protected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.addHeader("Content-Type","message/http");
StringBuffer msg = new StringBuffer();
msg.append(request.getMethod()).append(' ');
msg.append(request.getRequestURI()).append(' ');
msg.append(request.getProtocol()).append("\n");
// Now the headers
Enumeration enNames = request.getHeaderNames();
while (enNames.hasMoreElements())
{
String name = (String)enNames.nextElement();
Enumeration enValues = request.getHeaders(name);
while (enValues.hasMoreElements())
{
String value = (String)enValues.nextElement();
msg.append(name).append(": ").append(value).append("\n");
}
}
msg.append("\n");
response.getWriter().print(msg.toString());
}
}

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -0,0 +1,31 @@
<?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>rfc2616-webapp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>GZIPFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
<init-param>
<param-name>minGzipSize</param-name>
<param-value>1024</param-value>
</init-param>
<init-param>
<param-name>bufferSize</param-name>
<param-value>16384</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>GZIPFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>HttpMethodsServlet</servlet-name>
<servlet-class>org.eclipse.jetty.tests.webapp.HttpMethodsServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HttpMethodsServlet</servlet-name>
<url-pattern>/httpmethods</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -0,0 +1 @@
ABCDEFGHIJKLMNOPQRSTUVWXYZ

View File

@ -0,0 +1,153 @@
<html>
<head>
<title>Quotable "Solutions"</title>
<style type="text/css">
body {
font-family: sans-serif;
}
h1 {
background-color: black;
color: white;
padding: 5px;
}
ul li {
list-style: none;
margin-top: 10px;
}
li .author {
color: #777;
margin-left: 20px;
font-style: italic;
}
</style>
</head>
<body bgcolor="white">
<h1>Quotable "Solutions"</h1>
<ul>
<li>
An undefined problem has an infinite number of solutions.
<div class="author">Robert A. Humphrey</div>
</li>
<li>
There is always a well-known solution to every human problem--neat, plausible, and wrong.
<div class="author">H. L. Mencken (1880 - 1956), The Divine Afflatus / Prejudices: Second Series, 1920</div>
</li>
<li>
If you're not part of the solution, you're part of the precipitate.
<div class="author">Henry J. Tillman</div>
</li>
<li>
Two paradoxes are better than one; they may even suggest a solution.
<div class="author">Edward Teller (1908 - 2003)</div>
</li>
<li>
The direct use of force is such a poor solution to any problem, it is generally employed only by small children and large nations.
<div class="author">David Friedman</div>
</li>
<li>
When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong.
<div class="author">R. Buckminster Fuller (1895 - 1983)</div>
</li>
<li>
We are at the very beginning of time for the human race. It is not unreasonable that we grapple with problems. But there are tens of thousands of years in the future. Our responsibility is to do what we can, learn what we can, improve the solutions, and pass them on.
<div class="author">Richard Feynman (1918 - 1988)</div>
</li>
<li>
It's so much easier to suggest solutions when you don't know too much about the problem.
<div class="author">Malcolm Forbes (1919 - 1990)</div>
</li>
<li>
The greatest challenge to any thinker is stating the problem in a way that will allow a solution.
<div class="author">Bertrand Russell (1872 - 1970)</div>
</li>
<li>
All progress is precarious, and the solution of one problem brings us face to face with another problem.
<div class="author">Martin Luther King Jr. (1929 - 1968), 'Strength to Love,' 1963</div>
</li>
<li>
It isn't that they can't see the solution. It is that they can't see the problem.
<div class="author">G. K. Chesterton (1874 - 1936), Scandal of Father Brown (1935)</div>
</li>
<li>
Focus 90% of your time on solutions and only 10% of your time on problems.
<div class="author">Anthony J. D'Angelo, The College Blue Book</div>
</li>
<li>
Within the problem lies the solution
<div class="author">Milton Katselas</div>
</li>
<li>
Good management is the art of making problems so interesting and their solutions so constructive that everyone wants to get to work and deal with them.
<div class="author">Paul Hawken, Growing a Business</div>
</li>
<li>
An old puzzle asks how a barometer can be used to measure the height of a building. Answers range from dropping the instrument from the top and measuring the time of its fall to giving it to the building's superintendent in return for a look at the plans. A modern version of the puzzle asks how a personal computer can balance a checkbook. An elegant solution is to sell the machine and deposit the money.
<div class="author">Jon Bentley, More Programming Pearls</div>
</li>
<li>
Believe it can be done. When you believe something can be done, really believe, your mind will find the ways to do it. Believing a solution paves the way to solution.
<div class="author">Dr. David Schwartz</div>
</li>
<li>
To doubt everything or to believe everything are two equally convenient solutions; both dispense with the necessity of reflection.
<div class="author">Henri Poincare</div>
</li>
<li>
I have not failed. I've just found 10,000 ways that don't work.
<div class="author">Thomas Alva Edison</div>
</li>
<li>
Any solution to a problem changes the problem.
<div class="author">R.W. (Richard William) Johnson (b. 1916), U.S. journalist. Washingtonian (November 1979).</div>
</li>
<li>
Whatever creativity is, it is in part a solution to a problem.
<div class="author">Brian Aldiss (b. 1925), British science fiction writer.</div>
</li>
<li>
Only he is an artist who can make a riddle out of a solution.
<div class="author">Karl Kraus (1874 - 1936), Austrian writer.</div>
</li>
<li>
There is nothing more productive of problems than a really good solution.
<div class="author">Dr Nathan S Kline</div>
</li>
<li>
The problem is that we attempt to solve the simplest questions cleverly, thereby rendering them unusually complex. One should seek the simple solution.
<div class="author">Anton Pavlovich Chekhov (1860 - 1904), Russian author, playwright.</div>
</li>
<li>
Mankind always sets itself only such tasks as it can solve; since, looking at the matter more closely, we will always find that the task itself arises only when the material conditions necessary for its solution already exist or are at least in the process of formation.
<div class="author">Karl Marx (1818 - 1883), German political theorist, social philosopher.</div>
</li>
</ul>
</body>
</html>