Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2013-11-29 06:33:05 +0000
committerGreg Wilkins2013-11-29 06:33:05 +0000
commitf1fc661a2cf0f5c25d592f7c0b7124344e2fb035 (patch)
tree03da744c0df33789d0c5816a33352a9c20b8ff3e
parent51e82b4c5c8da918a21df84c331fcd55d7b51749 (diff)
downloadorg.eclipse.jetty.project-f1fc661a2cf0f5c25d592f7c0b7124344e2fb035.tar.gz
org.eclipse.jetty.project-f1fc661a2cf0f5c25d592f7c0b7124344e2fb035.tar.xz
org.eclipse.jetty.project-f1fc661a2cf0f5c25d592f7c0b7124344e2fb035.zip
reenabled integration and RFC2616 tests
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java1
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java3
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java7
-rw-r--r--jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java2
-rw-r--r--jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java8
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java1
-rw-r--r--jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java46
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java7
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java1
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java7
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java25
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java4
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java1
-rw-r--r--tests/pom.xml2
-rw-r--r--tests/test-integration/pom.xml2
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java131
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java3
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java5
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpTesting.java3
-rw-r--r--tests/test-integration/src/test/resources/RFC2616Base.xml4
20 files changed, 187 insertions, 76 deletions
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java
index 392cbc0d64..4be72b7aed 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/App.java
@@ -83,6 +83,7 @@ public class App
return _provider;
}
+ /* ------------------------------------------------------------ */
/**
* Get ContextHandler for the App.
*
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
index 7bf0b07e6c..1a9abac15c 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
@@ -217,6 +217,9 @@ public class DeploymentManager extends ContainerLifeCycle
@Override
protected void doStart() throws Exception
{
+ if (getContexts()==null)
+ throw new IllegalStateException("No Contexts");
+
if (_useStandardBindings)
{
LOG.debug("DeploymentManager using standard bindings");
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
index 8d1c997f20..ba1abaec9e 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
@@ -133,7 +133,12 @@ public abstract class ScanningAppProvider extends AbstractLifeCycle implements A
LOG.info("Deployment monitor " + _monitored + " at interval " + _scanInterval);
List<File> files = new ArrayList<>();
for (Resource resource:_monitored)
- files.add(resource.getFile());
+ {
+ if (resource.exists() && resource.getFile().canRead())
+ files.add(resource.getFile());
+ else
+ LOG.warn("Does not exist: "+resource);
+ }
_scanner = new Scanner();
_scanner.setScanDirs(files);
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java
index 4383465192..4b75a8aa69 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java
@@ -36,6 +36,7 @@ public class DeploymentManagerLifeCyclePathTest
public void testStateTransition_NewToDeployed() throws Exception
{
DeploymentManager depman = new DeploymentManager();
+ depman.setContexts(new ContextHandlerCollection());
depman.setDefaultLifeCycleGoal(null); // no default
AppLifeCyclePathCollector pathtracker = new AppLifeCyclePathCollector();
MockAppProvider mockProvider = new MockAppProvider();
@@ -68,6 +69,7 @@ public class DeploymentManagerLifeCyclePathTest
public void testStateTransition_Receive() throws Exception
{
DeploymentManager depman = new DeploymentManager();
+ depman.setContexts(new ContextHandlerCollection());
depman.setDefaultLifeCycleGoal(null); // no default
AppLifeCyclePathCollector pathtracker = new AppLifeCyclePathCollector();
MockAppProvider mockProvider = new MockAppProvider();
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java
index c1998a2761..a147249f6b 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerTest.java
@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.Set;
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
+import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.toolchain.test.TestingDir;
import org.junit.Assert;
import org.junit.Rule;
@@ -29,13 +30,14 @@ import org.junit.Test;
public class DeploymentManagerTest
{
- @Rule
- public TestingDir testdir = new TestingDir();
+ @Rule
+ public TestingDir testdir = new TestingDir();
- @Test
+ @Test
public void testReceiveApp() throws Exception
{
DeploymentManager depman = new DeploymentManager();
+ depman.setContexts(new ContextHandlerCollection());
depman.setDefaultLifeCycleGoal(null); // no default
AppLifeCyclePathCollector pathtracker = new AppLifeCyclePathCollector();
MockAppProvider mockProvider = new MockAppProvider();
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java
index 0befc6ea32..c83a827370 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java
@@ -28,6 +28,7 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.Trie;
import org.eclipse.jetty.util.TypeUtil;
+import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java
index 72a12dd973..94884effec 100644
--- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java
+++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java
@@ -31,6 +31,7 @@ import java.util.List;
import org.eclipse.jetty.http.HttpParser.State;
import org.eclipse.jetty.util.BufferUtil;
import org.hamcrest.Matchers;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -1177,6 +1178,51 @@ public class HttpParserTest
}
@Test
+ public void testUriHost11() throws Exception
+ {
+ ByteBuffer buffer= BufferUtil.toBuffer(
+ "GET http://host/ HTTP/1.1\015\012"
+ + "Connection: close\015\012"
+ + "\015\012");
+
+ HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
+ HttpParser parser= new HttpParser(handler);
+ parser.parseNext(buffer);
+ assertEquals("No Host",_bad);
+ assertEquals("http://host/",_uriOrStatus);
+ assertEquals(0,_port);
+ }
+
+ @Test
+ public void testUriHost10() throws Exception
+ {
+ ByteBuffer buffer= BufferUtil.toBuffer(
+ "GET http://host/ HTTP/1.0\015\012"
+ + "\015\012");
+
+ HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
+ HttpParser parser= new HttpParser(handler);
+ parser.parseNext(buffer);
+ Assert.assertNull(_bad);
+ assertEquals("http://host/",_uriOrStatus);
+ assertEquals(0,_port);
+ }
+
+ @Test
+ public void testNoHost() throws Exception
+ {
+ ByteBuffer buffer= BufferUtil.toBuffer(
+ "GET / HTTP/1.1\015\012"
+ + "Connection: close\015\012"
+ + "\015\012");
+
+ HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
+ HttpParser parser= new HttpParser(handler);
+ parser.parseNext(buffer);
+ assertEquals("No Host",_bad);
+ }
+
+ @Test
public void testIPHost() throws Exception
{
ByteBuffer buffer= BufferUtil.toBuffer(
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
index 9019594cef..9daa5235ee 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
@@ -603,8 +603,11 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
@Override
public boolean parsedHostHeader(String host, int port)
{
- _request.setServerName(host);
- _request.setServerPort(port);
+ if (_uri.getHost()==null)
+ {
+ _request.setServerName(host);
+ _request.setServerPort(port);
+ }
return false;
}
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java b/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java
index fa25e9522b..5e29949bdf 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java
@@ -102,6 +102,7 @@ public class DumpHandler extends AbstractHandler
writer.write("<pre>\npathInfo="+request.getPathInfo()+"\n</pre>\n");
writer.write("<pre>\ncontentType="+request.getContentType()+"\n</pre>\n");
writer.write("<pre>\nencoding="+request.getCharacterEncoding()+"\n</pre>\n");
+ writer.write("<pre>\nservername="+request.getServerName()+"\n</pre>\n");
writer.write("<h3>Header:</h3><pre>");
writer.write(request.getMethod()+" "+request.getRequestURI()+" "+request.getProtocol()+"\n");
Enumeration<String> headers = request.getHeaderNames();
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java b/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java
index 9e290ab2ec..36dc0faf34 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java
@@ -339,9 +339,10 @@ public class PartialRFC2616Test
// Default Host
int offset=0;
String response = connector.getResponses("GET http://VirtualHost:8888/path/R1 HTTP/1.1\n" + "Host: wronghost\n" + "Connection: close\n" + "\n");
- offset=checkContains(response,offset,"HTTP/1.1 200","Default host")+1;
- offset=checkContains(response,offset,"Dump HttpHandler","Default host")+1;
- offset=checkContains(response,offset,"pathInfo=/path/R1","Default host")+1;
+ offset=checkContains(response,offset,"HTTP/1.1 200","Virtual host")+1;
+ offset=checkContains(response,offset,"Virtual Dump","Virtual host")+1;
+ offset=checkContains(response,offset,"pathInfo=/path/R1","Virtual host")+1;
+ offset=checkContains(response,offset,"servername=VirtualHost","Virtual host")+1;
}
@Test
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
index 46f0fe3ea9..b8ccfe600b 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
@@ -415,6 +415,31 @@ public class RequestTest
assertEquals("0.0.0.0",results.get(i++));
assertEquals("myhost",results.get(i++));
assertEquals("8888",results.get(i++));
+
+
+ results.clear();
+ response=_connector.getResponses(
+ "GET http://myhost:8888/ HTTP/1.0\n"+
+ "\n");
+ i=0;
+ assertThat(response,Matchers.containsString("200 OK"));
+ assertEquals("http://myhost:8888/",results.get(i++));
+ assertEquals("0.0.0.0",results.get(i++));
+ assertEquals("myhost",results.get(i++));
+ assertEquals("8888",results.get(i++));
+
+ results.clear();
+ response=_connector.getResponses(
+ "GET http://myhost:8888/ HTTP/1.1\n"+
+ "Host: wrong:666\n"+
+ "Connection: close\n"+
+ "\n");
+ i=0;
+ assertThat(response,Matchers.containsString("200 OK"));
+ assertEquals("http://myhost:8888/",results.get(i++));
+ assertEquals("0.0.0.0",results.get(i++));
+ assertEquals("myhost",results.get(i++));
+ assertEquals("8888",results.get(i++));
results.clear();
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
index aad8d57640..7afc3dcfdc 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
@@ -918,6 +918,8 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
long singleLength = singleSatisfiableRange.getSize(content_length);
writeHeaders(response,content,singleLength );
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
+ if (!response.containsHeader(HttpHeader.DATE.asString()))
+ response.addDateHeader(HttpHeader.DATE.asString(),System.currentTimeMillis());
response.setHeader(HttpHeader.CONTENT_RANGE.asString(),
singleSatisfiableRange.toHeaderRangeString(content_length));
resource.writeTo(out,singleSatisfiableRange.getFirst(content_length),singleLength);
@@ -934,6 +936,8 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
LOG.warn("Unknown mimetype for "+request.getRequestURI());
MultiPartOutputStream multi = new MultiPartOutputStream(out);
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
+ if (!response.containsHeader(HttpHeader.DATE.asString()))
+ response.addDateHeader(HttpHeader.DATE.asString(),System.currentTimeMillis());
// If the request has a "Request-Range" header then we need to
// send an old style multipart/x-byteranges Content-Type. This
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java
index 44ba8b51eb..5de0805c27 100644
--- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java
+++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncServletIOTest.java
@@ -240,6 +240,7 @@ public class AsyncServletIOTest
int w=0;
for (String line : list)
{
+ System.err.println(line);
if ("-".equals(line))
continue;
assertEquals(writes[w],line.length());
diff --git a/tests/pom.xml b/tests/pom.xml
index 2821697f15..5f06787ed4 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -42,10 +42,10 @@
</plugins>
</build>
<modules>
- <!--module>test-integration</module-->
<module>test-webapps</module>
<module>test-sessions</module>
<module>test-continuation</module>
<module>test-loginservice</module>
+ <module>test-integration</module>
</modules>
</project>
diff --git a/tests/test-integration/pom.xml b/tests/test-integration/pom.xml
index d3232a33b2..5010e4fa76 100644
--- a/tests/test-integration/pom.xml
+++ b/tests/test-integration/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.eclipse.jetty.tests</groupId>
<artifactId>tests-parent</artifactId>
- <version>9.0.5-SNAPSHOT</version>
+ <version>9.1.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration</artifactId>
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java
index f9b575488c..b2404167cb 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616BaseTest.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Calendar;
+import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
@@ -41,6 +42,8 @@ import org.eclipse.jetty.test.support.rawhttp.HttpTesting;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.StringAssert;
+import org.eclipse.jetty.util.MultiPartInputStreamParser;
+import org.hamcrest.Matchers;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
@@ -91,6 +94,7 @@ public abstract class RFC2616BaseTest
server = testableserver;
server.load();
server.start();
+ //server.getServer().dumpStdErr();
}
@Before
@@ -216,11 +220,11 @@ public abstract class RFC2616BaseTest
response = responses.get(1); // Response 2
assertEquals("3.6.1 Transfer Codings / Response 2 Code", HttpStatus.OK_200, response.getStatus());
- assertTrue("3.6.1 Transfer Codings / Chunked String",response.getContent().contains("6789abcde\n"));
+ assertThat("3.6.1 Transfer Codings / Chunked String",response.getContent(),Matchers.containsString("6789abcde\n"));
response = responses.get(2); // Response 3
assertEquals("3.6.1 Transfer Codings / Response 3 Code", HttpStatus.OK_200, response.getStatus());
- assertTrue("3.6.1 Transfer Codings / No Body",response.getContent() == null);
+ assertEquals("3.6.1 Transfer Codings / No Body","",response.getContent());
}
/**
@@ -273,7 +277,7 @@ public abstract class RFC2616BaseTest
response = responses.get(2); // Response 3
assertEquals("3.6.1 Transfer Codings / Response 3 Code", HttpStatus.OK_200, response.getStatus());
- assertTrue("3.6.1 Transfer Codings / No Body", response.getContent() == null);
+ assertEquals("3.6.1 Transfer Codings / No Body","",response.getContent());
}
@@ -313,7 +317,7 @@ public abstract class RFC2616BaseTest
response = responses.get(1); // Response 2
assertEquals("3.6.1 Transfer Codings / Response 2 Code", HttpStatus.OK_200, response.getStatus());
- assertTrue("3.6.1 Transfer Codings / No Body", response.getContent() == null);
+ assertEquals("3.6.1 Transfer Codings / No Body","",response.getContent());
}
/**
@@ -368,10 +372,10 @@ public abstract class RFC2616BaseTest
HttpTester.Response response = responses.get(0);
assertEquals("4.4.2 Message Length / Response Code", HttpStatus.OK_200, response.getStatus());
- assertTrue("4.4.2 Message Length / Body",response.getContent().contains("123\n"));
+ assertThat("4.4.2 Message Length / Body",response.getContent(),Matchers.containsString("123\n"));
response = responses.get(1);
assertEquals("4.4.2 Message Length / Response Code", HttpStatus.OK_200, response.getStatus());
- assertTrue("4.4.2 Message Length / No Body", response.getContent() == null);
+ assertEquals("4.4.2 Message Length / No Body", "",response.getContent());
// 4.4.3 -
// Client - do not send 'Content-Length' if entity-length
@@ -464,7 +468,7 @@ public abstract class RFC2616BaseTest
HttpTester.Response response = http.request(req1);
assertEquals("5.2 Default Host", HttpStatus.OK_200, response.getStatus());
- assertTrue("5.2 Default Host",response.getContent().contains("Default DOCRoot"));
+ assertThat("5.2 Default Host",response.getContent(),Matchers.containsString("Default DOCRoot"));
}
/**
@@ -486,7 +490,7 @@ public abstract class RFC2616BaseTest
HttpTester.Response response = http.request(req2);
assertEquals("5.2 Virtual Host", HttpStatus.OK_200, response.getStatus());
- assertTrue("5.2 Virtual Host",response.getContent().contains("VirtualHost DOCRoot"));
+ assertThat("5.2 Virtual Host",response.getContent(),Matchers.containsString("VirtualHost DOCRoot"));
}
/**
@@ -508,7 +512,7 @@ public abstract class RFC2616BaseTest
HttpTester.Response response = http.request(req3);
assertEquals("5.2 Virtual Host (mixed case)", HttpStatus.OK_200, response.getStatus());
- assertTrue("5.2 Virtual Host (mixed case)",response.getContent().contains("VirtualHost DOCRoot"));
+ assertThat("5.2 Virtual Host (mixed case)",response.getContent(),Matchers.containsString("VirtualHost DOCRoot"));
}
/**
@@ -551,7 +555,7 @@ public abstract class RFC2616BaseTest
HttpTester.Response response = http.request(req5);
assertEquals("5.2 Bad Host",HttpStatus.OK_200, response.getStatus());
- assertTrue("5.2 Bad Host",response.getContent().contains("Default DOCRoot")); // served by default context
+ assertThat("5.2 Bad Host",response.getContent(),Matchers.containsString("Default DOCRoot")); // served by default context
}
/**
@@ -571,7 +575,7 @@ public abstract class RFC2616BaseTest
HttpTester.Response response = http.request(req6);
- // No host header should always return a 400 Bad Request.
+ // No host header should always return a 400 Bad Request by 19.6.1.1
assertEquals("5.2 Virtual Host as AbsoluteURI (No Host Header / HTTP 1.1)",HttpStatus.BAD_REQUEST_400,response.getStatus());
}
@@ -593,7 +597,7 @@ public abstract class RFC2616BaseTest
HttpTester.Response response = http.request(req6);
assertEquals("5.2 Virtual Host as AbsoluteURI (No Host Header / HTTP 1.0)",HttpStatus.OK_200, response.getStatus());
- assertTrue("5.2 Virtual Host as AbsoluteURI (No Host Header / HTTP 1.1)",response.getContent().contains("VirtualHost DOCRoot"));
+ assertThat("5.2 Virtual Host as AbsoluteURI (No Host Header / HTTP 1.1)",response.getContent(),Matchers.containsString("VirtualHost DOCRoot"));
}
/**
@@ -615,8 +619,8 @@ public abstract class RFC2616BaseTest
HttpTester.Response response = http.request(req7);
assertEquals("5.2 Virtual Host as AbsoluteURI (and Host header)", HttpStatus.OK_200, response.getStatus());
- System.err.println(response.getContent());
- assertTrue("5.2 Virtual Host as AbsoluteURI (and Host header)",response.getContent().contains("VirtualHost DOCRoot"));
+ // System.err.println(response.getContent());
+ assertThat("5.2 Virtual Host as AbsoluteURI (and Host header)",response.getContent(),Matchers.containsString("VirtualHost DOCRoot"));
}
/**
@@ -637,7 +641,7 @@ public abstract class RFC2616BaseTest
assertEquals("8.1 Persistent Connections", HttpStatus.OK_200, response.getStatus());
assertTrue("8.1 Persistent Connections", response.get("Content-Length") != null);
- assertTrue("8.1 Persistent Connections",response.getContent().contains("Resource=R1"));
+ assertThat("8.1 Persistent Connections",response.getContent(),Matchers.containsString("Resource=R1"));
StringBuffer req2 = new StringBuffer();
req2.append("GET /tests/R1.txt HTTP/1.1\n");
@@ -753,14 +757,11 @@ public abstract class RFC2616BaseTest
// System.err.println(responses);
HttpTester.Response response=responses.get(0);
- // System.err.println(response.getRawResponse());
+ // System.err.println(response);
assertEquals("8.2.3 ignored no 100",302, response.getStatus());
-
- response=responses.get(1);
- // System.err.println(response.getRawResponse());
- assertEquals("8.2.3 ignored no 100",200, response.getStatus());
- assertTrue(response.getContent().contains("87654321\n"));
+ assertEquals("close",response.get("Connection"));
+ assertEquals(1,responses.size());
}
/**
@@ -795,7 +796,7 @@ public abstract class RFC2616BaseTest
response = http.read(sock);
assertEquals("8.2.3 expect 100", HttpStatus.OK_200, response.getStatus());
- assertTrue("8.2.3 expect 100",response.getContent().contains("654321\n"));
+ assertThat("8.2.3 expect 100",response.getContent(),Matchers.containsString("654321\n"));
}
finally
{
@@ -935,8 +936,8 @@ public abstract class RFC2616BaseTest
// As there is a possibility that the time between GET and HEAD requests
// can cross the second mark. (eg: GET at 11:00:00.999 and HEAD at 11:00:01.001)
// So with that knowledge, we will remove the 'Date:' header from both sides before comparing.
- List<String> linesGet = StringUtil.asLines(rawGetResponse);
- List<String> linesHead = StringUtil.asLines(rawHeadResponse);
+ List<String> linesGet = StringUtil.asLines(rawGetResponse.trim());
+ List<String> linesHead = StringUtil.asLines(rawHeadResponse.trim());
StringUtil.removeStartsWith("Date: ",linesGet);
StringUtil.removeStartsWith("Date: ",linesHead);
@@ -1011,6 +1012,8 @@ public abstract class RFC2616BaseTest
req2.append("\n");
response = http.request(req2);
+
+ // System.err.println(response);
assertEquals("10.2.7 Partial Content",HttpStatus.PARTIAL_CONTENT_206, response.getStatus());
@@ -1052,7 +1055,7 @@ public abstract class RFC2616BaseTest
// TODO: Not sure how to test this condition.
// Test the body sent
- assertTrue("10.2.7 Partial Content",response.getContent().contains("BCD")); // should only have bytes 1-3
+ assertThat("10.2.7 Partial Content",response.getContent(),Matchers.containsString("BCD")); // should only have bytes 1-3
}
/**
@@ -1451,7 +1454,7 @@ public abstract class RFC2616BaseTest
req4.append("\n");
HttpTester.Response response = http.request(req4);
- assertEquals("14.23 HTTP/1.1 - Empty Host", HttpStatus.OK_200, response.getStatus());
+ assertEquals("14.23 HTTP/1.1 - Empty Host", HttpStatus.BAD_REQUEST_400, response.getStatus());
}
/**
@@ -1530,7 +1533,7 @@ public abstract class RFC2616BaseTest
req1.append("\n");
HttpTester.Response response = http.request(req1);
-
+
String msg = "Partial (Byte) Range: '" + rangedef + "'";
assertEquals(msg,HttpStatus.PARTIAL_CONTENT_206, response.getStatus());
@@ -1553,21 +1556,20 @@ public abstract class RFC2616BaseTest
Assert.assertNotNull(msg + " Should have found boundary in Content-Type header",boundary);
- // Find boundary offsets within body
- List<HttpTester.Response> multiparts = HttpTesting.getParts(boundary, response);
- Assert.assertEquals(msg + " multiparts in body (count)",2,multiparts.size());
-
- // Validate multipart #1
- HttpTester.Response multipart1 = multiparts.get(0);
- assertEquals(msg + " Multipart 1","text/plain", multipart1.get("Content-Type"));
- assertEquals(msg + " Multipart 1","bytes 23-23/27", multipart1.get("Content-Range"));
- assertTrue(msg + " Multipart 1", multipart1.getContent().contains("X"));
-
- // Validate multipart #2
- HttpTester.Response multipart2 = multiparts.get(1);
- assertEquals(msg + " Multipart 2","text/plain", multipart2.get("Content-Type"));
- assertEquals(msg + " Multipart 2","bytes 25-26/27", multipart2.get("Content-Range"));
- assertTrue(msg + " Multipart 2", multipart2.getContent().contains("Z\n"));
+ List<String> lines = StringUtil.asLines(response.getContent().trim());
+ int i=0;
+ assertEquals("--"+boundary,lines.get(i++));
+ assertEquals("Content-Type: text/plain",lines.get(i++));
+ assertEquals("Content-Range: bytes 23-23/27",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("X",lines.get(i++));
+ assertEquals("--"+boundary,lines.get(i++));
+ assertEquals("Content-Type: text/plain",lines.get(i++));
+ assertEquals("Content-Range: bytes 25-26/27",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("Z",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("--"+boundary+"--",lines.get(i++));
}
/**
@@ -1591,6 +1593,7 @@ public abstract class RFC2616BaseTest
req1.append("\n");
HttpTester.Response response = http.request(req1);
+ // System.err.println(response+response.getContent());
String msg = "Partial (Byte) Range: '" + rangedef + "'";
assertEquals(msg,HttpStatus.PARTIAL_CONTENT_206,response.getStatus());
@@ -1614,27 +1617,29 @@ public abstract class RFC2616BaseTest
Assert.assertNotNull(msg + " Should have found boundary in Content-Type header",boundary);
- // Find boundary offsets within body
- List<HttpTester.Response> multiparts = HttpTesting.getParts(boundary, response);
- Assert.assertEquals(msg + " multiparts in body (count)",3,multiparts.size());
-
- // Validate multipart #1
- HttpTester.Response multipart1 = multiparts.get(0);
- assertEquals(msg + " Multipart 1", "text/plain", multipart1.get("Content-Type"));
- assertEquals(msg + " Multipart 1","bytes 26-26/27", multipart1.get("Content-Range"));
- assertTrue(msg + " Multipart 1",multipart1.getContent().contains("\n"));
-
- // Validate multipart #2
- HttpTester.Response multipart2 = multiparts.get(1);
- assertEquals(msg + " Multipart 2","text/plain", multipart2.get("Content-Type"));
- assertEquals(msg + " Multipart 2","bytes 25-26/27", multipart2.get("Content-Range"));
- assertTrue(msg + " Multipart 2", multipart2.getContent().contains("Z\n"));
-
- // Validate multipart #3
- HttpTester.Response multipart3 = multiparts.get(2);
- assertEquals(msg + " Multipart 3","text/plain", multipart3.get("Content-Type"));
- assertEquals(msg + " Multipart 3","bytes 24-26/27", multipart3.get("Content-Range"));
- assertTrue(msg + " Multipart 3", multipart3.getContent().contains("YZ\n"));
+
+ List<String> lines = StringUtil.asLines(response.getContent().trim());
+ int i=0;
+ assertEquals("--"+boundary,lines.get(i++));
+ assertEquals("Content-Type: text/plain",lines.get(i++));
+ assertEquals("Content-Range: bytes 26-26/27",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("--"+boundary,lines.get(i++));
+ assertEquals("Content-Type: text/plain",lines.get(i++));
+ assertEquals("Content-Range: bytes 25-26/27",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("Z",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("--"+boundary,lines.get(i++));
+ assertEquals("Content-Type: text/plain",lines.get(i++));
+ assertEquals("Content-Range: bytes 24-26/27",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("YZ",lines.get(i++));
+ assertEquals("",lines.get(i++));
+ assertEquals("--"+boundary+"--",lines.get(i++));
+
}
/**
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java
index f33b5462ce..f0bf1fa331 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/rfcs/RFC2616NIOHttpsTest.java
@@ -23,10 +23,13 @@ import org.eclipse.jetty.test.support.TestableJettyServer;
import org.eclipse.jetty.test.support.rawhttp.HttpSocket;
import org.eclipse.jetty.test.support.rawhttp.HttpsSocketImpl;
import org.junit.BeforeClass;
+import org.junit.Ignore;
/**
* Perform the RFC2616 tests against a server running with the Jetty NIO Connector and listening on HTTPS (HTTP over SSL).
+ * TODO
*/
+@Ignore ("TODO")
public class RFC2616NIOHttpsTest extends RFC2616BaseTest
{
@BeforeClass
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java
index 7b1e911940..12ff1f0e41 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/TestableJettyServer.java
@@ -200,4 +200,9 @@ public class TestableJettyServer
uri.append(":").append(this._serverPort);
return URI.create(uri.toString());
}
+
+ public Server getServer()
+ {
+ return _server;
+ }
}
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpTesting.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpTesting.java
index c81fa3fe2a..445ecbb4e4 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpTesting.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/support/rawhttp/HttpTesting.java
@@ -52,6 +52,9 @@ public class HttpTesting
public static List<HttpTester.Response> getParts (String boundary, HttpTester.Response response) throws IOException
{
+ // TODO This method appears to be broken in how it uses the HttpParser
+ // Should use MultiPartInputStreamParser ??
+
List<HttpTester.Response> parts = new ArrayList<HttpTester.Response>();
BufferedReader buf = new BufferedReader(new StringReader(response.getContent()));
diff --git a/tests/test-integration/src/test/resources/RFC2616Base.xml b/tests/test-integration/src/test/resources/RFC2616Base.xml
index 3cc7a4b8f5..2c300d1498 100644
--- a/tests/test-integration/src/test/resources/RFC2616Base.xml
+++ b/tests/test-integration/src/test/resources/RFC2616Base.xml
@@ -76,7 +76,7 @@
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<Set name="contexts">
- <Ref refid="Contexts" />
+ <Ref refid="WebappContexts" />
</Set>
<Call name="setContextAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
@@ -86,7 +86,7 @@
<Call id="webappprovider" name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
- <Set name="monitoredDirName"><Property name="test.resourcesdir" default="src/test/resources" />/webapps-contexts/RFC2616</Set>
+ <Set name="monitoredDirName"><Property name="test.resourcesdir" default="src/test/resources" />/webapp-contexts/RFC2616</Set>
<Set name="scanInterval">1</Set>
<Set name="extractWars">true</Set>
<Set name="configurationManager">

Back to the top