fix checkstyle in test sources (#4013)
Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
parent
1a0f08b84d
commit
fe3d3f7158
|
@ -38,7 +38,7 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
@WebFilter(filterName = "CFilter", dispatcherTypes = {DispatcherType.REQUEST}, urlPatterns = {"/*"}, initParams = {
|
@WebFilter(filterName = "CFilter", dispatcherTypes = {DispatcherType.REQUEST}, urlPatterns = {"/*"}, initParams = {
|
||||||
@WebInitParam(name = "a", value = "99")
|
@WebInitParam(name = "a", value = "99")
|
||||||
}, asyncSupported = false)
|
}, asyncSupported = false)
|
||||||
@RunAs("admin")
|
@RunAs("admin")
|
||||||
public class FilterC implements Filter
|
public class FilterC implements Filter
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
@DeclareRoles({"alice"})
|
@DeclareRoles({"alice"})
|
||||||
@WebServlet(urlPatterns = {"/foo/*", "/bah/*"}, name = "CServlet", initParams = {
|
@WebServlet(urlPatterns = {"/foo/*", "/bah/*"}, name = "CServlet", initParams = {
|
||||||
@WebInitParam(name = "x", value = "y")
|
@WebInitParam(name = "x", value = "y")
|
||||||
}, loadOnStartup = 2, asyncSupported = false)
|
}, loadOnStartup = 2, asyncSupported = false)
|
||||||
@MultipartConfig(fileSizeThreshold = 1000, maxFileSize = 2000, maxRequestSize = 3000)
|
@MultipartConfig(fileSizeThreshold = 1000, maxFileSize = 2000, maxRequestSize = 3000)
|
||||||
@RunAs("admin")
|
@RunAs("admin")
|
||||||
@ServletSecurity(value = @HttpConstraint(rolesAllowed = {"fred", "bill", "dorothy"}), httpMethodConstraints = {
|
@ServletSecurity(value = @HttpConstraint(rolesAllowed = {"fred", "bill", "dorothy"}), httpMethodConstraints = {
|
||||||
|
|
|
@ -24,8 +24,8 @@ import javax.servlet.http.HttpServlet;
|
||||||
|
|
||||||
@WebServlet(urlPatterns = {"/", "/bah/*"}, name = "DServlet", initParams = {
|
@WebServlet(urlPatterns = {"/", "/bah/*"}, name = "DServlet", initParams = {
|
||||||
@WebInitParam(name = "x", value = "y")
|
@WebInitParam(name = "x", value = "y")
|
||||||
}, loadOnStartup = 1, asyncSupported = false)
|
}, loadOnStartup = 1, asyncSupported = false)
|
||||||
public class ServletD extends HttpServlet
|
public class ServletD extends HttpServlet
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,16 +63,14 @@ public class TestSecurityAnnotationConversions
|
||||||
|
|
||||||
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
|
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
|
||||||
"tom", "dick", "harry"
|
"tom", "dick", "harry"
|
||||||
}), httpMethodConstraints =
|
}), httpMethodConstraints = {@HttpMethodConstraint(value = "GET")})
|
||||||
{@HttpMethodConstraint(value = "GET")})
|
|
||||||
public static class Method1Servlet extends HttpServlet
|
public static class Method1Servlet extends HttpServlet
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
|
@ServletSecurity(value = @HttpConstraint(value = EmptyRoleSemantic.PERMIT, transportGuarantee = TransportGuarantee.CONFIDENTIAL, rolesAllowed = {
|
||||||
"tom", "dick", "harry"
|
"tom", "dick", "harry"
|
||||||
}), httpMethodConstraints =
|
}), httpMethodConstraints = {@HttpMethodConstraint(value = "GET", transportGuarantee = TransportGuarantee.CONFIDENTIAL)})
|
||||||
{@HttpMethodConstraint(value = "GET", transportGuarantee = TransportGuarantee.CONFIDENTIAL)})
|
|
||||||
public static class Method2Servlet extends HttpServlet
|
public static class Method2Servlet extends HttpServlet
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,8 @@ public class AntBuild
|
||||||
Matcher mat = pat.getMatcher(line);
|
Matcher mat = pat.getMatcher(line);
|
||||||
if (mat.find())
|
if (mat.find())
|
||||||
{
|
{
|
||||||
int num = 0, count = mat.groupCount();
|
int num = 0;
|
||||||
|
int count = mat.groupCount();
|
||||||
String[] match = new String[count];
|
String[] match = new String[count];
|
||||||
while (num++ < count)
|
while (num++ < count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -657,10 +657,10 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
assertEquals("1523430383", headerInfo.getParameter("nonce"));
|
assertEquals("1523430383", headerInfo.getParameter("nonce"));
|
||||||
|
|
||||||
// test multiple authentications
|
// test multiple authentications
|
||||||
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest qop=\"auth\", realm=\"thermostat\", nonce=\"1523430383\", "
|
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest qop=\"auth\", realm=\"thermostat\", nonce=\"1523430383\", " +
|
||||||
+ "Digest realm=\"thermostat2\", qop=\"auth2\", nonce=\"4522530354\", "
|
"Digest realm=\"thermostat2\", qop=\"auth2\", nonce=\"4522530354\", " +
|
||||||
+ "Digest qop=\"auth3\", nonce=\"9523570528\", realm=\"thermostat3\", "
|
"Digest qop=\"auth3\", nonce=\"9523570528\", realm=\"thermostat3\", " +
|
||||||
+ "Digest qop=\"auth4\", nonce=\"3526435321\"");
|
"Digest qop=\"auth4\", nonce=\"3526435321\"");
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(0).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(0).getType().equalsIgnoreCase("Digest"));
|
||||||
assertEquals("auth", headerInfoList.get(0).getParameter("qop"));
|
assertEquals("auth", headerInfoList.get(0).getParameter("qop"));
|
||||||
|
@ -744,8 +744,8 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
assertTrue(headerInfo.getType().equalsIgnoreCase("Negotiate"));
|
assertTrue(headerInfo.getType().equalsIgnoreCase("Negotiate"));
|
||||||
assertEquals("TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAFAs4OAAAADw==", headerInfo.getBase64());
|
assertEquals("TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAFAs4OAAAADw==", headerInfo.getBase64());
|
||||||
|
|
||||||
headerInfos = aph.getHeaderInfo("Negotiate TlRMTVNTUAABAAAAAAAAAFAs4OAAAADw==, "
|
headerInfos = aph.getHeaderInfo("Negotiate TlRMTVNTUAABAAAAAAAAAFAs4OAAAADw==, " +
|
||||||
+ "Negotiate YIIJvwYGKwYBBQUCoIIJszCCCa+gJDAi=");
|
"Negotiate YIIJvwYGKwYBBQUCoIIJszCCCa+gJDAi=");
|
||||||
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Negotiate"));
|
assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Negotiate"));
|
||||||
assertEquals("TlRMTVNTUAABAAAAAAAAAFAs4OAAAADw==", headerInfos.get(0).getBase64());
|
assertEquals("TlRMTVNTUAABAAAAAAAAAFAs4OAAAADw==", headerInfos.get(0).getBase64());
|
||||||
|
|
||||||
|
@ -766,9 +766,9 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest
|
||||||
assertEquals("=1523430383=", headerInfo.getParameter("nonce"));
|
assertEquals("=1523430383=", headerInfo.getParameter("nonce"));
|
||||||
|
|
||||||
// test multiple authentications
|
// test multiple authentications
|
||||||
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest qop=\"=au=th=\", realm=\"=ther=mostat=\", nonce=\"=152343=0383=\", "
|
List<HeaderInfo> headerInfoList = aph.getHeaderInfo("Digest qop=\"=au=th=\", realm=\"=ther=mostat=\", nonce=\"=152343=0383=\", " +
|
||||||
+ "Digest realm=\"=thermostat2\", qop=\"=auth2\", nonce=\"=4522530354\", "
|
"Digest realm=\"=thermostat2\", qop=\"=auth2\", nonce=\"=4522530354\", " +
|
||||||
+ "Digest qop=\"auth3=\", nonce=\"9523570528=\", realm=\"thermostat3=\", ");
|
"Digest qop=\"auth3=\", nonce=\"9523570528=\", realm=\"thermostat3=\", ");
|
||||||
|
|
||||||
assertTrue(headerInfoList.get(0).getType().equalsIgnoreCase("Digest"));
|
assertTrue(headerInfoList.get(0).getType().equalsIgnoreCase("Digest"));
|
||||||
assertEquals("=au=th=", headerInfoList.get(0).getParameter("qop"));
|
assertEquals("=au=th=", headerInfoList.get(0).getParameter("qop"));
|
||||||
|
|
|
@ -67,6 +67,8 @@ public class HttpClientTLSTest
|
||||||
private ServerConnector connector;
|
private ServerConnector connector;
|
||||||
private HttpClient client;
|
private HttpClient client;
|
||||||
|
|
||||||
|
private SSLSocket sslSocket;
|
||||||
|
|
||||||
private void startServer(SslContextFactory sslContextFactory, Handler handler) throws Exception
|
private void startServer(SslContextFactory sslContextFactory, Handler handler) throws Exception
|
||||||
{
|
{
|
||||||
ExecutorThreadPool serverThreads = new ExecutorThreadPool();
|
ExecutorThreadPool serverThreads = new ExecutorThreadPool();
|
||||||
|
@ -419,7 +421,7 @@ public class HttpClientTLSTest
|
||||||
String host = "localhost";
|
String host = "localhost";
|
||||||
int port = connector.getLocalPort();
|
int port = connector.getLocalPort();
|
||||||
Socket socket = new Socket(host, port);
|
Socket socket = new Socket(host, port);
|
||||||
SSLSocket sslSocket = (SSLSocket)clientTLSFactory.getSslContext().getSocketFactory().createSocket(socket, host, port, true);
|
sslSocket = (SSLSocket)clientTLSFactory.getSslContext().getSocketFactory().createSocket(socket, host, port, true);
|
||||||
CountDownLatch handshakeLatch1 = new CountDownLatch(1);
|
CountDownLatch handshakeLatch1 = new CountDownLatch(1);
|
||||||
AtomicReference<byte[]> session1 = new AtomicReference<>();
|
AtomicReference<byte[]> session1 = new AtomicReference<>();
|
||||||
sslSocket.addHandshakeCompletedListener(event ->
|
sslSocket.addHandshakeCompletedListener(event ->
|
||||||
|
@ -432,14 +434,12 @@ public class HttpClientTLSTest
|
||||||
|
|
||||||
// In TLS 1.3 the server sends a NewSessionTicket post-handshake message
|
// In TLS 1.3 the server sends a NewSessionTicket post-handshake message
|
||||||
// to enable session resumption and without a read, the message is not processed.
|
// to enable session resumption and without a read, the message is not processed.
|
||||||
try
|
|
||||||
|
assertThrows(SocketTimeoutException.class, () ->
|
||||||
{
|
{
|
||||||
sslSocket.setSoTimeout(1000);
|
sslSocket.setSoTimeout(1000);
|
||||||
sslSocket.getInputStream().read();
|
sslSocket.getInputStream().read();
|
||||||
}
|
});
|
||||||
catch (SocketTimeoutException expected)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// The client closes abruptly.
|
// The client closes abruptly.
|
||||||
socket.close();
|
socket.close();
|
||||||
|
|
|
@ -1810,7 +1810,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class RetryListener implements Response.CompleteListener
|
public abstract static class RetryListener implements Response.CompleteListener
|
||||||
{
|
{
|
||||||
private final HttpClient client;
|
private final HttpClient client;
|
||||||
private final String scheme;
|
private final String scheme;
|
||||||
|
|
|
@ -45,8 +45,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
|
public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
|
||||||
{
|
{
|
||||||
|
@ -298,14 +298,7 @@ public class HttpDestinationOverHTTPTest extends AbstractHttpClientServerTest
|
||||||
|
|
||||||
server.stop();
|
server.stop();
|
||||||
Request request = client.newRequest(host, port).scheme(scenario.getScheme());
|
Request request = client.newRequest(host, port).scheme(scenario.getScheme());
|
||||||
try
|
assertThrows(Exception.class, () -> request.send());
|
||||||
{
|
|
||||||
request.send();
|
|
||||||
fail("Request to a closed port must fail");
|
|
||||||
}
|
|
||||||
catch (Exception expected)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(1);
|
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(1);
|
||||||
while (!client.getDestinations().isEmpty() && System.nanoTime() < deadline)
|
while (!client.getDestinations().isEmpty() && System.nanoTime() < deadline)
|
||||||
|
|
|
@ -1397,6 +1397,7 @@ public class SslBytesServerTest extends SslBytesTest
|
||||||
{
|
{
|
||||||
case APPLICATION:
|
case APPLICATION:
|
||||||
fail("application data not allows after renegotiate");
|
fail("application data not allows after renegotiate");
|
||||||
|
return; // this is just to avoid checkstyle warning
|
||||||
case ALERT:
|
case ALERT:
|
||||||
break loop;
|
break loop;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -435,7 +435,7 @@ public class MultiPartContentProviderTest extends AbstractHttpClientServerTest
|
||||||
assertTrue(responseLatch.await(5, TimeUnit.SECONDS));
|
assertTrue(responseLatch.await(5, TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static abstract class AbstractMultiPartHandler extends AbstractHandler
|
private abstract static class AbstractMultiPartHandler extends AbstractHandler
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
|
|
|
@ -206,7 +206,7 @@ public class MultiPartFormInputStream
|
||||||
public Collection<String> getHeaders(String name)
|
public Collection<String> getHeaders(String name)
|
||||||
{
|
{
|
||||||
Collection<String> headers = _headers.getValues(name);
|
Collection<String> headers = _headers.getValues(name);
|
||||||
return headers == null ? Collections.emptyList():headers;
|
return headers == null ? Collections.emptyList() : headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class HttpParserTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLineParse_Mock_IP() throws Exception
|
public void testLineParseMockIP() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer("POST /mock/127.0.0.1 HTTP/1.1\r\n" + "\r\n");
|
ByteBuffer buffer = BufferUtil.toBuffer("POST /mock/127.0.0.1 HTTP/1.1\r\n" + "\r\n");
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class HttpParserTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLineParse1_RFC2616() throws Exception
|
public void testLineParse1RFC2616() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer("GET /999\r\n");
|
ByteBuffer buffer = BufferUtil.toBuffer("GET /999\r\n");
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ public class HttpParserTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLineParse2_RFC2616() throws Exception
|
public void testLineParse2RFC2616() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer("POST /222 \r\n");
|
ByteBuffer buffer = BufferUtil.toBuffer("POST /222 \r\n");
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ public class HttpParserTest
|
||||||
HttpCompliance.RFC7230, HttpCompliance.RFC2616
|
HttpCompliance.RFC7230, HttpCompliance.RFC2616
|
||||||
};
|
};
|
||||||
|
|
||||||
String whitespaces[][] = new String[][]
|
String[][] whitespaces = new String[][]
|
||||||
{
|
{
|
||||||
{" ", "Illegal character SPACE"},
|
{" ", "Illegal character SPACE"},
|
||||||
{"\t", "Illegal character HTAB"},
|
{"\t", "Illegal character HTAB"},
|
||||||
|
@ -802,9 +802,9 @@ public class HttpParserTest
|
||||||
public void testBadHeaderEncoding() throws Exception
|
public void testBadHeaderEncoding() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.0\r\n"
|
"GET / HTTP/1.0\r\n" +
|
||||||
+ "H\u00e6der0: value0\r\n"
|
"H\u00e6der0: value0\r\n" +
|
||||||
+ "\n\n");
|
"\n\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -832,7 +832,7 @@ public class HttpParserTest
|
||||||
"Foo/Bar: value\r\n",
|
"Foo/Bar: value\r\n",
|
||||||
"Foo]Bar: value\r\n",
|
"Foo]Bar: value\r\n",
|
||||||
"Foo[Bar: value\r\n",
|
"Foo[Bar: value\r\n",
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < bad.length; i++)
|
for (int i = 0; i < bad.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -1003,16 +1003,16 @@ public class HttpParserTest
|
||||||
public void testChunkParse() throws Exception
|
public void testChunkParse() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /chunk HTTP/1.0\r\n"
|
"GET /chunk HTTP/1.0\r\n" +
|
||||||
+ "Header1: value1\r\n"
|
"Header1: value1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n"
|
"0123456789\r\n" +
|
||||||
+ "1a\r\n"
|
"1a\r\n" +
|
||||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parseAll(parser, buffer);
|
parseAll(parser, buffer);
|
||||||
|
@ -1033,16 +1033,16 @@ public class HttpParserTest
|
||||||
public void testBadChunkParse() throws Exception
|
public void testBadChunkParse() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /chunk HTTP/1.0\r\n"
|
"GET /chunk HTTP/1.0\r\n" +
|
||||||
+ "Header1: value1\r\n"
|
"Header1: value1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked, identity\r\n"
|
"Transfer-Encoding: chunked, identity\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n"
|
"0123456789\r\n" +
|
||||||
+ "1a\r\n"
|
"1a\r\n" +
|
||||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parseAll(parser, buffer);
|
parseAll(parser, buffer);
|
||||||
|
@ -1057,17 +1057,17 @@ public class HttpParserTest
|
||||||
public void testChunkParseTrailer() throws Exception
|
public void testChunkParseTrailer() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /chunk HTTP/1.0\r\n"
|
"GET /chunk HTTP/1.0\r\n" +
|
||||||
+ "Header1: value1\r\n"
|
"Header1: value1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n"
|
"0123456789\r\n" +
|
||||||
+ "1a\r\n"
|
"1a\r\n" +
|
||||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
+ "Trailer: value\r\n"
|
"Trailer: value\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parseAll(parser, buffer);
|
parseAll(parser, buffer);
|
||||||
|
@ -1092,17 +1092,17 @@ public class HttpParserTest
|
||||||
public void testChunkParseTrailers() throws Exception
|
public void testChunkParseTrailers() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /chunk HTTP/1.0\r\n"
|
"GET /chunk HTTP/1.0\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n"
|
"0123456789\r\n" +
|
||||||
+ "1a\r\n"
|
"1a\r\n" +
|
||||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
+ "Trailer: value\r\n"
|
"Trailer: value\r\n" +
|
||||||
+ "Foo: bar\r\n"
|
"Foo: bar\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parseAll(parser, buffer);
|
parseAll(parser, buffer);
|
||||||
|
@ -1130,16 +1130,16 @@ public class HttpParserTest
|
||||||
public void testChunkParseBadTrailer() throws Exception
|
public void testChunkParseBadTrailer() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /chunk HTTP/1.0\r\n"
|
"GET /chunk HTTP/1.0\r\n" +
|
||||||
+ "Header1: value1\r\n"
|
"Header1: value1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n"
|
"0123456789\r\n" +
|
||||||
+ "1a\r\n"
|
"1a\r\n" +
|
||||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
+ "Trailer: value");
|
"Trailer: value");
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parseAll(parser, buffer);
|
parseAll(parser, buffer);
|
||||||
|
@ -1162,15 +1162,15 @@ public class HttpParserTest
|
||||||
public void testChunkParseNoTrailer() throws Exception
|
public void testChunkParseNoTrailer() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /chunk HTTP/1.0\r\n"
|
"GET /chunk HTTP/1.0\r\n" +
|
||||||
+ "Header1: value1\r\n"
|
"Header1: value1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n"
|
"0123456789\r\n" +
|
||||||
+ "1a\r\n"
|
"1a\r\n" +
|
||||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" +
|
||||||
+ "0\r\n");
|
"0\r\n");
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parseAll(parser, buffer);
|
parseAll(parser, buffer);
|
||||||
|
@ -1205,10 +1205,10 @@ public class HttpParserTest
|
||||||
public void testEarlyEOF() throws Exception
|
public void testEarlyEOF() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /uri HTTP/1.0\r\n"
|
"GET /uri HTTP/1.0\r\n" +
|
||||||
+ "Content-Length: 20\r\n"
|
"Content-Length: 20\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "0123456789");
|
"0123456789");
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parser.atEOF();
|
parser.atEOF();
|
||||||
|
@ -1226,12 +1226,12 @@ public class HttpParserTest
|
||||||
public void testChunkEarlyEOF() throws Exception
|
public void testChunkEarlyEOF() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /chunk HTTP/1.0\r\n"
|
"GET /chunk HTTP/1.0\r\n" +
|
||||||
+ "Header1: value1\r\n"
|
"Header1: value1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n");
|
"0123456789\r\n");
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parser.atEOF();
|
parser.atEOF();
|
||||||
|
@ -1252,31 +1252,31 @@ public class HttpParserTest
|
||||||
public void testMultiParse() throws Exception
|
public void testMultiParse() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET /mp HTTP/1.0\r\n"
|
"GET /mp HTTP/1.0\r\n" +
|
||||||
+ "Connection: Keep-Alive\r\n"
|
"Connection: Keep-Alive\r\n" +
|
||||||
+ "Header1: value1\r\n"
|
"Header1: value1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n"
|
"0123456789\r\n" +
|
||||||
+ "1a\r\n"
|
"1a\r\n" +
|
||||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
|
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
|
|
||||||
+ "POST /foo HTTP/1.0\r\n"
|
"POST /foo HTTP/1.0\r\n" +
|
||||||
+ "Connection: Keep-Alive\r\n"
|
"Connection: Keep-Alive\r\n" +
|
||||||
+ "Header2: value2\r\n"
|
"Header2: value2\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
|
|
||||||
+ "PUT /doodle HTTP/1.0\r\n"
|
"PUT /doodle HTTP/1.0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "Header3: value3\r\n"
|
"Header3: value3\r\n" +
|
||||||
+ "Content-Length: 10\r\n"
|
"Content-Length: 10\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "0123456789\r\n");
|
"0123456789\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1317,32 +1317,31 @@ public class HttpParserTest
|
||||||
public void testMultiParseEarlyEOF() throws Exception
|
public void testMultiParseEarlyEOF() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer0 = BufferUtil.toBuffer(
|
ByteBuffer buffer0 = BufferUtil.toBuffer(
|
||||||
"GET /mp HTTP/1.0\r\n"
|
"GET /mp HTTP/1.0\r\n" +
|
||||||
+ "Connection: Keep-Alive\r\n");
|
"Connection: Keep-Alive\r\n");
|
||||||
|
|
||||||
ByteBuffer buffer1 = BufferUtil.toBuffer("Header1: value1\r\n"
|
ByteBuffer buffer1 = BufferUtil.toBuffer("Header1: value1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "a;\r\n"
|
"a;\r\n" +
|
||||||
+ "0123456789\r\n"
|
"0123456789\r\n" +
|
||||||
+ "1a\r\n"
|
"1a\r\n" +
|
||||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
|
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
|
|
||||||
+ "POST /foo HTTP/1.0\r\n"
|
"POST /foo HTTP/1.0\r\n" +
|
||||||
+ "Connection: Keep-Alive\r\n"
|
"Connection: Keep-Alive\r\n" +
|
||||||
+ "Header2: value2\r\n"
|
"Header2: value2\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
|
|
||||||
+ "PUT /doodle HTTP/1.0\r\n"
|
"PUT /doodle HTTP/1.0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" + "Header3: value3\r\n" +
|
||||||
+ "Header3: value3\r\n"
|
"Content-Length: 10\r\n" +
|
||||||
+ "Content-Length: 10\r\n"
|
"\r\n" +
|
||||||
+ "\r\n"
|
"0123456789\r\n");
|
||||||
+ "0123456789\r\n");
|
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1384,11 +1383,11 @@ public class HttpParserTest
|
||||||
public void testResponseParse0() throws Exception
|
public void testResponseParse0() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 200 Correct\r\n"
|
"HTTP/1.1 200 Correct\r\n" +
|
||||||
+ "Content-Length: 10\r\n"
|
"Content-Length: 10\r\n" +
|
||||||
+ "Content-Type: text/plain\r\n"
|
"Content-Type: text/plain\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "0123456789\r\n");
|
"0123456789\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1405,9 +1404,9 @@ public class HttpParserTest
|
||||||
public void testResponseParse1() throws Exception
|
public void testResponseParse1() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 304 Not-Modified\r\n"
|
"HTTP/1.1 304 Not-Modified\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1423,15 +1422,15 @@ public class HttpParserTest
|
||||||
public void testResponseParse2() throws Exception
|
public void testResponseParse2() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 204 No-Content\r\n"
|
"HTTP/1.1 204 No-Content\r\n" +
|
||||||
+ "Header: value\r\n"
|
"Header: value\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
|
|
||||||
+ "HTTP/1.1 200 Correct\r\n"
|
"HTTP/1.1 200 Correct\r\n" +
|
||||||
+ "Content-Length: 10\r\n"
|
"Content-Length: 10\r\n" +
|
||||||
+ "Content-Type: text/plain\r\n"
|
"Content-Type: text/plain\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "0123456789\r\n");
|
"0123456789\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1459,11 +1458,11 @@ public class HttpParserTest
|
||||||
public void testResponseParse3() throws Exception
|
public void testResponseParse3() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 200\r\n"
|
"HTTP/1.1 200\r\n" +
|
||||||
+ "Content-Length: 10\r\n"
|
"Content-Length: 10\r\n" +
|
||||||
+ "Content-Type: text/plain\r\n"
|
"Content-Type: text/plain\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "0123456789\r\n");
|
"0123456789\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1480,11 +1479,11 @@ public class HttpParserTest
|
||||||
public void testResponseParse4() throws Exception
|
public void testResponseParse4() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 200 \r\n"
|
"HTTP/1.1 200 \r\n" +
|
||||||
+ "Content-Length: 10\r\n"
|
"Content-Length: 10\r\n" +
|
||||||
+ "Content-Type: text/plain\r\n"
|
"Content-Type: text/plain\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "0123456789\r\n");
|
"0123456789\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1501,10 +1500,10 @@ public class HttpParserTest
|
||||||
public void testResponseEOFContent() throws Exception
|
public void testResponseEOFContent() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 200 \r\n"
|
"HTTP/1.1 200 \r\n" +
|
||||||
+ "Content-Type: text/plain\r\n"
|
"Content-Type: text/plain\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "0123456789\r\n");
|
"0123456789\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1524,9 +1523,9 @@ public class HttpParserTest
|
||||||
public void testResponse304WithContentLength() throws Exception
|
public void testResponse304WithContentLength() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 304 found\r\n"
|
"HTTP/1.1 304 found\r\n" +
|
||||||
+ "Content-Length: 10\r\n"
|
"Content-Length: 10\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1543,9 +1542,9 @@ public class HttpParserTest
|
||||||
public void testResponse101WithTransferEncoding() throws Exception
|
public void testResponse101WithTransferEncoding() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 101 switching protocols\r\n"
|
"HTTP/1.1 101 switching protocols\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1562,9 +1561,9 @@ public class HttpParserTest
|
||||||
public void testResponseReasonIso8859_1() throws Exception
|
public void testResponseReasonIso8859_1() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 302 déplacé temporairement\r\n"
|
"HTTP/1.1 302 déplacé temporairement\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "\r\n", StandardCharsets.ISO_8859_1);
|
"\r\n", StandardCharsets.ISO_8859_1);
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1578,12 +1577,12 @@ public class HttpParserTest
|
||||||
public void testSeekEOF() throws Exception
|
public void testSeekEOF() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 200 OK\r\n"
|
"HTTP/1.1 200 OK\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "\r\n" // extra CRLF ignored
|
"\r\n" + // extra CRLF ignored
|
||||||
+ "HTTP/1.1 400 OK\r\n"); // extra data causes close ??
|
"HTTP/1.1 400 OK\r\n"); // extra data causes close ??
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1610,10 +1609,10 @@ public class HttpParserTest
|
||||||
public void testNoURI() throws Exception
|
public void testNoURI() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET\r\n"
|
"GET\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1632,10 +1631,10 @@ public class HttpParserTest
|
||||||
public void testNoURI2() throws Exception
|
public void testNoURI2() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET \r\n"
|
"GET \r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1654,10 +1653,10 @@ public class HttpParserTest
|
||||||
public void testUnknownReponseVersion() throws Exception
|
public void testUnknownReponseVersion() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HPPT/7.7 200 OK\r\n"
|
"HPPT/7.7 200 OK\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1676,10 +1675,10 @@ public class HttpParserTest
|
||||||
public void testNoStatus() throws Exception
|
public void testNoStatus() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1\r\n"
|
"HTTP/1.1\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1698,10 +1697,10 @@ public class HttpParserTest
|
||||||
public void testNoStatus2() throws Exception
|
public void testNoStatus2() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"HTTP/1.1 \r\n"
|
"HTTP/1.1 \r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.ResponseHandler handler = new Handler();
|
HttpParser.ResponseHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1720,10 +1719,10 @@ public class HttpParserTest
|
||||||
public void testBadRequestVersion() throws Exception
|
public void testBadRequestVersion() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HPPT/7.7\r\n"
|
"GET / HPPT/7.7\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1738,10 +1737,10 @@ public class HttpParserTest
|
||||||
assertEquals(HttpParser.State.CLOSED, parser.getState());
|
assertEquals(HttpParser.State.CLOSED, parser.getState());
|
||||||
|
|
||||||
buffer = BufferUtil.toBuffer(
|
buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.01\r\n"
|
"GET / HTTP/1.01\r\n" +
|
||||||
+ "Content-Length: 0\r\n"
|
"Content-Length: 0\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
parser = new HttpParser(handler);
|
parser = new HttpParser(handler);
|
||||||
|
@ -1760,10 +1759,10 @@ public class HttpParserTest
|
||||||
public void testBadCR() throws Exception
|
public void testBadCR() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.0\r\n"
|
"GET / HTTP/1.0\r\n" +
|
||||||
+ "Content-Length: 0\r"
|
"Content-Length: 0\r" +
|
||||||
+ "Connection: close\r"
|
"Connection: close\r" +
|
||||||
+ "\r");
|
"\r");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1777,10 +1776,10 @@ public class HttpParserTest
|
||||||
assertEquals(HttpParser.State.CLOSED, parser.getState());
|
assertEquals(HttpParser.State.CLOSED, parser.getState());
|
||||||
|
|
||||||
buffer = BufferUtil.toBuffer(
|
buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.0\r"
|
"GET / HTTP/1.0\r" +
|
||||||
+ "Content-Length: 0\r"
|
"Content-Length: 0\r" +
|
||||||
+ "Connection: close\r"
|
"Connection: close\r" +
|
||||||
+ "\r");
|
"\r");
|
||||||
|
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
parser = new HttpParser(handler);
|
parser = new HttpParser(handler);
|
||||||
|
@ -1798,10 +1797,10 @@ public class HttpParserTest
|
||||||
public void testBadContentLength0() throws Exception
|
public void testBadContentLength0() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.0\r\n"
|
"GET / HTTP/1.0\r\n" +
|
||||||
+ "Content-Length: abc\r\n"
|
"Content-Length: abc\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1820,10 +1819,10 @@ public class HttpParserTest
|
||||||
public void testBadContentLength1() throws Exception
|
public void testBadContentLength1() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.0\r\n"
|
"GET / HTTP/1.0\r\n" +
|
||||||
+ "Content-Length: 9999999999999999999999999999999999999999999999\r\n"
|
"Content-Length: 9999999999999999999999999999999999999999999999\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1842,10 +1841,10 @@ public class HttpParserTest
|
||||||
public void testBadContentLength2() throws Exception
|
public void testBadContentLength2() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.0\r\n"
|
"GET / HTTP/1.0\r\n" +
|
||||||
+ "Content-Length: 1.5\r\n"
|
"Content-Length: 1.5\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1864,12 +1863,12 @@ public class HttpParserTest
|
||||||
public void testMultipleContentLengthWithLargerThenCorrectValue()
|
public void testMultipleContentLengthWithLargerThenCorrectValue()
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"POST / HTTP/1.1\r\n"
|
"POST / HTTP/1.1\r\n" +
|
||||||
+ "Content-Length: 2\r\n"
|
"Content-Length: 2\r\n" +
|
||||||
+ "Content-Length: 1\r\n"
|
"Content-Length: 1\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "X");
|
"X");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1888,12 +1887,12 @@ public class HttpParserTest
|
||||||
public void testMultipleContentLengthWithCorrectThenLargerValue()
|
public void testMultipleContentLengthWithCorrectThenLargerValue()
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"POST / HTTP/1.1\r\n"
|
"POST / HTTP/1.1\r\n" +
|
||||||
+ "Content-Length: 1\r\n"
|
"Content-Length: 1\r\n" +
|
||||||
+ "Content-Length: 2\r\n"
|
"Content-Length: 2\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "X");
|
"X");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1912,15 +1911,15 @@ public class HttpParserTest
|
||||||
public void testTransferEncodingChunkedThenContentLength()
|
public void testTransferEncodingChunkedThenContentLength()
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"POST /chunk HTTP/1.1\r\n"
|
"POST /chunk HTTP/1.1\r\n" +
|
||||||
+ "Host: localhost\r\n"
|
"Host: localhost\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "Content-Length: 1\r\n"
|
"Content-Length: 1\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "1\r\n"
|
"1\r\n" +
|
||||||
+ "X\r\n"
|
"X\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616_LEGACY);
|
HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616_LEGACY);
|
||||||
|
@ -1941,15 +1940,16 @@ public class HttpParserTest
|
||||||
public void testContentLengthThenTransferEncodingChunked()
|
public void testContentLengthThenTransferEncodingChunked()
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"POST /chunk HTTP/1.1\r\n"
|
"POST /chunk HTTP/1.1\r\n" +
|
||||||
+ "Host: localhost\r\n"
|
"Host: localhost\r\n" +
|
||||||
+ "Content-Length: 1\r\n"
|
"Content-Length: 1\r\n" +
|
||||||
+ "Transfer-Encoding: chunked\r\n"
|
"Transfer-Encoding: chunked\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "1\r\n"
|
"1\r\n" +
|
||||||
+ "X\r\n"
|
"X\r\n" +
|
||||||
+ "0\r\n"
|
"0\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616_LEGACY);
|
HttpParser parser = new HttpParser(handler, HttpCompliance.RFC2616_LEGACY);
|
||||||
|
@ -1970,10 +1970,10 @@ public class HttpParserTest
|
||||||
public void testHost() throws Exception
|
public void testHost() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host: host\r\n"
|
"Host: host\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -1986,9 +1986,9 @@ public class HttpParserTest
|
||||||
public void testUriHost11() throws Exception
|
public void testUriHost11() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET http://host/ HTTP/1.1\r\n"
|
"GET http://host/ HTTP/1.1\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2002,8 +2002,8 @@ public class HttpParserTest
|
||||||
public void testUriHost10() throws Exception
|
public void testUriHost10() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET http://host/ HTTP/1.0\r\n"
|
"GET http://host/ HTTP/1.0\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2017,9 +2017,9 @@ public class HttpParserTest
|
||||||
public void testNoHost() throws Exception
|
public void testNoHost() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2031,10 +2031,10 @@ public class HttpParserTest
|
||||||
public void testIPHost() throws Exception
|
public void testIPHost() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host: 192.168.0.1\r\n"
|
"Host: 192.168.0.1\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2048,10 +2048,10 @@ public class HttpParserTest
|
||||||
{
|
{
|
||||||
Assumptions.assumeTrue(Net.isIpv6InterfaceAvailable());
|
Assumptions.assumeTrue(Net.isIpv6InterfaceAvailable());
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host: [::1]\r\n"
|
"Host: [::1]\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2066,10 +2066,10 @@ public class HttpParserTest
|
||||||
try (StacklessLogging s = new StacklessLogging(HttpParser.class))
|
try (StacklessLogging s = new StacklessLogging(HttpParser.class))
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host: [::1\r\n"
|
"Host: [::1\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2082,10 +2082,10 @@ public class HttpParserTest
|
||||||
public void testHostPort() throws Exception
|
public void testHostPort() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host: myhost:8888\r\n"
|
"Host: myhost:8888\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2098,10 +2098,10 @@ public class HttpParserTest
|
||||||
public void testHostBadPort() throws Exception
|
public void testHostBadPort() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host: myhost:testBadPort\r\n"
|
"Host: myhost:testBadPort\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2113,10 +2113,10 @@ public class HttpParserTest
|
||||||
public void testIPHostPort() throws Exception
|
public void testIPHostPort() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host: 192.168.0.1:8888\r\n"
|
"Host: 192.168.0.1:8888\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2130,10 +2130,10 @@ public class HttpParserTest
|
||||||
{
|
{
|
||||||
Assumptions.assumeTrue(Net.isIpv6InterfaceAvailable());
|
Assumptions.assumeTrue(Net.isIpv6InterfaceAvailable());
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host: [::1]:8888\r\n"
|
"Host: [::1]:8888\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
@ -2146,10 +2146,10 @@ public class HttpParserTest
|
||||||
public void testEmptyHostPort() throws Exception
|
public void testEmptyHostPort() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = BufferUtil.toBuffer(
|
ByteBuffer buffer = BufferUtil.toBuffer(
|
||||||
"GET / HTTP/1.1\r\n"
|
"GET / HTTP/1.1\r\n" +
|
||||||
+ "Host:\r\n"
|
"Host:\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n");
|
"\r\n");
|
||||||
|
|
||||||
HttpParser.RequestHandler handler = new Handler();
|
HttpParser.RequestHandler handler = new Handler();
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
|
|
|
@ -493,7 +493,7 @@ public class HttpTester
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public MetaData getInfo();
|
public abstract MetaData getInfo();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeaderCacheSize()
|
public int getHeaderCacheSize()
|
||||||
|
|
|
@ -77,9 +77,9 @@ public class MultiPartFormInputStreamTest
|
||||||
"Content-Disposition: form-data; name=\"fileup\"; filename=\"test.upload\"\r\n" +
|
"Content-Disposition: form-data; name=\"fileup\"; filename=\"test.upload\"\r\n" +
|
||||||
"Content-Type: application/octet-stream\r\n\r\n" +
|
"Content-Type: application/octet-stream\r\n\r\n" +
|
||||||
"How now brown cow." +
|
"How now brown cow." +
|
||||||
"\r\n--" + boundary + "-\r\n"
|
"\r\n--" + boundary + "-\r\n" +
|
||||||
+ "Content-Disposition: form-data; name=\"fileup\"; filename=\"test.upload\"\r\n"
|
"Content-Disposition: form-data; name=\"fileup\"; filename=\"test.upload\"\r\n" +
|
||||||
+ "\r\n";
|
"\r\n";
|
||||||
|
|
||||||
MultipartConfigElement config = new MultipartConfigElement(_dirname, 1024, 3072, 50);
|
MultipartConfigElement config = new MultipartConfigElement(_dirname, 1024, 3072, 50);
|
||||||
MultiPartFormInputStream mpis = new MultiPartFormInputStream(new ByteArrayInputStream(str.getBytes()),
|
MultiPartFormInputStream mpis = new MultiPartFormInputStream(new ByteArrayInputStream(str.getBytes()),
|
||||||
|
|
|
@ -173,13 +173,13 @@ public class MultiPartParserTest
|
||||||
};
|
};
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n"
|
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
|
||||||
+ "name0: value0\r\n"
|
"name0: value0\r\n" +
|
||||||
+ "name1 :value1 \r\n"
|
"name1 :value1 \r\n" +
|
||||||
+ "name2:value\r\n"
|
"name2:value\r\n" +
|
||||||
+ " 2\r\n"
|
" 2\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "Content");
|
"Content");
|
||||||
|
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.FIRST_OCTETS));
|
assertThat(parser.getState(), is(State.FIRST_OCTETS));
|
||||||
|
@ -193,11 +193,11 @@ public class MultiPartParserTest
|
||||||
TestHandler handler = new TestHandler();
|
TestHandler handler = new TestHandler();
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n"
|
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
|
||||||
+ "name: value\r\n"
|
"name: value\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "--BOUNDARY");
|
"--BOUNDARY");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.DELIMITER));
|
assertThat(parser.getState(), is(State.DELIMITER));
|
||||||
assertThat(data.remaining(), is(0));
|
assertThat(data.remaining(), is(0));
|
||||||
|
@ -211,10 +211,10 @@ public class MultiPartParserTest
|
||||||
TestHandler handler = new TestHandler();
|
TestHandler handler = new TestHandler();
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n"
|
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
|
||||||
+ "name: value\r\n"
|
"name: value\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "--BOUNDARY");
|
"--BOUNDARY");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.DELIMITER));
|
assertThat(parser.getState(), is(State.DELIMITER));
|
||||||
assertThat(data.remaining(), is(0));
|
assertThat(data.remaining(), is(0));
|
||||||
|
@ -228,10 +228,10 @@ public class MultiPartParserTest
|
||||||
TestHandler handler = new TestHandler();
|
TestHandler handler = new TestHandler();
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n"
|
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
|
||||||
+ "name: value\r\n"
|
"name: value\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "-");
|
"-");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
data = BufferUtil.toBuffer("Content!");
|
data = BufferUtil.toBuffer("Content!");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
|
@ -248,10 +248,10 @@ public class MultiPartParserTest
|
||||||
TestHandler handler = new TestHandler();
|
TestHandler handler = new TestHandler();
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n"
|
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
|
||||||
+ "name: value\n"
|
"name: value\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "Hello\r\n");
|
"Hello\r\n");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.OCTETS));
|
assertThat(parser.getState(), is(State.OCTETS));
|
||||||
assertThat(data.remaining(), is(0));
|
assertThat(data.remaining(), is(0));
|
||||||
|
@ -259,18 +259,18 @@ public class MultiPartParserTest
|
||||||
assertThat(handler.content, Matchers.contains("Hello"));
|
assertThat(handler.content, Matchers.contains("Hello"));
|
||||||
|
|
||||||
data = BufferUtil.toBuffer(
|
data = BufferUtil.toBuffer(
|
||||||
"Now is the time for all good ment to come to the aid of the party.\r\n"
|
"Now is the time for all good ment to come to the aid of the party.\r\n" +
|
||||||
+ "How now brown cow.\r\n"
|
"How now brown cow.\r\n" +
|
||||||
+ "The quick brown fox jumped over the lazy dog.\r\n"
|
"The quick brown fox jumped over the lazy dog.\r\n" +
|
||||||
+ "this is not a --BOUNDARY\r\n");
|
"this is not a --BOUNDARY\r\n");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.OCTETS));
|
assertThat(parser.getState(), is(State.OCTETS));
|
||||||
assertThat(data.remaining(), is(0));
|
assertThat(data.remaining(), is(0));
|
||||||
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
|
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
|
||||||
assertThat(handler.content, Matchers.contains("Hello", "\r\n", "Now is the time for all good ment to come to the aid of the party.\r\n"
|
assertThat(handler.content, Matchers.contains("Hello", "\r\n", "Now is the time for all good ment to come to the aid of the party.\r\n" +
|
||||||
+ "How now brown cow.\r\n"
|
"How now brown cow.\r\n" +
|
||||||
+ "The quick brown fox jumped over the lazy dog.\r\n"
|
"The quick brown fox jumped over the lazy dog.\r\n" +
|
||||||
+ "this is not a --BOUNDARY"));
|
"this is not a --BOUNDARY"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -279,11 +279,11 @@ public class MultiPartParserTest
|
||||||
TestHandler handler = new TestHandler();
|
TestHandler handler = new TestHandler();
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n"
|
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
|
||||||
+ "name: value\n"
|
"name: value\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "Hello\r\n"
|
"Hello\r\n" +
|
||||||
+ "--BOUNDARY");
|
"--BOUNDARY");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.DELIMITER));
|
assertThat(parser.getState(), is(State.DELIMITER));
|
||||||
assertThat(data.remaining(), is(0));
|
assertThat(data.remaining(), is(0));
|
||||||
|
@ -297,21 +297,21 @@ public class MultiPartParserTest
|
||||||
TestHandler handler = new TestHandler();
|
TestHandler handler = new TestHandler();
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n"
|
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\r\n" +
|
||||||
+ "name: value\n"
|
"name: value\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "Now is the time for all good ment to come to the aid of the party.\r\n"
|
"Now is the time for all good ment to come to the aid of the party.\r\n" +
|
||||||
+ "How now brown cow.\r\n"
|
"How now brown cow.\r\n" +
|
||||||
+ "The quick brown fox jumped over the lazy dog.\r\n"
|
"The quick brown fox jumped over the lazy dog.\r\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "--BOUNDARY");
|
"--BOUNDARY");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.DELIMITER));
|
assertThat(parser.getState(), is(State.DELIMITER));
|
||||||
assertThat(data.remaining(), is(0));
|
assertThat(data.remaining(), is(0));
|
||||||
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
|
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
|
||||||
assertThat(handler.content, Matchers.contains("Now is the time for all good ment to come to the aid of the party.\r\n"
|
assertThat(handler.content, Matchers.contains("Now is the time for all good ment to come to the aid of the party.\r\n" +
|
||||||
+ "How now brown cow.\r\n"
|
"How now brown cow.\r\n" +
|
||||||
+ "The quick brown fox jumped over the lazy dog.\r\n", "<<LAST>>"));
|
"The quick brown fox jumped over the lazy dog.\r\n", "<<LAST>>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -321,21 +321,21 @@ public class MultiPartParserTest
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
//boundary still requires carriage return
|
//boundary still requires carriage return
|
||||||
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\n"
|
ByteBuffer data = BufferUtil.toBuffer("--BOUNDARY\n" +
|
||||||
+ "name: value\n"
|
"name: value\n" +
|
||||||
+ "\n"
|
"\n" +
|
||||||
+ "Now is the time for all good men to come to the aid of the party.\n"
|
"Now is the time for all good men to come to the aid of the party.\n" +
|
||||||
+ "How now brown cow.\n"
|
"How now brown cow.\n" +
|
||||||
+ "The quick brown fox jumped over the lazy dog.\n"
|
"The quick brown fox jumped over the lazy dog.\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "--BOUNDARY");
|
"--BOUNDARY");
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.DELIMITER));
|
assertThat(parser.getState(), is(State.DELIMITER));
|
||||||
assertThat(data.remaining(), is(0));
|
assertThat(data.remaining(), is(0));
|
||||||
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
|
assertThat(handler.fields, Matchers.contains("name: value", "<<COMPLETE>>"));
|
||||||
assertThat(handler.content, Matchers.contains("Now is the time for all good men to come to the aid of the party.\n"
|
assertThat(handler.content, Matchers.contains("Now is the time for all good men to come to the aid of the party.\n" +
|
||||||
+ "How now brown cow.\n"
|
"How now brown cow.\n" +
|
||||||
+ "The quick brown fox jumped over the lazy dog.\n", "<<LAST>>"));
|
"The quick brown fox jumped over the lazy dog.\n", "<<LAST>>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -377,17 +377,17 @@ public class MultiPartParserTest
|
||||||
TestHandler handler = new TestHandler();
|
TestHandler handler = new TestHandler();
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer(""
|
ByteBuffer data = BufferUtil.toBuffer("" +
|
||||||
+ "--BOUNDARY\r\n"
|
"--BOUNDARY\r\n" +
|
||||||
+ "name: value\n"
|
"name: value\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "Hello\r\n"
|
"Hello\r\n" +
|
||||||
+ "--BOUNDARY--"
|
"--BOUNDARY--" +
|
||||||
+ "epilogue here:"
|
"epilogue here:" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "--BOUNDARY--"
|
"--BOUNDARY--" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "--BOUNDARY");
|
"--BOUNDARY");
|
||||||
|
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
assertThat(parser.getState(), is(State.DELIMITER));
|
assertThat(parser.getState(), is(State.DELIMITER));
|
||||||
|
@ -404,20 +404,20 @@ public class MultiPartParserTest
|
||||||
TestHandler handler = new TestHandler();
|
TestHandler handler = new TestHandler();
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
MultiPartParser parser = new MultiPartParser(handler, "BOUNDARY");
|
||||||
|
|
||||||
ByteBuffer data = BufferUtil.toBuffer(""
|
ByteBuffer data = BufferUtil.toBuffer("" +
|
||||||
+ "--BOUNDARY\r\n"
|
"--BOUNDARY\r\n" +
|
||||||
+ "name: value\n"
|
"name: value\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "Hello"
|
"Hello" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "--BOUNDARY\r\n"
|
"--BOUNDARY\r\n" +
|
||||||
+ "powerLevel: 9001\n"
|
"powerLevel: 9001\n" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "secondary"
|
"secondary" +
|
||||||
+ "\r\n"
|
"\r\n" +
|
||||||
+ "content"
|
"content" +
|
||||||
+ "\r\n--BOUNDARY--"
|
"\r\n--BOUNDARY--" +
|
||||||
+ "epilogue here");
|
"epilogue here");
|
||||||
|
|
||||||
/* Test First Content Section */
|
/* Test First Content Section */
|
||||||
parser.parse(data, false);
|
parser.parse(data, false);
|
||||||
|
@ -612,21 +612,21 @@ public class MultiPartParserTest
|
||||||
dataSeg.limit(length);
|
dataSeg.limit(length);
|
||||||
assertThat("Third " + i, parser.parse(dataSeg, true), is(true));
|
assertThat("Third " + i, parser.parse(dataSeg, true), is(true));
|
||||||
|
|
||||||
assertThat(handler.fields, Matchers.contains("Content-Disposition: form-data; name=\"text\"", "<<COMPLETE>>"
|
assertThat(handler.fields, Matchers.contains("Content-Disposition: form-data; name=\"text\"", "<<COMPLETE>>",
|
||||||
, "Content-Disposition: form-data; name=\"file1\"; filename=\"a.txt\""
|
"Content-Disposition: form-data; name=\"file1\"; filename=\"a.txt\"",
|
||||||
, "Content-Type: text/plain", "<<COMPLETE>>"
|
"Content-Type: text/plain", "<<COMPLETE>>",
|
||||||
, "Content-Disposition: form-data; name=\"file2\"; filename=\"a.html\""
|
"Content-Disposition: form-data; name=\"file2\"; filename=\"a.html\"",
|
||||||
, "Content-Type: text/html", "<<COMPLETE>>"
|
"Content-Type: text/html", "<<COMPLETE>>",
|
||||||
, "Field1: value1", "Field2: value2", "Field3: value3"
|
"Field1: value1", "Field2: value2", "Field3: value3",
|
||||||
, "Field4: value4", "Field5: value5", "Field6: value6"
|
"Field4: value4", "Field5: value5", "Field6: value6",
|
||||||
, "Field7: value7", "Field8: value8", "Field9: value 9", "<<COMPLETE>>"
|
"Field7: value7", "Field8: value8", "Field9: value 9", "<<COMPLETE>>",
|
||||||
, "Field1: value1", "<<COMPLETE>>"));
|
"Field1: value1", "<<COMPLETE>>"));
|
||||||
|
|
||||||
assertThat(handler.contentString(), is("text default" + "<<LAST>>"
|
assertThat(handler.contentString(), is("text default" + "<<LAST>>" +
|
||||||
+ "Content of a.txt.\n" + "<<LAST>>"
|
"Content of a.txt.\n" + "<<LAST>>" +
|
||||||
+ "<!DOCTYPE html><title>Content of a.html.</title>\n" + "<<LAST>>"
|
"<!DOCTYPE html><title>Content of a.html.</title>\n" + "<<LAST>>" +
|
||||||
+ "<<LAST>>"
|
"<<LAST>>" +
|
||||||
+ "But the amount of denudation which the strata have\n" +
|
"But the amount of denudation which the strata have\n" +
|
||||||
"in many places suffered, independently of the rate\n" +
|
"in many places suffered, independently of the rate\n" +
|
||||||
"of accumulation of the degraded matter, probably\n" +
|
"of accumulation of the degraded matter, probably\n" +
|
||||||
"offers the best evidence of the lapse of time. I remember\n" +
|
"offers the best evidence of the lapse of time. I remember\n" +
|
||||||
|
@ -670,18 +670,18 @@ public class MultiPartParserTest
|
||||||
};
|
};
|
||||||
|
|
||||||
MultiPartParser parser = new MultiPartParser(handler, "WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW");
|
MultiPartParser parser = new MultiPartParser(handler, "WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW");
|
||||||
ByteBuffer data = BufferUtil.toBuffer(""
|
ByteBuffer data = BufferUtil.toBuffer("" +
|
||||||
+ "Content-Type: multipart/form-data; boundary=WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\r\n" +
|
"Content-Type: multipart/form-data; boundary=WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\r\n" +
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\r\n" +
|
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\r\n" +
|
||||||
"Content-Disposition: form-data; name=\"part1\"\r\n" +
|
"Content-Disposition: form-data; name=\"part1\"\r\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"wNfミxVamt\r\n" +
|
"wNfミxVamt\r\n" +
|
||||||
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\n" +
|
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW\n" +
|
||||||
"Content-Disposition: form-data; name=\"part2\"\r\n" +
|
"Content-Disposition: form-data; name=\"part2\"\r\n" +
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
"&ᄈ취ᅢO\r\n" +
|
"&ᄈ취ᅢO\r\n" +
|
||||||
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW--");
|
"--WebKitFormBoundary7MA4YWf7OaKlSxkTrZu0gW--");
|
||||||
|
|
||||||
parser.parse(data, true);
|
parser.parse(data, true);
|
||||||
assertThat(parser.getState(), is(State.END));
|
assertThat(parser.getState(), is(State.END));
|
||||||
|
|
|
@ -881,7 +881,7 @@ public class StreamResetTest extends AbstractTest
|
||||||
// Try to write again, must fail immediately.
|
// Try to write again, must fail immediately.
|
||||||
output.write(0xFF);
|
output.write(0xFF);
|
||||||
}
|
}
|
||||||
catch (IOException xx)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
writeLatch2.countDown();
|
writeLatch2.countDown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class HpackContextTest
|
||||||
new HttpField("name", "v3"),
|
new HttpField("name", "v3"),
|
||||||
new HttpField("name", "v4"),
|
new HttpField("name", "v4"),
|
||||||
new HttpField("name", "v5"),
|
new HttpField("name", "v5"),
|
||||||
};
|
};
|
||||||
|
|
||||||
Entry[] entry = new Entry[field.length];
|
Entry[] entry = new Entry[field.length];
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public class HpackContextTest
|
||||||
new HttpField("fo8", "b8r"),
|
new HttpField("fo8", "b8r"),
|
||||||
new HttpField("fo9", "b9r"),
|
new HttpField("fo9", "b9r"),
|
||||||
new HttpField("foA", "bAr"),
|
new HttpField("foA", "bAr"),
|
||||||
};
|
};
|
||||||
|
|
||||||
Entry[] entry = new Entry[100];
|
Entry[] entry = new Entry[100];
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ public class HpackContextTest
|
||||||
new HttpField("fo8", "b8r"),
|
new HttpField("fo8", "b8r"),
|
||||||
new HttpField("fo9", "b9r"),
|
new HttpField("fo9", "b9r"),
|
||||||
new HttpField("foA", "bAr"),
|
new HttpField("foA", "bAr"),
|
||||||
};
|
};
|
||||||
Entry[] entry = new Entry[field.length];
|
Entry[] entry = new Entry[field.length];
|
||||||
|
|
||||||
// Add 5 entries
|
// Add 5 entries
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class HpackEncoderTest
|
||||||
new HttpField("fo8", "b8r"),
|
new HttpField("fo8", "b8r"),
|
||||||
new HttpField("fo9", "b9r"),
|
new HttpField("fo9", "b9r"),
|
||||||
new HttpField("foA", "bAr"),
|
new HttpField("foA", "bAr"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add 4 entries
|
// Add 4 entries
|
||||||
for (int i = 0; i <= 3; i++)
|
for (int i = 0; i <= 3; i++)
|
||||||
|
|
|
@ -35,6 +35,7 @@ public interface SslHandshakeListener extends EventListener
|
||||||
* <p>Callback method invoked when the TLS handshake succeeds.</p>
|
* <p>Callback method invoked when the TLS handshake succeeds.</p>
|
||||||
*
|
*
|
||||||
* @param event the event object carrying information about the TLS handshake event
|
* @param event the event object carrying information about the TLS handshake event
|
||||||
|
* @throws SSLException if any error happen during handshake
|
||||||
*/
|
*/
|
||||||
default void handshakeSucceeded(Event event) throws SSLException
|
default void handshakeSucceeded(Event event) throws SSLException
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.eclipse.jetty.util.BufferUtil;
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
import org.eclipse.jetty.util.IO;
|
import org.eclipse.jetty.util.IO;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.OS;
|
import org.junit.jupiter.api.condition.OS;
|
||||||
|
|
||||||
|
@ -93,14 +94,8 @@ public class IOTest
|
||||||
assertEquals(-1, server.getInputStream().read());
|
assertEquals(-1, server.getInputStream().read());
|
||||||
|
|
||||||
// but cannot write
|
// but cannot write
|
||||||
try
|
Assertions.assertThrows(SocketException.class, () -> client.getOutputStream().write(1));
|
||||||
{
|
|
||||||
client.getOutputStream().write(1);
|
|
||||||
fail("exception expected");
|
|
||||||
}
|
|
||||||
catch (SocketException expected)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// but can still write in opposite direction.
|
// but can still write in opposite direction.
|
||||||
server.getOutputStream().write(1);
|
server.getOutputStream().write(1);
|
||||||
|
@ -110,14 +105,7 @@ public class IOTest
|
||||||
server.shutdownInput();
|
server.shutdownInput();
|
||||||
|
|
||||||
// now we EOF instead of reading -1
|
// now we EOF instead of reading -1
|
||||||
try
|
Assertions.assertThrows(SocketException.class, () -> server.getInputStream().read());
|
||||||
{
|
|
||||||
server.getInputStream().read();
|
|
||||||
fail("exception expected");
|
|
||||||
}
|
|
||||||
catch (SocketException expected)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// but can still write in opposite direction.
|
// but can still write in opposite direction.
|
||||||
server.getOutputStream().write(1);
|
server.getOutputStream().write(1);
|
||||||
|
@ -127,14 +115,7 @@ public class IOTest
|
||||||
client.shutdownInput();
|
client.shutdownInput();
|
||||||
|
|
||||||
// now we EOF instead of reading -1
|
// now we EOF instead of reading -1
|
||||||
try
|
Assertions.assertThrows(SocketException.class, () -> client.getInputStream().read());
|
||||||
{
|
|
||||||
client.getInputStream().read();
|
|
||||||
fail("exception expected");
|
|
||||||
}
|
|
||||||
catch (SocketException expected)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// But we can still write at the server (data which will never be read)
|
// But we can still write at the server (data which will never be read)
|
||||||
server.getOutputStream().write(1);
|
server.getOutputStream().write(1);
|
||||||
|
@ -146,14 +127,7 @@ public class IOTest
|
||||||
server.shutdownOutput();
|
server.shutdownOutput();
|
||||||
|
|
||||||
// and now we can't write
|
// and now we can't write
|
||||||
try
|
Assertions.assertThrows(SocketException.class, () -> server.getOutputStream().write(1));
|
||||||
{
|
|
||||||
server.getOutputStream().write(1);
|
|
||||||
fail("exception expected");
|
|
||||||
}
|
|
||||||
catch (SocketException expected)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// but the sockets are still open
|
// but the sockets are still open
|
||||||
assertFalse(client.isClosed());
|
assertFalse(client.isClosed());
|
||||||
|
|
|
@ -461,6 +461,7 @@ public class SslConnectionTest
|
||||||
}
|
}
|
||||||
catch (SocketTimeoutException e)
|
catch (SocketTimeoutException e)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(__onIncompleteFlush.get());
|
assertTrue(__onIncompleteFlush.get());
|
||||||
|
@ -507,6 +508,7 @@ public class SslConnectionTest
|
||||||
}
|
}
|
||||||
catch (SocketTimeoutException e)
|
catch (SocketTimeoutException e)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
__blockFor.set(0);
|
__blockFor.set(0);
|
||||||
|
|
|
@ -18,12 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.jaas.spi;
|
package org.eclipse.jetty.jaas.spi;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.contains;
|
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
|
||||||
import static org.hamcrest.Matchers.not;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -33,6 +27,12 @@ import org.eclipse.jetty.jaas.callback.DefaultCallbackHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.not;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class PropertyFileLoginModuleTest
|
public class PropertyFileLoginModuleTest
|
||||||
{
|
{
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -472,9 +472,9 @@ public class TestJNDI
|
||||||
((Context)zzz.lookup("java:comp")).bind("crud2", "xxx2");
|
((Context)zzz.lookup("java:comp")).bind("crud2", "xxx2");
|
||||||
fail("Should not be able to write to locked context");
|
fail("Should not be able to write to locked context");
|
||||||
}
|
}
|
||||||
catch (NamingException ne)
|
catch (NamingException e)
|
||||||
{
|
{
|
||||||
assertThat(ne.getMessage(), Matchers.containsString("immutable"));
|
assertThat(e.getMessage(), Matchers.containsString("immutable"));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -492,9 +492,9 @@ public class TestJNDI
|
||||||
((Context)zzz.lookup("java:comp")).bind("foo", "bar");
|
((Context)zzz.lookup("java:comp")).bind("foo", "bar");
|
||||||
fail("Should not be able to write to locked context");
|
fail("Should not be able to write to locked context");
|
||||||
}
|
}
|
||||||
catch (NamingException ne)
|
catch (NamingException e)
|
||||||
{
|
{
|
||||||
assertThat(ne.getMessage(), Matchers.containsString("immutable"));
|
assertThat(e.getMessage(), Matchers.containsString("immutable"));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class TestGetContent
|
||||||
url += pathToCheck;
|
url += pathToCheck;
|
||||||
}
|
}
|
||||||
String response = httpClient.GET(url).getContentAsString();
|
String response = httpClient.GET(url).getContentAsString();
|
||||||
assertTrue(response.contains(contentCheck), "it test " + System.getProperty("maven.it.name")
|
assertTrue(response.contains(contentCheck), "it test " + System.getProperty("maven.it.name") +
|
||||||
+ ", response not contentCheck: " + contentCheck + ", response:" + response);
|
", response not contentCheck: " + contentCheck + ", response:" + response);
|
||||||
System.out.println("contentCheck");
|
System.out.println("contentCheck");
|
||||||
}
|
}
|
||||||
if (Boolean.getBoolean("helloTestServlet"))
|
if (Boolean.getBoolean("helloTestServlet"))
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -113,15 +114,15 @@ public class TestOSGiUtil
|
||||||
String mavenRepoPath = System.getProperty("mavenRepoPath");
|
String mavenRepoPath = System.getProperty("mavenRepoPath");
|
||||||
if (!StringUtil.isBlank(mavenRepoPath))
|
if (!StringUtil.isBlank(mavenRepoPath))
|
||||||
{
|
{
|
||||||
res.add( systemProperty( "org.ops4j.pax.url.mvn.localRepository" ).value( mavenRepoPath ) );
|
res.add(systemProperty("org.ops4j.pax.url.mvn.localRepository").value(mavenRepoPath));
|
||||||
res.add( systemProperty( "org.ops4j.pax.url.mvn.defaultRepositories" ).value( "file://" + mavenRepoPath + "@id=local.repo") );
|
res.add(systemProperty("org.ops4j.pax.url.mvn.defaultRepositories").value("file://" + mavenRepoPath + "@id=local.repo"));
|
||||||
res.add( systemProperty( "org.ops4j.pax.url.mvn.useFallbackRepositories").value( Boolean.FALSE.toString() ) );
|
res.add(systemProperty("org.ops4j.pax.url.mvn.useFallbackRepositories").value(Boolean.FALSE.toString()));
|
||||||
res.add( systemProperty( "org.ops4j.pax.url.mvn.repositories").value( "+https://repo1.maven.org/maven2@id=maven.central.repo" ) );
|
res.add(systemProperty("org.ops4j.pax.url.mvn.repositories").value("+https://repo1.maven.org/maven2@id=maven.central.repo"));
|
||||||
}
|
}
|
||||||
String settingsFilePath = System.getProperty("settingsFilePath");
|
String settingsFilePath = System.getProperty("settingsFilePath");
|
||||||
if (!StringUtil.isBlank(settingsFilePath))
|
if (!StringUtil.isBlank(settingsFilePath))
|
||||||
{
|
{
|
||||||
res.add( systemProperty( "org.ops4j.pax.url.mvn.settings" ).value( System.getProperty( "settingsFilePath" ) ) );
|
res.add(systemProperty("org.ops4j.pax.url.mvn.settings").value(System.getProperty("settingsFilePath")));
|
||||||
}
|
}
|
||||||
res.add(mavenBundle().groupId("org.ow2.asm").artifactId("asm").versionAsInProject().start());
|
res.add(mavenBundle().groupId("org.ow2.asm").artifactId("asm").versionAsInProject().start());
|
||||||
res.add(mavenBundle().groupId("org.ow2.asm").artifactId("asm-commons").versionAsInProject().start());
|
res.add(mavenBundle().groupId("org.ow2.asm").artifactId("asm-commons").versionAsInProject().start());
|
||||||
|
@ -194,11 +195,11 @@ public class TestOSGiUtil
|
||||||
for (Bundle b : bundleContext.getBundles())
|
for (Bundle b : bundleContext.getBundles())
|
||||||
{
|
{
|
||||||
Bundle prevBundle = _bundles.put(b.getSymbolicName(), b);
|
Bundle prevBundle = _bundles.put(b.getSymbolicName(), b);
|
||||||
String err = prevBundle != null ? "2 versions of the bundle " + b.getSymbolicName()
|
String err = prevBundle != null ? "2 versions of the bundle " + b.getSymbolicName() +
|
||||||
+ " "
|
" " +
|
||||||
+ b.getHeaders().get("Bundle-Version")
|
b.getHeaders().get("Bundle-Version") +
|
||||||
+ " and "
|
" and " +
|
||||||
+ prevBundle.getHeaders().get("Bundle-Version") : "";
|
prevBundle.getHeaders().get("Bundle-Version") : "";
|
||||||
assertNull(err, prevBundle);
|
assertNull(err, prevBundle);
|
||||||
}
|
}
|
||||||
return _bundles.get(symbolicName);
|
return _bundles.get(symbolicName);
|
||||||
|
@ -229,16 +230,16 @@ public class TestOSGiUtil
|
||||||
{
|
{
|
||||||
diagnoseNonActiveOrNonResolvedBundle(b);
|
diagnoseNonActiveOrNonResolvedBundle(b);
|
||||||
}
|
}
|
||||||
assertTrue("Bundle: " + b
|
assertTrue("Bundle: " + b +
|
||||||
+ " (state should be "
|
" (state should be " +
|
||||||
+ "ACTIVE["
|
"ACTIVE[" +
|
||||||
+ Bundle.ACTIVE
|
Bundle.ACTIVE +
|
||||||
+ "] or RESOLVED["
|
"] or RESOLVED[" +
|
||||||
+ Bundle.RESOLVED
|
Bundle.RESOLVED +
|
||||||
+ "]"
|
"]" +
|
||||||
+ ", but was ["
|
", but was [" +
|
||||||
+ b.getState()
|
b.getState() +
|
||||||
+ "])", (b.getState() == Bundle.ACTIVE) || (b.getState() == Bundle.RESOLVED));
|
"])", (b.getState() == Bundle.ACTIVE) || (b.getState() == Bundle.RESOLVED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,20 +18,15 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.plus.annotation;
|
package org.eclipse.jetty.plus.annotation;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.anEmptyMap;
|
|
||||||
import static org.hamcrest.Matchers.hasEntry;
|
|
||||||
import static org.hamcrest.Matchers.hasKey;
|
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class LifeCycleCallbackCollectionTest
|
public class LifeCycleCallbackCollectionTest
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -1533,7 +1533,7 @@ public class AsyncMiddleManServletTest
|
||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static abstract class HrefTransformer implements AsyncMiddleManServlet.ContentTransformer
|
private abstract static class HrefTransformer implements AsyncMiddleManServlet.ContentTransformer
|
||||||
{
|
{
|
||||||
private static final String PREFIX = "http://localhost/q=";
|
private static final String PREFIX = "http://localhost/q=";
|
||||||
private final HrefParser parser = new HrefParser();
|
private final HrefParser parser = new HrefParser();
|
||||||
|
|
|
@ -141,9 +141,11 @@ public class ReverseProxyTest
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
startProxy(new HashMap<String, String>()
|
startProxy(new HashMap<String, String>()
|
||||||
{{
|
{
|
||||||
put("preserveHost", "true");
|
{
|
||||||
}});
|
put("preserveHost", "true");
|
||||||
|
}
|
||||||
|
});
|
||||||
startClient();
|
startClient();
|
||||||
|
|
||||||
ContentResponse response = client.newRequest("localhost", proxyConnector.getLocalPort()).send();
|
ContentResponse response = client.newRequest("localhost", proxyConnector.getLocalPort()).send();
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class HeaderPatternRuleTest extends AbstractRuleTestCase
|
||||||
public void testHeaderWithTextValues() throws IOException
|
public void testHeaderWithTextValues() throws IOException
|
||||||
{
|
{
|
||||||
// different keys
|
// different keys
|
||||||
String headers[][] = {
|
String[][] headers = {
|
||||||
{"hnum#1", "test1"},
|
{"hnum#1", "test1"},
|
||||||
{"hnum#2", "2test2"},
|
{"hnum#2", "2test2"},
|
||||||
{"hnum#3", "test3"}
|
{"hnum#3", "test3"}
|
||||||
|
@ -53,7 +53,7 @@ public class HeaderPatternRuleTest extends AbstractRuleTestCase
|
||||||
@Test
|
@Test
|
||||||
public void testHeaderWithNumberValues() throws IOException
|
public void testHeaderWithNumberValues() throws IOException
|
||||||
{
|
{
|
||||||
String headers[][] = {
|
String[][] headers = {
|
||||||
{"hello", "1"},
|
{"hello", "1"},
|
||||||
{"hello", "-1"},
|
{"hello", "-1"},
|
||||||
{"hello", "100"},
|
{"hello", "100"},
|
||||||
|
@ -70,7 +70,7 @@ public class HeaderPatternRuleTest extends AbstractRuleTestCase
|
||||||
@Test
|
@Test
|
||||||
public void testHeaderOverwriteValues() throws IOException
|
public void testHeaderOverwriteValues() throws IOException
|
||||||
{
|
{
|
||||||
String headers[][] = {
|
String[][] headers = {
|
||||||
{"size", "100"},
|
{"size", "100"},
|
||||||
{"size", "200"},
|
{"size", "200"},
|
||||||
{"size", "300"},
|
{"size", "300"},
|
||||||
|
@ -100,7 +100,7 @@ public class HeaderPatternRuleTest extends AbstractRuleTestCase
|
||||||
assertEquals("abba1", _response.getHeader("title1"));
|
assertEquals("abba1", _response.getHeader("title1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertHeaders(String headers[][]) throws IOException
|
private void assertHeaders(String[][] headers) throws IOException
|
||||||
{
|
{
|
||||||
for (String[] header : headers)
|
for (String[] header : headers)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class HeaderRegexRuleTest extends AbstractRuleTestCase
|
||||||
public void testHeaderWithTextValues() throws IOException
|
public void testHeaderWithTextValues() throws IOException
|
||||||
{
|
{
|
||||||
// different keys
|
// different keys
|
||||||
String headers[][] =
|
String[][] headers =
|
||||||
{
|
{
|
||||||
{"hnum#1", "test1"},
|
{"hnum#1", "test1"},
|
||||||
{"hnum#2", "2test2"},
|
{"hnum#2", "2test2"},
|
||||||
|
@ -55,7 +55,7 @@ public class HeaderRegexRuleTest extends AbstractRuleTestCase
|
||||||
@Test
|
@Test
|
||||||
public void testHeaderWithNumberValues() throws IOException
|
public void testHeaderWithNumberValues() throws IOException
|
||||||
{
|
{
|
||||||
String headers[][] =
|
String[][] headers =
|
||||||
{
|
{
|
||||||
{"hello", "1"},
|
{"hello", "1"},
|
||||||
{"hello", "-1"},
|
{"hello", "-1"},
|
||||||
|
@ -72,7 +72,7 @@ public class HeaderRegexRuleTest extends AbstractRuleTestCase
|
||||||
@Test
|
@Test
|
||||||
public void testHeaderOverwriteValues() throws IOException
|
public void testHeaderOverwriteValues() throws IOException
|
||||||
{
|
{
|
||||||
String headers[][] =
|
String[][] headers =
|
||||||
{
|
{
|
||||||
{"size", "100"},
|
{"size", "100"},
|
||||||
{"size", "200"},
|
{"size", "200"},
|
||||||
|
@ -122,7 +122,7 @@ public class HeaderRegexRuleTest extends AbstractRuleTestCase
|
||||||
assertEquals(null, _response.getHeader("cache-control"));
|
assertEquals(null, _response.getHeader("cache-control"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertHeaders(String headers[][]) throws IOException
|
private void assertHeaders(String[][] headers) throws IOException
|
||||||
{
|
{
|
||||||
for (String[] header : headers)
|
for (String[] header : headers)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class RewritePatternRuleTest extends AbstractRuleTestCase
|
||||||
{"/foo/bar", "/foo/bar", "/replace"},
|
{"/foo/bar", "/foo/bar", "/replace"},
|
||||||
{"/foo/bar.txt", "*.txt", "/replace"},
|
{"/foo/bar.txt", "*.txt", "/replace"},
|
||||||
{"/foo/bar/%20x", "/foo/*", "/replace/bar/%20x"},
|
{"/foo/bar/%20x", "/foo/*", "/replace/bar/%20x"},
|
||||||
};
|
};
|
||||||
private RewritePatternRule _rule;
|
private RewritePatternRule _rule;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
|
@ -119,7 +119,9 @@ public class ValidUrlRuleTest extends AbstractRuleTestCase
|
||||||
// space
|
// space
|
||||||
assertTrue(_rule.isValidChar("\u0020".charAt(0)));
|
assertTrue(_rule.isValidChar("\u0020".charAt(0)));
|
||||||
// form feed
|
// form feed
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
assertFalse(_rule.isValidChar("\u000c".charAt(0)));
|
assertFalse(_rule.isValidChar("\u000c".charAt(0)));
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1708,7 +1708,7 @@ public class ConstraintTest
|
||||||
{
|
{
|
||||||
request.login("admin", "fail");
|
request.login("admin", "fail");
|
||||||
}
|
}
|
||||||
catch (ServletException se)
|
catch (ServletException e)
|
||||||
{
|
{
|
||||||
request.login("admin", "password");
|
request.login("admin", "password");
|
||||||
}
|
}
|
||||||
|
|
|
@ -723,8 +723,8 @@ public abstract class AbstractSessionCache extends ContainerLifeCycle implements
|
||||||
LOG.debug("Checking for idle {}", session.getId());
|
LOG.debug("Checking for idle {}", session.getId());
|
||||||
try (Lock s = session.lock())
|
try (Lock s = session.lock())
|
||||||
{
|
{
|
||||||
if (getEvictionPolicy() > 0 && session.isIdleLongerThan(getEvictionPolicy())
|
if (getEvictionPolicy() > 0 && session.isIdleLongerThan(getEvictionPolicy()) &&
|
||||||
&& session.isValid() && session.isResident() && session.getRequests() <= 0)
|
session.isValid() && session.isResident() && session.getRequests() <= 0)
|
||||||
{
|
{
|
||||||
//Be careful with saveOnInactiveEviction - you may be able to re-animate a session that was
|
//Be careful with saveOnInactiveEviction - you may be able to re-animate a session that was
|
||||||
//being managed on another node and has expired.
|
//being managed on another node and has expired.
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.server.session;
|
package org.eclipse.jetty.server.session;
|
||||||
|
|
||||||
import static java.lang.Math.round;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -65,6 +63,8 @@ import org.eclipse.jetty.util.thread.Locker.Lock;
|
||||||
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
||||||
import org.eclipse.jetty.util.thread.Scheduler;
|
import org.eclipse.jetty.util.thread.Scheduler;
|
||||||
|
|
||||||
|
import static java.lang.Math.round;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SessionHandler.
|
* SessionHandler.
|
||||||
*/
|
*/
|
||||||
|
@ -237,8 +237,8 @@ public class SessionHandler extends ScopedHandler
|
||||||
// Do we need to refresh the cookie?
|
// Do we need to refresh the cookie?
|
||||||
if (isUsingCookies() &&
|
if (isUsingCookies() &&
|
||||||
(s.isIdChanged() ||
|
(s.isIdChanged() ||
|
||||||
(getSessionCookieConfig().getMaxAge() > 0 && getRefreshCookieAge() > 0
|
(getSessionCookieConfig().getMaxAge() > 0 && getRefreshCookieAge() > 0 &&
|
||||||
&& ((now - s.getCookieSetTime())/1000 > getRefreshCookieAge()))))
|
((now - s.getCookieSetTime()) / 1000 > getRefreshCookieAge()))))
|
||||||
{
|
{
|
||||||
HttpCookie cookie = getSessionCookie(session, _context == null ? "/" : (_context.getContextPath()), secure);
|
HttpCookie cookie = getSessionCookie(session, _context == null ? "/" : (_context.getContextPath()), secure);
|
||||||
s.cookieSet();
|
s.cookieSet();
|
||||||
|
@ -847,8 +847,8 @@ public class SessionHandler extends ScopedHandler
|
||||||
public void setSessionIdPathParameterName(String param)
|
public void setSessionIdPathParameterName(String param)
|
||||||
{
|
{
|
||||||
_sessionIdPathParameterName = (param == null || "none".equals(param)) ? null : param;
|
_sessionIdPathParameterName = (param == null || "none".equals(param)) ? null : param;
|
||||||
_sessionIdPathParameterNamePrefix = (param == null || "none".equals(param)) ?
|
_sessionIdPathParameterNamePrefix = (param == null || "none".equals(param))
|
||||||
null : (";" + _sessionIdPathParameterName + "=");
|
? null : (";" + _sessionIdPathParameterName + "=");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1023,7 +1023,7 @@ public class SessionHandler extends ScopedHandler
|
||||||
sessionTrackingModes.size() > 1 &&
|
sessionTrackingModes.size() > 1 &&
|
||||||
sessionTrackingModes.contains(SessionTrackingMode.SSL))
|
sessionTrackingModes.contains(SessionTrackingMode.SSL))
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException ("sessionTrackingModes specifies a combination of SessionTrackingMode.SSL with a session tracking mode other than SessionTrackingMode.SSL");
|
throw new IllegalArgumentException("sessionTrackingModes specifies a combination of SessionTrackingMode.SSL with a session tracking mode other than SessionTrackingMode.SSL");
|
||||||
}
|
}
|
||||||
_sessionTrackingModes = new HashSet<>(sessionTrackingModes);
|
_sessionTrackingModes = new HashSet<>(sessionTrackingModes);
|
||||||
_usingCookies = _sessionTrackingModes.contains(SessionTrackingMode.COOKIE);
|
_usingCookies = _sessionTrackingModes.contains(SessionTrackingMode.COOKIE);
|
||||||
|
@ -1294,8 +1294,8 @@ public class SessionHandler extends ScopedHandler
|
||||||
//most efficient if it can be done as a bulk operation to eg reduce
|
//most efficient if it can be done as a bulk operation to eg reduce
|
||||||
//roundtrips to the persistent store. Only do this if the HouseKeeper that
|
//roundtrips to the persistent store. Only do this if the HouseKeeper that
|
||||||
//does the scavenging is configured to actually scavenge
|
//does the scavenging is configured to actually scavenge
|
||||||
if (_sessionIdManager.getSessionHouseKeeper() != null
|
if (_sessionIdManager.getSessionHouseKeeper() != null &&
|
||||||
&& _sessionIdManager.getSessionHouseKeeper().getIntervalSec() > 0)
|
_sessionIdManager.getSessionHouseKeeper().getIntervalSec() > 0)
|
||||||
{
|
{
|
||||||
_candidateSessionIdsForExpiry.add(session.getId());
|
_candidateSessionIdsForExpiry.add(session.getId());
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
|
@ -1525,9 +1525,9 @@ public class SessionHandler extends ScopedHandler
|
||||||
{
|
{
|
||||||
HttpCookie cookie = access(existingSession, request.isSecure());
|
HttpCookie cookie = access(existingSession, request.isSecure());
|
||||||
// Handle changed ID or max-age refresh, but only if this is not a redispatched request
|
// Handle changed ID or max-age refresh, but only if this is not a redispatched request
|
||||||
if ((cookie != null)
|
if ((cookie != null) &&
|
||||||
&& (request.getDispatcherType() == DispatcherType.ASYNC
|
(request.getDispatcherType() == DispatcherType.ASYNC ||
|
||||||
|| request.getDispatcherType() == DispatcherType.REQUEST))
|
request.getDispatcherType() == DispatcherType.REQUEST))
|
||||||
baseRequest.getResponse().replaceCookie(cookie);
|
baseRequest.getResponse().replaceCookie(cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,11 +86,11 @@ public abstract class AbstractHttpTest
|
||||||
HttpTester.Input input = HttpTester.from(socket.getInputStream());
|
HttpTester.Input input = HttpTester.from(socket.getInputStream());
|
||||||
HttpTester.parseResponse(input, response);
|
HttpTester.parseResponse(input, response);
|
||||||
|
|
||||||
if (httpVersion.is("HTTP/1.1")
|
if (httpVersion.is("HTTP/1.1") &&
|
||||||
&& response.isComplete()
|
response.isComplete() &&
|
||||||
&& response.get("content-length") == null
|
response.get("content-length") == null &&
|
||||||
&& response.get("transfer-encoding") == null
|
response.get("transfer-encoding") == null &&
|
||||||
&& !__noBodyCodes.contains(response.getStatus()))
|
!__noBodyCodes.contains(response.getStatus()))
|
||||||
assertThat("If HTTP/1.1 response doesn't contain transfer-encoding or content-length headers, " +
|
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"));
|
"it should contain connection:close", response.get("connection"), is("close"));
|
||||||
return response;
|
return response;
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class AsyncStressTest
|
||||||
{"/path?suspend=<PERIOD>", "TIMEOUT"},
|
{"/path?suspend=<PERIOD>", "TIMEOUT"},
|
||||||
{"/path?suspend=60000&resume=<PERIOD>", "RESUMED"},
|
{"/path?suspend=60000&resume=<PERIOD>", "RESUMED"},
|
||||||
{"/path?suspend=60000&complete=<PERIOD>", "COMPLETED"},
|
{"/path?suspend=60000&complete=<PERIOD>", "COMPLETED"},
|
||||||
};
|
};
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void init() throws Exception
|
public void init() throws Exception
|
||||||
|
|
|
@ -41,10 +41,7 @@ public class CheckReverseProxyHeadersTest
|
||||||
// Classic ProxyPass from example.com:80 to localhost:8080
|
// Classic ProxyPass from example.com:80 to localhost:8080
|
||||||
testRequest("Host: localhost:8080\n" +
|
testRequest("Host: localhost:8080\n" +
|
||||||
"X-Forwarded-For: 10.20.30.40\n" +
|
"X-Forwarded-For: 10.20.30.40\n" +
|
||||||
"X-Forwarded-Host: example.com", new RequestValidator()
|
"X-Forwarded-Host: example.com", request ->
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void validate(HttpServletRequest request)
|
|
||||||
{
|
{
|
||||||
assertEquals("example.com", request.getServerName());
|
assertEquals("example.com", request.getServerName());
|
||||||
assertEquals(80, request.getServerPort());
|
assertEquals(80, request.getServerPort());
|
||||||
|
@ -53,16 +50,12 @@ public class CheckReverseProxyHeadersTest
|
||||||
assertEquals("example.com", request.getHeader("Host"));
|
assertEquals("example.com", request.getHeader("Host"));
|
||||||
assertEquals("http", request.getScheme());
|
assertEquals("http", request.getScheme());
|
||||||
assertFalse(request.isSecure());
|
assertFalse(request.isSecure());
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// IPv6 ProxyPass from example.com:80 to localhost:8080
|
// IPv6 ProxyPass from example.com:80 to localhost:8080
|
||||||
testRequest("Host: localhost:8080\n" +
|
testRequest("Host: localhost:8080\n" +
|
||||||
"X-Forwarded-For: 10.20.30.40\n" +
|
"X-Forwarded-For: 10.20.30.40\n" +
|
||||||
"X-Forwarded-Host: [::1]", new RequestValidator()
|
"X-Forwarded-Host: [::1]", request ->
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void validate(HttpServletRequest request)
|
|
||||||
{
|
{
|
||||||
assertEquals("[::1]", request.getServerName());
|
assertEquals("[::1]", request.getServerName());
|
||||||
assertEquals(80, request.getServerPort());
|
assertEquals(80, request.getServerPort());
|
||||||
|
@ -71,16 +64,12 @@ public class CheckReverseProxyHeadersTest
|
||||||
assertEquals("[::1]", request.getHeader("Host"));
|
assertEquals("[::1]", request.getHeader("Host"));
|
||||||
assertEquals("http", request.getScheme());
|
assertEquals("http", request.getScheme());
|
||||||
assertFalse(request.isSecure());
|
assertFalse(request.isSecure());
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// IPv6 ProxyPass from example.com:80 to localhost:8080
|
// IPv6 ProxyPass from example.com:80 to localhost:8080
|
||||||
testRequest("Host: localhost:8080\n" +
|
testRequest("Host: localhost:8080\n" +
|
||||||
"X-Forwarded-For: 10.20.30.40\n" +
|
"X-Forwarded-For: 10.20.30.40\n" +
|
||||||
"X-Forwarded-Host: [::1]:8888", new RequestValidator()
|
"X-Forwarded-Host: [::1]:8888", request ->
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void validate(HttpServletRequest request)
|
|
||||||
{
|
{
|
||||||
assertEquals("[::1]", request.getServerName());
|
assertEquals("[::1]", request.getServerName());
|
||||||
assertEquals(8888, request.getServerPort());
|
assertEquals(8888, request.getServerPort());
|
||||||
|
@ -89,18 +78,14 @@ public class CheckReverseProxyHeadersTest
|
||||||
assertEquals("[::1]:8888", request.getHeader("Host"));
|
assertEquals("[::1]:8888", request.getHeader("Host"));
|
||||||
assertEquals("http", request.getScheme());
|
assertEquals("http", request.getScheme());
|
||||||
assertFalse(request.isSecure());
|
assertFalse(request.isSecure());
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// ProxyPass from example.com:81 to localhost:8080
|
// ProxyPass from example.com:81 to localhost:8080
|
||||||
testRequest("Host: localhost:8080\n" +
|
testRequest("Host: localhost:8080\n" +
|
||||||
"X-Forwarded-For: 10.20.30.40\n" +
|
"X-Forwarded-For: 10.20.30.40\n" +
|
||||||
"X-Forwarded-Host: example.com:81\n" +
|
"X-Forwarded-Host: example.com:81\n" +
|
||||||
"X-Forwarded-Server: example.com\n" +
|
"X-Forwarded-Server: example.com\n" +
|
||||||
"X-Forwarded-Proto: https", new RequestValidator()
|
"X-Forwarded-Proto: https", request ->
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void validate(HttpServletRequest request)
|
|
||||||
{
|
{
|
||||||
assertEquals("example.com", request.getServerName());
|
assertEquals("example.com", request.getServerName());
|
||||||
assertEquals(81, request.getServerPort());
|
assertEquals(81, request.getServerPort());
|
||||||
|
@ -109,18 +94,15 @@ public class CheckReverseProxyHeadersTest
|
||||||
assertEquals("example.com:81", request.getHeader("Host"));
|
assertEquals("example.com:81", request.getHeader("Host"));
|
||||||
assertEquals("https", request.getScheme());
|
assertEquals("https", request.getScheme());
|
||||||
assertTrue(request.isSecure());
|
assertTrue(request.isSecure());
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Multiple ProxyPass from example.com:80 to rp.example.com:82 to localhost:8080
|
// Multiple ProxyPass from example.com:80 to rp.example.com:82 to localhost:8080
|
||||||
testRequest("Host: localhost:8080\n" +
|
testRequest("Host: localhost:8080\n" +
|
||||||
"X-Forwarded-For: 10.20.30.40, 10.0.0.1\n" +
|
"X-Forwarded-For: 10.20.30.40, 10.0.0.1\n" +
|
||||||
"X-Forwarded-Host: example.com, rp.example.com:82\n" +
|
"X-Forwarded-Host: example.com, rp.example.com:82\n" +
|
||||||
"X-Forwarded-Server: example.com, rp.example.com\n" +
|
"X-Forwarded-Server: example.com, rp.example.com\n" +
|
||||||
"X-Forwarded-Proto: https, http", new RequestValidator()
|
"X-Forwarded-Proto: https, http", request ->
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void validate(HttpServletRequest request)
|
|
||||||
{
|
{
|
||||||
assertEquals("example.com", request.getServerName());
|
assertEquals("example.com", request.getServerName());
|
||||||
assertEquals(443, request.getServerPort());
|
assertEquals(443, request.getServerPort());
|
||||||
|
@ -129,8 +111,7 @@ public class CheckReverseProxyHeadersTest
|
||||||
assertEquals("example.com", request.getHeader("Host"));
|
assertEquals("example.com", request.getHeader("Host"));
|
||||||
assertEquals("https", request.getScheme());
|
assertEquals("https", request.getScheme());
|
||||||
assertTrue(request.isSecure());
|
assertTrue(request.isSecure());
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testRequest(String headers, RequestValidator requestValidator) throws Exception
|
private void testRequest(String headers, RequestValidator requestValidator) throws Exception
|
||||||
|
|
|
@ -59,10 +59,9 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
|
||||||
final CountDownLatch latch = new CountDownLatch(requestCount);
|
final CountDownLatch latch = new CountDownLatch(requestCount);
|
||||||
|
|
||||||
configureServer(new HelloWorldHandler());
|
configureServer(new HelloWorldHandler());
|
||||||
|
|
||||||
URI uri = _server.getURI();
|
URI uri = _server.getURI();
|
||||||
Socket client = newSocket(uri.getHost(), uri.getPort());
|
|
||||||
try
|
try (Socket client = newSocket(uri.getHost(), uri.getPort()))
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
|
||||||
|
@ -119,10 +118,6 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
|
||||||
reader.setDone();
|
reader.setDone();
|
||||||
runner.join();
|
runner.join();
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int iterations(int cnt)
|
private int iterations(int cnt)
|
||||||
|
@ -136,8 +131,8 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
|
||||||
configureServer(new EchoHandler());
|
configureServer(new EchoHandler());
|
||||||
|
|
||||||
URI uri = _server.getURI();
|
URI uri = _server.getURI();
|
||||||
Socket client = newSocket(uri.getHost(), uri.getPort());
|
|
||||||
try
|
try (Socket client = newSocket(uri.getHost(), uri.getPort()))
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
|
||||||
|
@ -181,10 +176,6 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
|
||||||
String in = reader.getResponse().toString();
|
String in = reader.getResponse().toString();
|
||||||
assertTrue(in.indexOf(__content.substring(__length - 64)) > 0);
|
assertTrue(in.indexOf(__content.substring(__length - 64)) > 0);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
client.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ResponseReader implements Runnable
|
public class ResponseReader implements Runnable
|
||||||
|
@ -226,11 +217,9 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
|
||||||
count = doRead();
|
count = doRead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException | InterruptedException e)
|
||||||
{
|
|
||||||
}
|
|
||||||
catch (InterruptedException ex)
|
|
||||||
{
|
{
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -240,6 +229,7 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,22 +392,15 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
os.write("\r\n".getBytes("utf-8"));
|
os.write("\r\n".getBytes("utf-8"));
|
||||||
os.flush();
|
os.flush();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
long duration = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start;
|
long duration = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start;
|
||||||
assertThat(duration, greaterThan(500L));
|
assertThat(duration, greaterThan(500L));
|
||||||
|
|
||||||
try
|
// read the response
|
||||||
{
|
String response = IO.toString(is);
|
||||||
// read the response
|
assertThat(response, startsWith("HTTP/1.1 500 "));
|
||||||
String response = IO.toString(is);
|
assertThat(response, containsString("InterruptedIOException"));
|
||||||
assertThat(response, startsWith("HTTP/1.1 500 "));
|
|
||||||
assertThat(response, containsString("InterruptedIOException"));
|
|
||||||
}
|
|
||||||
catch (SSLException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -499,9 +492,6 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
long end = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
long end = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
long duration = end - start;
|
long duration = end - start;
|
||||||
assertThat(duration, lessThan(20L * 128L));
|
assertThat(duration, lessThan(20L * 128L));
|
||||||
|
|
|
@ -223,12 +223,13 @@ public class GracefulStopTest
|
||||||
{
|
{
|
||||||
try (Socket s = new Socket("127.0.0.1", port))
|
try (Socket s = new Socket("127.0.0.1", port))
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
catch (ConnectException e)
|
catch (ConnectException e)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try another request on existing connection
|
// Try another request on existing connection
|
||||||
|
@ -298,6 +299,7 @@ public class GracefulStopTest
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* To change the template for this generated file go to
|
* To change the template for this generated file go to
|
||||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.eclipse.jetty.server;
|
package org.eclipse.jetty.server;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
@ -145,7 +146,7 @@ public class HttpConnectionTest
|
||||||
* HTTP/0.9 does not support HttpVersion (this is a bad request)
|
* HTTP/0.9 does not support HttpVersion (this is a bad request)
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHttp09_NoVersion() throws Exception
|
public void testHttp09NoVersion() throws Exception
|
||||||
{
|
{
|
||||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
||||||
String request = "GET / HTTP/0.9\r\n\r\n";
|
String request = "GET / HTTP/0.9\r\n\r\n";
|
||||||
|
@ -162,7 +163,7 @@ public class HttpConnectionTest
|
||||||
* HTTP/0.9 does not support headers
|
* HTTP/0.9 does not support headers
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHttp09_NoHeaders() throws Exception
|
public void testHttp09NoHeaders() throws Exception
|
||||||
{
|
{
|
||||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
||||||
// header looking like another request is ignored
|
// header looking like another request is ignored
|
||||||
|
@ -176,7 +177,7 @@ public class HttpConnectionTest
|
||||||
* Http/0.9 does not support pipelining.
|
* Http/0.9 does not support pipelining.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHttp09_MultipleRequests() throws Exception
|
public void testHttp09MultipleRequests() throws Exception
|
||||||
{
|
{
|
||||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616);
|
||||||
|
|
||||||
|
@ -193,7 +194,7 @@ public class HttpConnectionTest
|
||||||
* Ensure that excessively large hexadecimal chunk body length is parsed properly.
|
* Ensure that excessively large hexadecimal chunk body length is parsed properly.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHttp11_ChunkedBodyTruncation() throws Exception
|
public void testHttp11ChunkedBodyTruncation() throws Exception
|
||||||
{
|
{
|
||||||
String request = "POST /?id=123 HTTP/1.1\r\n" +
|
String request = "POST /?id=123 HTTP/1.1\r\n" +
|
||||||
"Host: local\r\n" +
|
"Host: local\r\n" +
|
||||||
|
@ -222,10 +223,10 @@ public class HttpConnectionTest
|
||||||
* More then 1 Content-Length is a bad requests per HTTP rfcs.
|
* More then 1 Content-Length is a bad requests per HTTP rfcs.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHttp11_MultipleContentLength() throws Exception
|
public void testHttp11MultipleContentLength() throws Exception
|
||||||
{
|
{
|
||||||
HttpParser.LOG.info("badMessage: 400 Bad messages EXPECTED...");
|
HttpParser.LOG.info("badMessage: 400 Bad messages EXPECTED...");
|
||||||
int contentLengths[][] = {
|
int[][] contentLengths = {
|
||||||
{0, 8},
|
{0, 8},
|
||||||
{8, 0},
|
{8, 0},
|
||||||
{8, 8},
|
{8, 8},
|
||||||
|
@ -266,10 +267,10 @@ public class HttpConnectionTest
|
||||||
* More then 1 Content-Length is a bad requests per HTTP rfcs.
|
* More then 1 Content-Length is a bad requests per HTTP rfcs.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHttp11_ContentLengthAndChunk() throws Exception
|
public void testHttp11ContentLengthAndChunk() throws Exception
|
||||||
{
|
{
|
||||||
HttpParser.LOG.info("badMessage: 400 Bad messages EXPECTED...");
|
HttpParser.LOG.info("badMessage: 400 Bad messages EXPECTED...");
|
||||||
int contentLengths[][] = {
|
int[][] contentLengths = {
|
||||||
{-1, 8},
|
{-1, 8},
|
||||||
{8, -1},
|
{8, -1},
|
||||||
{8, -1, 8},
|
{8, -1, 8},
|
||||||
|
@ -403,7 +404,7 @@ public class HttpConnectionTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_0_9() throws Exception
|
public void test09() throws Exception
|
||||||
{
|
{
|
||||||
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616_LEGACY);
|
connector.getConnectionFactory(HttpConnectionFactory.class).setHttpCompliance(HttpCompliance.RFC2616_LEGACY);
|
||||||
LocalEndPoint endp = connector.executeRequest("GET /R1\n");
|
LocalEndPoint endp = connector.executeRequest("GET /R1\n");
|
||||||
|
|
|
@ -46,7 +46,7 @@ import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class HttpManyWaysToAsyncCommitBadBehaviourTest extends AbstractHttpTest
|
public class HttpManyWaysToAsyncCommitBadBehaviourTest extends AbstractHttpTest
|
||||||
{
|
{
|
||||||
private final String CONTEXT_ATTRIBUTE = getClass().getName() + ".asyncContext";
|
private final String contextAttribute = getClass().getName() + ".asyncContext";
|
||||||
|
|
||||||
public static Stream<Arguments> httpVersions()
|
public static Stream<Arguments> httpVersions()
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ public class HttpManyWaysToAsyncCommitBadBehaviourTest extends AbstractHttpTest
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
|
|
|
@ -44,7 +44,7 @@ import static org.hamcrest.Matchers.nullValue;
|
||||||
//TODO: add protocol specific tests for connection: close and/or chunking
|
//TODO: add protocol specific tests for connection: close and/or chunking
|
||||||
public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
{
|
{
|
||||||
private final String CONTEXT_ATTRIBUTE = getClass().getName() + ".asyncContext";
|
private final String contextAttribute = getClass().getName() + ".asyncContext";
|
||||||
|
|
||||||
public static Stream<Arguments> httpVersion()
|
public static Stream<Arguments> httpVersion()
|
||||||
{
|
{
|
||||||
|
@ -101,10 +101,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -164,10 +164,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -227,10 +227,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -301,10 +301,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -377,10 +377,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -453,10 +453,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -533,10 +533,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -610,10 +610,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -688,10 +688,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -761,10 +761,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -835,10 +835,10 @@ public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
|
||||||
@Override
|
@Override
|
||||||
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
public void doNonErrorHandle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
|
if (request.getAttribute(contextAttribute) == null)
|
||||||
{
|
{
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
|
request.setAttribute(contextAttribute, asyncContext);
|
||||||
new Thread(new Runnable()
|
new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -60,14 +60,15 @@ import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public abstract class HttpServerTestBase extends HttpServerTestFixture
|
public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
private static final String REQUEST1_HEADER = "POST / HTTP/1.0\n" + "Host: localhost\n" + "Content-Type: text/xml; charset=utf-8\n" + "Connection: close\n" + "Content-Length: ";
|
private static final String REQUEST1_HEADER = "POST / HTTP/1.0\n" + "Host: localhost\n" + "Content-Type: text/xml; charset=utf-8\n" + "Connection: close\n" + "Content-Length: ";
|
||||||
private static final String REQUEST1_CONTENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
private static final String REQUEST1_CONTENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||||
+ "<nimbus xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:noNamespaceSchemaLocation=\"nimbus.xsd\" version=\"1.0\">\n"
|
"<nimbus xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:noNamespaceSchemaLocation=\"nimbus.xsd\" version=\"1.0\">\n" +
|
||||||
+ "</nimbus>";
|
"</nimbus>";
|
||||||
private static final String REQUEST1 = REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT;
|
private static final String REQUEST1 = REQUEST1_HEADER + REQUEST1_CONTENT.getBytes().length + "\n\n" + REQUEST1_CONTENT;
|
||||||
|
|
||||||
private static final String RESPONSE1 = "HTTP/1.1 200 OK\n" + "Content-Length: 13\n" + "Server: Jetty(" + Server.getVersion() + ")\n" + "\n" + "Hello world\n";
|
private static final String RESPONSE1 = "HTTP/1.1 200 OK\n" + "Content-Length: 13\n" + "Server: Jetty(" + Server.getVersion() + ")\n" + "\n" + "Hello world\n";
|
||||||
|
@ -102,8 +103,8 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
" <getJobDetails>\n" +
|
" <getJobDetails>\n" +
|
||||||
" <jobId>73</jobId>\n" +
|
" <jobId>73</jobId>\n" +
|
||||||
" </getJobDetails>\n" +
|
" </getJobDetails>\n" +
|
||||||
" </request>\n"
|
" </request>\n" +
|
||||||
+ "</nimbus>\n";
|
"</nimbus>\n";
|
||||||
protected static final String RESPONSE2 =
|
protected static final String RESPONSE2 =
|
||||||
"HTTP/1.1 200 OK\n" +
|
"HTTP/1.1 200 OK\n" +
|
||||||
"Content-Type: text/xml;charset=iso-8859-1\n" +
|
"Content-Type: text/xml;charset=iso-8859-1\n" +
|
||||||
|
@ -141,10 +142,10 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
|
||||||
os.write(("OPTIONS * HTTP/1.1\r\n"
|
os.write(("OPTIONS * HTTP/1.1\r\n" +
|
||||||
+ "Host: " + _serverURI.getHost() + "\r\n"
|
"Host: " + _serverURI.getHost() + "\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n").getBytes(StandardCharsets.ISO_8859_1));
|
"\r\n").getBytes(StandardCharsets.ISO_8859_1));
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
// Read the response.
|
// Read the response.
|
||||||
|
@ -158,10 +159,10 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
|
||||||
os.write(("GET * HTTP/1.1\r\n"
|
os.write(("GET * HTTP/1.1\r\n" +
|
||||||
+ "Host: " + _serverURI.getHost() + "\r\n"
|
"Host: " + _serverURI.getHost() + "\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n").getBytes(StandardCharsets.ISO_8859_1));
|
"\r\n").getBytes(StandardCharsets.ISO_8859_1));
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
// Read the response.
|
// Read the response.
|
||||||
|
@ -184,7 +185,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
StacklessLogging stackless = new StacklessLogging(HttpConnection.class))
|
StacklessLogging stackless = new StacklessLogging(HttpConnection.class))
|
||||||
{
|
{
|
||||||
client.setSoTimeout(10000);
|
client.setSoTimeout(10000);
|
||||||
((AbstractLogger)Log.getLogger(HttpConnection.class)).info("expect request is too large, then ISE extra data ...");
|
Log.getLogger(HttpConnection.class).info("expect request is too large, then ISE extra data ...");
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
|
||||||
byte[] buffer = new byte[64 * 1024];
|
byte[] buffer = new byte[64 * 1024];
|
||||||
|
@ -433,22 +434,27 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
os.write(("GET /R2 HTTP/1.1\015\012" +
|
os.write(("GET /R2 HTTP/1.1\015\012" +
|
||||||
"Host: localhost\015\012" +
|
"Host: localhost\015\012" +
|
||||||
"Transfer-Encoding: chunked\015\012" +
|
"Transfer-Encoding: chunked\015\012" +
|
||||||
"Content-Type: text/plain\015\012" +
|
"Content-Type: text/plain\015\012" +
|
||||||
"Connection: close\015\012" +
|
"Connection: close\015\012" +
|
||||||
"\015\012").getBytes());
|
"\015\012").getBytes());
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
os.flush();
|
os.flush();
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
os.write(("5").getBytes());
|
os.write(("5").getBytes());
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
os.write(("\015\012").getBytes());
|
os.write(("\015\012").getBytes());
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
os.flush();
|
os.flush();
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
os.write(("ABCDE\015\012" +
|
os.write(("ABCDE\015\012" +
|
||||||
"0;\015\012\015\012").getBytes());
|
"0;\015\012\015\012").getBytes());
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
// Read the response.
|
// Read the response.
|
||||||
|
@ -465,7 +471,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
||||||
{
|
{
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
os.write(("GET /R2 HTTP/1.1\015\012" +
|
os.write(("GET /R2 HTTP/1.1\015\012" +
|
||||||
"Host: localhost\015\012" +
|
"Host: localhost\015\012" +
|
||||||
"Content-Length: 5\015\012" +
|
"Content-Length: 5\015\012" +
|
||||||
|
@ -474,6 +480,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
"\015\012" +
|
"\015\012" +
|
||||||
"ABCDE\015\012" +
|
"ABCDE\015\012" +
|
||||||
"\015\012"
|
"\015\012"
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
).getBytes());
|
).getBytes());
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
|
@ -939,7 +946,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
}
|
}
|
||||||
|
|
||||||
// check close
|
// check close
|
||||||
assertTrue(in.readLine() == null);
|
assertNull(in.readLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1127,6 +1134,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
OutputStream os = client.getOutputStream();
|
OutputStream os = client.getOutputStream();
|
||||||
InputStream is = client.getInputStream();
|
InputStream is = client.getInputStream();
|
||||||
|
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
os.write((
|
os.write((
|
||||||
"POST /R1 HTTP/1.1\015\012" +
|
"POST /R1 HTTP/1.1\015\012" +
|
||||||
"Host: " + _serverURI.getHost() + ":" + _serverURI.getPort() + "\r\n" +
|
"Host: " + _serverURI.getHost() + ":" + _serverURI.getPort() + "\r\n" +
|
||||||
|
@ -1149,7 +1157,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
"Connection: close\015\012" +
|
"Connection: close\015\012" +
|
||||||
"\015\012" +
|
"\015\012" +
|
||||||
"abcdefghi\n"
|
"abcdefghi\n"
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
).getBytes(StandardCharsets.ISO_8859_1));
|
).getBytes(StandardCharsets.ISO_8859_1));
|
||||||
|
|
||||||
String in = IO.toString(is);
|
String in = IO.toString(is);
|
||||||
|
@ -1281,7 +1289,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
client.close();
|
client.close();
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
|
|
||||||
assertTrue(!handler._endp.isOpen());
|
assertFalse(handler._endp.isOpen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1547,8 +1555,8 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
||||||
{
|
{
|
||||||
byte[] bytes = (
|
byte[] bytes = (
|
||||||
"GET / HTTP/1.1\r\n" +
|
"GET / HTTP/1.1\r\n" +
|
||||||
"Host: localhost\r\n"
|
"Host: localhost\r\n" +
|
||||||
+ "Content-Length: " + cl + "\r\n" +
|
"Content-Length: " + cl + "\r\n" +
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
content).getBytes(StandardCharsets.ISO_8859_1);
|
content).getBytes(StandardCharsets.ISO_8859_1);
|
||||||
|
|
||||||
|
|
|
@ -328,7 +328,7 @@ public class LocalAsyncContextTest
|
||||||
|
|
||||||
final AsyncContext asyncContext = baseRequest.startAsync();
|
final AsyncContext asyncContext = baseRequest.startAsync();
|
||||||
response.getOutputStream().println("STARTASYNC");
|
response.getOutputStream().println("STARTASYNC");
|
||||||
asyncContext.addListener(__asyncListener);
|
asyncContext.addListener(_asyncListener);
|
||||||
if (_suspendFor > 0)
|
if (_suspendFor > 0)
|
||||||
asyncContext.setTimeout(_suspendFor);
|
asyncContext.setTimeout(_suspendFor);
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ public class LocalAsyncContextTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsyncListener __asyncListener = new AsyncListener()
|
private AsyncListener _asyncListener = new AsyncListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(AsyncEvent event) throws IOException
|
public void onComplete(AsyncEvent event) throws IOException
|
||||||
|
|
|
@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class NotAcceptingTest
|
public class NotAcceptingTest
|
||||||
{
|
{
|
||||||
private final long IDLE_TIMEOUT = 2000;
|
private final long idleTimeout = 2000;
|
||||||
Server server;
|
Server server;
|
||||||
LocalConnector localConnector;
|
LocalConnector localConnector;
|
||||||
ServerConnector blockingConnector;
|
ServerConnector blockingConnector;
|
||||||
|
@ -57,18 +57,18 @@ public class NotAcceptingTest
|
||||||
server = new Server();
|
server = new Server();
|
||||||
|
|
||||||
localConnector = new LocalConnector(server);
|
localConnector = new LocalConnector(server);
|
||||||
localConnector.setIdleTimeout(IDLE_TIMEOUT);
|
localConnector.setIdleTimeout(idleTimeout);
|
||||||
server.addConnector(localConnector);
|
server.addConnector(localConnector);
|
||||||
|
|
||||||
blockingConnector = new ServerConnector(server, 1, 1);
|
blockingConnector = new ServerConnector(server, 1, 1);
|
||||||
blockingConnector.setPort(0);
|
blockingConnector.setPort(0);
|
||||||
blockingConnector.setIdleTimeout(IDLE_TIMEOUT);
|
blockingConnector.setIdleTimeout(idleTimeout);
|
||||||
blockingConnector.setAcceptQueueSize(10);
|
blockingConnector.setAcceptQueueSize(10);
|
||||||
server.addConnector(blockingConnector);
|
server.addConnector(blockingConnector);
|
||||||
|
|
||||||
asyncConnector = new ServerConnector(server, 0, 1);
|
asyncConnector = new ServerConnector(server, 0, 1);
|
||||||
asyncConnector.setPort(0);
|
asyncConnector.setPort(0);
|
||||||
asyncConnector.setIdleTimeout(IDLE_TIMEOUT);
|
asyncConnector.setIdleTimeout(idleTimeout);
|
||||||
asyncConnector.setAcceptQueueSize(10);
|
asyncConnector.setAcceptQueueSize(10);
|
||||||
server.addConnector(asyncConnector);
|
server.addConnector(asyncConnector);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public class NotAcceptingTest
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uri = handler.exchange.exchange("delayed connection", IDLE_TIMEOUT, TimeUnit.MILLISECONDS);
|
uri = handler.exchange.exchange("delayed connection", idleTimeout, TimeUnit.MILLISECONDS);
|
||||||
fail("Failed near URI: " + uri); // this displays last URI, not current (obviously)
|
fail("Failed near URI: " + uri); // this displays last URI, not current (obviously)
|
||||||
}
|
}
|
||||||
catch (TimeoutException e)
|
catch (TimeoutException e)
|
||||||
|
@ -177,7 +177,7 @@ public class NotAcceptingTest
|
||||||
{
|
{
|
||||||
local[i] = client;
|
local[i] = client;
|
||||||
client.addInputAndExecute(BufferUtil.toBuffer("GET /three HTTP/1.1\r\nHost:localhost\r\n\r\n"));
|
client.addInputAndExecute(BufferUtil.toBuffer("GET /three HTTP/1.1\r\nHost:localhost\r\n\r\n"));
|
||||||
response = HttpTester.parseResponse(client.getResponse(false, IDLE_TIMEOUT, TimeUnit.MILLISECONDS));
|
response = HttpTester.parseResponse(client.getResponse(false, idleTimeout, TimeUnit.MILLISECONDS));
|
||||||
|
|
||||||
// A few local connections may succeed
|
// A few local connections may succeed
|
||||||
if (i == local.length - 1)
|
if (i == local.length - 1)
|
||||||
|
@ -245,7 +245,7 @@ public class NotAcceptingTest
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uri = handler.exchange.exchange("delayed connection", IDLE_TIMEOUT, TimeUnit.MILLISECONDS);
|
uri = handler.exchange.exchange("delayed connection", idleTimeout, TimeUnit.MILLISECONDS);
|
||||||
fail(uri);
|
fail(uri);
|
||||||
}
|
}
|
||||||
catch (TimeoutException e)
|
catch (TimeoutException e)
|
||||||
|
@ -415,9 +415,9 @@ public class NotAcceptingTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waitFor(localConnector::isAccepting, is(true), 2 * IDLE_TIMEOUT, TimeUnit.MILLISECONDS);
|
waitFor(localConnector::isAccepting, is(true), 2 * idleTimeout, TimeUnit.MILLISECONDS);
|
||||||
waitFor(blockingConnector::isAccepting, is(true), 2 * IDLE_TIMEOUT, TimeUnit.MILLISECONDS);
|
waitFor(blockingConnector::isAccepting, is(true), 2 * idleTimeout, TimeUnit.MILLISECONDS);
|
||||||
waitFor(asyncConnector::isAccepting, is(true), 2 * IDLE_TIMEOUT, TimeUnit.MILLISECONDS);
|
waitFor(asyncConnector::isAccepting, is(true), 2 * idleTimeout, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HelloHandler extends AbstractHandler
|
public static class HelloHandler extends AbstractHandler
|
||||||
|
@ -459,6 +459,7 @@ public class NotAcceptingTest
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class PartialRFC2616Test
|
public class PartialRFC2616Test
|
||||||
{
|
{
|
||||||
|
@ -116,10 +117,12 @@ public class PartialRFC2616Test
|
||||||
"Host: localhost\n" +
|
"Host: localhost\n" +
|
||||||
"Transfer-Encoding: chunked,identity\n" +
|
"Transfer-Encoding: chunked,identity\n" +
|
||||||
"Content-Type: text/plain\n" +
|
"Content-Type: text/plain\n" +
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
"\015\012" +
|
"\015\012" +
|
||||||
"5;\015\012" +
|
"5;\015\012" +
|
||||||
"123\015\012\015\012" +
|
"123\015\012\015\012" +
|
||||||
"0;\015\012\015\012");
|
"0;\015\012\015\012");
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
checkContains(response, offset, "HTTP/1.1 400 Bad", "Chunked last");
|
checkContains(response, offset, "HTTP/1.1 400 Bad", "Chunked last");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,8 +311,9 @@ public class PartialRFC2616Test
|
||||||
"Content-Type: text/plain\n" +
|
"Content-Type: text/plain\n" +
|
||||||
"Content-Length: 5\n" +
|
"Content-Length: 5\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
"123\015\012" +
|
"123\015\012" +
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
"GET /R2 HTTP/1.1\n" +
|
"GET /R2 HTTP/1.1\n" +
|
||||||
"Host: localhost\n" +
|
"Host: localhost\n" +
|
||||||
"Transfer-Encoding: other\n" +
|
"Transfer-Encoding: other\n" +
|
||||||
|
@ -440,7 +444,9 @@ public class PartialRFC2616Test
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
String response = connector.getResponse("GET /R1 HTTP/1.1\n" + "Host: localhost\n" + "\n", 250, TimeUnit.MILLISECONDS);
|
String response = connector.getResponse("GET /R1 HTTP/1.1\n" + "Host: localhost\n" + "\n", 250, TimeUnit.MILLISECONDS);
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "8.1.2 default") + 10;
|
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "8.1.2 default") + 10;
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
checkContains(response, offset, "Content-Length: ", "8.1.2 default");
|
checkContains(response, offset, "Content-Length: ", "8.1.2 default");
|
||||||
|
|
||||||
LocalEndPoint endp = connector.executeRequest("GET /R1 HTTP/1.1\n" + "Host: localhost\n" + "\n" +
|
LocalEndPoint endp = connector.executeRequest("GET /R1 HTTP/1.1\n" + "Host: localhost\n" + "\n" +
|
||||||
|
@ -449,12 +455,16 @@ public class PartialRFC2616Test
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
response = endp.getResponse();
|
response = endp.getResponse();
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "8.1.2 default") + 1;
|
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "8.1.2 default") + 1;
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
offset = checkContains(response, offset, "/R1", "8.1.2 default") + 1;
|
offset = checkContains(response, offset, "/R1", "8.1.2 default") + 1;
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
response = endp.getResponse();
|
response = endp.getResponse();
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "8.1.2.2 pipeline") + 11;
|
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "8.1.2.2 pipeline") + 11;
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
offset = checkContains(response, offset, "Connection: close", "8.1.2.2 pipeline") + 1;
|
offset = checkContains(response, offset, "Connection: close", "8.1.2.2 pipeline") + 1;
|
||||||
offset = checkContains(response, offset, "/R2", "8.1.2.1 close") + 3;
|
offset = checkContains(response, offset, "/R2", "8.1.2.1 close") + 3;
|
||||||
|
|
||||||
|
@ -491,7 +501,9 @@ public class PartialRFC2616Test
|
||||||
"Content-Length: 8\n" +
|
"Content-Length: 8\n" +
|
||||||
"Connection: close\n" +
|
"Connection: close\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
"123456\015\012");
|
"123456\015\012");
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
checkNotContained(response, offset, "HTTP/1.1 100 ", "8.2.3 expect 100");
|
checkNotContained(response, offset, "HTTP/1.1 100 ", "8.2.3 expect 100");
|
||||||
offset = checkContains(response, offset, "HTTP/1.1 200 OK", "8.2.3 expect with body") + 1;
|
offset = checkContains(response, offset, "HTTP/1.1 200 OK", "8.2.3 expect with body") + 1;
|
||||||
}
|
}
|
||||||
|
@ -511,9 +523,9 @@ public class PartialRFC2616Test
|
||||||
String infomational = endp.getResponse();
|
String infomational = endp.getResponse();
|
||||||
offset = checkContains(infomational, offset, "HTTP/1.1 100 ", "8.2.3 expect 100") + 1;
|
offset = checkContains(infomational, offset, "HTTP/1.1 100 ", "8.2.3 expect 100") + 1;
|
||||||
checkNotContained(infomational, offset, "HTTP/1.1 200", "8.2.3 expect 100");
|
checkNotContained(infomational, offset, "HTTP/1.1 200", "8.2.3 expect 100");
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
endp.addInput("654321\015\012");
|
endp.addInput("654321\015\012");
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
String response = endp.getResponse();
|
String response = endp.getResponse();
|
||||||
offset = 0;
|
offset = 0;
|
||||||
offset = checkContains(response, offset, "HTTP/1.1 200", "8.2.3 expect 100") + 1;
|
offset = checkContains(response, offset, "HTTP/1.1 200", "8.2.3 expect 100") + 1;
|
||||||
|
@ -608,6 +620,7 @@ public class PartialRFC2616Test
|
||||||
{
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
String response = connector.getResponse("GET /R1 HTTP/1.0\n" + "\n");
|
String response = connector.getResponse("GET /R1 HTTP/1.0\n" + "\n");
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "19.6.2 default close") + 10;
|
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "19.6.2 default close") + 10;
|
||||||
checkNotContained(response, offset, "Connection: close", "19.6.2 not assumed");
|
checkNotContained(response, offset, "Connection: close", "19.6.2 not assumed");
|
||||||
|
|
||||||
|
@ -659,7 +672,7 @@ public class PartialRFC2616Test
|
||||||
response = endp.getResponse();
|
response = endp.getResponse();
|
||||||
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "19.6.2 Keep-alive 2") + 11;
|
offset = checkContains(response, offset, "HTTP/1.1 200 OK\015\012", "19.6.2 Keep-alive 2") + 11;
|
||||||
offset = checkContains(response, offset, "/R2", "19.6.2 Keep-alive close") + 3;
|
offset = checkContains(response, offset, "/R2", "19.6.2 Keep-alive close") + 3;
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
offset = 0;
|
offset = 0;
|
||||||
response = endp.getResponse();
|
response = endp.getResponse();
|
||||||
assertThat("19.6.2 closed", response, nullValue());
|
assertThat("19.6.2 closed", response, nullValue());
|
||||||
|
@ -667,7 +680,7 @@ public class PartialRFC2616Test
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
assertTrue(false);
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,15 +226,7 @@ public class RequestTest
|
||||||
assertNull(request.getCookies());
|
assertNull(request.getCookies());
|
||||||
assertEquals("", request.getHeader("Name"));
|
assertEquals("", request.getHeader("Name"));
|
||||||
assertTrue(request.getHeaders("Name").hasMoreElements()); // empty
|
assertTrue(request.getHeaders("Name").hasMoreElements()); // empty
|
||||||
try
|
assertThrows(IllegalArgumentException.class, () -> request.getDateHeader("Name"));
|
||||||
{
|
|
||||||
request.getDateHeader("Name");
|
|
||||||
assertTrue(false);
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
assertEquals(-1, request.getDateHeader("Other"));
|
assertEquals(-1, request.getDateHeader("Other"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -640,26 +632,26 @@ public class RequestTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContentLength_ExceedsMaxInteger() throws Exception
|
public void testContentLengthExceedsMaxInteger() throws Exception
|
||||||
{
|
{
|
||||||
final long HUGE_LENGTH = (long) Integer.MAX_VALUE * 10L;
|
final long HUGE_LENGTH = (long)Integer.MAX_VALUE * 10L;
|
||||||
|
|
||||||
_handler._checker = (request, response) ->
|
_handler._checker = (request, response) ->
|
||||||
request.getContentLength() == (-1) // per HttpServletRequest javadoc this must return (-1);
|
request.getContentLength() == (-1) && // per HttpServletRequest javadoc this must return (-1);
|
||||||
&& request.getContentLengthLong() == HUGE_LENGTH;
|
request.getContentLengthLong() == HUGE_LENGTH;
|
||||||
|
|
||||||
//Send a request with encoded form content
|
//Send a request with encoded form content
|
||||||
String request="POST / HTTP/1.1\r\n"+
|
String request = "POST / HTTP/1.1\r\n" +
|
||||||
"Host: whatever\r\n"+
|
"Host: whatever\r\n" +
|
||||||
"Content-Type: application/octet-stream\n"+
|
"Content-Type: application/octet-stream\n" +
|
||||||
"Content-Length: " + HUGE_LENGTH + "\n"+
|
"Content-Length: " + HUGE_LENGTH + "\n" +
|
||||||
"Connection: close\n"+
|
"Connection: close\n" +
|
||||||
"\n"+
|
"\n" +
|
||||||
"<insert huge amount of content here>\n";
|
"<insert huge amount of content here>\n";
|
||||||
|
|
||||||
System.out.println(request);
|
System.out.println(request);
|
||||||
|
|
||||||
String responses=_connector.getResponse(request);
|
String responses = _connector.getResponse(request);
|
||||||
assertThat(responses,startsWith("HTTP/1.1 200"));
|
assertThat(responses,startsWith("HTTP/1.1 200"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,25 +659,25 @@ public class RequestTest
|
||||||
* The Servlet spec and API cannot parse Content-Length that exceeds Long.MAX_VALUE
|
* The Servlet spec and API cannot parse Content-Length that exceeds Long.MAX_VALUE
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testContentLength_ExceedsMaxLong() throws Exception
|
public void testContentLengthExceedsMaxLong() throws Exception
|
||||||
{
|
{
|
||||||
String HUGE_LENGTH = Long.MAX_VALUE + "0";
|
String hugeLength = Long.MAX_VALUE + "0";
|
||||||
|
|
||||||
_handler._checker = (request, response) ->
|
_handler._checker = (request, response) ->
|
||||||
request.getHeader("Content-Length").equals(HUGE_LENGTH)
|
request.getHeader("Content-Length").equals(hugeLength) &&
|
||||||
&& request.getContentLength() == (-1) // per HttpServletRequest javadoc this must return (-1);
|
request.getContentLength() == (-1) && // per HttpServletRequest javadoc this must return (-1);
|
||||||
&& request.getContentLengthLong() == (-1); // exact behavior here not specified in Servlet javadoc
|
request.getContentLengthLong() == (-1); // exact behavior here not specified in Servlet javadoc
|
||||||
|
|
||||||
//Send a request with encoded form content
|
//Send a request with encoded form content
|
||||||
String request="POST / HTTP/1.1\r\n"+
|
String request = "POST / HTTP/1.1\r\n" +
|
||||||
"Host: whatever\r\n"+
|
"Host: whatever\r\n" +
|
||||||
"Content-Type: application/octet-stream\n"+
|
"Content-Type: application/octet-stream\n" +
|
||||||
"Content-Length: " + HUGE_LENGTH + "\n"+
|
"Content-Length: " + hugeLength + "\n" +
|
||||||
"Connection: close\n"+
|
"Connection: close\n" +
|
||||||
"\n"+
|
"\n" +
|
||||||
"<insert huge amount of content here>\n";
|
"<insert huge amount of content here>\n";
|
||||||
|
|
||||||
String responses=_connector.getResponse(request);
|
String responses = _connector.getResponse(request);
|
||||||
assertThat(responses, startsWith("HTTP/1.1 400"));
|
assertThat(responses, startsWith("HTTP/1.1 400"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1667,8 +1659,7 @@ public class RequestTest
|
||||||
String request = "POST / HTTP/1.1\r\n" +
|
String request = "POST / HTTP/1.1\r\n" +
|
||||||
"Host: whatever\r\n" +
|
"Host: whatever\r\n" +
|
||||||
"Cookie: other=cookie\r\n" +
|
"Cookie: other=cookie\r\n" +
|
||||||
"\r\n"
|
"\r\n" +
|
||||||
+
|
|
||||||
"POST / HTTP/1.1\r\n" +
|
"POST / HTTP/1.1\r\n" +
|
||||||
"Host: whatever\r\n" +
|
"Host: whatever\r\n" +
|
||||||
"Cookie: name=value\r\n" +
|
"Cookie: name=value\r\n" +
|
||||||
|
@ -1683,8 +1674,7 @@ public class RequestTest
|
||||||
request = "POST / HTTP/1.1\r\n" +
|
request = "POST / HTTP/1.1\r\n" +
|
||||||
"Host: whatever\r\n" +
|
"Host: whatever\r\n" +
|
||||||
"Cookie: name=value\r\n" +
|
"Cookie: name=value\r\n" +
|
||||||
"\r\n"
|
"\r\n" +
|
||||||
+
|
|
||||||
"POST / HTTP/1.1\r\n" +
|
"POST / HTTP/1.1\r\n" +
|
||||||
"Host: whatever\r\n" +
|
"Host: whatever\r\n" +
|
||||||
"Cookie: \r\n" +
|
"Cookie: \r\n" +
|
||||||
|
@ -1699,8 +1689,7 @@ public class RequestTest
|
||||||
"Host: whatever\r\n" +
|
"Host: whatever\r\n" +
|
||||||
"Cookie: name=value\r\n" +
|
"Cookie: name=value\r\n" +
|
||||||
"Cookie: other=cookie\r\n" +
|
"Cookie: other=cookie\r\n" +
|
||||||
"\r\n"
|
"\r\n" +
|
||||||
+
|
|
||||||
"POST / HTTP/1.1\r\n" +
|
"POST / HTTP/1.1\r\n" +
|
||||||
"Host: whatever\r\n" +
|
"Host: whatever\r\n" +
|
||||||
"Cookie: name=value\r\n" +
|
"Cookie: name=value\r\n" +
|
||||||
|
@ -1727,11 +1716,11 @@ public class RequestTest
|
||||||
buf.append("a=b");
|
buf.append("a=b");
|
||||||
|
|
||||||
// The evil keys file is not distributed - as it is dangerous
|
// The evil keys file is not distributed - as it is dangerous
|
||||||
File evil_keys = new File("/tmp/keys_mapping_to_zero_2m");
|
File evilKeys = new File("/tmp/keys_mapping_to_zero_2m");
|
||||||
if (evil_keys.exists())
|
if (evilKeys.exists())
|
||||||
{
|
{
|
||||||
// Using real evil keys!
|
// Using real evil keys!
|
||||||
try (BufferedReader in = new BufferedReader(new FileReader(evil_keys)))
|
try (BufferedReader in = new BufferedReader(new FileReader(evilKeys)))
|
||||||
{
|
{
|
||||||
String key = null;
|
String key = null;
|
||||||
while ((key = in.readLine()) != null)
|
while ((key = in.readLine()) != null)
|
||||||
|
@ -1879,9 +1868,9 @@ public class RequestTest
|
||||||
{
|
{
|
||||||
((Request)request).setHandled(true);
|
((Request)request).setHandled(true);
|
||||||
|
|
||||||
if (request.getContentLength() > 0
|
if (request.getContentLength() > 0 &&
|
||||||
&& !request.getContentType().startsWith(MimeTypes.Type.FORM_ENCODED.asString())
|
!request.getContentType().startsWith(MimeTypes.Type.FORM_ENCODED.asString()) &&
|
||||||
&& !request.getContentType().startsWith("multipart/form-data"))
|
!request.getContentType().startsWith("multipart/form-data"))
|
||||||
_content = IO.toString(request.getInputStream());
|
_content = IO.toString(request.getInputStream());
|
||||||
|
|
||||||
if (_checker != null && _checker.check(request, response))
|
if (_checker != null && _checker.check(request, response))
|
||||||
|
|
|
@ -18,17 +18,17 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.server;
|
package org.eclipse.jetty.server;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import java.io.IOException;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import javax.servlet.AsyncContext;
|
import javax.servlet.AsyncContext;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletRequestWrapper;
|
import javax.servlet.ServletRequestWrapper;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
|
||||||
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class StressTest
|
||||||
"/path/d",
|
"/path/d",
|
||||||
"/path/e",
|
"/path/e",
|
||||||
"/path/f",
|
"/path/f",
|
||||||
};
|
};
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void init() throws Exception
|
public static void init() throws Exception
|
||||||
|
|
|
@ -40,6 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
|
@ -138,23 +139,8 @@ public class ContextHandlerGetResourceTest
|
||||||
public void testBadPath() throws Exception
|
public void testBadPath() throws Exception
|
||||||
{
|
{
|
||||||
final String path = "bad";
|
final String path = "bad";
|
||||||
try
|
assertThrows(MalformedURLException.class,() -> context.getResource(path));
|
||||||
{
|
assertThrows(MalformedURLException.class,() -> context.getServletContext().getResource(path));
|
||||||
context.getResource(path);
|
|
||||||
fail("Expected " + MalformedURLException.class);
|
|
||||||
}
|
|
||||||
catch (MalformedURLException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
context.getServletContext().getResource(path);
|
|
||||||
fail("Expected " + MalformedURLException.class);
|
|
||||||
}
|
|
||||||
catch (MalformedURLException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -169,7 +169,7 @@ public class InetAccessHandlerTest
|
||||||
{"127.0.0.1-127.0.0.254", "", "", "nothttp", "200"},
|
{"127.0.0.1-127.0.0.254", "", "", "nothttp", "200"},
|
||||||
{"192.0.0.1", "", "", "nothttp", "403"},
|
{"192.0.0.1", "", "", "nothttp", "403"},
|
||||||
{"192.0.0.1-192.0.0.254", "", "", "nothttp", "403"},
|
{"192.0.0.1-192.0.0.254", "", "", "nothttp", "403"},
|
||||||
};
|
};
|
||||||
return Arrays.asList(data).stream().map(Arguments::of);
|
return Arrays.asList(data).stream().map(Arguments::of);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,7 +625,7 @@ public class NcsaRequestLogTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static abstract class AbstractTestHandler extends AbstractHandler
|
private abstract static class AbstractTestHandler extends AbstractHandler
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
|
|
|
@ -26,7 +26,6 @@ import javax.servlet.SessionTrackingMode;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
||||||
public class SessionHandlerTest
|
public class SessionHandlerTest
|
||||||
{
|
{
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -254,6 +254,7 @@ public class SSLEngineTest
|
||||||
}
|
}
|
||||||
catch (SocketException e)
|
catch (SocketException e)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class SniSslConnectionFactoryTest
|
||||||
{
|
{
|
||||||
private Server _server;
|
private Server _server;
|
||||||
private ServerConnector _connector;
|
private ServerConnector _connector;
|
||||||
private HttpConfiguration _https_config;
|
private HttpConfiguration _httpsConfiguration;
|
||||||
private int _port;
|
private int _port;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
@ -85,11 +85,11 @@ public class SniSslConnectionFactoryTest
|
||||||
http_config.setSecureScheme("https");
|
http_config.setSecureScheme("https");
|
||||||
http_config.setSecurePort(8443);
|
http_config.setSecurePort(8443);
|
||||||
http_config.setOutputBufferSize(32768);
|
http_config.setOutputBufferSize(32768);
|
||||||
_https_config = new HttpConfiguration(http_config);
|
_httpsConfiguration = new HttpConfiguration(http_config);
|
||||||
SecureRequestCustomizer src = new SecureRequestCustomizer();
|
SecureRequestCustomizer src = new SecureRequestCustomizer();
|
||||||
src.setSniHostCheck(true);
|
src.setSniHostCheck(true);
|
||||||
_https_config.addCustomizer(src);
|
_httpsConfiguration.addCustomizer(src);
|
||||||
_https_config.addCustomizer((connector, httpConfig, request) ->
|
_httpsConfiguration.addCustomizer((connector, httpConfig, request) ->
|
||||||
{
|
{
|
||||||
EndPoint endp = request.getHttpChannel().getEndPoint();
|
EndPoint endp = request.getHttpChannel().getEndPoint();
|
||||||
if (endp instanceof SslConnection.DecryptedEndPoint)
|
if (endp instanceof SslConnection.DecryptedEndPoint)
|
||||||
|
@ -126,7 +126,7 @@ public class SniSslConnectionFactoryTest
|
||||||
|
|
||||||
ServerConnector https = _connector = new ServerConnector(_server,
|
ServerConnector https = _connector = new ServerConnector(_server,
|
||||||
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
|
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
|
||||||
new HttpConnectionFactory(_https_config));
|
new HttpConnectionFactory(_httpsConfiguration));
|
||||||
_server.addConnector(https);
|
_server.addConnector(https);
|
||||||
|
|
||||||
_server.setHandler(new AbstractHandler.ErrorDispatchHandler()
|
_server.setHandler(new AbstractHandler.ErrorDispatchHandler()
|
||||||
|
|
|
@ -2120,6 +2120,7 @@ public class DefaultServletTest
|
||||||
}
|
}
|
||||||
catch (InvalidPathException | IOException ignore)
|
catch (InvalidPathException | IOException ignore)
|
||||||
{
|
{
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
assumeTrue(ret != null, "Directory creation not supported on OS: " + path + File.separator + subpath);
|
assumeTrue(ret != null, "Directory creation not supported on OS: " + path + File.separator + subpath);
|
||||||
|
|
|
@ -225,6 +225,7 @@ public class ErrorPageTest
|
||||||
}
|
}
|
||||||
catch (Throwable ignore)
|
catch (Throwable ignore)
|
||||||
{
|
{
|
||||||
|
// no opEchoSocket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,11 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version $Rev$ $Date$
|
*
|
||||||
*/
|
*/
|
||||||
public class HolderTest
|
public class HolderTest
|
||||||
{
|
{
|
||||||
|
@ -59,44 +59,19 @@ public class HolderTest
|
||||||
{
|
{
|
||||||
ServletHolder holder = new ServletHolder(Source.JAVAX_API);
|
ServletHolder holder = new ServletHolder(Source.JAVAX_API);
|
||||||
ServletRegistration reg = holder.getRegistration();
|
ServletRegistration reg = holder.getRegistration();
|
||||||
try
|
|
||||||
{
|
assertThrows(IllegalArgumentException.class,() -> reg.setInitParameter(null, "foo"));
|
||||||
reg.setInitParameter(null, "foo");
|
|
||||||
fail("null name accepted");
|
assertThrows(IllegalArgumentException.class,() -> reg.setInitParameter("foo", null));
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
reg.setInitParameter("foo", null);
|
|
||||||
fail("null value accepted");
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
reg.setInitParameter("foo", "bar");
|
reg.setInitParameter("foo", "bar");
|
||||||
assertFalse(reg.setInitParameter("foo", "foo"));
|
assertFalse(reg.setInitParameter("foo", "foo"));
|
||||||
|
|
||||||
Set<String> clash = reg.setInitParameters(Collections.singletonMap("foo", "bax"));
|
Set<String> clash = reg.setInitParameters(Collections.singletonMap("foo", "bax"));
|
||||||
assertTrue(clash != null && clash.size() == 1, "should be one clash");
|
assertTrue(clash != null && clash.size() == 1, "should be one clash");
|
||||||
|
|
||||||
try
|
assertThrows(IllegalArgumentException.class,() -> reg.setInitParameters(Collections.singletonMap((String)null, "bax")));
|
||||||
{
|
assertThrows(IllegalArgumentException.class,() -> reg.setInitParameters(Collections.singletonMap("foo", (String)null)));
|
||||||
reg.setInitParameters(Collections.singletonMap((String)null, "bax"));
|
|
||||||
fail("null name in map accepted");
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
reg.setInitParameters(Collections.singletonMap("foo", (String)null));
|
|
||||||
fail("null value in map accepted");
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> clash2 = reg.setInitParameters(Collections.singletonMap("FOO", "bax"));
|
Set<String> clash2 = reg.setInitParameters(Collections.singletonMap("FOO", "bax"));
|
||||||
assertTrue(clash2.isEmpty(), "should be no clash");
|
assertTrue(clash2.isEmpty(), "should be no clash");
|
||||||
|
|
|
@ -68,18 +68,18 @@ public class PostServletTest
|
||||||
len = request.getInputStream().read(buffer);
|
len = request.getInputStream().read(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e0)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ex0.set(e0);
|
ex0.set(e);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// this read-call should fail immediately
|
// this read-call should fail immediately
|
||||||
request.getInputStream().read(buffer);
|
request.getInputStream().read(buffer);
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex1.set(e1);
|
ex1.set(ex);
|
||||||
LOG.warn(e1.toString());
|
LOG.warn(ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|
|
@ -18,17 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.servlet;
|
package org.eclipse.jetty.servlet;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -84,6 +73,17 @@ import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class ServletContextHandlerTest
|
public class ServletContextHandlerTest
|
||||||
{
|
{
|
||||||
private Server _server;
|
private Server _server;
|
||||||
|
@ -119,15 +119,8 @@ public class ServletContextHandlerTest
|
||||||
{
|
{
|
||||||
super.doStart();
|
super.doStart();
|
||||||
//call the SCI
|
//call the SCI
|
||||||
try
|
_ctx.setExtendedListenerTypes(true);
|
||||||
{
|
_sci.onStartup(Collections.emptySet(), _ctx);
|
||||||
_ctx.setExtendedListenerTypes(true);
|
|
||||||
_sci.onStartup(Collections.emptySet(), _ctx);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,8 +261,8 @@ public class ServletContextHandlerTest
|
||||||
|
|
||||||
public static class MySListener implements HttpSessionListener
|
public static class MySListener implements HttpSessionListener
|
||||||
{
|
{
|
||||||
public static int creates = 0;
|
public static int creates = 0;
|
||||||
public static int destroys = 0;
|
public static int destroys = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sessionCreated(HttpSessionEvent se)
|
public void sessionCreated(HttpSessionEvent se)
|
||||||
|
@ -309,8 +302,7 @@ public class ServletContextHandlerTest
|
||||||
++replaces;
|
++replaces;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class MySIListener implements HttpSessionIdListener
|
public static class MySIListener implements HttpSessionIdListener
|
||||||
{
|
{
|
||||||
public static int changes = 0;
|
public static int changes = 0;
|
||||||
|
@ -485,7 +477,7 @@ public class ServletContextHandlerTest
|
||||||
StringBuffer request = new StringBuffer();
|
StringBuffer request = new StringBuffer();
|
||||||
request.append("GET /test?session=replace HTTP/1.0\n");
|
request.append("GET /test?session=replace HTTP/1.0\n");
|
||||||
request.append("Host: localhost\n");
|
request.append("Host: localhost\n");
|
||||||
request.append("Cookie: "+sessionid+"\n");
|
request.append("Cookie: " + sessionid + "\n");
|
||||||
request.append("\n");
|
request.append("\n");
|
||||||
response = _connector.getResponse(request.toString());
|
response = _connector.getResponse(request.toString());
|
||||||
assertThat(response, Matchers.containsString("200 OK"));
|
assertThat(response, Matchers.containsString("200 OK"));
|
||||||
|
@ -496,7 +488,7 @@ public class ServletContextHandlerTest
|
||||||
request = new StringBuffer();
|
request = new StringBuffer();
|
||||||
request.append("GET /test?session=remove HTTP/1.0\n");
|
request.append("GET /test?session=remove HTTP/1.0\n");
|
||||||
request.append("Host: localhost\n");
|
request.append("Host: localhost\n");
|
||||||
request.append("Cookie: "+sessionid+"\n");
|
request.append("Cookie: " + sessionid + "\n");
|
||||||
request.append("\n");
|
request.append("\n");
|
||||||
response = _connector.getResponse(request.toString());
|
response = _connector.getResponse(request.toString());
|
||||||
assertThat(response, Matchers.containsString("200 OK"));
|
assertThat(response, Matchers.containsString("200 OK"));
|
||||||
|
@ -509,7 +501,7 @@ public class ServletContextHandlerTest
|
||||||
request = new StringBuffer();
|
request = new StringBuffer();
|
||||||
request.append("GET /test?session=change HTTP/1.0\n");
|
request.append("GET /test?session=change HTTP/1.0\n");
|
||||||
request.append("Host: localhost\n");
|
request.append("Host: localhost\n");
|
||||||
request.append("Cookie: "+sessionid+"\n");
|
request.append("Cookie: " + sessionid + "\n");
|
||||||
request.append("\n");
|
request.append("\n");
|
||||||
response = _connector.getResponse(request.toString());
|
response = _connector.getResponse(request.toString());
|
||||||
assertThat(response, Matchers.containsString("200 OK"));
|
assertThat(response, Matchers.containsString("200 OK"));
|
||||||
|
@ -520,7 +512,7 @@ public class ServletContextHandlerTest
|
||||||
request = new StringBuffer();
|
request = new StringBuffer();
|
||||||
request.append("GET /test?session=delete HTTP/1.0\n");
|
request.append("GET /test?session=delete HTTP/1.0\n");
|
||||||
request.append("Host: localhost\n");
|
request.append("Host: localhost\n");
|
||||||
request.append("Cookie: "+sessionid+"\n");
|
request.append("Cookie: " + sessionid + "\n");
|
||||||
request.append("\n");
|
request.append("\n");
|
||||||
response = _connector.getResponse(request.toString());
|
response = _connector.getResponse(request.toString());
|
||||||
assertThat(response, Matchers.containsString("200 OK"));
|
assertThat(response, Matchers.containsString("200 OK"));
|
||||||
|
@ -1025,8 +1017,6 @@ public class ServletContextHandlerTest
|
||||||
//change and remove context attribute
|
//change and remove context attribute
|
||||||
req.getServletContext().setAttribute("foo", "foo");
|
req.getServletContext().setAttribute("foo", "foo");
|
||||||
req.getServletContext().removeAttribute("foo");
|
req.getServletContext().removeAttribute("foo");
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,9 @@ public class ServletHolderTest
|
||||||
{
|
{
|
||||||
assertThat(e.getMessage(), containsString("foo"));
|
assertThat(e.getMessage(), containsString("foo"));
|
||||||
}
|
}
|
||||||
catch (MultiException m)
|
catch (MultiException e)
|
||||||
{
|
{
|
||||||
assertThat(m.getCause().getMessage(), containsString("foo"));
|
assertThat(e.getCause().getMessage(), containsString("foo"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,9 +132,9 @@ public class ServletHolderTest
|
||||||
{
|
{
|
||||||
assertThat(e.getMessage(), containsString("foo"));
|
assertThat(e.getMessage(), containsString("foo"));
|
||||||
}
|
}
|
||||||
catch (MultiException m)
|
catch (MultiException e)
|
||||||
{
|
{
|
||||||
assertThat(m.getCause().getMessage(), containsString("foo"));
|
assertThat(e.getCause().getMessage(), containsString("foo"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class ServletRequestLogTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
private static abstract class AbstractTestServlet extends HttpServlet
|
private abstract static class AbstractTestServlet extends HttpServlet
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
|
|
|
@ -244,9 +244,9 @@ public class ServletTester extends ContainerLifeCycle
|
||||||
else
|
else
|
||||||
connector.open();
|
connector.open();
|
||||||
|
|
||||||
return "http://" + (localhost ? "127.0.0.1" :
|
return "http://" + (localhost ? "127.0.0.1"
|
||||||
InetAddress.getLocalHost().getHostAddress()
|
: InetAddress.getLocalHost().getHostAddress()) +
|
||||||
) + ":" + connector.getLocalPort();
|
":" + connector.getLocalPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalConnector createLocalConnector()
|
public LocalConnector createLocalConnector()
|
||||||
|
|
|
@ -128,7 +128,8 @@ public class StatisticsServletTest
|
||||||
|
|
||||||
public static class Stats
|
public static class Stats
|
||||||
{
|
{
|
||||||
int responses2xx, responses4xx;
|
int responses2xx;
|
||||||
|
int responses4xx;
|
||||||
|
|
||||||
public Stats(int responses2xx, int responses4xx)
|
public Stats(int responses2xx, int responses4xx)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class GzipDefaultNoRecompressTest
|
||||||
{
|
{
|
||||||
public static Stream<Arguments> data()
|
public static Stream<Arguments> data()
|
||||||
{
|
{
|
||||||
return Arrays.asList(new Object[][]
|
return Arrays.stream(new Object[][]
|
||||||
{
|
{
|
||||||
// Some already compressed files
|
// Some already compressed files
|
||||||
{"test_quotes.gz", "application/gzip", GzipHandler.GZIP},
|
{"test_quotes.gz", "application/gzip", GzipHandler.GZIP},
|
||||||
|
@ -64,7 +64,7 @@ public class GzipDefaultNoRecompressTest
|
||||||
//qvalue disables compression
|
//qvalue disables compression
|
||||||
{"test_quotes.txt", "text/plain", GzipHandler.GZIP + ";q=0"},
|
{"test_quotes.txt", "text/plain", GzipHandler.GZIP + ";q=0"},
|
||||||
{"test_quotes.txt", "text/plain", GzipHandler.GZIP + "; q = 0 "},
|
{"test_quotes.txt", "text/plain", GzipHandler.GZIP + "; q = 0 "},
|
||||||
}).stream().map(Arguments::of);
|
}).map(Arguments::of);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkDir testingdir;
|
public WorkDir testingdir;
|
||||||
|
|
|
@ -101,10 +101,10 @@ public class GzipDefaultTest
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class HttpContentTypeWithEncoding extends HttpServlet
|
public static class HttpContentTypeWithEncoding extends HttpServlet
|
||||||
{
|
{
|
||||||
public static final String COMPRESSED_CONTENT = "<html><head></head><body><h1>COMPRESSABLE CONTENT</h1>"
|
public static final String COMPRESSED_CONTENT = "<html><head></head><body><h1>COMPRESSABLE CONTENT</h1>" +
|
||||||
+ "This content must be longer than the default min gzip length, which is 256 bytes. "
|
"This content must be longer than the default min gzip length, which is 256 bytes. " +
|
||||||
+ "The moon is blue to a fish in love. How now brown cow. The quick brown fox jumped over the lazy dog. A woman needs a man like a fish needs a bicycle!"
|
"The moon is blue to a fish in love. How now brown cow. The quick brown fox jumped over the lazy dog. A woman needs a man like a fish needs a bicycle!" +
|
||||||
+ "</body></html>";
|
"</body></html>";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
|
||||||
|
|
|
@ -57,7 +57,7 @@ public final class Hex
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String asHex(byte buf[])
|
public static String asHex(byte[] buf)
|
||||||
{
|
{
|
||||||
int len = buf.length;
|
int len = buf.length;
|
||||||
char[] out = new char[len * 2];
|
char[] out = new char[len * 2];
|
||||||
|
|
|
@ -341,6 +341,7 @@ public abstract class AbstractDoSFilterTest
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +359,7 @@ public abstract class AbstractDoSFilterTest
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,9 @@ public class QoSFilterTest
|
||||||
|
|
||||||
private ServletTester _tester;
|
private ServletTester _tester;
|
||||||
private LocalConnector[] _connectors;
|
private LocalConnector[] _connectors;
|
||||||
private final int NUM_CONNECTIONS = 8;
|
private final int numConnections = 8;
|
||||||
private final int NUM_LOOPS = 6;
|
private final int numLoops = 6;
|
||||||
private final int MAX_QOS = 4;
|
private final int maxQos = 4;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
|
@ -71,7 +71,7 @@ public class QoSFilterTest
|
||||||
TestServlet.__maxSleepers = 0;
|
TestServlet.__maxSleepers = 0;
|
||||||
TestServlet.__sleepers = 0;
|
TestServlet.__sleepers = 0;
|
||||||
|
|
||||||
_connectors = new LocalConnector[NUM_CONNECTIONS];
|
_connectors = new LocalConnector[numConnections];
|
||||||
for (int i = 0; i < _connectors.length; ++i)
|
for (int i = 0; i < _connectors.length; ++i)
|
||||||
{
|
{
|
||||||
_connectors[i] = _tester.createLocalConnector();
|
_connectors[i] = _tester.createLocalConnector();
|
||||||
|
@ -90,20 +90,20 @@ public class QoSFilterTest
|
||||||
public void testNoFilter() throws Exception
|
public void testNoFilter() throws Exception
|
||||||
{
|
{
|
||||||
List<Worker> workers = new ArrayList<>();
|
List<Worker> workers = new ArrayList<>();
|
||||||
for (int i = 0; i < NUM_CONNECTIONS; ++i)
|
for (int i = 0; i < numConnections; ++i)
|
||||||
{
|
{
|
||||||
workers.add(new Worker(i));
|
workers.add(new Worker(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(NUM_CONNECTIONS);
|
ExecutorService executor = Executors.newFixedThreadPool(numConnections);
|
||||||
List<Future<Void>> futures = executor.invokeAll(workers, 10, TimeUnit.SECONDS);
|
List<Future<Void>> futures = executor.invokeAll(workers, 10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
rethrowExceptions(futures);
|
rethrowExceptions(futures);
|
||||||
|
|
||||||
if (TestServlet.__maxSleepers <= MAX_QOS)
|
if (TestServlet.__maxSleepers <= maxQos)
|
||||||
LOG.warn("TEST WAS NOT PARALLEL ENOUGH!");
|
LOG.warn("TEST WAS NOT PARALLEL ENOUGH!");
|
||||||
else
|
else
|
||||||
assertThat(TestServlet.__maxSleepers, Matchers.lessThanOrEqualTo(NUM_CONNECTIONS));
|
assertThat(TestServlet.__maxSleepers, Matchers.lessThanOrEqualTo(numConnections));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Issue #2627")
|
@Disabled("Issue #2627")
|
||||||
|
@ -112,24 +112,24 @@ public class QoSFilterTest
|
||||||
{
|
{
|
||||||
FilterHolder holder = new FilterHolder(QoSFilter2.class);
|
FilterHolder holder = new FilterHolder(QoSFilter2.class);
|
||||||
holder.setAsyncSupported(true);
|
holder.setAsyncSupported(true);
|
||||||
holder.setInitParameter(QoSFilter.MAX_REQUESTS_INIT_PARAM, "" + MAX_QOS);
|
holder.setInitParameter(QoSFilter.MAX_REQUESTS_INIT_PARAM, "" + maxQos);
|
||||||
_tester.getContext().getServletHandler().addFilterWithMapping(holder, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC));
|
_tester.getContext().getServletHandler().addFilterWithMapping(holder, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC));
|
||||||
|
|
||||||
List<Worker> workers = new ArrayList<>();
|
List<Worker> workers = new ArrayList<>();
|
||||||
for (int i = 0; i < NUM_CONNECTIONS; ++i)
|
for (int i = 0; i < numConnections; ++i)
|
||||||
{
|
{
|
||||||
workers.add(new Worker(i));
|
workers.add(new Worker(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(NUM_CONNECTIONS);
|
ExecutorService executor = Executors.newFixedThreadPool(numConnections);
|
||||||
List<Future<Void>> futures = executor.invokeAll(workers, 10, TimeUnit.SECONDS);
|
List<Future<Void>> futures = executor.invokeAll(workers, 10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
rethrowExceptions(futures);
|
rethrowExceptions(futures);
|
||||||
|
|
||||||
if (TestServlet.__maxSleepers < MAX_QOS)
|
if (TestServlet.__maxSleepers < maxQos)
|
||||||
LOG.warn("TEST WAS NOT PARALLEL ENOUGH!");
|
LOG.warn("TEST WAS NOT PARALLEL ENOUGH!");
|
||||||
else
|
else
|
||||||
assertEquals(TestServlet.__maxSleepers, MAX_QOS);
|
assertEquals(TestServlet.__maxSleepers, maxQos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -137,24 +137,24 @@ public class QoSFilterTest
|
||||||
{
|
{
|
||||||
FilterHolder holder = new FilterHolder(QoSFilter2.class);
|
FilterHolder holder = new FilterHolder(QoSFilter2.class);
|
||||||
holder.setAsyncSupported(true);
|
holder.setAsyncSupported(true);
|
||||||
holder.setInitParameter(QoSFilter.MAX_REQUESTS_INIT_PARAM, String.valueOf(MAX_QOS));
|
holder.setInitParameter(QoSFilter.MAX_REQUESTS_INIT_PARAM, String.valueOf(maxQos));
|
||||||
_tester.getContext().getServletHandler().addFilterWithMapping(holder, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC));
|
_tester.getContext().getServletHandler().addFilterWithMapping(holder, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC));
|
||||||
|
|
||||||
List<Worker2> workers = new ArrayList<>();
|
List<Worker2> workers = new ArrayList<>();
|
||||||
for (int i = 0; i < NUM_CONNECTIONS; ++i)
|
for (int i = 0; i < numConnections; ++i)
|
||||||
{
|
{
|
||||||
workers.add(new Worker2(i));
|
workers.add(new Worker2(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(NUM_CONNECTIONS);
|
ExecutorService executor = Executors.newFixedThreadPool(numConnections);
|
||||||
List<Future<Void>> futures = executor.invokeAll(workers, 20, TimeUnit.SECONDS);
|
List<Future<Void>> futures = executor.invokeAll(workers, 20, TimeUnit.SECONDS);
|
||||||
|
|
||||||
rethrowExceptions(futures);
|
rethrowExceptions(futures);
|
||||||
|
|
||||||
if (TestServlet.__maxSleepers < MAX_QOS)
|
if (TestServlet.__maxSleepers < maxQos)
|
||||||
LOG.warn("TEST WAS NOT PARALLEL ENOUGH!");
|
LOG.warn("TEST WAS NOT PARALLEL ENOUGH!");
|
||||||
else
|
else
|
||||||
assertEquals(TestServlet.__maxSleepers, MAX_QOS);
|
assertEquals(TestServlet.__maxSleepers, maxQos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rethrowExceptions(List<Future<Void>> futures) throws Exception
|
private void rethrowExceptions(List<Future<Void>> futures) throws Exception
|
||||||
|
@ -177,7 +177,7 @@ public class QoSFilterTest
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception
|
public Void call() throws Exception
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUM_LOOPS; i++)
|
for (int i = 0; i < numLoops; i++)
|
||||||
{
|
{
|
||||||
HttpTester.Request request = HttpTester.newRequest();
|
HttpTester.Request request = HttpTester.newRequest();
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ public class QoSFilterTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String addr = _tester.createConnector(true);
|
String addr = _tester.createConnector(true);
|
||||||
for (int i = 0; i < NUM_LOOPS; i++)
|
for (int i = 0; i < numLoops; i++)
|
||||||
{
|
{
|
||||||
url = new URL(addr + "/context/test?priority=" + (_num % QoSFilter.DEFAULT_MAX_PRIORITY) + "&n=" + _num + "&l=" + i);
|
url = new URL(addr + "/context/test?priority=" + (_num % QoSFilter.DEFAULT_MAX_PRIORITY) + "&n=" + _num + "&l=" + i);
|
||||||
url.getContent();
|
url.getContent();
|
||||||
|
|
|
@ -43,7 +43,9 @@ public class PathMatchersAbsoluteTest
|
||||||
arguments.add(Arguments.of("/opt/florb", true));
|
arguments.add(Arguments.of("/opt/florb", true));
|
||||||
arguments.add(Arguments.of("/home/user/benfranklin", true));
|
arguments.add(Arguments.of("/home/user/benfranklin", true));
|
||||||
arguments.add(Arguments.of("glob:/home/user/benfranklin/*.jar", true));
|
arguments.add(Arguments.of("glob:/home/user/benfranklin/*.jar", true));
|
||||||
|
//@checkstyle-disable-check : LegacyMethodSeparators
|
||||||
arguments.add(Arguments.of("glob:/**/*.jar", true));
|
arguments.add(Arguments.of("glob:/**/*.jar", true));
|
||||||
|
//@checkstyle-enable-check : LegacyMethodSeparators
|
||||||
arguments.add(Arguments.of("regex:/*-[^dev].ini", true));
|
arguments.add(Arguments.of("regex:/*-[^dev].ini", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ public class PathMatchersSearchRootTest
|
||||||
{
|
{
|
||||||
// absolute first
|
// absolute first
|
||||||
arguments.add(Arguments.of("/opt/app/*.jar", "/opt/app"));
|
arguments.add(Arguments.of("/opt/app/*.jar", "/opt/app"));
|
||||||
|
//@checkstyle-disable-check : LegacyMethodSeparators
|
||||||
arguments.add(Arguments.of("/lib/jvm/**/jre/lib/*.jar", "/lib/jvm"));
|
arguments.add(Arguments.of("/lib/jvm/**/jre/lib/*.jar", "/lib/jvm"));
|
||||||
|
//@checkstyle-enable-check : LegacyMethodSeparators
|
||||||
arguments.add(Arguments.of("glob:/var/lib/*.xml", "/var/lib"));
|
arguments.add(Arguments.of("glob:/var/lib/*.xml", "/var/lib"));
|
||||||
arguments.add(Arguments.of("glob:/var/lib/*.{xml,java}", "/var/lib"));
|
arguments.add(Arguments.of("glob:/var/lib/*.{xml,java}", "/var/lib"));
|
||||||
arguments.add(Arguments.of("glob:/opt/corporate/lib-{dev,prod}/*.ini", "/opt/corporate"));
|
arguments.add(Arguments.of("glob:/opt/corporate/lib-{dev,prod}/*.ini", "/opt/corporate"));
|
||||||
|
|
|
@ -45,11 +45,11 @@ public class UnixSocketClient
|
||||||
body = IO.readToString(content);
|
body = IO.readToString(content);
|
||||||
content_length = body.length();
|
content_length = body.length();
|
||||||
}
|
}
|
||||||
String data = method + " / HTTP/1.1\r\n"
|
String data = method + " / HTTP/1.1\r\n" +
|
||||||
+ "Host: unixsock\r\n"
|
"Host: unixsock\r\n" +
|
||||||
+ "Content-Length: " + content_length + "\r\n"
|
"Content-Length: " + content_length + "\r\n" +
|
||||||
+ "Connection: close\r\n"
|
"Connection: close\r\n" +
|
||||||
+ "\r\n";
|
"\r\n";
|
||||||
if (body != null)
|
if (body != null)
|
||||||
data += body;
|
data += body;
|
||||||
|
|
||||||
|
|
|
@ -45,13 +45,13 @@ public class JSONPojoConvertorFactoryTest
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
foo._int1 = 1;
|
foo._int1 = 1;
|
||||||
foo._int2 = new Integer(2);
|
foo._int2 = Integer.valueOf(2);
|
||||||
foo._long1 = 1000001l;
|
foo._long1 = 1000001L;
|
||||||
foo._long2 = new Long(1000002l);
|
foo._long2 = Long.valueOf(1000002L);
|
||||||
foo._float1 = 10.11f;
|
foo._float1 = 10.11f;
|
||||||
foo._float2 = new Float(10.22f);
|
foo._float2 = Float.valueOf(10.22f);
|
||||||
foo._double1 = 10000.11111d;
|
foo._double1 = 10000.11111d;
|
||||||
foo._double2 = new Double(10000.22222d);
|
foo._double2 = Double.valueOf(10000.22222d);
|
||||||
|
|
||||||
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo), new Baz[]{
|
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo), new Baz[]{
|
||||||
new Baz("baz0", Boolean.TRUE, null), new Baz("baz1", Boolean.FALSE, null)
|
new Baz("baz0", Boolean.TRUE, null), new Baz("baz1", Boolean.FALSE, null)
|
||||||
|
@ -91,13 +91,13 @@ public class JSONPojoConvertorFactoryTest
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
foo._int1 = 1;
|
foo._int1 = 1;
|
||||||
foo._int2 = new Integer(2);
|
foo._int2 = Integer.valueOf(2);
|
||||||
foo._long1 = 1000001l;
|
foo._long1 = 1000001L;
|
||||||
foo._long2 = new Long(1000002l);
|
foo._long2 = Long.valueOf(1000002L);
|
||||||
foo._float1 = 10.11f;
|
foo._float1 = 10.11f;
|
||||||
foo._float2 = new Float(10.22f);
|
foo._float2 = Float.valueOf(10.22f);
|
||||||
foo._double1 = 10000.11111d;
|
foo._double1 = 10000.11111d;
|
||||||
foo._double2 = new Double(10000.22222d);
|
foo._double2 = Double.valueOf(10000.22222d);
|
||||||
|
|
||||||
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo), new Baz[]{
|
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo), new Baz[]{
|
||||||
new Baz("baz0", Boolean.TRUE, null), new Baz("baz1", Boolean.FALSE, null)
|
new Baz("baz0", Boolean.TRUE, null), new Baz("baz1", Boolean.FALSE, null)
|
||||||
|
@ -134,7 +134,8 @@ public class JSONPojoConvertorFactoryTest
|
||||||
|
|
||||||
public static class Bar
|
public static class Bar
|
||||||
{
|
{
|
||||||
private String _title, _nullTest;
|
private String _title;
|
||||||
|
private String _nullTest;
|
||||||
private Baz _baz;
|
private Baz _baz;
|
||||||
private boolean _boolean1;
|
private boolean _boolean1;
|
||||||
private Baz[] _bazs;
|
private Baz[] _bazs;
|
||||||
|
@ -328,15 +329,15 @@ public class JSONPojoConvertorFactoryTest
|
||||||
if (another instanceof Foo)
|
if (another instanceof Foo)
|
||||||
{
|
{
|
||||||
Foo foo = (Foo)another;
|
Foo foo = (Foo)another;
|
||||||
return getName().equals(foo.getName())
|
return getName().equals(foo.getName()) &&
|
||||||
&& getInt1() == foo.getInt1()
|
getInt1() == foo.getInt1() &&
|
||||||
&& getInt2().equals(foo.getInt2())
|
getInt2().equals(foo.getInt2()) &&
|
||||||
&& getLong1() == foo.getLong1()
|
getLong1() == foo.getLong1() &&
|
||||||
&& getLong2().equals(foo.getLong2())
|
getLong2().equals(foo.getLong2()) &&
|
||||||
&& getFloat1() == foo.getFloat1()
|
getFloat1() == foo.getFloat1() &&
|
||||||
&& getFloat2().equals(foo.getFloat2())
|
getFloat2().equals(foo.getFloat2()) &&
|
||||||
&& getDouble1() == foo.getDouble1()
|
getDouble1() == foo.getDouble1() &&
|
||||||
&& getDouble2().equals(foo.getDouble2());
|
getDouble2().equals(foo.getDouble2());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -44,15 +44,15 @@ public class JSONPojoConvertorTest
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
foo._int1 = 1;
|
foo._int1 = 1;
|
||||||
foo._int2 = new Integer(2);
|
foo._int2 = Integer.valueOf(2);
|
||||||
foo._long1 = 1000001l;
|
foo._long1 = 1000001L;
|
||||||
foo._long2 = new Long(1000002l);
|
foo._long2 = Long.valueOf(1000002L);
|
||||||
foo._float1 = 10.11f;
|
foo._float1 = 10.11f;
|
||||||
foo._float2 = new Float(10.22f);
|
foo._float2 = Float.valueOf(10.22f);
|
||||||
foo._double1 = 10000.11111d;
|
foo._double1 = 10000.11111d;
|
||||||
foo._double2 = new Double(10000.22222d);
|
foo._double2 = Double.valueOf(10000.22222d);
|
||||||
foo._char1 = 'a';
|
foo._char1 = 'a';
|
||||||
foo._char2 = new Character('b');
|
foo._char2 = Character.valueOf('b');
|
||||||
|
|
||||||
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo), new Baz[]{
|
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo), new Baz[]{
|
||||||
new Baz("baz0", Boolean.TRUE, null), new Baz("baz1", Boolean.FALSE, null)
|
new Baz("baz0", Boolean.TRUE, null), new Baz("baz1", Boolean.FALSE, null)
|
||||||
|
@ -92,15 +92,15 @@ public class JSONPojoConvertorTest
|
||||||
Foo foo = new Foo();
|
Foo foo = new Foo();
|
||||||
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
foo._name = "Foo @ " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
foo._int1 = 1;
|
foo._int1 = 1;
|
||||||
foo._int2 = new Integer(2);
|
foo._int2 = Integer.valueOf(2);
|
||||||
foo._long1 = 1000001l;
|
foo._long1 = 1000001L;
|
||||||
foo._long2 = new Long(1000002l);
|
foo._long2 = Long.valueOf(1000002L);
|
||||||
foo._float1 = 10.11f;
|
foo._float1 = 10.11f;
|
||||||
foo._float2 = new Float(10.22f);
|
foo._float2 = Float.valueOf(10.22f);
|
||||||
foo._double1 = 10000.11111d;
|
foo._double1 = 10000.11111d;
|
||||||
foo._double2 = new Double(10000.22222d);
|
foo._double2 = Double.valueOf(10000.22222d);
|
||||||
foo._char1 = 'a';
|
foo._char1 = 'a';
|
||||||
foo._char2 = new Character('b');
|
foo._char2 = Character.valueOf('b');
|
||||||
|
|
||||||
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo));
|
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo));
|
||||||
// bar.setColor(Color.Blue);
|
// bar.setColor(Color.Blue);
|
||||||
|
@ -135,7 +135,8 @@ public class JSONPojoConvertorTest
|
||||||
|
|
||||||
public static class Bar
|
public static class Bar
|
||||||
{
|
{
|
||||||
private String _title, _nullTest;
|
private String _title;
|
||||||
|
private String _nullTest;
|
||||||
private Baz _baz;
|
private Baz _baz;
|
||||||
private boolean _boolean1;
|
private boolean _boolean1;
|
||||||
private Baz[] _bazs;
|
private Baz[] _bazs;
|
||||||
|
@ -334,17 +335,17 @@ public class JSONPojoConvertorTest
|
||||||
if (another instanceof Foo)
|
if (another instanceof Foo)
|
||||||
{
|
{
|
||||||
Foo foo = (Foo)another;
|
Foo foo = (Foo)another;
|
||||||
return getName().equals(foo.getName())
|
return getName().equals(foo.getName()) &&
|
||||||
&& getInt1() == foo.getInt1()
|
getInt1() == foo.getInt1() &&
|
||||||
&& getInt2().equals(foo.getInt2())
|
getInt2().equals(foo.getInt2()) &&
|
||||||
&& getLong1() == foo.getLong1()
|
getLong1() == foo.getLong1() &&
|
||||||
&& getLong2().equals(foo.getLong2())
|
getLong2().equals(foo.getLong2()) &&
|
||||||
&& getFloat1() == foo.getFloat1()
|
getFloat1() == foo.getFloat1() &&
|
||||||
&& getFloat2().equals(foo.getFloat2())
|
getFloat2().equals(foo.getFloat2()) &&
|
||||||
&& getDouble1() == foo.getDouble1()
|
getDouble1() == foo.getDouble1() &&
|
||||||
&& getDouble2().equals(foo.getDouble2())
|
getDouble2().equals(foo.getDouble2()) &&
|
||||||
&& getChar1() == foo.getChar1()
|
getChar1() == foo.getChar1() &&
|
||||||
&& getChar2().equals(foo.getChar2());
|
getChar2().equals(foo.getChar2());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class BufferUtilTest
|
||||||
@Test
|
@Test
|
||||||
public void testToInt() throws Exception
|
public void testToInt() throws Exception
|
||||||
{
|
{
|
||||||
ByteBuffer buf[] =
|
ByteBuffer[] buf =
|
||||||
{
|
{
|
||||||
BufferUtil.toBuffer("0"),
|
BufferUtil.toBuffer("0"),
|
||||||
BufferUtil.toBuffer(" 42 "),
|
BufferUtil.toBuffer(" 42 "),
|
||||||
|
@ -51,9 +51,9 @@ public class BufferUtilTest
|
||||||
BufferUtil.toBuffer(" - 45;"),
|
BufferUtil.toBuffer(" - 45;"),
|
||||||
BufferUtil.toBuffer("-2147483648"),
|
BufferUtil.toBuffer("-2147483648"),
|
||||||
BufferUtil.toBuffer("2147483647"),
|
BufferUtil.toBuffer("2147483647"),
|
||||||
};
|
};
|
||||||
|
|
||||||
int val[] =
|
int[] val =
|
||||||
{
|
{
|
||||||
0, 42, 43, -44, -45, -2147483648, 2147483647
|
0, 42, 43, -44, -45, -2147483648, 2147483647
|
||||||
};
|
};
|
||||||
|
@ -67,12 +67,12 @@ public class BufferUtilTest
|
||||||
@Test
|
@Test
|
||||||
public void testPutInt() throws Exception
|
public void testPutInt() throws Exception
|
||||||
{
|
{
|
||||||
int val[] =
|
int[] val =
|
||||||
{
|
{
|
||||||
0, 42, 43, -44, -45, Integer.MIN_VALUE, Integer.MAX_VALUE
|
0, 42, 43, -44, -45, Integer.MIN_VALUE, Integer.MAX_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
String str[] =
|
String[] str =
|
||||||
{
|
{
|
||||||
"0", "42", "43", "-44", "-45", "" + Integer.MIN_VALUE, "" + Integer.MAX_VALUE
|
"0", "42", "43", "-44", "-45", "" + Integer.MIN_VALUE, "" + Integer.MAX_VALUE
|
||||||
};
|
};
|
||||||
|
@ -91,12 +91,12 @@ public class BufferUtilTest
|
||||||
@Test
|
@Test
|
||||||
public void testPutLong() throws Exception
|
public void testPutLong() throws Exception
|
||||||
{
|
{
|
||||||
long val[] =
|
long[] val =
|
||||||
{
|
{
|
||||||
0L, 42L, 43L, -44L, -45L, Long.MIN_VALUE, Long.MAX_VALUE
|
0L, 42L, 43L, -44L, -45L, Long.MIN_VALUE, Long.MAX_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
String str[] =
|
String[] str =
|
||||||
{
|
{
|
||||||
"0", "42", "43", "-44", "-45", "" + Long.MIN_VALUE, "" + Long.MAX_VALUE
|
"0", "42", "43", "-44", "-45", "" + Long.MIN_VALUE, "" + Long.MAX_VALUE
|
||||||
};
|
};
|
||||||
|
@ -115,12 +115,12 @@ public class BufferUtilTest
|
||||||
@Test
|
@Test
|
||||||
public void testPutHexInt() throws Exception
|
public void testPutHexInt() throws Exception
|
||||||
{
|
{
|
||||||
int val[] =
|
int[] val =
|
||||||
{
|
{
|
||||||
0, 42, 43, -44, -45, -2147483648, 2147483647
|
0, 42, 43, -44, -45, -2147483648, 2147483647
|
||||||
};
|
};
|
||||||
|
|
||||||
String str[] =
|
String[] str =
|
||||||
{
|
{
|
||||||
"0", "2A", "2B", "-2C", "-2D", "-80000000", "7FFFFFFF"
|
"0", "2A", "2B", "-2C", "-2D", "-80000000", "7FFFFFFF"
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,8 +28,10 @@ import org.hamcrest.Matchers;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
|
@ -49,14 +51,7 @@ public class FutureCallbackTest
|
||||||
FutureCallback fcb = new FutureCallback();
|
FutureCallback fcb = new FutureCallback();
|
||||||
|
|
||||||
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
assertThrows(TimeoutException.class, () -> fcb.get(500, TimeUnit.MILLISECONDS));
|
||||||
{
|
|
||||||
fcb.get(500, TimeUnit.MILLISECONDS);
|
|
||||||
fail("Expected a TimeoutException");
|
|
||||||
}
|
|
||||||
catch (TimeoutException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.greaterThan(50L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.greaterThan(50L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,22 +74,18 @@ public class FutureCallbackTest
|
||||||
final FutureCallback fcb = new FutureCallback();
|
final FutureCallback fcb = new FutureCallback();
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
new Thread(new Runnable()
|
new Thread(() ->
|
||||||
{
|
{
|
||||||
@Override
|
latch.countDown();
|
||||||
public void run()
|
try
|
||||||
{
|
{
|
||||||
latch.countDown();
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
try
|
|
||||||
{
|
|
||||||
TimeUnit.MILLISECONDS.sleep(100);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
fcb.succeeded();
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
fcb.succeeded();
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
|
@ -117,15 +108,9 @@ public class FutureCallbackTest
|
||||||
assertFalse(fcb.isCancelled());
|
assertFalse(fcb.isCancelled());
|
||||||
|
|
||||||
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
ExecutionException e = assertThrows(ExecutionException.class, () -> fcb.get());
|
||||||
{
|
assertEquals(ex, e.getCause());
|
||||||
fcb.get();
|
|
||||||
fail("Expected an ExecutionException");
|
|
||||||
}
|
|
||||||
catch (ExecutionException ee)
|
|
||||||
{
|
|
||||||
assertEquals(ex, ee.getCause());
|
|
||||||
}
|
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.lessThan(100L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.lessThan(100L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,35 +121,24 @@ public class FutureCallbackTest
|
||||||
final Exception ex = new Exception("FAILED");
|
final Exception ex = new Exception("FAILED");
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
new Thread(new Runnable()
|
new Thread(() ->
|
||||||
{
|
{
|
||||||
@Override
|
latch.countDown();
|
||||||
public void run()
|
try
|
||||||
{
|
{
|
||||||
latch.countDown();
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
try
|
|
||||||
{
|
|
||||||
TimeUnit.MILLISECONDS.sleep(100);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
fcb.failed(ex);
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
fcb.failed(ex);
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
ExecutionException e = assertThrows(ExecutionException.class, () -> fcb.get(10000, TimeUnit.MILLISECONDS));
|
||||||
{
|
assertEquals(ex, e.getCause());
|
||||||
fcb.get(10000, TimeUnit.MILLISECONDS);
|
|
||||||
fail("Expected an ExecutionException");
|
|
||||||
}
|
|
||||||
catch (ExecutionException ee)
|
|
||||||
{
|
|
||||||
assertEquals(ex, ee.getCause());
|
|
||||||
}
|
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.greaterThan(10L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.greaterThan(10L));
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.lessThan(5000L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.lessThan(5000L));
|
||||||
|
|
||||||
|
@ -181,15 +155,8 @@ public class FutureCallbackTest
|
||||||
assertTrue(fcb.isCancelled());
|
assertTrue(fcb.isCancelled());
|
||||||
|
|
||||||
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
CancellationException e = assertThrows(CancellationException.class, () -> fcb.get());
|
||||||
{
|
assertThat(e.getCause(), Matchers.instanceOf(CancellationException.class));
|
||||||
fcb.get();
|
|
||||||
fail("Expected a CancellationException");
|
|
||||||
}
|
|
||||||
catch (CancellationException e)
|
|
||||||
{
|
|
||||||
assertThat(e.getCause(), Matchers.instanceOf(CancellationException.class));
|
|
||||||
}
|
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.lessThan(100L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.lessThan(100L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,35 +166,25 @@ public class FutureCallbackTest
|
||||||
final FutureCallback fcb = new FutureCallback();
|
final FutureCallback fcb = new FutureCallback();
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
new Thread(new Runnable()
|
new Thread(() ->
|
||||||
{
|
{
|
||||||
@Override
|
latch.countDown();
|
||||||
public void run()
|
try
|
||||||
{
|
{
|
||||||
latch.countDown();
|
TimeUnit.MILLISECONDS.sleep(100);
|
||||||
try
|
|
||||||
{
|
|
||||||
TimeUnit.MILLISECONDS.sleep(100);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
fcb.cancel(true);
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
fcb.cancel(true);
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
long start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
try
|
CancellationException e = assertThrows(CancellationException.class,() -> fcb.get(10000, TimeUnit.MILLISECONDS));
|
||||||
{
|
assertThat(e.getCause(), Matchers.instanceOf(CancellationException.class));
|
||||||
fcb.get(10000, TimeUnit.MILLISECONDS);
|
|
||||||
fail("Expected a CancellationException");
|
|
||||||
}
|
|
||||||
catch (CancellationException e)
|
|
||||||
{
|
|
||||||
assertThat(e.getCause(), Matchers.instanceOf(CancellationException.class));
|
|
||||||
}
|
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.greaterThan(10L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.greaterThan(10L));
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.lessThan(1000L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, Matchers.lessThan(1000L));
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class InetAddressSetTest
|
||||||
"[::1",
|
"[::1",
|
||||||
"[xxx]",
|
"[xxx]",
|
||||||
"[:::1]",
|
"[:::1]",
|
||||||
};
|
};
|
||||||
|
|
||||||
InetAddressSet set = new InetAddressSet();
|
InetAddressSet set = new InetAddressSet();
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ public class InetAddressSetTest
|
||||||
"255.255.8.0/16",
|
"255.255.8.0/16",
|
||||||
"255.255.8.1/17",
|
"255.255.8.1/17",
|
||||||
"[::1]/129",
|
"[::1]/129",
|
||||||
};
|
};
|
||||||
|
|
||||||
InetAddressSet set = new InetAddressSet();
|
InetAddressSet set = new InetAddressSet();
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ public class InetAddressSetTest
|
||||||
{
|
{
|
||||||
"10.0.0.0-9.0.0.0",
|
"10.0.0.0-9.0.0.0",
|
||||||
"9.0.0.0-[::10.0.0.0]",
|
"9.0.0.0-[::10.0.0.0]",
|
||||||
};
|
};
|
||||||
|
|
||||||
InetAddressSet set = new InetAddressSet();
|
InetAddressSet set = new InetAddressSet();
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ public class InetAddressSetTest
|
||||||
"9.0-10.0",
|
"9.0-10.0",
|
||||||
"10.0.0--1.1",
|
"10.0.0--1.1",
|
||||||
"10.0.0-256.1",
|
"10.0.0-256.1",
|
||||||
};
|
};
|
||||||
|
|
||||||
InetAddressSet set = new InetAddressSet();
|
InetAddressSet set = new InetAddressSet();
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class RolloverFileOutputStreamTest
|
||||||
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
||||||
assertThat("Midnight", toString(midnight), is("2017.04.27-12:00:00.0 AM PDT"));
|
assertThat("Midnight", toString(midnight), is("2017.04.27-12:00:00.0 AM PDT"));
|
||||||
|
|
||||||
Object expected[][] = {
|
Object[][] expected = {
|
||||||
{"2017.04.27-12:00:00.0 AM PDT", 14_400_000L},
|
{"2017.04.27-12:00:00.0 AM PDT", 14_400_000L},
|
||||||
{"2017.04.28-12:00:00.0 AM PDT", 86_400_000L},
|
{"2017.04.28-12:00:00.0 AM PDT", 86_400_000L},
|
||||||
{"2017.04.29-12:00:00.0 AM PDT", 86_400_000L},
|
{"2017.04.29-12:00:00.0 AM PDT", 86_400_000L},
|
||||||
|
@ -115,7 +115,7 @@ public class RolloverFileOutputStreamTest
|
||||||
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
||||||
assertThat("Midnight", toString(midnight), is("2016.03.11-12:00:00.0 AM PST"));
|
assertThat("Midnight", toString(midnight), is("2016.03.11-12:00:00.0 AM PST"));
|
||||||
|
|
||||||
Object expected[][] = {
|
Object[][] expected = {
|
||||||
{"2016.03.12-12:00:00.0 AM PST", 86_400_000L},
|
{"2016.03.12-12:00:00.0 AM PST", 86_400_000L},
|
||||||
{"2016.03.13-12:00:00.0 AM PST", 86_400_000L},
|
{"2016.03.13-12:00:00.0 AM PST", 86_400_000L},
|
||||||
{"2016.03.14-12:00:00.0 AM PDT", 82_800_000L}, // the short day
|
{"2016.03.14-12:00:00.0 AM PDT", 82_800_000L}, // the short day
|
||||||
|
@ -135,7 +135,7 @@ public class RolloverFileOutputStreamTest
|
||||||
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
||||||
assertThat("Midnight", toString(midnight), is("2016.11.04-12:00:00.0 AM PDT"));
|
assertThat("Midnight", toString(midnight), is("2016.11.04-12:00:00.0 AM PDT"));
|
||||||
|
|
||||||
Object expected[][] = {
|
Object[][] expected = {
|
||||||
{"2016.11.05-12:00:00.0 AM PDT", 86_400_000L},
|
{"2016.11.05-12:00:00.0 AM PDT", 86_400_000L},
|
||||||
{"2016.11.06-12:00:00.0 AM PDT", 86_400_000L},
|
{"2016.11.06-12:00:00.0 AM PDT", 86_400_000L},
|
||||||
{"2016.11.07-12:00:00.0 AM PST", 90_000_000L}, // the long day
|
{"2016.11.07-12:00:00.0 AM PST", 90_000_000L}, // the long day
|
||||||
|
@ -155,7 +155,7 @@ public class RolloverFileOutputStreamTest
|
||||||
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
||||||
assertThat("Midnight", toString(midnight), is("2016.10.01-12:00:00.0 AM AEST"));
|
assertThat("Midnight", toString(midnight), is("2016.10.01-12:00:00.0 AM AEST"));
|
||||||
|
|
||||||
Object expected[][] = {
|
Object[][] expected = {
|
||||||
{"2016.10.02-12:00:00.0 AM AEST", 86_400_000L},
|
{"2016.10.02-12:00:00.0 AM AEST", 86_400_000L},
|
||||||
{"2016.10.03-12:00:00.0 AM AEDT", 82_800_000L}, // the short day
|
{"2016.10.03-12:00:00.0 AM AEDT", 82_800_000L}, // the short day
|
||||||
{"2016.10.04-12:00:00.0 AM AEDT", 86_400_000L},
|
{"2016.10.04-12:00:00.0 AM AEDT", 86_400_000L},
|
||||||
|
@ -175,7 +175,7 @@ public class RolloverFileOutputStreamTest
|
||||||
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
ZonedDateTime midnight = RolloverFileOutputStream.toMidnight(initialDate);
|
||||||
assertThat("Midnight", toString(midnight), is("2016.04.02-12:00:00.0 AM AEDT"));
|
assertThat("Midnight", toString(midnight), is("2016.04.02-12:00:00.0 AM AEDT"));
|
||||||
|
|
||||||
Object expected[][] = {
|
Object[][] expected = {
|
||||||
{"2016.04.03-12:00:00.0 AM AEDT", 86_400_000L},
|
{"2016.04.03-12:00:00.0 AM AEDT", 86_400_000L},
|
||||||
{"2016.04.04-12:00:00.0 AM AEST", 90_000_000L}, // The long day
|
{"2016.04.04-12:00:00.0 AM AEST", 90_000_000L}, // The long day
|
||||||
{"2016.04.05-12:00:00.0 AM AEST", 86_400_000L},
|
{"2016.04.05-12:00:00.0 AM AEST", 86_400_000L},
|
||||||
|
|
|
@ -123,10 +123,10 @@ public class SharedBlockingCallbackTest
|
||||||
}
|
}
|
||||||
fail("Should have thrown IOException");
|
fail("Should have thrown IOException");
|
||||||
}
|
}
|
||||||
catch (IOException ee)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
start = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
|
||||||
assertEquals(ex, ee.getCause());
|
assertEquals(ex, e.getCause());
|
||||||
}
|
}
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, lessThan(100L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, lessThan(100L));
|
||||||
assertEquals(0, notComplete.get());
|
assertEquals(0, notComplete.get());
|
||||||
|
@ -168,9 +168,9 @@ public class SharedBlockingCallbackTest
|
||||||
}
|
}
|
||||||
fail("Should have thrown IOException");
|
fail("Should have thrown IOException");
|
||||||
}
|
}
|
||||||
catch (IOException ee)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
assertEquals(ex, ee.getCause());
|
assertEquals(ex, e.getCause());
|
||||||
}
|
}
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, greaterThan(10L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, greaterThan(10L));
|
||||||
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, lessThan(1000L));
|
assertThat(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - start, lessThan(1000L));
|
||||||
|
|
|
@ -204,7 +204,9 @@ public class StringUtilTest
|
||||||
assertThat(StringUtil.indexOfControlChars("\t"), is(0));
|
assertThat(StringUtil.indexOfControlChars("\t"), is(0));
|
||||||
assertThat(StringUtil.indexOfControlChars(";\n"), is(1));
|
assertThat(StringUtil.indexOfControlChars(";\n"), is(1));
|
||||||
assertThat(StringUtil.indexOfControlChars("abc\fz"), is(3));
|
assertThat(StringUtil.indexOfControlChars("abc\fz"), is(3));
|
||||||
|
//@checkstyle-disable-check : IllegalTokenText
|
||||||
assertThat(StringUtil.indexOfControlChars("z\010"), is(1));
|
assertThat(StringUtil.indexOfControlChars("z\010"), is(1));
|
||||||
|
//@checkstyle-enable-check : IllegalTokenText
|
||||||
assertThat(StringUtil.indexOfControlChars(":\u001c"), is(1));
|
assertThat(StringUtil.indexOfControlChars(":\u001c"), is(1));
|
||||||
|
|
||||||
assertThat(StringUtil.indexOfControlChars(null), is(-1));
|
assertThat(StringUtil.indexOfControlChars(null), is(-1));
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class URIUtilCanonicalPathTest
|
||||||
// paths with encoded segments should remain encoded
|
// paths with encoded segments should remain encoded
|
||||||
// canonicalPath() is not responsible for decoding characters
|
// canonicalPath() is not responsible for decoding characters
|
||||||
{"%2e%2e/", "%2e%2e/"},
|
{"%2e%2e/", "%2e%2e/"},
|
||||||
};
|
};
|
||||||
|
|
||||||
ArrayList<Arguments> ret = new ArrayList<>();
|
ArrayList<Arguments> ret = new ArrayList<>();
|
||||||
for (String[] args : canonical)
|
for (String[] args : canonical)
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class URLEncodedTest
|
||||||
{StringUtil.__ISO_8859_1, StringUtil.__ISO_8859_1, "%30"},
|
{StringUtil.__ISO_8859_1, StringUtil.__ISO_8859_1, "%30"},
|
||||||
{StringUtil.__UTF8, StringUtil.__UTF8, "%30"},
|
{StringUtil.__UTF8, StringUtil.__UTF8, "%30"},
|
||||||
{StringUtil.__UTF16, StringUtil.__UTF16, "%00%30"},
|
{StringUtil.__UTF16, StringUtil.__UTF16, "%00%30"},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note: "%30" -> decode -> "0"
|
// Note: "%30" -> decode -> "0"
|
||||||
|
|
||||||
|
|
|
@ -375,9 +375,8 @@ public class ContainerLifeCycleTest
|
||||||
child.add(c);
|
child.add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public
|
|
||||||
@Override
|
@Override
|
||||||
String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "listener";
|
return "listener";
|
||||||
}
|
}
|
||||||
|
@ -385,18 +384,16 @@ public class ContainerLifeCycleTest
|
||||||
|
|
||||||
ContainerLifeCycle c0 = new ContainerLifeCycle()
|
ContainerLifeCycle c0 = new ContainerLifeCycle()
|
||||||
{
|
{
|
||||||
public
|
|
||||||
@Override
|
@Override
|
||||||
String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "c0";
|
return "c0";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ContainerLifeCycle c00 = new ContainerLifeCycle()
|
ContainerLifeCycle c00 = new ContainerLifeCycle()
|
||||||
{
|
{
|
||||||
public
|
|
||||||
@Override
|
@Override
|
||||||
String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "c00";
|
return "c00";
|
||||||
}
|
}
|
||||||
|
@ -437,9 +434,8 @@ public class ContainerLifeCycleTest
|
||||||
child.add(c);
|
child.add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public
|
|
||||||
@Override
|
@Override
|
||||||
String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "inherited";
|
return "inherited";
|
||||||
}
|
}
|
||||||
|
@ -526,27 +522,24 @@ public class ContainerLifeCycleTest
|
||||||
{
|
{
|
||||||
ContainerLifeCycle c0 = new ContainerLifeCycle()
|
ContainerLifeCycle c0 = new ContainerLifeCycle()
|
||||||
{
|
{
|
||||||
public
|
|
||||||
@Override
|
@Override
|
||||||
String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "c0";
|
return "c0";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ContainerLifeCycle c00 = new ContainerLifeCycle()
|
ContainerLifeCycle c00 = new ContainerLifeCycle()
|
||||||
{
|
{
|
||||||
public
|
|
||||||
@Override
|
@Override
|
||||||
String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "c00";
|
return "c00";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ContainerLifeCycle c01 = new ContainerLifeCycle()
|
ContainerLifeCycle c01 = new ContainerLifeCycle()
|
||||||
{
|
{
|
||||||
public
|
|
||||||
@Override
|
@Override
|
||||||
String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "c01";
|
return "c01";
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.is;
|
||||||
public class LifeCycleListenerNestedTest
|
public class LifeCycleListenerNestedTest
|
||||||
{
|
{
|
||||||
// Set this true to use test-specific workaround.
|
// Set this true to use test-specific workaround.
|
||||||
private final boolean WORKAROUND = false;
|
private final boolean workaround = false;
|
||||||
|
|
||||||
public static class Foo extends ContainerLifeCycle
|
public static class Foo extends ContainerLifeCycle
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ public class LifeCycleListenerNestedTest
|
||||||
|
|
||||||
CapturingListener listener = new CapturingListener();
|
CapturingListener listener = new CapturingListener();
|
||||||
foo.addLifeCycleListener(listener);
|
foo.addLifeCycleListener(listener);
|
||||||
if (WORKAROUND)
|
if (workaround)
|
||||||
foo.addEventListener(listener);
|
foo.addEventListener(listener);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -217,7 +217,7 @@ public class LifeCycleListenerNestedTest
|
||||||
|
|
||||||
CapturingListener listener = new CapturingListener();
|
CapturingListener listener = new CapturingListener();
|
||||||
foo.addLifeCycleListener(listener);
|
foo.addLifeCycleListener(listener);
|
||||||
if (WORKAROUND)
|
if (workaround)
|
||||||
foo.addEventListener(listener);
|
foo.addEventListener(listener);
|
||||||
|
|
||||||
Bar bara = new Bar("a");
|
Bar bara = new Bar("a");
|
||||||
|
@ -255,7 +255,7 @@ public class LifeCycleListenerNestedTest
|
||||||
|
|
||||||
CapturingListener listener = new CapturingListener();
|
CapturingListener listener = new CapturingListener();
|
||||||
foo.addLifeCycleListener(listener);
|
foo.addLifeCycleListener(listener);
|
||||||
if (WORKAROUND)
|
if (workaround)
|
||||||
foo.addEventListener(listener);
|
foo.addEventListener(listener);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -726,19 +726,25 @@ public class StdErrLogTest
|
||||||
|
|
||||||
Exception inner = new Exception("inner");
|
Exception inner = new Exception("inner");
|
||||||
inner.addSuppressed(new IllegalStateException()
|
inner.addSuppressed(new IllegalStateException()
|
||||||
{{
|
{
|
||||||
addSuppressed(new Exception("branch0"));
|
{
|
||||||
}});
|
addSuppressed(new Exception("branch0"));
|
||||||
|
}
|
||||||
|
});
|
||||||
IOException outer = new IOException("outer", inner);
|
IOException outer = new IOException("outer", inner);
|
||||||
|
|
||||||
outer.addSuppressed(new IllegalStateException()
|
outer.addSuppressed(new IllegalStateException()
|
||||||
{{
|
{
|
||||||
addSuppressed(new Exception("branch1"));
|
{
|
||||||
}});
|
addSuppressed(new Exception("branch1"));
|
||||||
|
}
|
||||||
|
});
|
||||||
outer.addSuppressed(new IllegalArgumentException()
|
outer.addSuppressed(new IllegalArgumentException()
|
||||||
{{
|
{
|
||||||
addSuppressed(new Exception("branch2"));
|
{
|
||||||
}});
|
addSuppressed(new Exception("branch2"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
log.warn("problem", outer);
|
log.warn("problem", outer);
|
||||||
|
|
||||||
|
|
|
@ -336,6 +336,7 @@ public class FileSystemResourceTest
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
// FIXME why ignoring exceptions??
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,10 +89,7 @@ public class CounterStatisticTest
|
||||||
for (int i = N; i-- > 0; )
|
for (int i = N; i-- > 0; )
|
||||||
{
|
{
|
||||||
threads[i] = (i >= N / 2)
|
threads[i] = (i >= N / 2)
|
||||||
? new Thread()
|
? new Thread(() ->
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -110,12 +107,9 @@ public class CounterStatisticTest
|
||||||
if (random.nextInt(5) == 0)
|
if (random.nextInt(5) == 0)
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
|
||||||
: new Thread()
|
: new Thread(() ->
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -134,8 +128,7 @@ public class CounterStatisticTest
|
||||||
if (random.nextInt(5) == 0)
|
if (random.nextInt(5) == 0)
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
};
|
|
||||||
threads[i].start();
|
threads[i].start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,15 +35,15 @@ public class SampleStatisticTest
|
||||||
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 90, 110, 95, 105, 97,
|
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 90, 110, 95, 105, 97,
|
||||||
103
|
103
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
private static double[][] results =
|
private static double[][] results =
|
||||||
{ /* {mean,stddev}*/
|
/* {mean,stddev}*/
|
||||||
{100.0, 0.0},
|
{{100.0, 0.0},
|
||||||
{100.0, Math.sqrt((10 * 10 + 10 * 10) / 12.0)},
|
{100.0, Math.sqrt((10 * 10 + 10 * 10) / 12.0)},
|
||||||
{100.0, Math.sqrt((10 * 10 + 10 * 10 + 5 * 5 + 5 * 5 + 3 * 3 + 3 * 3) / 14.0)},
|
{100.0, Math.sqrt((10 * 10 + 10 * 10 + 5 * 5 + 5 * 5 + 3 * 3 + 3 * 3) / 14.0)},
|
||||||
{100.0, Math.sqrt((10 * 10 + 10 * 10 + 5 * 5 + 5 * 5 + 3 * 3 + 3 * 3) / 24.0)},
|
{100.0, Math.sqrt((10 * 10 + 10 * 10 + 5 * 5 + 5 * 5 + 3 * 3 + 3 * 3) / 24.0)},
|
||||||
{100.0, Math.sqrt((10 * 10 + 10 * 10 + 5 * 5 + 5 * 5 + 3 * 3 + 3 * 3) / 104.0)}
|
{100.0, Math.sqrt((10 * 10 + 10 * 10 + 5 * 5 + 5 * 5 + 3 * 3 + 3 * 3) / 104.0)}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -44,7 +44,7 @@ public abstract class AbstractThreadPoolTest
|
||||||
ProcessorUtils.setAvailableProcessors(originalCoreCount);
|
ProcessorUtils.setAvailableProcessors(originalCoreCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected SizedThreadPool newPool(int max);
|
protected abstract SizedThreadPool newPool(int max);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBudget_constructMaxThenLease()
|
public void testBudget_constructMaxThenLease()
|
||||||
|
|
|
@ -466,6 +466,7 @@ public class QueuedThreadPoolTest extends AbstractThreadPoolTest
|
||||||
}
|
}
|
||||||
catch (InterruptedException expected)
|
catch (InterruptedException expected)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -70,6 +70,7 @@ public class SchedulerTest
|
||||||
}
|
}
|
||||||
catch (Exception ignore)
|
catch (Exception ignore)
|
||||||
{
|
{
|
||||||
|
// no op
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class ExecutionStrategyTest
|
||||||
_threads.stop();
|
_threads.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class TestProducer implements Producer
|
public abstract static class TestProducer implements Producer
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
|
@ -122,14 +122,7 @@ public class ExecutionStrategyTest
|
||||||
{
|
{
|
||||||
if (tasks-- > 0)
|
if (tasks-- > 0)
|
||||||
{
|
{
|
||||||
return new Runnable()
|
return () -> latch.countDown();
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -175,15 +168,7 @@ public class ExecutionStrategyTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final CountDownLatch latch = q.take();
|
final CountDownLatch latch = q.take();
|
||||||
return new Runnable()
|
return () -> latch.countDown();
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
// System.err.println("RUN "+id);
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -605,6 +605,7 @@ public class WebAppClassLoader extends URLClassLoader implements ClassVisibility
|
||||||
* @param name the name of the class to load
|
* @param name the name of the class to load
|
||||||
* @param checkSystemResource if true and the class isn't a system class we return it
|
* @param checkSystemResource if true and the class isn't a system class we return it
|
||||||
* @return the loaded class
|
* @return the loaded class
|
||||||
|
* @throws ClassNotFoundException if the class cannot be found
|
||||||
*/
|
*/
|
||||||
protected Class<?> loadAsResource(final String name, boolean checkSystemResource) throws ClassNotFoundException
|
protected Class<?> loadAsResource(final String name, boolean checkSystemResource) throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
|
|
|
@ -407,9 +407,6 @@ public class WebAppContextTest
|
||||||
}
|
}
|
||||||
history.add(e.getMessage());
|
history.add(e.getMessage());
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(history, contains("I0", "I1", "I2", "Listener2 init broken", "D1", "D0", "Listener1 destroy broken"));
|
assertThat(history, contains("I0", "I1", "I2", "Listener2 init broken", "D1", "D0", "Listener1 destroy broken"));
|
||||||
|
|
|
@ -59,13 +59,13 @@ public class MessageReceivingTest
|
||||||
private static EchoHandler handler;
|
private static EchoHandler handler;
|
||||||
private static URI serverUri;
|
private static URI serverUri;
|
||||||
private WebSocketContainer container;
|
private WebSocketContainer container;
|
||||||
private final String VERY_LONG_STRING;
|
private final String veryLongString;
|
||||||
|
|
||||||
public MessageReceivingTest()
|
public MessageReceivingTest()
|
||||||
{
|
{
|
||||||
byte[] raw = new byte[1024 * 1024];
|
byte[] raw = new byte[1024 * 1024];
|
||||||
Arrays.fill(raw, (byte)'x');
|
Arrays.fill(raw, (byte)'x');
|
||||||
VERY_LONG_STRING = new String(raw, StandardCharsets.UTF_8);
|
veryLongString = new String(raw, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
|
@ -137,7 +137,7 @@ public class MessageReceivingTest
|
||||||
LOG.debug("Client Connected: {}", session);
|
LOG.debug("Client Connected: {}", session);
|
||||||
session.getBasicRemote().sendText("");
|
session.getBasicRemote().sendText("");
|
||||||
session.getBasicRemote().sendText("Echo");
|
session.getBasicRemote().sendText("Echo");
|
||||||
session.getBasicRemote().sendText(VERY_LONG_STRING);
|
session.getBasicRemote().sendText(veryLongString);
|
||||||
session.getBasicRemote().sendText("Echo");
|
session.getBasicRemote().sendText("Echo");
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Client Message Sent");
|
LOG.debug("Client Message Sent");
|
||||||
|
@ -232,7 +232,7 @@ public class MessageReceivingTest
|
||||||
/**
|
/**
|
||||||
* Abstract message handler implementation, used for tests.
|
* Abstract message handler implementation, used for tests.
|
||||||
*/
|
*/
|
||||||
private static abstract class AbstractHandler implements MessageHandler
|
private abstract static class AbstractHandler implements MessageHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Message queue to put the result messages.
|
* Message queue to put the result messages.
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class ClientAnnotatedEndpointScanner_GoodSignaturesTest
|
||||||
// The JsrAnnotatedMetadata field that should be populated
|
// The JsrAnnotatedMetadata field that should be populated
|
||||||
Field metadataField;
|
Field metadataField;
|
||||||
// The expected parameters for the Callable found by the scanner
|
// The expected parameters for the Callable found by the scanner
|
||||||
Class<?> expectedParameters[];
|
Class<?>[] expectedParameters;
|
||||||
|
|
||||||
public Scenario(Class<?> pojo, Field metadataField, Class<?>... expectedParams)
|
public Scenario(Class<?> pojo, Field metadataField, Class<?>... expectedParams)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,15 +39,15 @@ public class ReflectUtilsTest
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Apple<T extends Object> implements Fruit<T>, Color<String>
|
public abstract static class Apple<T extends Object> implements Fruit<T>, Color<String>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Cherry<A extends Object, B extends Number> implements Fruit<A>, Color<B>
|
public abstract static class Cherry<A extends Object, B extends Number> implements Fruit<A>, Color<B>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Banana implements Fruit<String>, Color<String>
|
public abstract static class Banana implements Fruit<String>, Color<String>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue