Merge branch 'jetty-9.3.x' into jetty-9.4.x
This commit is contained in:
commit
5e57b9562f
|
@ -19,12 +19,16 @@
|
|||
package org.eclipse.jetty.jstl;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
|
||||
|
@ -33,7 +37,7 @@ import org.eclipse.jetty.server.ServerConnector;
|
|||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.JAR;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -104,32 +108,43 @@ public class JstlTest
|
|||
@Test
|
||||
public void testUrlsBasic() throws IOException
|
||||
{
|
||||
SimpleRequest req = new SimpleRequest(baseUri);
|
||||
String resp = req.getString("/urls.jsp");
|
||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:url")));
|
||||
assertThat("Response", resp, containsString("[c:url value] = /ref.jsp;jsessionid="));
|
||||
assertThat("Response", resp, containsString("[c:url param] = ref.jsp;key=value;jsessionid="));
|
||||
HttpURLConnection http = (HttpURLConnection) baseUri.resolve("/urls.jsp").toURL().openConnection();
|
||||
assertThat("http response", http.getResponseCode(), is(200));
|
||||
try(InputStream input = http.getInputStream())
|
||||
{
|
||||
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:url")));
|
||||
assertThat("Response", resp, containsString("[c:url value] = /ref.jsp;jsessionid="));
|
||||
assertThat("Response", resp, containsString("[c:url param] = ref.jsp;key=value;jsessionid="));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCatchBasic() throws IOException
|
||||
{
|
||||
SimpleRequest req = new SimpleRequest(baseUri);
|
||||
String resp = req.getString("/catch-basic.jsp");
|
||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:catch")));
|
||||
assertThat("Response", resp, containsString("[c:catch] exception : " + JspException.class.getName()));
|
||||
assertThat("Response", resp, containsString("[c:catch] exception.message : In <parseNumber>"));
|
||||
HttpURLConnection http = (HttpURLConnection) baseUri.resolve("/catch-basic.jsp").toURL().openConnection();
|
||||
assertThat("http response", http.getResponseCode(), is(200));
|
||||
try(InputStream input = http.getInputStream())
|
||||
{
|
||||
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:catch")));
|
||||
assertThat("Response", resp, containsString("[c:catch] exception : " + JspException.class.getName()));
|
||||
assertThat("Response", resp, containsString("[c:catch] exception.message : In <parseNumber>"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testCatchTaglib() throws IOException
|
||||
{
|
||||
SimpleRequest req = new SimpleRequest(baseUri);
|
||||
String resp = req.getString("/catch-taglib.jsp");
|
||||
System.out.println("resp = " + resp);
|
||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:catch>")));
|
||||
assertThat("Response should be JSP processed", resp, not(containsString("<jtest:errorhandler>")));
|
||||
assertThat("Response", resp, not(containsString("[jtest:errorhandler] exception is null")));
|
||||
HttpURLConnection http = (HttpURLConnection) baseUri.resolve("/catch-taglib.jsp").toURL().openConnection();
|
||||
assertThat("http response", http.getResponseCode(), is(200));
|
||||
try(InputStream input = http.getInputStream())
|
||||
{
|
||||
String resp = IO.toString(input, StandardCharsets.UTF_8);
|
||||
assertThat("Response should be JSP processed", resp, not(containsString("<c:catch>")));
|
||||
assertThat("Response should be JSP processed", resp, not(containsString("<jtest:errorhandler>")));
|
||||
assertThat("Response", resp, not(containsString("[jtest:errorhandler] exception is null")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ public class TestAnnotationParser
|
|||
// Intentionally using a base director name that starts with a "."
|
||||
// This mimics what you see in jenkins, hudson, hadoop, solr, camel, and selenium for their
|
||||
// installed and/or managed webapps
|
||||
File basedir = testdir.getFile(".base/workspace/classes");
|
||||
File basedir = testdir.getPathFile(".base/workspace/classes").toFile();
|
||||
FS.ensureEmpty(basedir);
|
||||
|
||||
// Copy in class that is known to have annotations.
|
||||
|
|
|
@ -64,7 +64,7 @@ public class AntBuild
|
|||
Project antProject = new Project();
|
||||
try
|
||||
{
|
||||
antProject.setBaseDir(MavenTestingUtils.getBasedir());
|
||||
antProject.setBaseDir(MavenTestingUtils.getBaseDir());
|
||||
antProject.setUserProperty("ant.file",buildFile.getAbsolutePath());
|
||||
DefaultLogger logger = new DefaultLogger();
|
||||
|
||||
|
|
|
@ -19,15 +19,18 @@
|
|||
package org.eclipse.jetty.cdi.servlet;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.log.JettyLogHandler;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -91,25 +94,27 @@ public class WeldInitializationTest
|
|||
@Test
|
||||
public void testRequestParamServletDefault() throws Exception
|
||||
{
|
||||
SimpleRequest req = new SimpleRequest(serverHttpURI);
|
||||
String resp = req.getString("req-info");
|
||||
|
||||
System.out.println(resp);
|
||||
|
||||
assertThat("Response",resp,containsString("request is PRESENT"));
|
||||
assertThat("Response",resp,containsString("parameters.size = [0]"));
|
||||
HttpURLConnection http = (HttpURLConnection) serverHttpURI.resolve("req-info").toURL().openConnection();
|
||||
assertThat("response code", http.getResponseCode(), is(200));
|
||||
try(InputStream inputStream = http.getInputStream())
|
||||
{
|
||||
String resp = IO.toString(inputStream);
|
||||
assertThat("Response", resp, containsString("request is PRESENT"));
|
||||
assertThat("Response", resp, containsString("parameters.size = [0]"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestParamServletAbc() throws Exception
|
||||
{
|
||||
SimpleRequest req = new SimpleRequest(serverHttpURI);
|
||||
String resp = req.getString("req-info?abc=123");
|
||||
|
||||
System.out.println(resp);
|
||||
|
||||
assertThat("Response",resp,containsString("request is PRESENT"));
|
||||
assertThat("Response",resp,containsString("parameters.size = [1]"));
|
||||
assertThat("Response",resp,containsString(" param[abc] = [123]"));
|
||||
HttpURLConnection http = (HttpURLConnection) serverHttpURI.resolve("req-info?abc=123").toURL().openConnection();
|
||||
assertThat("response code", http.getResponseCode(), is(200));
|
||||
try(InputStream inputStream = http.getInputStream())
|
||||
{
|
||||
String resp = IO.toString(inputStream);
|
||||
assertThat("Response", resp, containsString("request is PRESENT"));
|
||||
assertThat("Response", resp, containsString("parameters.size = [1]"));
|
||||
assertThat("Response", resp, containsString(" param[abc] = [123]"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ public class AppLifeCycleTest
|
|||
AppLifeCycle lifecycle = new AppLifeCycle();
|
||||
List<String> expected = new ArrayList<String>();
|
||||
|
||||
File outputDir = testdir.getEmptyDir();
|
||||
File outputDir = testdir.getEmptyPathDir().toFile();
|
||||
|
||||
// Modify graph to add new 'staging' -> 'staged' between 'deployed' and 'started'
|
||||
GraphOutputDot.write(lifecycle,new File(outputDir,"multiple-1.dot")); // before change
|
||||
|
|
|
@ -70,7 +70,7 @@ public class XmlConfiguredJetty
|
|||
_xmlConfigurations = new ArrayList<>();
|
||||
Properties properties = new Properties();
|
||||
|
||||
String jettyHomeBase = testdir.getDir().getAbsolutePath();
|
||||
String jettyHomeBase = testdir.getPath().toString();
|
||||
// Ensure we have a new (pristene) directory to work with.
|
||||
int idx = 0;
|
||||
_jettyHome = new File(jettyHomeBase + "#" + idx);
|
||||
|
@ -116,7 +116,7 @@ public class XmlConfiguredJetty
|
|||
System.setProperty("java.io.tmpdir",tmpDir.getAbsolutePath());
|
||||
properties.setProperty("jetty.home",_jettyHome.getAbsolutePath());
|
||||
System.setProperty("jetty.home",_jettyHome.getAbsolutePath());
|
||||
properties.setProperty("test.basedir",MavenTestingUtils.getBasedir().getAbsolutePath());
|
||||
properties.setProperty("test.basedir",MavenTestingUtils.getBaseDir().getAbsolutePath());
|
||||
properties.setProperty("test.resourcesdir",MavenTestingUtils.getTestResourcesDir().getAbsolutePath());
|
||||
properties.setProperty("test.webapps",webappsDir.getAbsolutePath());
|
||||
properties.setProperty("test.targetdir",MavenTestingUtils.getTargetDir().getAbsolutePath());
|
||||
|
|
|
@ -21,14 +21,13 @@ package org.eclipse.jetty.http;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ByteChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
|
||||
|
||||
|
@ -88,7 +87,7 @@ public class HttpTester
|
|||
parser.parseNext(request);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
public static Response parseResponse(String response)
|
||||
{
|
||||
Response r=new Response();
|
||||
|
@ -104,6 +103,17 @@ public class HttpTester
|
|||
parser.parseNext(response);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Response parseResponse(InputStream responseStream) throws IOException
|
||||
{
|
||||
ByteArrayOutputStream contentStream = new ByteArrayOutputStream();
|
||||
IO.copy(responseStream, contentStream);
|
||||
|
||||
Response r=new Response();
|
||||
HttpParser parser =new HttpParser(r);
|
||||
parser.parseNext(ByteBuffer.wrap(contentStream.toByteArray()));
|
||||
return r;
|
||||
}
|
||||
|
||||
public abstract static class Input
|
||||
{
|
||||
|
|
|
@ -18,10 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.proxy;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -45,14 +43,13 @@ import org.eclipse.jetty.client.api.Response;
|
|||
import org.eclipse.jetty.client.util.BytesContentProvider;
|
||||
import org.eclipse.jetty.client.util.DeferredContentProvider;
|
||||
import org.eclipse.jetty.server.HttpChannel;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpParser;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.log.StacklessLogging;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
|
@ -68,7 +65,7 @@ public class ProxyServletFailureTest
|
|||
{
|
||||
private static final String PROXIED_HEADER = "X-Proxied";
|
||||
|
||||
@Parameterized.Parameters
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Iterable<Object[]> data()
|
||||
{
|
||||
return Arrays.asList(new Object[][]{
|
||||
|
@ -206,14 +203,13 @@ public class ProxyServletFailureTest
|
|||
// Do not send the promised content, wait to idle timeout.
|
||||
|
||||
socket.setSoTimeout(2 * idleTimeout);
|
||||
SimpleHttpParser parser = new SimpleHttpParser();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
|
||||
SimpleHttpResponse response = parser.readResponse(reader);
|
||||
Assert.assertTrue(Integer.parseInt(response.getCode()) >= 500);
|
||||
String connectionHeader = response.getHeaders().get("connection");
|
||||
|
||||
HttpTester.Response response = HttpTester.parseResponse(socket.getInputStream());
|
||||
Assert.assertTrue(response.getStatus() >= 500);
|
||||
String connectionHeader = response.get("connection");
|
||||
Assert.assertNotNull(connectionHeader);
|
||||
Assert.assertTrue(connectionHeader.contains("close"));
|
||||
Assert.assertEquals(-1, reader.read());
|
||||
Assert.assertEquals(-1, socket.getInputStream().read());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,14 +238,13 @@ public class ProxyServletFailureTest
|
|||
// Do not send all the promised content, wait to idle timeout.
|
||||
|
||||
socket.setSoTimeout(2 * idleTimeout);
|
||||
SimpleHttpParser parser = new SimpleHttpParser();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
|
||||
SimpleHttpResponse response = parser.readResponse(reader);
|
||||
Assert.assertTrue(Integer.parseInt(response.getCode()) >= 500);
|
||||
String connectionHeader = response.getHeaders().get("connection");
|
||||
|
||||
HttpTester.Response response = HttpTester.parseResponse(socket.getInputStream());
|
||||
Assert.assertTrue(response.getStatus() >= 500);
|
||||
String connectionHeader = response.get("connection");
|
||||
Assert.assertNotNull(connectionHeader);
|
||||
Assert.assertTrue(connectionHeader.contains("close"));
|
||||
Assert.assertEquals(-1, reader.read());
|
||||
Assert.assertEquals(-1, socket.getInputStream().read());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ public class PropertyUserStoreTest
|
|||
|
||||
private File initUsersText() throws Exception
|
||||
{
|
||||
Path dir = testdir.getDir().toPath().toRealPath();
|
||||
Path dir = testdir.getPath().toRealPath();
|
||||
FS.ensureDirExists(dir.toFile());
|
||||
File users = dir.resolve("users.txt").toFile();
|
||||
|
||||
|
|
|
@ -21,14 +21,11 @@ package org.eclipse.jetty.server;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -37,11 +34,10 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.io.ArrayByteBufferPool;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpParser;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.eclipse.jetty.util.log.StacklessLogging;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -57,8 +53,7 @@ public abstract class AbstractHttpTest
|
|||
protected static Server server;
|
||||
protected static ServerConnector connector;
|
||||
protected String httpVersion;
|
||||
protected SimpleHttpParser httpParser;
|
||||
StacklessLogging stackless;
|
||||
private StacklessLogging stacklessChannelLogging;
|
||||
|
||||
|
||||
public AbstractHttpTest(String httpVersion)
|
||||
|
@ -74,50 +69,49 @@ public abstract class AbstractHttpTest
|
|||
connector.setIdleTimeout(10000);
|
||||
|
||||
server.addConnector(connector);
|
||||
httpParser = new SimpleHttpParser();
|
||||
stackless=new StacklessLogging(HttpChannel.class);
|
||||
stacklessChannelLogging =new StacklessLogging(HttpChannel.class);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
server.stop();
|
||||
stackless.close();
|
||||
stacklessChannelLogging.close();
|
||||
}
|
||||
|
||||
protected SimpleHttpResponse executeRequest() throws URISyntaxException, IOException
|
||||
protected HttpTester.Response executeRequest() throws URISyntaxException, IOException
|
||||
{
|
||||
try(Socket socket = new Socket("localhost", connector.getLocalPort()))
|
||||
{
|
||||
socket.setSoTimeout((int)connector.getIdleTimeout());
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
|
||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
|
||||
|
||||
writer.write("GET / " + httpVersion + "\r\n");
|
||||
writer.write("Host: localhost\r\n");
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
|
||||
// TODO replace the SimpleHttp stuff
|
||||
SimpleHttpResponse response = httpParser.readResponse(reader);
|
||||
if ("HTTP/1.1".equals(httpVersion)
|
||||
&& response.getHeaders().get("content-length") == null
|
||||
&& response.getHeaders().get("transfer-encoding") == null
|
||||
&& !__noBodyCodes.contains(response.getCode()))
|
||||
assertThat("If HTTP/1.1 response doesn't contain transfer-encoding or content-length headers, " +
|
||||
"it should contain connection:close", response.getHeaders().get("connection"), is("close"));
|
||||
return response;
|
||||
|
||||
try(PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream())))
|
||||
{
|
||||
writer.write("GET / " + httpVersion + "\r\n");
|
||||
writer.write("Host: localhost\r\n");
|
||||
writer.write("\r\n");
|
||||
writer.flush();
|
||||
|
||||
HttpTester.Response response = HttpTester.parseResponse(socket.getInputStream());
|
||||
if ("HTTP/1.1".equals(httpVersion)
|
||||
&& response.get("content-length") == null
|
||||
&& response.get("transfer-encoding") == null
|
||||
&& !__noBodyCodes.contains(response.getStatus()))
|
||||
assertThat("If HTTP/1.1 response doesn't contain transfer-encoding or content-length headers, " +
|
||||
"it should contain connection:close", response.get("connection"), is("close"));
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertResponseBody(SimpleHttpResponse response, String expectedResponseBody)
|
||||
protected void assertResponseBody(HttpTester.Response response, String expectedResponseBody)
|
||||
{
|
||||
assertThat("response body is" + expectedResponseBody, response.getBody(), is(expectedResponseBody));
|
||||
assertThat("response body is" + expectedResponseBody, response.getContent(), is(expectedResponseBody));
|
||||
}
|
||||
|
||||
protected void assertHeader(SimpleHttpResponse response, String headerName, String expectedValue)
|
||||
protected void assertHeader(HttpTester.Response response, String headerName, String expectedValue)
|
||||
{
|
||||
assertThat(headerName + "=" + expectedValue, response.getHeaders().get(headerName), is(expectedValue));
|
||||
assertThat(headerName + "=" + expectedValue, response.get(headerName), is(expectedValue));
|
||||
}
|
||||
|
||||
protected static class TestCommitException extends IllegalStateException
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -33,12 +35,12 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
@ -136,30 +138,32 @@ public class ConnectionOpenCloseTest extends AbstractHttpTest
|
|||
}
|
||||
});
|
||||
|
||||
Socket socket = new Socket("localhost", connector.getLocalPort());
|
||||
socket.setSoTimeout((int)connector.getIdleTimeout());
|
||||
OutputStream output = socket.getOutputStream();
|
||||
output.write((
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost:" + connector.getLocalPort() + "\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
SimpleHttpResponse response = httpParser.readResponse(reader);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
|
||||
Assert.assertEquals(-1, reader.read());
|
||||
socket.close();
|
||||
|
||||
Assert.assertTrue(openLatch.await(5, TimeUnit.SECONDS));
|
||||
Assert.assertTrue(closeLatch.await(5, TimeUnit.SECONDS));
|
||||
|
||||
// Wait some time to see if the callbacks are called too many times
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
|
||||
Assert.assertEquals(2, callbacks.get());
|
||||
try( Socket socket = new Socket("localhost", connector.getLocalPort()) )
|
||||
{
|
||||
socket.setSoTimeout((int) connector.getIdleTimeout());
|
||||
OutputStream output = socket.getOutputStream();
|
||||
output.write((
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Host: localhost:" + connector.getLocalPort() + "\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
InputStream inputStream = socket.getInputStream();
|
||||
HttpTester.Response response = HttpTester.parseResponse(inputStream);
|
||||
assertThat("Status Code", response.getStatus(), is(200));
|
||||
|
||||
Assert.assertEquals(-1, inputStream.read());
|
||||
socket.close();
|
||||
|
||||
Assert.assertTrue(openLatch.await(5, TimeUnit.SECONDS));
|
||||
Assert.assertTrue(closeLatch.await(5, TimeUnit.SECONDS));
|
||||
|
||||
// Wait some time to see if the callbacks are called too many times
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
|
||||
Assert.assertEquals(2, callbacks.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Slow
|
||||
|
@ -217,11 +221,11 @@ public class ConnectionOpenCloseTest extends AbstractHttpTest
|
|||
"\r\n").getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
SimpleHttpResponse response = httpParser.readResponse(reader);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
InputStream inputStream = socket.getInputStream();
|
||||
HttpTester.Response response = HttpTester.parseResponse(inputStream);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
|
||||
Assert.assertEquals(-1, reader.read());
|
||||
Assert.assertEquals(-1, inputStream.read());
|
||||
socket.close();
|
||||
|
||||
Assert.assertTrue(openLatch.await(5, TimeUnit.SECONDS));
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -29,10 +27,9 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpParser;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
@ -69,24 +66,25 @@ public class HostHeaderCustomizerTest
|
|||
{
|
||||
try (Socket socket = new Socket("localhost", connector.getLocalPort()))
|
||||
{
|
||||
OutputStream output = socket.getOutputStream();
|
||||
String request = "" +
|
||||
"GET / HTTP/1.0\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
|
||||
SimpleHttpParser parser = new SimpleHttpParser();
|
||||
SimpleHttpResponse response = parser.readResponse(input);
|
||||
|
||||
String location = response.getHeaders().get("location");
|
||||
Assert.assertNotNull(location);
|
||||
String schemePrefix = "http://";
|
||||
Assert.assertTrue(location.startsWith(schemePrefix));
|
||||
Assert.assertTrue(location.endsWith(redirectPath));
|
||||
String hostPort = location.substring(schemePrefix.length(), location.length() - redirectPath.length());
|
||||
Assert.assertEquals(serverName + ":" + serverPort, hostPort);
|
||||
try(OutputStream output = socket.getOutputStream())
|
||||
{
|
||||
String request = "" +
|
||||
"GET / HTTP/1.0\r\n" +
|
||||
"\r\n";
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
HttpTester.Input input = HttpTester.from(socket.getInputStream());
|
||||
HttpTester.Response response = HttpTester.parseResponse(input);
|
||||
|
||||
String location = response.get("location");
|
||||
Assert.assertNotNull(location);
|
||||
String schemePrefix = "http://";
|
||||
Assert.assertTrue(location.startsWith(schemePrefix));
|
||||
Assert.assertTrue(location.endsWith(redirectPath));
|
||||
String hostPort = location.substring(schemePrefix.length(), location.length() - redirectPath.length());
|
||||
Assert.assertEquals(serverName + ":" + serverPort, hostPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -35,8 +35,8 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
@ -71,9 +71,9 @@ public class HttpManyWaysToAsyncCommitBadBehaviourTest extends AbstractHttpTest
|
|||
server.setHandler(new SetHandledWriteSomeDataHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response code is 500", response.getStatus(), is(500));
|
||||
}
|
||||
|
||||
private class SetHandledWriteSomeDataHandler extends ThrowExceptionOnDemandHandler
|
||||
|
|
|
@ -32,8 +32,8 @@ import javax.servlet.ServletResponse;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
@ -46,7 +46,7 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
private final String CONTEXT_ATTRIBUTE = getClass().getName() + ".asyncContext";
|
||||
private boolean dispatch; // if true we dispatch, otherwise we complete
|
||||
|
||||
@Parameterized.Parameters
|
||||
@Parameterized.Parameters(name = "{0} dispatch={1}")
|
||||
public static Collection<Object[]> data()
|
||||
{
|
||||
Object[][] data = new Object[][]
|
||||
|
@ -73,9 +73,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 404", response.getCode(), is("404"));
|
||||
assertThat("response code", response.getStatus(), is(404));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
||||
|
@ -86,9 +86,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
||||
|
@ -129,9 +129,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
if (HttpVersion.HTTP_1_1.asString().equals(httpVersion))
|
||||
assertHeader(response, "content-length", "0");
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
|
@ -144,9 +144,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
||||
|
@ -188,9 +188,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertHeader(response, "content-length", "6");
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
@ -202,9 +202,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
||||
|
@ -254,10 +254,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -270,9 +270,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -326,9 +326,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -341,9 +341,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -395,9 +395,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked"); // HTTP/1.0 does not do chunked. it will just send content and close
|
||||
|
@ -410,9 +410,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -467,9 +467,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobar");
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -483,10 +483,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Buffer size is too small, so the content is written directly producing a 200 response
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobar");
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -541,10 +541,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
assertHeader(response, "content-length", "3");
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
@ -556,11 +556,11 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
//TODO: should we expect 500 here?
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
assertHeader(response, "content-length", "3");
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
@ -613,11 +613,11 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
// jetty truncates the body when content-length is reached.! This is correct and desired behaviour?
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
assertHeader(response, "content-length", "3");
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
@ -629,11 +629,11 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// TODO: we throw before response is committed. should we expect 500?
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
assertHeader(response, "content-length", "3");
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
@ -686,9 +686,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
//TODO: jetty ignores setContentLength and sends transfer-encoding header. Correct?
|
||||
}
|
||||
|
@ -700,9 +700,9 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
||||
|
@ -754,10 +754,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Setting a content-length too small throws an IllegalStateException
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
||||
|
@ -768,10 +768,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
|||
server.setHandler(handler);
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Setting a content-length too small throws an IllegalStateException
|
||||
assertThat(response.getCode(), is("500"));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
assertThat("no exceptions", handler.failure(), is(nullValue()));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.hamcrest.Matchers.endsWith;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -31,20 +32,19 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
//TODO: reset buffer tests
|
||||
//TODO: add protocol specific tests for connection: close and/or chunking
|
||||
@RunWith(value = Parameterized.class)
|
||||
@RunWith(Parameterized.class)
|
||||
public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
||||
{
|
||||
@Parameterized.Parameters
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
public static Collection<Object[]> data()
|
||||
{
|
||||
Object[][] data = new Object[][]{{HttpVersion.HTTP_1_0.asString()}, {HttpVersion.HTTP_1_1.asString()}};
|
||||
|
@ -61,10 +61,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
{
|
||||
server.setHandler(new DoesNotSetHandledHandler(false));
|
||||
server.start();
|
||||
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
|
||||
assertThat("response code is 404", response.getCode(), is("404"));
|
||||
assertThat("response code", response.getStatus(), is(404));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -72,10 +72,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
{
|
||||
server.setHandler(new DoesNotSetHandledHandler(true));
|
||||
server.start();
|
||||
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
}
|
||||
|
||||
private class DoesNotSetHandledHandler extends ThrowExceptionOnDemandHandler
|
||||
|
@ -99,10 +99,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new OnlySetHandledHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
if (HttpVersion.HTTP_1_1.asString().equals(httpVersion))
|
||||
assertHeader(response, "content-length", "0");
|
||||
}
|
||||
|
@ -113,9 +112,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new OnlySetHandledHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
}
|
||||
|
||||
private class OnlySetHandledHandler extends ThrowExceptionOnDemandHandler
|
||||
|
@ -139,9 +138,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new SetHandledWriteSomeDataHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobar");
|
||||
assertHeader(response, "content-length", "6");
|
||||
}
|
||||
|
@ -152,10 +151,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new SetHandledWriteSomeDataHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response body is not foobar", response.getBody(), not(is("foobar")));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
assertThat("response body", response.getContent(), not(is("foobar")));
|
||||
}
|
||||
|
||||
private class SetHandledWriteSomeDataHandler extends ThrowExceptionOnDemandHandler
|
||||
|
@ -180,9 +179,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new ExplicitFlushHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobar");
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -194,11 +193,11 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new ExplicitFlushHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Since the 200 was committed, the 500 did not get the chance to be written
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foobar", response.getBody(), is("foobar"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foobar"));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
}
|
||||
|
@ -226,9 +225,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new SetHandledAndFlushWithoutContentHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
}
|
||||
|
@ -239,9 +238,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new SetHandledAndFlushWithoutContentHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
}
|
||||
|
@ -268,9 +267,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new WriteFlushWriteMoreHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobar");
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -282,11 +281,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new WriteFlushWriteMoreHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Since the 200 was committed, the 500 did not get the chance to be written
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
}
|
||||
|
@ -315,9 +313,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new OverflowHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobar");
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -329,9 +327,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new Overflow2Handler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobarfoobar");
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -343,9 +341,9 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new Overflow3Handler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobarfoobar");
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -357,10 +355,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new OverflowHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Response was committed when we throw, so 200 expected
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertResponseBody(response, "foobar");
|
||||
if (!"HTTP/1.0".equals(httpVersion))
|
||||
assertHeader(response, "transfer-encoding", "chunked");
|
||||
|
@ -430,13 +428,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.start();
|
||||
try
|
||||
{
|
||||
// TODO This test is compromised by the SimpleHttpResponse mechanism.
|
||||
// Replace with a better client
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
String failed_body = ""+(char)-1+(char)-1+(char)-1;
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat(response.getBody(), Matchers.endsWith(failed_body));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat(response.getContent(), endsWith(failed_body));
|
||||
assertHeader(response, "content-length", "6");
|
||||
}
|
||||
catch(EOFException e)
|
||||
|
@ -453,12 +448,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
|
||||
try
|
||||
{
|
||||
// TODO This test is compromised by the SimpleHttpResponse mechanism.
|
||||
// Replace with a better client
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
String failed_body = ""+(char)-1+(char)-1+(char)-1;
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat(response.getBody(), Matchers.endsWith(failed_body));
|
||||
assertThat("response code is 200", response.getStatus(), is(200));
|
||||
assertThat(response.getContent(), endsWith(failed_body));
|
||||
assertHeader(response, "content-length", "6");
|
||||
}
|
||||
catch(EOFException e)
|
||||
|
@ -473,10 +466,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new SetContentLengthAndWriteThatAmountOfBytesHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
assertHeader(response, "content-length", "3");
|
||||
}
|
||||
|
||||
|
@ -486,11 +479,11 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new SetContentLengthAndWriteThatAmountOfBytesHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Setting the content-length and then writing the bytes commits the response
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
}
|
||||
|
||||
private class SetContentLengthAndWriteInsufficientBytesHandler extends AbstractHandler
|
||||
|
@ -535,10 +528,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new SetContentLengthAndWriteMoreBytesHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
assertHeader(response, "content-length", "3");
|
||||
}
|
||||
|
||||
|
@ -548,11 +541,11 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new SetContentLengthAndWriteMoreBytesHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Setting the content-length and then writing the bytes commits the response
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
}
|
||||
|
||||
private class SetContentLengthAndWriteMoreBytesHandler extends ThrowExceptionOnDemandHandler
|
||||
|
@ -579,10 +572,10 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new WriteAndSetContentLengthHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
assertHeader(response, "content-length", "3");
|
||||
}
|
||||
|
||||
|
@ -592,11 +585,11 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new WriteAndSetContentLengthHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Writing the bytes and then setting the content-length commits the response
|
||||
assertThat("response code is 200", response.getCode(), is("200"));
|
||||
assertThat("response body is foo", response.getBody(), is("foo"));
|
||||
assertThat("response code", response.getStatus(), is(200));
|
||||
assertThat("response body", response.getContent(), is("foo"));
|
||||
}
|
||||
|
||||
private class WriteAndSetContentLengthHandler extends ThrowExceptionOnDemandHandler
|
||||
|
@ -622,11 +615,11 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new WriteAndSetContentLengthTooSmallHandler(false));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Setting a content-length too small throws an IllegalStateException
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response body is not foo", response.getBody(), not(is("foo")));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
assertThat("response body", response.getContent(), not(is("foo")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -635,11 +628,11 @@ public class HttpManyWaysToCommitTest extends AbstractHttpTest
|
|||
server.setHandler(new WriteAndSetContentLengthTooSmallHandler(true));
|
||||
server.start();
|
||||
|
||||
SimpleHttpResponse response = executeRequest();
|
||||
HttpTester.Response response = executeRequest();
|
||||
|
||||
// Setting a content-length too small throws an IllegalStateException
|
||||
assertThat("response code is 500", response.getCode(), is("500"));
|
||||
assertThat("response body is not foo", response.getBody(), not(is("foo")));
|
||||
assertThat("response code", response.getStatus(), is(500));
|
||||
assertThat("response body", response.getContent(), not(is("foo")));
|
||||
}
|
||||
|
||||
private class WriteAndSetContentLengthTooSmallHandler extends ThrowExceptionOnDemandHandler
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
|
||||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyStore;
|
||||
|
@ -50,7 +50,6 @@ import org.eclipse.jetty.server.Request;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
import org.junit.After;
|
||||
|
@ -155,8 +154,8 @@ public class DebugHandlerTest
|
|||
@Test
|
||||
public void testThreadName() throws IOException
|
||||
{
|
||||
SimpleRequest req = new SimpleRequest(serverURI);
|
||||
req.getString("/foo/bar?a=b");
|
||||
HttpURLConnection http = (HttpURLConnection) serverURI.resolve("/foo/bar?a=b").toURL().openConnection();
|
||||
assertThat("Response Code", http.getResponseCode(), is(200));
|
||||
|
||||
String log = capturedLog.toString(StandardCharsets.UTF_8.name());
|
||||
String expectedThreadName = String.format("//%s:%s/foo/bar?a=b",serverURI.getHost(),serverURI.getPort());
|
||||
|
@ -169,8 +168,8 @@ public class DebugHandlerTest
|
|||
@Test
|
||||
public void testSecureThreadName() throws IOException
|
||||
{
|
||||
SimpleRequest req = new SimpleRequest(secureServerURI);
|
||||
req.getString("/foo/bar?a=b");
|
||||
HttpURLConnection http = (HttpURLConnection) secureServerURI.resolve("/foo/bar?a=b").toURL().openConnection();
|
||||
assertThat("Response Code", http.getResponseCode(), is(200));
|
||||
|
||||
String log = capturedLog.toString(StandardCharsets.UTF_8.name());
|
||||
String expectedThreadName = String.format("https://%s:%s/foo/bar?a=b",secureServerURI.getHost(),secureServerURI.getPort());
|
||||
|
|
|
@ -18,15 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
|
@ -37,10 +34,9 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpParser;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -67,7 +63,8 @@ public class AsyncContextListenersTest
|
|||
{
|
||||
_server.stop();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@Test
|
||||
public void testListenerClearedOnSecondRequest() throws Exception
|
||||
{
|
||||
|
@ -105,7 +102,7 @@ public class AsyncContextListenersTest
|
|||
asyncContext.complete();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
try (Socket socket = new Socket("localhost", _connector.getLocalPort()))
|
||||
{
|
||||
OutputStream output = socket.getOutputStream();
|
||||
|
@ -116,11 +113,10 @@ public class AsyncContextListenersTest
|
|||
"\r\n";
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
|
||||
SimpleHttpParser parser = new SimpleHttpParser();
|
||||
SimpleHttpResponse response = parser.readResponse(reader);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
|
||||
HttpTester.Input input = HttpTester.from(socket.getInputStream());
|
||||
HttpTester.Response response = HttpTester.parseResponse(input);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
completes.get().await(10,TimeUnit.SECONDS);
|
||||
|
||||
// Send a second request
|
||||
|
@ -128,12 +124,13 @@ public class AsyncContextListenersTest
|
|||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = parser.readResponse(reader);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
response = HttpTester.parseResponse(input);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
completes.get().await(10,TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
@Test
|
||||
public void testListenerAddedFromListener() throws Exception
|
||||
{
|
||||
|
@ -188,19 +185,18 @@ public class AsyncContextListenersTest
|
|||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
|
||||
SimpleHttpParser parser = new SimpleHttpParser();
|
||||
SimpleHttpResponse response = parser.readResponse(reader);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
HttpTester.Input input = HttpTester.from(socket.getInputStream());
|
||||
HttpTester.Response response = HttpTester.parseResponse(input);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
completes.get().await(10,TimeUnit.SECONDS);
|
||||
|
||||
// Send a second request
|
||||
completes.set(new CountDownLatch(1));
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = parser.readResponse(reader);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
|
||||
response = HttpTester.parseResponse(input);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
completes.get().await(10,TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
@ -265,11 +261,10 @@ public class AsyncContextListenersTest
|
|||
"\r\n";
|
||||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
|
||||
SimpleHttpParser parser = new SimpleHttpParser();
|
||||
SimpleHttpResponse response = parser.readResponse(reader);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
|
||||
HttpTester.Input input = HttpTester.from(socket.getInputStream());
|
||||
HttpTester.Response response = HttpTester.parseResponse(input);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
completes.get().await(10,TimeUnit.SECONDS);
|
||||
|
||||
// Send a second request
|
||||
|
@ -277,8 +272,8 @@ public class AsyncContextListenersTest
|
|||
output.write(request.getBytes(StandardCharsets.UTF_8));
|
||||
output.flush();
|
||||
|
||||
response = parser.readResponse(reader);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
response = HttpTester.parseResponse(input);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
completes.get().await(10,TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -33,11 +31,10 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.toolchain.test.TestTracker;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpParser;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
|
@ -129,7 +126,7 @@ public class AsyncServletLongPollTest
|
|||
|
||||
Assert.assertTrue(asyncLatch.await(5, TimeUnit.SECONDS));
|
||||
|
||||
String error = "408";
|
||||
int error = 408;
|
||||
try (Socket socket2 = new Socket("localhost", connector.getLocalPort()))
|
||||
{
|
||||
String request2 = "DELETE " + uri + "?error=" + error + " HTTP/1.1\r\n" +
|
||||
|
@ -139,17 +136,16 @@ public class AsyncServletLongPollTest
|
|||
output2.write(request2.getBytes(StandardCharsets.UTF_8));
|
||||
output2.flush();
|
||||
|
||||
SimpleHttpParser parser2 = new SimpleHttpParser();
|
||||
BufferedReader input2 = new BufferedReader(new InputStreamReader(socket2.getInputStream(), StandardCharsets.UTF_8));
|
||||
SimpleHttpResponse response2 = parser2.readResponse(input2);
|
||||
Assert.assertEquals("200", response2.getCode());
|
||||
HttpTester.Input input2 = HttpTester.from(socket2.getInputStream());
|
||||
HttpTester.Response response2 = HttpTester.parseResponse(input2);
|
||||
Assert.assertEquals(200, response2.getStatus());
|
||||
}
|
||||
|
||||
socket1.setSoTimeout(2 * wait);
|
||||
SimpleHttpParser parser1 = new SimpleHttpParser();
|
||||
BufferedReader input1 = new BufferedReader(new InputStreamReader(socket1.getInputStream(), StandardCharsets.UTF_8));
|
||||
SimpleHttpResponse response1 = parser1.readResponse(input1);
|
||||
Assert.assertEquals(error, response1.getCode());
|
||||
|
||||
HttpTester.Input input1 = HttpTester.from(socket1.getInputStream());
|
||||
HttpTester.Response response1 = HttpTester.parseResponse(input1);
|
||||
Assert.assertEquals(error, response1.getStatus());
|
||||
|
||||
// Now try to make another request on the first connection
|
||||
// to verify that we set correctly the read interest (#409842)
|
||||
|
@ -159,8 +155,8 @@ public class AsyncServletLongPollTest
|
|||
output1.write(request3.getBytes(StandardCharsets.UTF_8));
|
||||
output1.flush();
|
||||
|
||||
SimpleHttpResponse response3 = parser1.readResponse(input1);
|
||||
Assert.assertEquals("200", response3.getCode());
|
||||
HttpTester.Response response3 = HttpTester.parseResponse(input1);
|
||||
Assert.assertEquals(200, response3.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class DefaultServletRangesTest
|
|||
|
||||
|
||||
testdir.ensureEmpty();
|
||||
File resBase = testdir.getFile("docroot");
|
||||
File resBase = testdir.getPathFile("docroot").toFile();
|
||||
FS.ensureDirExists(resBase);
|
||||
File data = new File(resBase, "data.txt");
|
||||
createFile(data, DATA);
|
||||
|
|
|
@ -18,9 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.servlet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.Arrays;
|
||||
|
@ -35,10 +34,9 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpParser;
|
||||
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -49,7 +47,7 @@ import org.junit.runners.Parameterized;
|
|||
@RunWith(Parameterized.class)
|
||||
public class SSLAsyncIOServletTest
|
||||
{
|
||||
@Parameterized.Parameters
|
||||
@Parameterized.Parameters(name = "ssl={0}")
|
||||
public static Collection<SslContextFactory[]> parameters()
|
||||
{
|
||||
return Arrays.asList(new SslContextFactory[]{null}, new SslContextFactory[]{new SslContextFactory()});
|
||||
|
@ -159,16 +157,16 @@ public class SSLAsyncIOServletTest
|
|||
String request = "" +
|
||||
"GET " + contextPath + servletPath + " HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"\r\n";
|
||||
OutputStream output = client.getOutputStream();
|
||||
output.write(request.getBytes("UTF-8"));
|
||||
output.flush();
|
||||
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(client.getInputStream(), "UTF-8"));
|
||||
SimpleHttpParser parser = new SimpleHttpParser();
|
||||
SimpleHttpResponse response = parser.readResponse(input);
|
||||
Assert.assertEquals("200", response.getCode());
|
||||
Assert.assertArrayEquals(content, response.getBody().getBytes("UTF-8"));
|
||||
|
||||
InputStream inputStream = client.getInputStream();
|
||||
HttpTester.Response response = HttpTester.parseResponse(inputStream);
|
||||
Assert.assertEquals(200, response.getStatus());
|
||||
Assert.assertArrayEquals(content, response.getContent().getBytes("UTF-8"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ public class GzipDefaultNoRecompressTest
|
|||
private void copyTestFileToServer(String testFilename) throws IOException
|
||||
{
|
||||
File testFile = MavenTestingUtils.getTestResourceFile(testFilename);
|
||||
File outFile = testingdir.getFile(testFilename);
|
||||
File outFile = testingdir.getPathFile(testFilename).toFile();
|
||||
IO.copy(testFile,outFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ public class GzipDefaultTest
|
|||
|
||||
String content = tester.readResponse(response);
|
||||
assertThat("Response content size",content.length(),is(filesize));
|
||||
String expectedContent = IO.readToString(testingdir.getFile("file.txt"));
|
||||
String expectedContent = IO.readToString(testingdir.getPathFile("file.txt").toFile());
|
||||
assertThat("Response content",content,is(expectedContent));
|
||||
}
|
||||
finally
|
||||
|
@ -216,7 +216,7 @@ public class GzipDefaultTest
|
|||
|
||||
String content = tester.readResponse(response);
|
||||
assertThat("Response content size",content.length(),is(0));
|
||||
String expectedContent = IO.readToString(testingdir.getFile("empty.txt"));
|
||||
String expectedContent = IO.readToString(testingdir.getPathFile("empty.txt").toFile());
|
||||
assertThat("Response content",content,is(expectedContent));
|
||||
}
|
||||
finally
|
||||
|
@ -737,7 +737,7 @@ public class GzipDefaultTest
|
|||
assertThat("ETag",response.get("ETAG"),startsWith("W/"));
|
||||
}
|
||||
|
||||
File serverFile = testingdir.getFile(filename);
|
||||
File serverFile = testingdir.getPathFile(filename).toFile();
|
||||
String expectedResponse = IO.readToString(serverFile);
|
||||
|
||||
String actual = tester.readResponse(response);
|
||||
|
|
|
@ -276,7 +276,7 @@ public class GzipTester
|
|||
Assert.assertThat(response.get("ETag"),Matchers.startsWith("W/"));
|
||||
|
||||
// Assert that the decompressed contents are what we expect.
|
||||
File serverFile = testdir.getFile(serverFilename);
|
||||
File serverFile = testdir.getPathFile(serverFilename).toFile();
|
||||
String expected = IO.readToString(serverFile);
|
||||
String actual = null;
|
||||
|
||||
|
@ -538,7 +538,7 @@ public class GzipTester
|
|||
*/
|
||||
public File prepareServerFile(String filename, int filesize) throws IOException
|
||||
{
|
||||
File dir = testdir.getDir();
|
||||
File dir = testdir.getPath().toFile();
|
||||
File testFile = new File(dir,filename);
|
||||
// Make sure we have a uniq filename (to work around windows File.delete bug)
|
||||
int i = 0;
|
||||
|
@ -573,7 +573,7 @@ public class GzipTester
|
|||
public void copyTestServerFile(String filename) throws IOException
|
||||
{
|
||||
File srcFile = MavenTestingUtils.getTestResourceFile(filename);
|
||||
File testFile = testdir.getFile(filename);
|
||||
File testFile = testdir.getPathFile(filename).toFile();
|
||||
|
||||
IO.copy(srcFile,testFile);
|
||||
}
|
||||
|
@ -587,10 +587,11 @@ public class GzipTester
|
|||
*/
|
||||
public void setContentServlet(Class<? extends Servlet> servletClass) throws IOException
|
||||
{
|
||||
String resourceBase = testdir.getPath().toString();
|
||||
tester.setContextPath("/context");
|
||||
tester.setResourceBase(testdir.getDir().getCanonicalPath());
|
||||
tester.setResourceBase(resourceBase);
|
||||
ServletHolder servletHolder = tester.addServlet(servletClass,"/");
|
||||
servletHolder.setInitParameter("baseDir",testdir.getDir().getAbsolutePath());
|
||||
servletHolder.setInitParameter("baseDir",resourceBase);
|
||||
servletHolder.setInitParameter("etags","true");
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class IncludedGzipTest
|
|||
{
|
||||
testdir.ensureEmpty();
|
||||
|
||||
File testFile = testdir.getFile("file.txt");
|
||||
File testFile = testdir.getPathFile("file.txt").toFile();
|
||||
try (OutputStream testOut = new BufferedOutputStream(new FileOutputStream(testFile)))
|
||||
{
|
||||
ByteArrayInputStream testIn = new ByteArrayInputStream(__content.getBytes("ISO8859_1"));
|
||||
|
@ -85,7 +85,7 @@ public class IncludedGzipTest
|
|||
}
|
||||
|
||||
tester=new ServletTester("/context");
|
||||
tester.getContext().setResourceBase(testdir.getDir().getCanonicalPath());
|
||||
tester.getContext().setResourceBase(testdir.getPath().toString());
|
||||
tester.getContext().addServlet(org.eclipse.jetty.servlet.DefaultServlet.class, "/");
|
||||
|
||||
GzipHandler gzipHandler = new GzipHandler();
|
||||
|
@ -97,7 +97,6 @@ public class IncludedGzipTest
|
|||
public void tearDown() throws Exception
|
||||
{
|
||||
tester.stop();
|
||||
IO.delete(testdir.getDir());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.is;
|
|||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -69,13 +70,13 @@ public class IncludeJettyDirTest
|
|||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
|
||||
private MainResult runMain(File baseDir, File homeDir, String... cmdLineArgs) throws Exception
|
||||
private MainResult runMain(Path baseDir, Path homeDir, String... cmdLineArgs) throws Exception
|
||||
{
|
||||
MainResult ret = new MainResult();
|
||||
ret.main = new Main();
|
||||
List<String> cmdLine = new ArrayList<>();
|
||||
cmdLine.add("jetty.home=" + homeDir.getAbsolutePath());
|
||||
cmdLine.add("jetty.base=" + baseDir.getAbsolutePath());
|
||||
cmdLine.add("jetty.home=" + homeDir.toString());
|
||||
cmdLine.add("jetty.base=" + baseDir.toString());
|
||||
// cmdLine.add("--debug");
|
||||
for (String arg : cmdLineArgs)
|
||||
{
|
||||
|
@ -89,13 +90,12 @@ public class IncludeJettyDirTest
|
|||
public void testNoExtras() throws Exception
|
||||
{
|
||||
// Create home
|
||||
testdir.getPathFile("home").toFile();
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -115,17 +115,17 @@ public class IncludeJettyDirTest
|
|||
public void testCommandLine_1Extra() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -133,11 +133,11 @@ public class IncludeJettyDirTest
|
|||
// Simple command line reference to include-jetty-dir
|
||||
MainResult result = runMain(base,home,
|
||||
// direct reference via path
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
List<String> expectedSearchOrder = new ArrayList<>();
|
||||
expectedSearchOrder.add("${jetty.base}");
|
||||
expectedSearchOrder.add(common.getAbsolutePath());
|
||||
expectedSearchOrder.add(common.toString());
|
||||
expectedSearchOrder.add("${jetty.home}");
|
||||
result.assertSearchOrder(expectedSearchOrder);
|
||||
|
||||
|
@ -149,17 +149,17 @@ public class IncludeJettyDirTest
|
|||
public void testCommandLine_1Extra_FromSimpleProp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -167,7 +167,7 @@ public class IncludeJettyDirTest
|
|||
// Simple command line reference to include-jetty-dir via property (also on command line)
|
||||
MainResult result = runMain(base,home,
|
||||
// property
|
||||
"my.common=" + common.getAbsolutePath(),
|
||||
"my.common=" + common.toString(),
|
||||
// reference via property
|
||||
"--include-jetty-dir=${my.common}");
|
||||
|
||||
|
@ -185,21 +185,21 @@ public class IncludeJettyDirTest
|
|||
public void testCommandLine_1Extra_FromPropPrefix() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create opt
|
||||
File opt = testdir.getPathFile("opt").toFile();
|
||||
Path opt = testdir.getPathFile("opt");
|
||||
FS.ensureEmpty(opt);
|
||||
|
||||
// Create common
|
||||
File common = new File(opt,"common");
|
||||
Path common = opt.resolve("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -209,7 +209,7 @@ public class IncludeJettyDirTest
|
|||
// Simple command line reference to include-jetty-dir via property (also on command line)
|
||||
MainResult result = runMain(base,home,
|
||||
// property to 'opt' dir
|
||||
"my.opt=" + opt.getAbsolutePath(),
|
||||
"my.opt=" + opt.toString(),
|
||||
// reference via property prefix
|
||||
"--include-jetty-dir=" + dirRef);
|
||||
|
||||
|
@ -227,21 +227,21 @@ public class IncludeJettyDirTest
|
|||
public void testCommandLine_1Extra_FromCompoundProp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create opt
|
||||
File opt = testdir.getPathFile("opt").toFile();
|
||||
Path opt = testdir.getPathFile("opt");
|
||||
FS.ensureEmpty(opt);
|
||||
|
||||
// Create common
|
||||
File common = new File(opt,"common");
|
||||
Path common = opt.resolve("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -251,7 +251,7 @@ public class IncludeJettyDirTest
|
|||
// Simple command line reference to include-jetty-dir via property (also on command line)
|
||||
MainResult result = runMain(base,home,
|
||||
// property to 'opt' dir
|
||||
"my.opt=" + opt.getAbsolutePath(),
|
||||
"my.opt=" + opt.toString(),
|
||||
// property to commmon dir name
|
||||
"my.dir=common",
|
||||
// reference via property prefix
|
||||
|
@ -271,27 +271,27 @@ public class IncludeJettyDirTest
|
|||
public void testRefCommon() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
MainResult result = runMain(base,home);
|
||||
|
||||
List<String> expectedSearchOrder = new ArrayList<>();
|
||||
expectedSearchOrder.add("${jetty.base}");
|
||||
expectedSearchOrder.add(common.getAbsolutePath());
|
||||
expectedSearchOrder.add(common.toString());
|
||||
expectedSearchOrder.add("${jetty.home}");
|
||||
result.assertSearchOrder(expectedSearchOrder);
|
||||
|
||||
|
@ -303,33 +303,33 @@ public class IncludeJettyDirTest
|
|||
public void testRefCommonAndCorp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getPathFile("corp").toFile();
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath(), //
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString(), //
|
||||
"--include-jetty-dir=" + corp.toString());
|
||||
|
||||
MainResult result = runMain(base,home);
|
||||
|
||||
List<String> expectedSearchOrder = new ArrayList<>();
|
||||
expectedSearchOrder.add("${jetty.base}");
|
||||
expectedSearchOrder.add(common.getAbsolutePath());
|
||||
expectedSearchOrder.add(corp.getAbsolutePath());
|
||||
expectedSearchOrder.add(common.toString());
|
||||
expectedSearchOrder.add(corp.toString());
|
||||
expectedSearchOrder.add("${jetty.home}");
|
||||
result.assertSearchOrder(expectedSearchOrder);
|
||||
|
||||
|
@ -341,35 +341,35 @@ public class IncludeJettyDirTest
|
|||
public void testRefCommonRefCorp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getPathFile("corp").toFile();
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini","jetty.http.port=9090");
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini", //
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath(), //
|
||||
"--include-jetty-dir=" + corp.toString(), //
|
||||
"jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
MainResult result = runMain(base,home);
|
||||
|
||||
List<String> expectedSearchOrder = new ArrayList<>();
|
||||
expectedSearchOrder.add("${jetty.base}");
|
||||
expectedSearchOrder.add(common.getAbsolutePath());
|
||||
expectedSearchOrder.add(corp.getAbsolutePath());
|
||||
expectedSearchOrder.add(common.toString());
|
||||
expectedSearchOrder.add(corp.toString());
|
||||
expectedSearchOrder.add("${jetty.home}");
|
||||
result.assertSearchOrder(expectedSearchOrder);
|
||||
|
||||
|
@ -381,30 +381,30 @@ public class IncludeJettyDirTest
|
|||
public void testRefCommonRefCorp_FromSimpleProps() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getPathFile("corp").toFile();
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini", //
|
||||
"jetty.http.port=9090");
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini", //
|
||||
"my.corp=" + corp.getAbsolutePath(), //
|
||||
"my.corp=" + corp.toString(), //
|
||||
"--include-jetty-dir=${my.corp}", //
|
||||
"jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"my.common=" + common.getAbsolutePath(), //
|
||||
"my.common=" + common.toString(), //
|
||||
"--include-jetty-dir=${my.common}");
|
||||
|
||||
MainResult result = runMain(base,home);
|
||||
|
@ -424,46 +424,46 @@ public class IncludeJettyDirTest
|
|||
public void testRefCommonRefCorp_CmdLineRef() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create devops
|
||||
File devops = testdir.getPathFile("devops").toFile();
|
||||
Path devops = testdir.getPathFile("devops");
|
||||
FS.ensureEmpty(devops);
|
||||
TestEnv.makeFile(devops,"start.ini", //
|
||||
"--module=optional", //
|
||||
"jetty.http.port=2222");
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getPathFile("corp").toFile();
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini", //
|
||||
"jetty.http.port=9090");
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini", //
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath(), //
|
||||
"--include-jetty-dir=" + corp.toString(), //
|
||||
"jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
MainResult result = runMain(base,home,
|
||||
// command line provided include-jetty-dir ref
|
||||
"--include-jetty-dir=" + devops.getAbsolutePath());
|
||||
"--include-jetty-dir=" + devops.toString());
|
||||
|
||||
List<String> expectedSearchOrder = new ArrayList<>();
|
||||
expectedSearchOrder.add("${jetty.base}");
|
||||
expectedSearchOrder.add(devops.getAbsolutePath());
|
||||
expectedSearchOrder.add(common.getAbsolutePath());
|
||||
expectedSearchOrder.add(corp.getAbsolutePath());
|
||||
expectedSearchOrder.add(devops.toString());
|
||||
expectedSearchOrder.add(common.toString());
|
||||
expectedSearchOrder.add(corp.toString());
|
||||
expectedSearchOrder.add("${jetty.home}");
|
||||
result.assertSearchOrder(expectedSearchOrder);
|
||||
|
||||
|
@ -475,29 +475,29 @@ public class IncludeJettyDirTest
|
|||
public void testRefCommonRefCorp_CmdLineProp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getPathFile("corp").toFile();
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini", //
|
||||
"jetty.http.port=9090");
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini", //
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath(), //
|
||||
"--include-jetty-dir=" + corp.toString(), //
|
||||
"jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
MainResult result = runMain(base,home,
|
||||
// command line property should override all others
|
||||
|
@ -505,8 +505,8 @@ public class IncludeJettyDirTest
|
|||
|
||||
List<String> expectedSearchOrder = new ArrayList<>();
|
||||
expectedSearchOrder.add("${jetty.base}");
|
||||
expectedSearchOrder.add(common.getAbsolutePath());
|
||||
expectedSearchOrder.add(corp.getAbsolutePath());
|
||||
expectedSearchOrder.add(common.toString());
|
||||
expectedSearchOrder.add(corp.toString());
|
||||
expectedSearchOrder.add("${jetty.home}");
|
||||
result.assertSearchOrder(expectedSearchOrder);
|
||||
|
||||
|
@ -518,36 +518,36 @@ public class IncludeJettyDirTest
|
|||
public void testBadDoubleRef() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getPathFile("home").toFile();
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getPathFile("common").toFile();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getPathFile("corp").toFile();
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini",
|
||||
// standard property
|
||||
"jetty.http.port=9090",
|
||||
// INTENTIONAL BAD Reference (duplicate)
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
// Populate common
|
||||
TestEnv.makeFile(common,"start.ini",
|
||||
// standard property
|
||||
"jetty.http.port=8080",
|
||||
// reference to corp
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath());
|
||||
"--include-jetty-dir=" + corp.toString());
|
||||
|
||||
// Create base
|
||||
File base = testdir.getPathFile("base").toFile();
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.start;
|
|||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
|
@ -43,16 +42,16 @@ public class ModuleGraphWriterTest
|
|||
public void testGenerate_NothingEnabled() throws IOException
|
||||
{
|
||||
// Test Env
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("dist-home");
|
||||
File baseDir = testdir.getEmptyDir();
|
||||
Path homeDir = MavenTestingUtils.getTestResourcePathDir("dist-home");
|
||||
Path baseDir = testdir.getEmptyPathDir();
|
||||
String cmdLine[] = new String[] {"jetty.version=TEST"};
|
||||
|
||||
// Configuration
|
||||
CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(cmdLineSource);
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(baseDir.toPath()));
|
||||
config.add(new JettyHomeConfigSource(homeDir));
|
||||
config.add(new JettyBaseConfigSource(baseDir));
|
||||
|
||||
// Initialize
|
||||
BaseHome basehome = new BaseHome(config);
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.hamcrest.Matchers.is;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
||||
import org.eclipse.jetty.start.config.ConfigSources;
|
||||
|
@ -44,16 +45,16 @@ public class ModuleTest
|
|||
public void testLoadMain() throws IOException
|
||||
{
|
||||
// Test Env
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("dist-home");
|
||||
File baseDir = testdir.getEmptyPathDir().toFile();
|
||||
Path homeDir = MavenTestingUtils.getTestResourcePathDir("dist-home");
|
||||
Path baseDir = testdir.getEmptyPathDir();
|
||||
String cmdLine[] = new String[] {"jetty.version=TEST"};
|
||||
|
||||
// Configuration
|
||||
CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(cmdLineSource);
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(baseDir.toPath()));
|
||||
config.add(new JettyHomeConfigSource(homeDir));
|
||||
config.add(new JettyBaseConfigSource(baseDir));
|
||||
|
||||
// Initialize
|
||||
BaseHome basehome = new BaseHome(config);
|
||||
|
|
|
@ -42,8 +42,7 @@ public class PathFinderTest
|
|||
{
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("hb.1/home");
|
||||
Path homePath = homeDir.toPath().toAbsolutePath();
|
||||
File baseDir = testdir.getEmptyDir();
|
||||
Path basePath = baseDir.toPath().toAbsolutePath();
|
||||
Path basePath = testdir.getEmptyPathDir();
|
||||
|
||||
PathFinder finder = new PathFinder();
|
||||
finder.setFileMatcher("glob:**/*.ini");
|
||||
|
@ -69,8 +68,7 @@ public class PathFinderTest
|
|||
{
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("dist-home");
|
||||
Path homePath = homeDir.toPath().toAbsolutePath();
|
||||
File baseDir = testdir.getEmptyDir();
|
||||
Path basePath = baseDir.toPath().toAbsolutePath();
|
||||
Path basePath = testdir.getEmptyPathDir();
|
||||
|
||||
List<String> expected = new ArrayList<>();
|
||||
File modulesDir = new File(homeDir,"modules");
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.IO;
|
||||
|
@ -30,18 +32,19 @@ import org.eclipse.jetty.toolchain.test.OS;
|
|||
|
||||
public class TestEnv
|
||||
{
|
||||
public static void copyTestDir(String testResourceDir, File destDir) throws IOException
|
||||
public static void copyTestDir(String testResourceDir, Path destDir) throws IOException
|
||||
{
|
||||
FS.ensureDirExists(destDir);
|
||||
File srcDir = MavenTestingUtils.getTestResourceDir(testResourceDir);
|
||||
IO.copyDir(srcDir,destDir);
|
||||
IO.copyDir(srcDir,destDir.toFile());
|
||||
}
|
||||
|
||||
public static void makeFile(File dir, String relFilePath, String... contents) throws IOException
|
||||
public static void makeFile(Path dir, String relFilePath, String... contents) throws IOException
|
||||
{
|
||||
File outputFile = new File(dir,OS.separators(relFilePath));
|
||||
FS.ensureDirExists(outputFile.getParentFile());
|
||||
try (FileWriter writer = new FileWriter(outputFile); PrintWriter out = new PrintWriter(writer))
|
||||
Path outputFile = dir.resolve(OS.separators(relFilePath));
|
||||
FS.ensureDirExists(outputFile.getParent());
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(outputFile);
|
||||
PrintWriter out = new PrintWriter(writer))
|
||||
{
|
||||
for (String content : contents)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ConfigSourcesTest
|
|||
ConfigurationAssert.assertOrdered("ConfigSources.id order",expectedList,actualList);
|
||||
}
|
||||
|
||||
private void assertDirOrder(ConfigSources sources, File... expectedDirOrder)
|
||||
private void assertDirOrder(ConfigSources sources, Path... expectedDirOrder) throws IOException
|
||||
{
|
||||
List<String> actualList = new ArrayList<>();
|
||||
for (ConfigSource source : sources)
|
||||
|
@ -66,9 +66,9 @@ public class ConfigSourcesTest
|
|||
}
|
||||
}
|
||||
List<String> expectedList = new ArrayList<>();
|
||||
for (File path : expectedDirOrder)
|
||||
for (Path path : expectedDirOrder)
|
||||
{
|
||||
expectedList.add(path.getAbsolutePath());
|
||||
expectedList.add(path.toRealPath().toString());
|
||||
}
|
||||
ConfigurationAssert.assertOrdered("ConfigSources.dir order",expectedList,actualList);
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ public class ConfigSourcesTest
|
|||
public void testOrder_BasicConfig() throws IOException
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -98,8 +98,8 @@ public class ConfigSourcesTest
|
|||
|
||||
String[] cmdLine = new String[0];
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}","${jetty.home}");
|
||||
}
|
||||
|
@ -108,17 +108,17 @@ public class ConfigSourcesTest
|
|||
public void testOrder_With1ExtraConfig() throws IOException
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
Path common = testdir.getFile("common").toPath();
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common.toFile());
|
||||
common = common.toRealPath();
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
|
@ -128,8 +128,8 @@ public class ConfigSourcesTest
|
|||
|
||||
String[] cmdLine = new String[0];
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath().toRealPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath().toRealPath()));
|
||||
sources.add(new JettyHomeConfigSource(home.toRealPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toRealPath()));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}",common.toString(),"${jetty.home}");
|
||||
}
|
||||
|
@ -138,17 +138,17 @@ public class ConfigSourcesTest
|
|||
public void testCommandLine_1Extra_FromSimpleProp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getFile("common");
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -159,13 +159,13 @@ public class ConfigSourcesTest
|
|||
|
||||
String[] cmdLine = new String[] {
|
||||
// property
|
||||
"my.common=" + common.getAbsolutePath(),
|
||||
"my.common=" + common.toString(),
|
||||
// reference via property
|
||||
"--include-jetty-dir=${my.common}" };
|
||||
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}","${my.common}","${jetty.home}");
|
||||
|
||||
|
@ -179,21 +179,21 @@ public class ConfigSourcesTest
|
|||
public void testCommandLine_1Extra_FromPropPrefix() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create opt
|
||||
File opt = testdir.getFile("opt");
|
||||
Path opt = testdir.getPathFile("opt");
|
||||
FS.ensureEmpty(opt);
|
||||
|
||||
// Create common
|
||||
File common = new File(opt,"common");
|
||||
Path common = opt.resolve("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -205,13 +205,13 @@ public class ConfigSourcesTest
|
|||
// Simple command line reference to include-jetty-dir via property (also on command line)
|
||||
String[] cmdLine = new String[] {
|
||||
// property to 'opt' dir
|
||||
"my.opt=" + opt.getAbsolutePath(),
|
||||
"my.opt=" + opt.toString(),
|
||||
// reference via property prefix
|
||||
"--include-jetty-dir=" + dirRef };
|
||||
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}",dirRef,"${jetty.home}");
|
||||
|
||||
|
@ -225,21 +225,21 @@ public class ConfigSourcesTest
|
|||
public void testCommandLine_1Extra_FromCompoundProp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create opt
|
||||
File opt = testdir.getFile("opt");
|
||||
Path opt = testdir.getPathFile("opt");
|
||||
FS.ensureEmpty(opt);
|
||||
|
||||
// Create common
|
||||
File common = new File(opt,"common");
|
||||
Path common = opt.resolve("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1");
|
||||
|
@ -252,15 +252,15 @@ public class ConfigSourcesTest
|
|||
|
||||
String[] cmdLine = new String[] {
|
||||
// property to 'opt' dir
|
||||
"my.opt=" + opt.getAbsolutePath(),
|
||||
"my.opt=" + opt.toString(),
|
||||
// property to commmon dir name
|
||||
"my.dir=common",
|
||||
// reference via property prefix
|
||||
"--include-jetty-dir=" + dirRef };
|
||||
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}",dirRef,"${jetty.home}");
|
||||
|
||||
|
@ -274,30 +274,30 @@ public class ConfigSourcesTest
|
|||
public void testRefCommon() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getFile("common");
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
ConfigSources sources = new ConfigSources();
|
||||
|
||||
String cmdLine[] = new String[0];
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}",common.getAbsolutePath(),"${jetty.home}");
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}",common.toString(),"${jetty.home}");
|
||||
|
||||
assertDirOrder(sources,base,common,home);
|
||||
|
||||
|
@ -309,37 +309,37 @@ public class ConfigSourcesTest
|
|||
public void testRefCommonAndCorp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getFile("common");
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini","jetty.http.port=8080");
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getFile("corp");
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath(), //
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString(), //
|
||||
"--include-jetty-dir=" + corp.toString());
|
||||
|
||||
ConfigSources sources = new ConfigSources();
|
||||
|
||||
String cmdLine[] = new String[0];
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}",
|
||||
common.getAbsolutePath(),
|
||||
corp.getAbsolutePath(),
|
||||
common.toString(),
|
||||
corp.toString(),
|
||||
"${jetty.home}");
|
||||
|
||||
assertDirOrder(sources,base,common,corp,home);
|
||||
|
@ -352,40 +352,40 @@ public class ConfigSourcesTest
|
|||
public void testRefCommonRefCorp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getFile("corp");
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini", //
|
||||
"jetty.http.port=9090");
|
||||
|
||||
// Create common
|
||||
File common = testdir.getFile("common");
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini", //
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath(), //
|
||||
"--include-jetty-dir=" + corp.toString(), //
|
||||
"jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
ConfigSources sources = new ConfigSources();
|
||||
|
||||
String cmdLine[] = new String[0];
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}",
|
||||
common.getAbsolutePath(),
|
||||
corp.getAbsolutePath(),
|
||||
common.toString(),
|
||||
corp.toString(),
|
||||
"${jetty.home}");
|
||||
|
||||
assertDirOrder(sources,base,common,corp,home);
|
||||
|
@ -398,38 +398,38 @@ public class ConfigSourcesTest
|
|||
public void testRefCommonRefCorp_FromSimpleProps() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getFile("corp");
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini", //
|
||||
"jetty.http.port=9090");
|
||||
|
||||
// Create common
|
||||
File common = testdir.getFile("common");
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini", //
|
||||
"my.corp=" + corp.getAbsolutePath(), //
|
||||
"my.corp=" + corp.toString(), //
|
||||
"--include-jetty-dir=${my.corp}", //
|
||||
"jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"my.common="+common.getAbsolutePath(), //
|
||||
"my.common="+common.toString(), //
|
||||
"--include-jetty-dir=${my.common}");
|
||||
|
||||
ConfigSources sources = new ConfigSources();
|
||||
|
||||
String cmdLine[] = new String[0];
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>",
|
||||
"${jetty.base}",
|
||||
|
@ -447,51 +447,51 @@ public class ConfigSourcesTest
|
|||
public void testRefCommonRefCorp_CmdLineRef() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create devops
|
||||
File devops = testdir.getFile("devops");
|
||||
Path devops = testdir.getPathFile("devops");
|
||||
FS.ensureEmpty(devops);
|
||||
TestEnv.makeFile(devops,"start.ini", //
|
||||
"--module=logging", //
|
||||
"jetty.http.port=2222");
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getFile("corp");
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini", //
|
||||
"jetty.http.port=9090");
|
||||
|
||||
// Create common
|
||||
File common = testdir.getFile("common");
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini", //
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath(), //
|
||||
"--include-jetty-dir=" + corp.toString(), //
|
||||
"jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
ConfigSources sources = new ConfigSources();
|
||||
|
||||
String cmdLine[] = new String[]{
|
||||
// command line provided include-jetty-dir ref
|
||||
"--include-jetty-dir=" + devops.getAbsolutePath()};
|
||||
"--include-jetty-dir=" + devops.toString()};
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>",
|
||||
"${jetty.base}",
|
||||
devops.getAbsolutePath(),
|
||||
common.getAbsolutePath(),
|
||||
corp.getAbsolutePath(),
|
||||
devops.toString(),
|
||||
common.toString(),
|
||||
corp.toString(),
|
||||
"${jetty.home}");
|
||||
|
||||
assertDirOrder(sources,base,devops,common,corp,home);
|
||||
|
@ -504,29 +504,29 @@ public class ConfigSourcesTest
|
|||
public void testRefCommonRefCorp_CmdLineProp() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getFile("corp");
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini", //
|
||||
"jetty.http.port=9090");
|
||||
|
||||
// Create common
|
||||
File common = testdir.getFile("common");
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
TestEnv.makeFile(common,"start.ini", //
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath(), //
|
||||
"--include-jetty-dir=" + corp.toString(), //
|
||||
"jetty.http.port=8080");
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
ConfigSources sources = new ConfigSources();
|
||||
|
||||
|
@ -535,12 +535,12 @@ public class ConfigSourcesTest
|
|||
"jetty.http.port=7070"
|
||||
};
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
assertIdOrder(sources,"<command-line>","${jetty.base}",
|
||||
common.getAbsolutePath(),
|
||||
corp.getAbsolutePath(),
|
||||
common.toString(),
|
||||
corp.toString(),
|
||||
"${jetty.home}");
|
||||
|
||||
assertDirOrder(sources,base,common,corp,home);
|
||||
|
@ -553,36 +553,36 @@ public class ConfigSourcesTest
|
|||
public void testBadDoubleRef() throws Exception
|
||||
{
|
||||
// Create home
|
||||
File home = testdir.getFile("home");
|
||||
Path home = testdir.getPathFile("home");
|
||||
FS.ensureEmpty(home);
|
||||
TestEnv.copyTestDir("dist-home",home);
|
||||
|
||||
// Create common
|
||||
File common = testdir.getFile("common");
|
||||
Path common = testdir.getPathFile("common");
|
||||
FS.ensureEmpty(common);
|
||||
|
||||
// Create corp
|
||||
File corp = testdir.getFile("corp");
|
||||
Path corp = testdir.getPathFile("corp");
|
||||
FS.ensureEmpty(corp);
|
||||
TestEnv.makeFile(corp,"start.ini",
|
||||
// standard property
|
||||
"jetty.http.port=9090",
|
||||
// INTENTIONAL BAD Reference (duplicate)
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
// Populate common
|
||||
TestEnv.makeFile(common,"start.ini",
|
||||
// standard property
|
||||
"jetty.http.port=8080",
|
||||
// reference to corp
|
||||
"--include-jetty-dir=" + corp.getAbsolutePath());
|
||||
"--include-jetty-dir=" + corp.toString());
|
||||
|
||||
// Create base
|
||||
File base = testdir.getFile("base");
|
||||
Path base = testdir.getPathFile("base");
|
||||
FS.ensureEmpty(base);
|
||||
TestEnv.makeFile(base,"start.ini", //
|
||||
"jetty.http.host=127.0.0.1",//
|
||||
"--include-jetty-dir=" + common.getAbsolutePath());
|
||||
"--include-jetty-dir=" + common.toString());
|
||||
|
||||
ConfigSources sources = new ConfigSources();
|
||||
|
||||
|
@ -590,8 +590,8 @@ public class ConfigSourcesTest
|
|||
{
|
||||
String cmdLine[] = new String[0];
|
||||
sources.add(new CommandLineConfigSource(cmdLine));
|
||||
sources.add(new JettyHomeConfigSource(home.toPath()));
|
||||
sources.add(new JettyBaseConfigSource(base.toPath()));
|
||||
sources.add(new JettyHomeConfigSource(home));
|
||||
sources.add(new JettyBaseConfigSource(base));
|
||||
|
||||
Assert.fail("Should have thrown a UsageException");
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.eclipse.jetty.start.BaseHome;
|
||||
import org.eclipse.jetty.start.config.ConfigSources;
|
||||
|
@ -52,11 +52,11 @@ public class MavenLocalRepoFileInitializerTest
|
|||
@Before
|
||||
public void setupBaseHome() throws IOException
|
||||
{
|
||||
File homeDir = testdir.getEmptyDir();
|
||||
Path homeDir = testdir.getEmptyPathDir();
|
||||
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyHomeConfigSource(homeDir));
|
||||
config.add(new JettyBaseConfigSource(homeDir));
|
||||
|
||||
this.baseHome = new BaseHome(config);
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testConfig_ShouldRecurse_0() throws IOException
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
// Create a few directories
|
||||
Files.createDirectories(dir.resolve("a/b/c/d"));
|
||||
|
@ -307,7 +307,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testConfig_ShouldRecurse_1() throws IOException
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
// Create a few directories
|
||||
Files.createDirectories(dir.resolve("a/b/c/d"));
|
||||
|
@ -323,7 +323,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testConfig_ShouldRecurse_2() throws IOException
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
// Create a few directories
|
||||
Files.createDirectories(dir.resolve("a/b/c/d"));
|
||||
|
@ -341,7 +341,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testConfig_ShouldRecurse_3() throws IOException
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
//Create some deep dirs
|
||||
Files.createDirectories(dir.resolve("a/b/c/d/e/f/g"));
|
||||
|
@ -361,7 +361,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testRestart() throws Exception
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
Files.createDirectories(dir.resolve("b/c"));
|
||||
Files.createFile(dir.resolve("a.txt"));
|
||||
Files.createFile(dir.resolve("b.txt"));
|
||||
|
@ -427,7 +427,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testStartupFindFiles() throws Exception
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
// Files we are interested in
|
||||
Files.createFile(dir.resolve("foo.war"));
|
||||
|
@ -479,7 +479,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testGlobPattern () throws Exception
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
// Files we are interested in
|
||||
Files.createFile(dir.resolve("a.txt"));
|
||||
|
@ -531,7 +531,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testDeployFiles_Update_Delete() throws Exception
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
// Files we are interested in
|
||||
Files.createFile(dir.resolve("foo.war"));
|
||||
|
@ -592,7 +592,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testDeployFiles_NewWar() throws Exception
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
// Files we are interested in
|
||||
Files.createFile(dir.resolve("foo.war"));
|
||||
|
@ -656,7 +656,7 @@ public class PathWatcherTest
|
|||
@Test
|
||||
public void testDeployFiles_NewWar_LargeSlowCopy() throws Exception
|
||||
{
|
||||
Path dir = testdir.getEmptyDir().toPath();
|
||||
Path dir = testdir.getEmptyPathDir();
|
||||
|
||||
// Files we are interested in
|
||||
Files.createFile(dir.resolve("foo.war"));
|
||||
|
|
|
@ -335,7 +335,7 @@ public class FileSystemResourceTest
|
|||
public void testLastModified() throws Exception
|
||||
{
|
||||
Path dir = testdir.getPath().normalize().toRealPath();
|
||||
File file = testdir.getFile("foo");
|
||||
File file = testdir.getPathFile("foo").toFile();
|
||||
file.createNewFile();
|
||||
|
||||
long expected = file.lastModified();
|
||||
|
@ -1398,4 +1398,4 @@ public class FileSystemResourceTest
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class WSServer
|
|||
|
||||
public WSServer(TestingDir testdir, String contextName)
|
||||
{
|
||||
this(testdir.getDir(),contextName);
|
||||
this(testdir.getPath().toFile(),contextName);
|
||||
}
|
||||
|
||||
public WSServer(File testdir, String contextName)
|
||||
|
|
|
@ -70,7 +70,7 @@ public class WSServer
|
|||
|
||||
public WSServer(TestingDir testdir, String contextName)
|
||||
{
|
||||
this(testdir.getDir(),contextName);
|
||||
this(testdir.getPath().toFile(),contextName);
|
||||
}
|
||||
|
||||
public WSServer(File testdir, String contextName)
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -940,7 +940,7 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<version>3.1</version>
|
||||
<version>4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
|
|
|
@ -276,7 +276,7 @@ public class JettyDistro
|
|||
*/
|
||||
public JettyDistro(TestingDir testdir) throws IOException
|
||||
{
|
||||
this.jettyHomeDir = testdir.getDir();
|
||||
this.jettyHomeDir = testdir.getPath().toFile();
|
||||
copyBaseDistro();
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ public class JettyDistro
|
|||
*/
|
||||
public JettyDistro(TestingDir testdir, String artifact) throws IOException
|
||||
{
|
||||
this.jettyHomeDir = testdir.getDir();
|
||||
this.jettyHomeDir = testdir.getPath().toFile();
|
||||
if (artifact != null)
|
||||
{
|
||||
this.artifactName = artifact;
|
||||
|
|
|
@ -25,7 +25,9 @@ import static org.hamcrest.Matchers.startsWith;
|
|||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.management.MBeanServerConnection;
|
||||
|
@ -34,14 +36,14 @@ import javax.management.remote.JMXConnector;
|
|||
import javax.management.remote.JMXConnectorFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.jmx.ConnectorServer;
|
||||
import org.eclipse.jetty.jmx.MBeanContainer;
|
||||
import org.eclipse.jetty.server.NetworkConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -140,8 +142,13 @@ public class JmxIT
|
|||
public void testBasic() throws Exception
|
||||
{
|
||||
URI serverURI = new URI("http://localhost:"+String.valueOf(__port)+"/jmx-webapp/");
|
||||
SimpleRequest req = new SimpleRequest(serverURI);
|
||||
assertThat(req.getString("ping"),startsWith("Servlet Pong at "));
|
||||
HttpURLConnection http = (HttpURLConnection) serverURI.resolve("ping").toURL().openConnection();
|
||||
assertThat("http response", http.getResponseCode(), is(200));
|
||||
try(InputStream inputStream = http.getInputStream())
|
||||
{
|
||||
String resp = IO.toString(inputStream);
|
||||
assertThat(resp,startsWith("Servlet Pong at "));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -57,8 +57,7 @@ public class ReloadedSessionMissingClassTest
|
|||
Resource.setDefaultUseCaches(false);
|
||||
String contextPath = "/foo";
|
||||
|
||||
File unpackedWarDir = testdir.getDir();
|
||||
testdir.ensureEmpty();
|
||||
File unpackedWarDir = testdir.getEmptyPathDir().toFile();
|
||||
|
||||
File webInfDir = new File (unpackedWarDir, "WEB-INF");
|
||||
webInfDir.mkdir();
|
||||
|
|
Loading…
Reference in New Issue