mirror of
https://github.com/jetty/jetty.project.git
synced 2025-02-28 19:09:10 +00:00
Fixed imports referencing JUnit 3 and old matcher libraries.
This commit is contained in:
parent
86d13b91a5
commit
1089a33578
@ -34,14 +34,12 @@ import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* This test class runs tests to make sure that hostname verification (http://www.ietf.org/rfc/rfc2818.txt
|
||||
* section 3.1) is configurable in SslContextFactory and works as expected.
|
||||
@ -106,7 +104,7 @@ public class HostnameVerificationTest
|
||||
try
|
||||
{
|
||||
client.GET(uri);
|
||||
fail("sending request to client should have failed with an Exception!");
|
||||
Assert.fail("sending request to client should have failed with an Exception!");
|
||||
}
|
||||
catch (ExecutionException x)
|
||||
{
|
||||
@ -119,9 +117,9 @@ public class HostnameVerificationTest
|
||||
// ExecutionException wraps an SSLHandshakeException
|
||||
Throwable cause = x.getCause();
|
||||
if (cause instanceof SSLHandshakeException)
|
||||
assertThat(cause.getCause().getCause(), instanceOf(CertificateException.class));
|
||||
Assert.assertThat(cause.getCause().getCause(), Matchers.instanceOf(CertificateException.class));
|
||||
else
|
||||
assertThat(cause.getCause(), instanceOf(ClosedChannelException.class));
|
||||
Assert.assertThat(cause.getCause(), Matchers.instanceOf(ClosedChannelException.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +140,7 @@ public class HostnameVerificationTest
|
||||
}
|
||||
catch (ExecutionException e)
|
||||
{
|
||||
fail("SSLHandshake should work just fine as hostname verification is disabled! " + e.getMessage());
|
||||
Assert.fail("SSLHandshake should work just fine as hostname verification is disabled! " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +161,7 @@ public class HostnameVerificationTest
|
||||
}
|
||||
catch (ExecutionException e)
|
||||
{
|
||||
fail("SSLHandshake should work just fine as hostname verification is disabled! " + e.getMessage());
|
||||
Assert.fail("SSLHandshake should work just fine as hostname verification is disabled! " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,20 +18,15 @@
|
||||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HttpGeneratorClientTest
|
||||
{
|
||||
public final static String CONTENT="The quick brown fox jumped over the lazy dog.\nNow is the time for all good men to come to the aid of the party\nThe moon is blue to a fish in love.\n";
|
||||
public final static String[] connect={null,"keep-alive","close"};
|
||||
|
||||
class Info extends HttpGenerator.RequestInfo
|
||||
@ -55,33 +50,33 @@ public class HttpGeneratorClientTest
|
||||
|
||||
HttpGenerator.Result
|
||||
result=gen.generateRequest(null,null,null,null, true);
|
||||
assertEquals(HttpGenerator.Result.NEED_INFO,result);
|
||||
assertEquals(HttpGenerator.State.START,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_INFO, result);
|
||||
Assert.assertEquals(HttpGenerator.State.START, gen.getState());
|
||||
|
||||
Info info = new Info("GET","/index.html");
|
||||
info.getHttpFields().add("Host","something");
|
||||
info.getHttpFields().add("User-Agent","test");
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
|
||||
result=gen.generateRequest(info,null,null,null, true);
|
||||
assertEquals(HttpGenerator.Result.NEED_HEADER,result);
|
||||
assertEquals(HttpGenerator.State.START,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_HEADER, result);
|
||||
Assert.assertEquals(HttpGenerator.State.START, gen.getState());
|
||||
|
||||
result=gen.generateRequest(info,header,null,null, true);
|
||||
assertEquals(HttpGenerator.Result.FLUSH,result);
|
||||
assertEquals(HttpGenerator.State.COMPLETING,gen.getState());
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.FLUSH, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMPLETING, gen.getState());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
String out = BufferUtil.toString(header);
|
||||
BufferUtil.clear(header);
|
||||
|
||||
result=gen.generateResponse(null,null,null,null, false);
|
||||
assertEquals(HttpGenerator.Result.DONE,result);
|
||||
assertEquals(HttpGenerator.State.END,gen.getState());
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.DONE, result);
|
||||
Assert.assertEquals(HttpGenerator.State.END, gen.getState());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
|
||||
assertEquals(0,gen.getContentPrepared());
|
||||
assertThat(out,containsString("GET /index.html HTTP/1.1"));
|
||||
assertThat(out,not(containsString("Content-Length")));
|
||||
Assert.assertEquals(0, gen.getContentPrepared());
|
||||
Assert.assertThat(out, Matchers.containsString("GET /index.html HTTP/1.1"));
|
||||
Assert.assertThat(out, Matchers.not(Matchers.containsString("Content-Length")));
|
||||
|
||||
}
|
||||
|
||||
@ -95,38 +90,38 @@ public class HttpGeneratorClientTest
|
||||
|
||||
HttpGenerator.Result
|
||||
result=gen.generateRequest(null,null,null,content0, true);
|
||||
assertEquals(HttpGenerator.Result.NEED_INFO,result);
|
||||
assertEquals(HttpGenerator.State.START,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_INFO, result);
|
||||
Assert.assertEquals(HttpGenerator.State.START, gen.getState());
|
||||
|
||||
Info info = new Info("POST","/index.html");
|
||||
info.getHttpFields().add("Host","something");
|
||||
info.getHttpFields().add("User-Agent","test");
|
||||
|
||||
result=gen.generateRequest(info,null,null,content0, true);
|
||||
assertEquals(HttpGenerator.Result.NEED_HEADER,result);
|
||||
assertEquals(HttpGenerator.State.START,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_HEADER, result);
|
||||
Assert.assertEquals(HttpGenerator.State.START, gen.getState());
|
||||
|
||||
result=gen.generateRequest(info,header,null,content0, true);
|
||||
assertEquals(HttpGenerator.Result.FLUSH,result);
|
||||
assertEquals(HttpGenerator.State.COMPLETING,gen.getState());
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.FLUSH, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMPLETING, gen.getState());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
out = BufferUtil.toString(header);
|
||||
BufferUtil.clear(header);
|
||||
out+=BufferUtil.toString(content0);
|
||||
BufferUtil.clear(content0);
|
||||
|
||||
result=gen.generateResponse(null,null,null,null, false);
|
||||
assertEquals(HttpGenerator.Result.DONE,result);
|
||||
assertEquals(HttpGenerator.State.END,gen.getState());
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.DONE, result);
|
||||
Assert.assertEquals(HttpGenerator.State.END, gen.getState());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
|
||||
|
||||
assertThat(out,containsString("POST /index.html HTTP/1.1"));
|
||||
assertThat(out,containsString("Host: something"));
|
||||
assertThat(out,containsString("Content-Length: 58"));
|
||||
assertThat(out,containsString("Hello World. The quick brown fox jumped over the lazy dog."));
|
||||
Assert.assertThat(out, Matchers.containsString("POST /index.html HTTP/1.1"));
|
||||
Assert.assertThat(out, Matchers.containsString("Host: something"));
|
||||
Assert.assertThat(out, Matchers.containsString("Content-Length: 58"));
|
||||
Assert.assertThat(out, Matchers.containsString("Hello World. The quick brown fox jumped over the lazy dog."));
|
||||
|
||||
assertEquals(58,gen.getContentPrepared());
|
||||
Assert.assertEquals(58, gen.getContentPrepared());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -141,63 +136,63 @@ public class HttpGeneratorClientTest
|
||||
|
||||
HttpGenerator.Result
|
||||
result=gen.generateRequest(null,null,null,content0, false);
|
||||
assertEquals(HttpGenerator.Result.NEED_INFO,result);
|
||||
assertEquals(HttpGenerator.State.START,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_INFO, result);
|
||||
Assert.assertEquals(HttpGenerator.State.START, gen.getState());
|
||||
|
||||
Info info = new Info("POST","/index.html");
|
||||
info.getHttpFields().add("Host","something");
|
||||
info.getHttpFields().add("User-Agent","test");
|
||||
|
||||
result=gen.generateRequest(info,null,null,content0, false);
|
||||
assertEquals(HttpGenerator.Result.NEED_HEADER,result);
|
||||
assertEquals(HttpGenerator.State.START,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_HEADER, result);
|
||||
Assert.assertEquals(HttpGenerator.State.START, gen.getState());
|
||||
|
||||
result=gen.generateRequest(info,header,null,content0, false);
|
||||
assertEquals(HttpGenerator.Result.FLUSH,result);
|
||||
assertEquals(HttpGenerator.State.COMMITTED,gen.getState());
|
||||
assertTrue(gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.FLUSH, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMMITTED, gen.getState());
|
||||
Assert.assertTrue(gen.isChunking());
|
||||
out = BufferUtil.toString(header);
|
||||
BufferUtil.clear(header);
|
||||
out+=BufferUtil.toString(content0);
|
||||
BufferUtil.clear(content0);
|
||||
|
||||
result=gen.generateRequest(null,header,null,content1, false);
|
||||
assertEquals(HttpGenerator.Result.NEED_CHUNK,result);
|
||||
assertEquals(HttpGenerator.State.COMMITTED,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_CHUNK, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMMITTED, gen.getState());
|
||||
|
||||
result=gen.generateRequest(null,null,chunk,content1, false);
|
||||
assertEquals(HttpGenerator.Result.FLUSH,result);
|
||||
assertEquals(HttpGenerator.State.COMMITTED,gen.getState());
|
||||
assertTrue(gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.FLUSH, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMMITTED, gen.getState());
|
||||
Assert.assertTrue(gen.isChunking());
|
||||
out+=BufferUtil.toString(chunk);
|
||||
BufferUtil.clear(chunk);
|
||||
out+=BufferUtil.toString(content1);
|
||||
BufferUtil.clear(content1);
|
||||
|
||||
result=gen.generateResponse(null,null,chunk,null, true);
|
||||
assertEquals(HttpGenerator.Result.CONTINUE,result);
|
||||
assertEquals(HttpGenerator.State.COMPLETING,gen.getState());
|
||||
assertTrue(gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.CONTINUE, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMPLETING, gen.getState());
|
||||
Assert.assertTrue(gen.isChunking());
|
||||
|
||||
result=gen.generateResponse(null,null,chunk,null, true);
|
||||
assertEquals(HttpGenerator.Result.FLUSH,result);
|
||||
assertEquals(HttpGenerator.State.COMPLETING,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.FLUSH, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMPLETING, gen.getState());
|
||||
out+=BufferUtil.toString(chunk);
|
||||
BufferUtil.clear(chunk);
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
|
||||
result=gen.generateResponse(null,null,chunk,null, true);
|
||||
assertEquals(HttpGenerator.Result.DONE,result);
|
||||
assertEquals(HttpGenerator.State.END,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.DONE, result);
|
||||
Assert.assertEquals(HttpGenerator.State.END, gen.getState());
|
||||
|
||||
assertThat(out,containsString("POST /index.html HTTP/1.1"));
|
||||
assertThat(out,containsString("Host: something"));
|
||||
assertThat(out,containsString("Transfer-Encoding: chunked"));
|
||||
assertThat(out,containsString("\r\nD\r\nHello World. \r\n"));
|
||||
assertThat(out,containsString("\r\n2D\r\nThe quick brown fox jumped over the lazy dog.\r\n"));
|
||||
assertThat(out,containsString("\r\n0\r\n\r\n"));
|
||||
Assert.assertThat(out, Matchers.containsString("POST /index.html HTTP/1.1"));
|
||||
Assert.assertThat(out, Matchers.containsString("Host: something"));
|
||||
Assert.assertThat(out, Matchers.containsString("Transfer-Encoding: chunked"));
|
||||
Assert.assertThat(out, Matchers.containsString("\r\nD\r\nHello World. \r\n"));
|
||||
Assert.assertThat(out, Matchers.containsString("\r\n2D\r\nThe quick brown fox jumped over the lazy dog.\r\n"));
|
||||
Assert.assertThat(out, Matchers.containsString("\r\n0\r\n\r\n"));
|
||||
|
||||
assertEquals(58,gen.getContentPrepared());
|
||||
Assert.assertEquals(58, gen.getContentPrepared());
|
||||
|
||||
}
|
||||
|
||||
@ -213,50 +208,50 @@ public class HttpGeneratorClientTest
|
||||
|
||||
HttpGenerator.Result
|
||||
result=gen.generateRequest(null,null,null,content0, false);
|
||||
assertEquals(HttpGenerator.Result.NEED_INFO,result);
|
||||
assertEquals(HttpGenerator.State.START,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_INFO, result);
|
||||
Assert.assertEquals(HttpGenerator.State.START, gen.getState());
|
||||
|
||||
Info info = new Info("POST","/index.html",58);
|
||||
info.getHttpFields().add("Host","something");
|
||||
info.getHttpFields().add("User-Agent","test");
|
||||
|
||||
result=gen.generateRequest(info,null,null,content0, false);
|
||||
assertEquals(HttpGenerator.Result.NEED_HEADER,result);
|
||||
assertEquals(HttpGenerator.State.START,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.NEED_HEADER, result);
|
||||
Assert.assertEquals(HttpGenerator.State.START, gen.getState());
|
||||
|
||||
result=gen.generateRequest(info,header,null,content0, false);
|
||||
assertEquals(HttpGenerator.Result.FLUSH,result);
|
||||
assertEquals(HttpGenerator.State.COMMITTED,gen.getState());
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.FLUSH, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMMITTED, gen.getState());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
out = BufferUtil.toString(header);
|
||||
BufferUtil.clear(header);
|
||||
out+=BufferUtil.toString(content0);
|
||||
BufferUtil.clear(content0);
|
||||
|
||||
result=gen.generateRequest(null,null,null,content1, false);
|
||||
assertEquals(HttpGenerator.Result.FLUSH,result);
|
||||
assertEquals(HttpGenerator.State.COMMITTED,gen.getState());
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.FLUSH, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMMITTED, gen.getState());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
out+=BufferUtil.toString(content1);
|
||||
BufferUtil.clear(content1);
|
||||
|
||||
result=gen.generateResponse(null,null,null,null, true);
|
||||
assertEquals(HttpGenerator.Result.CONTINUE,result);
|
||||
assertEquals(HttpGenerator.State.COMPLETING,gen.getState());
|
||||
assertTrue(!gen.isChunking());
|
||||
Assert.assertEquals(HttpGenerator.Result.CONTINUE, result);
|
||||
Assert.assertEquals(HttpGenerator.State.COMPLETING, gen.getState());
|
||||
Assert.assertTrue(!gen.isChunking());
|
||||
|
||||
result=gen.generateResponse(null,null,null,null, true);
|
||||
assertEquals(HttpGenerator.Result.DONE,result);
|
||||
assertEquals(HttpGenerator.State.END,gen.getState());
|
||||
Assert.assertEquals(HttpGenerator.Result.DONE, result);
|
||||
Assert.assertEquals(HttpGenerator.State.END, gen.getState());
|
||||
out+=BufferUtil.toString(chunk);
|
||||
BufferUtil.clear(chunk);
|
||||
|
||||
assertThat(out,containsString("POST /index.html HTTP/1.1"));
|
||||
assertThat(out,containsString("Host: something"));
|
||||
assertThat(out,containsString("Content-Length: 58"));
|
||||
assertThat(out,containsString("\r\n\r\nHello World. The quick brown fox jumped over the lazy dog."));
|
||||
Assert.assertThat(out, Matchers.containsString("POST /index.html HTTP/1.1"));
|
||||
Assert.assertThat(out, Matchers.containsString("Host: something"));
|
||||
Assert.assertThat(out, Matchers.containsString("Content-Length: 58"));
|
||||
Assert.assertThat(out, Matchers.containsString("\r\n\r\nHello World. The quick brown fox jumped over the lazy dog."));
|
||||
|
||||
assertEquals(58,gen.getContentPrepared());
|
||||
Assert.assertEquals(58, gen.getContentPrepared());
|
||||
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,12 +18,8 @@
|
||||
|
||||
package org.eclipse.jetty.security;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -42,13 +38,12 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1441 $ $Date: 2010-04-02 12:28:17 +0200 (Fri, 02 Apr 2010) $
|
||||
*/
|
||||
public class DataConstraintsTest
|
||||
{
|
||||
private Server _server;
|
||||
@ -134,15 +129,15 @@ public class DataConstraintsTest
|
||||
|
||||
String response;
|
||||
response = _connector.getResponses("GET /ctx/some/thing HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connector.getResponses("GET /ctx/integral/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: BWTP://"));
|
||||
assertThat(response, containsString(":9999"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("Location: BWTP://"));
|
||||
Assert.assertThat(response, Matchers.containsString(":9999"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/integral/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
}
|
||||
|
||||
@ -166,15 +161,15 @@ public class DataConstraintsTest
|
||||
|
||||
String response;
|
||||
response = _connector.getResponses("GET /ctx/some/thing HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
assertThat(response, containsString("Location: BWTP://"));
|
||||
assertThat(response, containsString(":9999"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("Location: BWTP://"));
|
||||
Assert.assertThat(response, Matchers.containsString(":9999"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
}
|
||||
|
||||
@ -198,10 +193,10 @@ public class DataConstraintsTest
|
||||
String response;
|
||||
|
||||
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
}
|
||||
|
||||
@ -226,16 +221,16 @@ public class DataConstraintsTest
|
||||
String response;
|
||||
|
||||
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connector.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
|
||||
|
||||
response = _connectorS.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
}
|
||||
@Test
|
||||
@ -260,16 +255,16 @@ public class DataConstraintsTest
|
||||
String response;
|
||||
|
||||
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connector.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
|
||||
|
||||
response = _connectorS.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
}
|
||||
|
||||
@ -299,25 +294,25 @@ public class DataConstraintsTest
|
||||
String response;
|
||||
|
||||
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connector.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
|
||||
|
||||
response = _connectorS.getResponses("POST /ctx/confid/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 401 Unauthorized"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 401 Unauthorized"));
|
||||
|
||||
response = _connector.getResponses("GET /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connector.getResponses("POST /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 302 Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 302 Found"));
|
||||
|
||||
response = _connectorS.getResponses("POST /ctx/confid/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
}
|
||||
|
||||
@ -341,16 +336,16 @@ public class DataConstraintsTest
|
||||
String response;
|
||||
|
||||
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
}
|
||||
|
||||
@ -375,16 +370,16 @@ public class DataConstraintsTest
|
||||
String response;
|
||||
|
||||
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n Authorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n Authorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 403 Forbidden"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 403 Forbidden"));
|
||||
|
||||
}
|
||||
|
||||
@ -413,16 +408,16 @@ public class DataConstraintsTest
|
||||
String response;
|
||||
|
||||
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 401 Unauthorized"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 401 Unauthorized"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\r\n\r\n");
|
||||
assertThat(response, containsString("HTTP/1.1 401 Unauthorized"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 401 Unauthorized"));
|
||||
|
||||
response = _connector.getResponses("GET /ctx/restricted/info HTTP/1.0\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\n\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
response = _connectorS.getResponses("GET /ctx/restricted/info HTTP/1.0\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\n\n");
|
||||
assertThat(response, containsString("HTTP/1.1 404 Not Found"));
|
||||
Assert.assertThat(response, Matchers.containsString("HTTP/1.1 404 Not Found"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,6 @@
|
||||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -30,7 +25,6 @@ import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.concurrent.Exchanger;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -40,6 +34,7 @@ import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.ssl.SslConnection;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -64,7 +59,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
@ -80,10 +75,10 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
IO.toString(is);
|
||||
|
||||
Thread.sleep(sleepTime);
|
||||
assertEquals(-1, is.read());
|
||||
Assert.assertEquals(-1, is.read());
|
||||
|
||||
Assert.assertTrue(System.currentTimeMillis()-start>minimumTestRuntime);
|
||||
Assert.assertTrue(System.currentTimeMillis()-start<maximumTestRuntime);
|
||||
Assert.assertTrue(System.currentTimeMillis() - start > minimumTestRuntime);
|
||||
Assert.assertTrue(System.currentTimeMillis() - start < maximumTestRuntime);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -93,7 +88,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
@ -113,10 +108,10 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
IO.toString(is);
|
||||
|
||||
Thread.sleep(sleepTime);
|
||||
assertEquals(-1, is.read());
|
||||
Assert.assertEquals(-1, is.read());
|
||||
|
||||
Assert.assertTrue(System.currentTimeMillis()-start>minimumTestRuntime);
|
||||
Assert.assertTrue(System.currentTimeMillis()-start<maximumTestRuntime);
|
||||
Assert.assertTrue(System.currentTimeMillis() - start > minimumTestRuntime);
|
||||
Assert.assertTrue(System.currentTimeMillis() - start < maximumTestRuntime);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -144,7 +139,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
@ -163,10 +158,10 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
|
||||
// read the response
|
||||
String result=IO.toString(is);
|
||||
Assert.assertThat("OK",result,containsString("200 OK"));
|
||||
Assert.assertThat("OK",result, Matchers.containsString("200 OK"));
|
||||
|
||||
// check client reads EOF
|
||||
assertEquals(-1, is.read());
|
||||
Assert.assertEquals(-1, is.read());
|
||||
|
||||
// wait for idle timeout
|
||||
TimeUnit.MILLISECONDS.sleep(3 * MAX_IDLE_TIME);
|
||||
@ -218,7 +213,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
@ -237,11 +232,11 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
|
||||
// read the response
|
||||
String result=IO.toString(is);
|
||||
Assert.assertThat("OK",result,containsString("200 OK"));
|
||||
Assert.assertThat("OK",result, Matchers.containsString("200 OK"));
|
||||
|
||||
// check client reads EOF
|
||||
assertEquals(-1, is.read());
|
||||
assertTrue(endPoint.isOutputShutdown());
|
||||
Assert.assertEquals(-1, is.read());
|
||||
Assert.assertTrue(endPoint.isOutputShutdown());
|
||||
|
||||
Thread.sleep(2 * MAX_IDLE_TIME);
|
||||
|
||||
@ -294,7 +289,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
@ -318,7 +313,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
IO.toString(is);
|
||||
|
||||
// check client reads EOF
|
||||
assertEquals(-1, is.read());
|
||||
Assert.assertEquals(-1, is.read());
|
||||
|
||||
TimeUnit.MILLISECONDS.sleep(3*MAX_IDLE_TIME);
|
||||
|
||||
@ -353,14 +348,14 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
InputStream is=client.getInputStream();
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
Thread.sleep(sleepTime);
|
||||
long start = System.currentTimeMillis();
|
||||
try
|
||||
{
|
||||
IO.toString(is);
|
||||
assertEquals(-1, is.read());
|
||||
Assert.assertEquals(-1, is.read());
|
||||
}
|
||||
catch(SSLException e)
|
||||
{
|
||||
@ -370,7 +365,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertTrue(System.currentTimeMillis()-start<maximumTestRuntime);
|
||||
Assert.assertTrue(System.currentTimeMillis() - start < maximumTestRuntime);
|
||||
|
||||
}
|
||||
|
||||
@ -381,7 +376,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
@ -410,7 +405,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
for (int i =0;i<20;i++)
|
||||
{
|
||||
offset=in.indexOf("Wibble",offset+1);
|
||||
Assert.assertTrue(""+i,offset>0);
|
||||
Assert.assertTrue("" + i, offset > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,7 +416,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
@ -439,7 +434,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
for (int i =0;i<20;i++)
|
||||
{
|
||||
offset=in.indexOf("Hello World",offset+1);
|
||||
Assert.assertTrue(""+i,offset>0);
|
||||
Assert.assertTrue("" + i, offset > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,7 +445,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
Socket client=newSocket(_serverURI.getHost(),_serverURI.getPort());
|
||||
client.setSoTimeout(10000);
|
||||
|
||||
assertFalse(client.isClosed());
|
||||
Assert.assertFalse(client.isClosed());
|
||||
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
@ -465,7 +460,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
|
||||
String in = IO.toString(is);
|
||||
int offset=in.indexOf("Hello World");
|
||||
Assert.assertTrue(offset>0);
|
||||
Assert.assertTrue(offset > 0);
|
||||
}
|
||||
|
||||
protected static class SlowResponseHandler extends AbstractHandler
|
||||
|
@ -18,18 +18,12 @@
|
||||
|
||||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -43,9 +37,6 @@ import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ContextHandlerTest
|
||||
{
|
||||
@Test
|
||||
@ -97,9 +88,9 @@ public class ContextHandlerTest
|
||||
server.start();
|
||||
connector.getResponses("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
|
||||
|
||||
assertTrue(handlerA.isHandled());
|
||||
assertFalse(handlerB.isHandled());
|
||||
assertFalse(handlerC.isHandled());
|
||||
Assert.assertTrue(handlerA.isHandled());
|
||||
Assert.assertFalse(handlerB.isHandled());
|
||||
Assert.assertFalse(handlerC.isHandled());
|
||||
|
||||
handlerA.reset();
|
||||
handlerB.reset();
|
||||
@ -107,9 +98,9 @@ public class ContextHandlerTest
|
||||
|
||||
connector.getResponses("GET / HTTP/1.0\n" + "Host: www.example2.com\n\n");
|
||||
|
||||
assertFalse(handlerA.isHandled());
|
||||
assertTrue(handlerB.isHandled());
|
||||
assertFalse(handlerC.isHandled());
|
||||
Assert.assertFalse(handlerA.isHandled());
|
||||
Assert.assertTrue(handlerB.isHandled());
|
||||
Assert.assertFalse(handlerC.isHandled());
|
||||
|
||||
}
|
||||
finally
|
||||
@ -153,33 +144,33 @@ public class ContextHandlerTest
|
||||
try
|
||||
{
|
||||
connector.getResponses("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
|
||||
assertTrue(handlerA.isHandled());
|
||||
assertFalse(handlerB.isHandled());
|
||||
assertFalse(handlerC.isHandled());
|
||||
Assert.assertTrue(handlerA.isHandled());
|
||||
Assert.assertFalse(handlerB.isHandled());
|
||||
Assert.assertFalse(handlerC.isHandled());
|
||||
handlerA.reset();
|
||||
handlerB.reset();
|
||||
handlerC.reset();
|
||||
|
||||
connector.getResponses("GET / HTTP/1.0\n" + "Host: localhost\n\n");
|
||||
assertFalse(handlerA.isHandled());
|
||||
assertFalse(handlerB.isHandled());
|
||||
assertTrue(handlerC.isHandled());
|
||||
Assert.assertFalse(handlerA.isHandled());
|
||||
Assert.assertFalse(handlerB.isHandled());
|
||||
Assert.assertTrue(handlerC.isHandled());
|
||||
handlerA.reset();
|
||||
handlerB.reset();
|
||||
handlerC.reset();
|
||||
|
||||
connectorN.getResponses("GET / HTTP/1.0\n" + "Host: www.example.com.\n\n");
|
||||
assertTrue(handlerA.isHandled());
|
||||
assertFalse(handlerB.isHandled());
|
||||
assertFalse(handlerC.isHandled());
|
||||
Assert.assertTrue(handlerA.isHandled());
|
||||
Assert.assertFalse(handlerB.isHandled());
|
||||
Assert.assertFalse(handlerC.isHandled());
|
||||
handlerA.reset();
|
||||
handlerB.reset();
|
||||
handlerC.reset();
|
||||
|
||||
connectorN.getResponses("GET / HTTP/1.0\n" + "Host: localhost\n\n");
|
||||
assertFalse(handlerA.isHandled());
|
||||
assertTrue(handlerB.isHandled());
|
||||
assertFalse(handlerC.isHandled());
|
||||
Assert.assertFalse(handlerA.isHandled());
|
||||
Assert.assertTrue(handlerB.isHandled());
|
||||
Assert.assertFalse(handlerC.isHandled());
|
||||
handlerA.reset();
|
||||
handlerB.reset();
|
||||
handlerC.reset();
|
||||
@ -209,19 +200,19 @@ public class ContextHandlerTest
|
||||
|
||||
// System.err.println(server.dump());
|
||||
|
||||
Assert.assertEquals(rootA._scontext,rootA._scontext.getContext("/"));
|
||||
Assert.assertEquals(fooA._scontext,rootA._scontext.getContext("/foo"));
|
||||
Assert.assertEquals(foobarA._scontext,rootA._scontext.getContext("/foo/bar"));
|
||||
Assert.assertEquals(foobarA._scontext,rootA._scontext.getContext("/foo/bar/bob.jsp"));
|
||||
Assert.assertEquals(rootA._scontext,rootA._scontext.getContext("/other"));
|
||||
Assert.assertEquals(fooA._scontext,rootA._scontext.getContext("/foo/other"));
|
||||
Assert.assertEquals(rootA._scontext, rootA._scontext.getContext("/"));
|
||||
Assert.assertEquals(fooA._scontext, rootA._scontext.getContext("/foo"));
|
||||
Assert.assertEquals(foobarA._scontext, rootA._scontext.getContext("/foo/bar"));
|
||||
Assert.assertEquals(foobarA._scontext, rootA._scontext.getContext("/foo/bar/bob.jsp"));
|
||||
Assert.assertEquals(rootA._scontext, rootA._scontext.getContext("/other"));
|
||||
Assert.assertEquals(fooA._scontext, rootA._scontext.getContext("/foo/other"));
|
||||
|
||||
Assert.assertEquals(rootA._scontext,foobarA._scontext.getContext("/"));
|
||||
Assert.assertEquals(fooA._scontext,foobarA._scontext.getContext("/foo"));
|
||||
Assert.assertEquals(foobarA._scontext,foobarA._scontext.getContext("/foo/bar"));
|
||||
Assert.assertEquals(foobarA._scontext,foobarA._scontext.getContext("/foo/bar/bob.jsp"));
|
||||
Assert.assertEquals(rootA._scontext,foobarA._scontext.getContext("/other"));
|
||||
Assert.assertEquals(fooA._scontext,foobarA._scontext.getContext("/foo/other"));
|
||||
Assert.assertEquals(rootA._scontext, foobarA._scontext.getContext("/"));
|
||||
Assert.assertEquals(fooA._scontext, foobarA._scontext.getContext("/foo"));
|
||||
Assert.assertEquals(foobarA._scontext, foobarA._scontext.getContext("/foo/bar"));
|
||||
Assert.assertEquals(foobarA._scontext, foobarA._scontext.getContext("/foo/bar/bob.jsp"));
|
||||
Assert.assertEquals(rootA._scontext, foobarA._scontext.getContext("/other"));
|
||||
Assert.assertEquals(fooA._scontext, foobarA._scontext.getContext("/foo/other"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -242,39 +233,39 @@ public class ContextHandlerTest
|
||||
|
||||
// check that all contexts start normally
|
||||
server.start();
|
||||
assertThat(connector.getResponses("GET / HTTP/1.0\n\n"),Matchers.containsString("ctx=''"));
|
||||
assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx='/foo'"));
|
||||
assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx='/foo/bar'"));
|
||||
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo/bar'"));
|
||||
|
||||
// If we stop foobar, then requests will be handled by foo
|
||||
foobar.stop();
|
||||
assertThat(connector.getResponses("GET / HTTP/1.0\n\n"),Matchers.containsString("ctx=''"));
|
||||
assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx='/foo'"));
|
||||
assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx='/foo'"));
|
||||
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
|
||||
|
||||
// If we shutdown foo then requests will be 503'd
|
||||
foo.shutdown().get();
|
||||
assertThat(connector.getResponses("GET / HTTP/1.0\n\n"),Matchers.containsString("ctx=''"));
|
||||
assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"),Matchers.containsString("503"));
|
||||
assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"),Matchers.containsString("503"));
|
||||
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("503"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("503"));
|
||||
|
||||
// If we stop foo then requests will be handled by root
|
||||
foo.stop();
|
||||
assertThat(connector.getResponses("GET / HTTP/1.0\n\n"),Matchers.containsString("ctx=''"));
|
||||
assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx=''"));
|
||||
assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx=''"));
|
||||
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
|
||||
|
||||
// If we start foo then foobar requests will be handled by foo
|
||||
foo.start();
|
||||
assertThat(connector.getResponses("GET / HTTP/1.0\n\n"),Matchers.containsString("ctx=''"));
|
||||
assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx='/foo'"));
|
||||
assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx='/foo'"));
|
||||
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
|
||||
|
||||
// If we start foobar then foobar requests will be handled by foobar
|
||||
foobar.start();
|
||||
assertThat(connector.getResponses("GET / HTTP/1.0\n\n"),Matchers.containsString("ctx=''"));
|
||||
assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx='/foo'"));
|
||||
assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"),Matchers.containsString("ctx='/foo/bar'"));
|
||||
Assert.assertThat(connector.getResponses("GET / HTTP/1.0\n\n"), Matchers.containsString("ctx=''"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo'"));
|
||||
Assert.assertThat(connector.getResponses("GET /foo/bar/xxx HTTP/1.0\n\n"), Matchers.containsString("ctx='/foo/bar'"));
|
||||
}
|
||||
|
||||
|
||||
@ -311,17 +302,17 @@ public class ContextHandlerTest
|
||||
|
||||
// System.err.println(server.dump());
|
||||
|
||||
Assert.assertEquals(rootA._scontext,rootA._scontext.getContext("/"));
|
||||
Assert.assertEquals(fooA._scontext,rootA._scontext.getContext("/foo"));
|
||||
Assert.assertEquals(foobarA._scontext,rootA._scontext.getContext("/foo/bar"));
|
||||
Assert.assertEquals(foobarA._scontext,rootA._scontext.getContext("/foo/bar/bob"));
|
||||
Assert.assertEquals(rootA._scontext, rootA._scontext.getContext("/"));
|
||||
Assert.assertEquals(fooA._scontext, rootA._scontext.getContext("/foo"));
|
||||
Assert.assertEquals(foobarA._scontext, rootA._scontext.getContext("/foo/bar"));
|
||||
Assert.assertEquals(foobarA._scontext, rootA._scontext.getContext("/foo/bar/bob"));
|
||||
|
||||
Assert.assertEquals(rootA._scontext,rootA._scontext.getContext("/other"));
|
||||
Assert.assertEquals(rootB._scontext,rootB._scontext.getContext("/other"));
|
||||
Assert.assertEquals(rootC._scontext,rootC._scontext.getContext("/other"));
|
||||
Assert.assertEquals(rootA._scontext, rootA._scontext.getContext("/other"));
|
||||
Assert.assertEquals(rootB._scontext, rootB._scontext.getContext("/other"));
|
||||
Assert.assertEquals(rootC._scontext, rootC._scontext.getContext("/other"));
|
||||
|
||||
Assert.assertEquals(fooB._scontext,rootB._scontext.getContext("/foo/other"));
|
||||
Assert.assertEquals(rootC._scontext,rootC._scontext.getContext("/foo/other"));
|
||||
Assert.assertEquals(fooB._scontext, rootB._scontext.getContext("/foo/other"));
|
||||
Assert.assertEquals(rootC._scontext, rootC._scontext.getContext("/foo/other"));
|
||||
}
|
||||
|
||||
|
||||
@ -371,27 +362,27 @@ public class ContextHandlerTest
|
||||
|
||||
// test singular
|
||||
context.setVirtualHosts(new String[] { "www.example.com"} );
|
||||
Assert.assertEquals(1,context.getVirtualHosts().length);
|
||||
Assert.assertEquals(1, context.getVirtualHosts().length);
|
||||
|
||||
// test adding two more
|
||||
context.addVirtualHosts(new String[] { "www.example2.com", "www.example3.com"});
|
||||
Assert.assertEquals(3,context.getVirtualHosts().length);
|
||||
Assert.assertEquals(3, context.getVirtualHosts().length);
|
||||
|
||||
// test adding existing context
|
||||
context.addVirtualHosts(new String[] { "www.example.com" });
|
||||
Assert.assertEquals(3,context.getVirtualHosts().length);
|
||||
Assert.assertEquals(3, context.getVirtualHosts().length);
|
||||
|
||||
// test removing existing
|
||||
context.removeVirtualHosts(new String[] { "www.example3.com" });
|
||||
Assert.assertEquals(2,context.getVirtualHosts().length);
|
||||
Assert.assertEquals(2, context.getVirtualHosts().length);
|
||||
|
||||
// test removing non-existent
|
||||
context.removeVirtualHosts(new String[] { "www.example3.com" });
|
||||
Assert.assertEquals(2,context.getVirtualHosts().length);
|
||||
Assert.assertEquals(2, context.getVirtualHosts().length);
|
||||
|
||||
// test removing all remaining and resets to null
|
||||
context.removeVirtualHosts(new String[] { "www.example.com", "www.example2.com" });
|
||||
Assert.assertEquals(null,context.getVirtualHosts());
|
||||
Assert.assertArrayEquals(null, context.getVirtualHosts());
|
||||
|
||||
}
|
||||
|
||||
@ -401,31 +392,31 @@ public class ContextHandlerTest
|
||||
ContextHandler handler = new ContextHandler();
|
||||
handler.setServer(new Server());
|
||||
handler.setAttribute("aaa","111");
|
||||
assertEquals("111",handler.getServletContext().getAttribute("aaa"));
|
||||
assertEquals(null,handler.getAttribute("bbb"));
|
||||
Assert.assertEquals("111", handler.getServletContext().getAttribute("aaa"));
|
||||
Assert.assertEquals(null, handler.getAttribute("bbb"));
|
||||
|
||||
handler.start();
|
||||
|
||||
handler.getServletContext().setAttribute("aaa","000");
|
||||
handler.setAttribute("ccc","333");
|
||||
handler.getServletContext().setAttribute("ddd","444");
|
||||
assertEquals("111",handler.getServletContext().getAttribute("aaa"));
|
||||
assertEquals(null,handler.getServletContext().getAttribute("bbb"));
|
||||
Assert.assertEquals("111", handler.getServletContext().getAttribute("aaa"));
|
||||
Assert.assertEquals(null, handler.getServletContext().getAttribute("bbb"));
|
||||
handler.getServletContext().setAttribute("bbb","222");
|
||||
assertEquals("333",handler.getServletContext().getAttribute("ccc"));
|
||||
assertEquals("444",handler.getServletContext().getAttribute("ddd"));
|
||||
Assert.assertEquals("333", handler.getServletContext().getAttribute("ccc"));
|
||||
Assert.assertEquals("444", handler.getServletContext().getAttribute("ddd"));
|
||||
|
||||
assertEquals("111",handler.getAttribute("aaa"));
|
||||
assertEquals(null,handler.getAttribute("bbb"));
|
||||
assertEquals("333",handler.getAttribute("ccc"));
|
||||
assertEquals(null,handler.getAttribute("ddd"));
|
||||
Assert.assertEquals("111", handler.getAttribute("aaa"));
|
||||
Assert.assertEquals(null, handler.getAttribute("bbb"));
|
||||
Assert.assertEquals("333", handler.getAttribute("ccc"));
|
||||
Assert.assertEquals(null, handler.getAttribute("ddd"));
|
||||
|
||||
handler.stop();
|
||||
|
||||
assertEquals("111",handler.getServletContext().getAttribute("aaa"));
|
||||
assertEquals(null,handler.getServletContext().getAttribute("bbb"));
|
||||
assertEquals("333",handler.getServletContext().getAttribute("ccc"));
|
||||
assertEquals(null,handler.getServletContext().getAttribute("ddd"));
|
||||
Assert.assertEquals("111", handler.getServletContext().getAttribute("aaa"));
|
||||
Assert.assertEquals(null, handler.getServletContext().getAttribute("bbb"));
|
||||
Assert.assertEquals("333", handler.getServletContext().getAttribute("ccc"));
|
||||
Assert.assertEquals(null, handler.getServletContext().getAttribute("ddd"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -435,10 +426,10 @@ public class ContextHandlerTest
|
||||
String[] protectedTargets = {"/foo-inf", "/bar-inf"};
|
||||
handler.setProtectedTargets(protectedTargets);
|
||||
|
||||
assertTrue(handler.isProtectedTarget("/foo-inf/x/y/z"));
|
||||
assertFalse(handler.isProtectedTarget("/foo/x/y/z"));
|
||||
assertTrue(handler.isProtectedTarget("/foo-inf?x=y&z=1"));
|
||||
assertFalse(handler.isProtectedTarget("/foo-inf-bar"));
|
||||
Assert.assertTrue(handler.isProtectedTarget("/foo-inf/x/y/z"));
|
||||
Assert.assertFalse(handler.isProtectedTarget("/foo/x/y/z"));
|
||||
Assert.assertTrue(handler.isProtectedTarget("/foo-inf?x=y&z=1"));
|
||||
Assert.assertFalse(handler.isProtectedTarget("/foo-inf-bar"));
|
||||
|
||||
protectedTargets = new String[4];
|
||||
System.arraycopy(handler.getProtectedTargets(), 0, protectedTargets, 0, 2);
|
||||
@ -446,13 +437,13 @@ public class ContextHandlerTest
|
||||
protectedTargets[3] = "/def";
|
||||
handler.setProtectedTargets(protectedTargets);
|
||||
|
||||
assertTrue(handler.isProtectedTarget("/foo-inf/x/y/z"));
|
||||
assertFalse(handler.isProtectedTarget("/foo/x/y/z"));
|
||||
assertTrue(handler.isProtectedTarget("/foo-inf?x=y&z=1"));
|
||||
assertTrue(handler.isProtectedTarget("/abc/124"));
|
||||
assertTrue(handler.isProtectedTarget("//def"));
|
||||
Assert.assertTrue(handler.isProtectedTarget("/foo-inf/x/y/z"));
|
||||
Assert.assertFalse(handler.isProtectedTarget("/foo/x/y/z"));
|
||||
Assert.assertTrue(handler.isProtectedTarget("/foo-inf?x=y&z=1"));
|
||||
Assert.assertTrue(handler.isProtectedTarget("/abc/124"));
|
||||
Assert.assertTrue(handler.isProtectedTarget("//def"));
|
||||
|
||||
assertTrue(handler.isProtectedTarget("/ABC/7777"));
|
||||
Assert.assertTrue(handler.isProtectedTarget("/ABC/7777"));
|
||||
}
|
||||
|
||||
|
||||
@ -463,15 +454,15 @@ public class ContextHandlerTest
|
||||
|
||||
ContextHandler handler = new ContextHandler();
|
||||
|
||||
assertTrue("Not a directory " + testDirectory,testDirectory.isDirectory());
|
||||
Assert.assertTrue("Not a directory " + testDirectory, testDirectory.isDirectory());
|
||||
handler.setBaseResource(Resource.newResource(Resource.toURL(testDirectory)));
|
||||
|
||||
List<String> paths = new ArrayList<String>(handler.getResourcePaths(root));
|
||||
assertEquals(2,paths.size());
|
||||
List<String> paths = new ArrayList<>(handler.getResourcePaths(root));
|
||||
Assert.assertEquals(2, paths.size());
|
||||
|
||||
Collections.sort(paths);
|
||||
assertEquals("/WEB-INF/jsp/",paths.get(0));
|
||||
assertEquals("/WEB-INF/web.xml",paths.get(1));
|
||||
Assert.assertEquals("/WEB-INF/jsp/", paths.get(0));
|
||||
Assert.assertEquals("/WEB-INF/web.xml", paths.get(1));
|
||||
}
|
||||
|
||||
private File setupTestDirectory() throws IOException
|
||||
@ -479,19 +470,19 @@ public class ContextHandlerTest
|
||||
File tmpDir = new File( System.getProperty( "basedir",".") + "/target/tmp/ContextHandlerTest" );
|
||||
tmpDir=tmpDir.getCanonicalFile();
|
||||
if (!tmpDir.exists())
|
||||
assertTrue(tmpDir.mkdirs());
|
||||
Assert.assertTrue(tmpDir.mkdirs());
|
||||
File tmp = File.createTempFile("cht",null, tmpDir );
|
||||
assertTrue(tmp.delete());
|
||||
assertTrue(tmp.mkdir());
|
||||
Assert.assertTrue(tmp.delete());
|
||||
Assert.assertTrue(tmp.mkdir());
|
||||
tmp.deleteOnExit();
|
||||
File root = new File(tmp,getClass().getName());
|
||||
assertTrue(root.mkdir());
|
||||
Assert.assertTrue(root.mkdir());
|
||||
|
||||
File webInf = new File(root,"WEB-INF");
|
||||
assertTrue(webInf.mkdir());
|
||||
Assert.assertTrue(webInf.mkdir());
|
||||
|
||||
assertTrue(new File(webInf,"jsp").mkdir());
|
||||
assertTrue(new File(webInf,"web.xml").createNewFile());
|
||||
Assert.assertTrue(new File(webInf, "jsp").mkdir());
|
||||
Assert.assertTrue(new File(webInf, "web.xml").createNewFile());
|
||||
|
||||
return root;
|
||||
}
|
||||
@ -507,9 +498,9 @@ public class ContextHandlerTest
|
||||
{
|
||||
connector.getResponses("GET / HTTP/1.1\n" + "Host: "+host+"\nConnection:close\n\n");
|
||||
if(succeed)
|
||||
assertTrue("'"+host+"' should have been handled.",handler.isHandled());
|
||||
Assert.assertTrue("'" + host + "' should have been handled.", handler.isHandled());
|
||||
else
|
||||
assertFalse("'"+host + "' should not have been handled.", handler.isHandled());
|
||||
Assert.assertFalse("'" + host + "' should not have been handled.", handler.isHandled());
|
||||
handler.reset();
|
||||
}
|
||||
|
||||
|
@ -20,20 +20,18 @@ package org.eclipse.jetty.server.session;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HashSessionManagerTest
|
||||
{
|
||||
|
||||
@After
|
||||
public void enableStacks()
|
||||
{
|
||||
@ -59,10 +57,10 @@ public class HashSessionManagerTest
|
||||
manager.setDeleteUnrestorableSessions(true);
|
||||
manager.setLazyLoad(true);
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir("hashes");
|
||||
testDir.mkdirs();
|
||||
Assert.assertTrue(testDir.mkdirs());
|
||||
manager.setStoreDirectory(testDir);
|
||||
|
||||
MavenTestingUtils.getTargetFile("dangerFile.session").createNewFile();
|
||||
|
||||
Assert.assertTrue(MavenTestingUtils.getTargetFile("dangerFile.session").createNewFile());
|
||||
|
||||
Assert.assertTrue("File should exist!", MavenTestingUtils.getTargetFile("dangerFile.session").exists());
|
||||
|
||||
@ -79,10 +77,10 @@ public class HashSessionManagerTest
|
||||
manager.setDeleteUnrestorableSessions(true);
|
||||
manager.setLazyLoad(true);
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir("hashes");
|
||||
testDir.mkdirs();
|
||||
Assert.assertTrue(testDir.mkdirs());
|
||||
manager.setStoreDirectory(testDir);
|
||||
|
||||
new File(testDir, "validFile.session").createNewFile();
|
||||
|
||||
Assert.assertTrue(new File(testDir, "validFile.session").createNewFile());
|
||||
|
||||
Assert.assertTrue("File should exist!", new File(testDir, "validFile.session").exists());
|
||||
|
||||
@ -96,7 +94,7 @@ public class HashSessionManagerTest
|
||||
public void testHashSession() throws Exception
|
||||
{
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir("saved");
|
||||
testDir.mkdirs();
|
||||
Assert.assertTrue(testDir.mkdirs());
|
||||
|
||||
Server server = new Server();
|
||||
SessionHandler handler = new SessionHandler();
|
||||
|
@ -18,11 +18,9 @@
|
||||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class B64CodeTest
|
||||
|
@ -18,20 +18,12 @@
|
||||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class StringMapTest
|
||||
{
|
||||
StringMap<String> m0;
|
||||
@ -46,18 +38,18 @@ public class StringMapTest
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
m0=new StringMap<String>();
|
||||
m1=new StringMap<String>(false);
|
||||
m0=new StringMap<>();
|
||||
m1=new StringMap<>(false);
|
||||
m1.put("abc", "0");
|
||||
|
||||
m5=new StringMap<String>(false);
|
||||
m5=new StringMap<>(false);
|
||||
m5.put("a", "0");
|
||||
m5.put("ab", "1");
|
||||
m5.put("abc", "2");
|
||||
m5.put("abb", "3");
|
||||
m5.put("bbb", "4");
|
||||
|
||||
m5i=new StringMap<String>(true);
|
||||
m5i=new StringMap<>(true);
|
||||
m5i.put("ab", "1");
|
||||
m5i.put("abc", "2");
|
||||
m5i.put("abb", "3");
|
||||
@ -66,28 +58,28 @@ public class StringMapTest
|
||||
@Test
|
||||
public void testSize()
|
||||
{
|
||||
assertEquals(0, m0.size());
|
||||
assertEquals(1, m1.size());
|
||||
assertEquals(5, m5.size());
|
||||
assertEquals(3, m5i.size());
|
||||
Assert.assertEquals(0, m0.size());
|
||||
Assert.assertEquals(1, m1.size());
|
||||
Assert.assertEquals(5, m5.size());
|
||||
Assert.assertEquals(3, m5i.size());
|
||||
|
||||
m1.remove("abc");
|
||||
m5.remove("abc");
|
||||
m5.put("bbb","x");
|
||||
m5i.put("ABC", "x");
|
||||
assertEquals(0, m0.size());
|
||||
assertEquals(0, m1.size());
|
||||
assertEquals(4, m5.size());
|
||||
assertEquals(3, m5i.size());
|
||||
Assert.assertEquals(0, m0.size());
|
||||
Assert.assertEquals(0, m1.size());
|
||||
Assert.assertEquals(4, m5.size());
|
||||
Assert.assertEquals(3, m5i.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEmpty()
|
||||
{
|
||||
assertTrue(m0.isEmpty());
|
||||
assertFalse(m1.isEmpty());
|
||||
assertFalse(m5.isEmpty());
|
||||
assertFalse(m5i.isEmpty());
|
||||
Assert.assertTrue(m0.isEmpty());
|
||||
Assert.assertFalse(m1.isEmpty());
|
||||
Assert.assertFalse(m5.isEmpty());
|
||||
Assert.assertFalse(m5i.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -97,13 +89,13 @@ public class StringMapTest
|
||||
m1.clear();
|
||||
m5.clear();
|
||||
m5i.clear();
|
||||
assertTrue(m0.isEmpty());
|
||||
assertTrue(m1.isEmpty());
|
||||
assertTrue(m5.isEmpty());
|
||||
assertTrue(m5i.isEmpty());
|
||||
assertEquals(null,m1.get("abc"));
|
||||
assertEquals(null,m5.get("abc"));
|
||||
assertEquals(null,m5i.get("abc"));
|
||||
Assert.assertTrue(m0.isEmpty());
|
||||
Assert.assertTrue(m1.isEmpty());
|
||||
Assert.assertTrue(m5.isEmpty());
|
||||
Assert.assertTrue(m5i.isEmpty());
|
||||
Assert.assertEquals(null, m1.get("abc"));
|
||||
Assert.assertEquals(null, m5.get("abc"));
|
||||
Assert.assertEquals(null, m5i.get("abc"));
|
||||
}
|
||||
|
||||
|
||||
@ -113,20 +105,20 @@ public class StringMapTest
|
||||
@Test
|
||||
public void testPutGet()
|
||||
{
|
||||
assertEquals("2",m5.get("abc"));
|
||||
assertEquals(null,m5.get("aBc"));
|
||||
assertEquals("2",m5i.get("abc"));
|
||||
assertEquals("2",m5i.get("aBc"));
|
||||
Assert.assertEquals("2", m5.get("abc"));
|
||||
Assert.assertEquals(null, m5.get("aBc"));
|
||||
Assert.assertEquals("2", m5i.get("abc"));
|
||||
Assert.assertEquals("2", m5i.get("aBc"));
|
||||
|
||||
m5.put("aBc", "x");
|
||||
m5i.put("AbC", "x");
|
||||
|
||||
StringBuilder buffer=new StringBuilder();
|
||||
buffer.append("aBc");
|
||||
assertEquals("2",m5.get("abc"));
|
||||
assertEquals("x",m5.get(buffer));
|
||||
assertEquals("x",m5i.get((Object)"abc"));
|
||||
assertEquals("x",m5i.get("aBc"));
|
||||
Assert.assertEquals("2", m5.get("abc"));
|
||||
Assert.assertEquals("x", m5.get(buffer));
|
||||
Assert.assertEquals("x", m5i.get((Object)"abc"));
|
||||
Assert.assertEquals("x", m5i.get("aBc"));
|
||||
|
||||
|
||||
}
|
||||
@ -143,14 +135,14 @@ public class StringMapTest
|
||||
m5.remove("bbb");
|
||||
m5i.remove("aBc");
|
||||
|
||||
assertEquals(0, m0.size());
|
||||
assertEquals(0, m1.size());
|
||||
assertEquals(4, m5.size());
|
||||
assertEquals(2, m5i.size());
|
||||
Assert.assertEquals(0, m0.size());
|
||||
Assert.assertEquals(0, m1.size());
|
||||
Assert.assertEquals(4, m5.size());
|
||||
Assert.assertEquals(2, m5i.size());
|
||||
|
||||
assertEquals("2",m5.get("abc"));
|
||||
assertEquals(null,m5.get("bbb"));
|
||||
assertEquals(null,m5i.get("AbC"));
|
||||
Assert.assertEquals("2", m5.get("abc"));
|
||||
Assert.assertEquals(null, m5.get("bbb"));
|
||||
Assert.assertEquals(null, m5i.get("AbC"));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -162,9 +154,9 @@ public class StringMapTest
|
||||
Set es0=m0.entrySet();
|
||||
Set es1=m1.entrySet();
|
||||
Set es5=m5.entrySet();
|
||||
assertEquals(0, es0.size());
|
||||
assertEquals(1, es1.size());
|
||||
assertEquals(5, es5.size());
|
||||
Assert.assertEquals(0, es0.size());
|
||||
Assert.assertEquals(1, es1.size());
|
||||
Assert.assertEquals(5, es5.size());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -173,28 +165,28 @@ public class StringMapTest
|
||||
@Test
|
||||
public void testContainsKey()
|
||||
{
|
||||
assertTrue(m5.containsKey("abc"));
|
||||
assertTrue(!m5.containsKey("aBc"));
|
||||
assertTrue(m5.containsKey("bbb"));
|
||||
assertTrue(!m5.containsKey("xyz"));
|
||||
Assert.assertTrue(m5.containsKey("abc"));
|
||||
Assert.assertTrue(!m5.containsKey("aBc"));
|
||||
Assert.assertTrue(m5.containsKey("bbb"));
|
||||
Assert.assertTrue(!m5.containsKey("xyz"));
|
||||
|
||||
assertTrue(m5i.containsKey("abc"));
|
||||
assertTrue(m5i.containsKey("aBc"));
|
||||
assertTrue(m5i.containsKey("ABC"));
|
||||
Assert.assertTrue(m5i.containsKey("abc"));
|
||||
Assert.assertTrue(m5i.containsKey("aBc"));
|
||||
Assert.assertTrue(m5i.containsKey("ABC"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString()
|
||||
{
|
||||
assertEquals("{}",m0.toString());
|
||||
assertEquals("{abc=0}",m1.toString());
|
||||
assertTrue(m5.toString().indexOf("abc=2")>0);
|
||||
Assert.assertEquals("{}", m0.toString());
|
||||
Assert.assertEquals("{abc=0}", m1.toString());
|
||||
Assert.assertTrue(m5.toString().indexOf("abc=2") > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreCase()
|
||||
{
|
||||
StringMap<String> map = new StringMap<String>(true);
|
||||
StringMap<String> map = new StringMap<>(true);
|
||||
map.put("POST","1");
|
||||
map.put("HEAD","2");
|
||||
map.put("PUT","3");
|
||||
@ -204,13 +196,13 @@ public class StringMapTest
|
||||
map.put("CONNECT","7");
|
||||
map.put("Upgrade","8");
|
||||
|
||||
assertEquals("1",map.get("POST"));
|
||||
assertEquals("1",map.get("pOST"));
|
||||
assertEquals("1",map.get("Post"));
|
||||
Assert.assertEquals("1", map.get("POST"));
|
||||
Assert.assertEquals("1", map.get("pOST"));
|
||||
Assert.assertEquals("1", map.get("Post"));
|
||||
|
||||
assertEquals("8",map.get("UPGRADE"));
|
||||
assertEquals("8",map.get("Upgrade"));
|
||||
assertEquals("8",map.get("upgrade"));
|
||||
Assert.assertEquals("8", map.get("UPGRADE"));
|
||||
Assert.assertEquals("8", map.get("Upgrade"));
|
||||
Assert.assertEquals("8", map.get("upgrade"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -18,21 +18,16 @@
|
||||
|
||||
package org.eclipse.jetty.util.resource;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class ResourceAliasTest
|
||||
{
|
||||
static File __dir;
|
||||
@ -56,59 +51,59 @@ public class ResourceAliasTest
|
||||
public void testNullCharEndingFilename() throws Exception
|
||||
{
|
||||
File file=new File(__dir,"test.txt");
|
||||
assertFalse(file.exists());
|
||||
file.createNewFile();
|
||||
assertTrue(file.exists());
|
||||
Assert.assertFalse(file.exists());
|
||||
Assert.assertTrue(file.createNewFile());
|
||||
Assert.assertTrue(file.exists());
|
||||
|
||||
File file0=new File(__dir,"test.txt\0");
|
||||
if (!file0.exists())
|
||||
return; // this file system does not suffer this problem
|
||||
|
||||
assertTrue(file0.exists()); // This is an alias!
|
||||
Assert.assertTrue(file0.exists()); // This is an alias!
|
||||
|
||||
Resource dir = Resource.newResource(__dir);
|
||||
|
||||
// Test not alias paths
|
||||
Resource resource = Resource.newResource(file);
|
||||
assertTrue(resource.exists());
|
||||
assertNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNull(resource.getAlias());
|
||||
resource = Resource.newResource(file.getAbsoluteFile());
|
||||
assertTrue(resource.exists());
|
||||
assertNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNull(resource.getAlias());
|
||||
resource = Resource.newResource(file.toURI());
|
||||
assertTrue(resource.exists());
|
||||
assertNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNull(resource.getAlias());
|
||||
resource = Resource.newResource(file.toURI().toString());
|
||||
assertTrue(resource.exists());
|
||||
assertNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNull(resource.getAlias());
|
||||
resource = dir.addPath("test.txt");
|
||||
assertTrue(resource.exists());
|
||||
assertNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNull(resource.getAlias());
|
||||
|
||||
|
||||
// Test alias paths
|
||||
resource = Resource.newResource(file0);
|
||||
assertTrue(resource.exists());
|
||||
assertNotNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNotNull(resource.getAlias());
|
||||
resource = Resource.newResource(file0.getAbsoluteFile());
|
||||
assertTrue(resource.exists());
|
||||
assertNotNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNotNull(resource.getAlias());
|
||||
resource = Resource.newResource(file0.toURI());
|
||||
assertTrue(resource.exists());
|
||||
assertNotNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNotNull(resource.getAlias());
|
||||
resource = Resource.newResource(file0.toURI().toString());
|
||||
assertTrue(resource.exists());
|
||||
assertNotNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNotNull(resource.getAlias());
|
||||
|
||||
try
|
||||
{
|
||||
resource = dir.addPath("test.txt\0");
|
||||
assertTrue(resource.exists());
|
||||
assertNotNull(resource.getAlias());
|
||||
Assert.assertTrue(resource.exists());
|
||||
Assert.assertNotNull(resource.getAlias());
|
||||
}
|
||||
catch(MalformedURLException e)
|
||||
{
|
||||
assertTrue(true);
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user