mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-04 12:59:30 +00:00
Jetty9 - Cleaned up and fixed the failing tests.
This commit is contained in:
parent
e74a5cd105
commit
85ffa8807e
@ -26,7 +26,6 @@ import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import javax.servlet.ServletException;
|
||||
@ -34,25 +33,20 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpGenerator.ResponseInfo;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
import org.eclipse.jetty.io.AbstractEndPoint;
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.session.HashSessionIdManager;
|
||||
import org.eclipse.jetty.server.session.HashSessionManager;
|
||||
import org.eclipse.jetty.server.session.HashedSession;
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -60,13 +54,9 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ResponseTest
|
||||
{
|
||||
private Server _server;
|
||||
private LocalConnector _connector;
|
||||
private HttpChannel _channel;
|
||||
private ScheduledExecutorService _timer;
|
||||
|
||||
@ -74,55 +64,31 @@ public class ResponseTest
|
||||
public void init() throws Exception
|
||||
{
|
||||
_server = new Server();
|
||||
_connector = new LocalConnector(_server);
|
||||
_server.addConnector(_connector);
|
||||
_timer = new ScheduledThreadPoolExecutor(1);
|
||||
LocalConnector connector = new LocalConnector(_server, null, _timer, null, null, 1);
|
||||
_server.addConnector(connector);
|
||||
_server.setHandler(new DumpHandler());
|
||||
_server.start();
|
||||
_timer=new ScheduledThreadPoolExecutor(1);
|
||||
|
||||
AbstractEndPoint endp = new ByteArrayEndPoint(_timer, 5000);
|
||||
HttpInput input = new HttpInput();
|
||||
Connection connection = new AbstractConnection(endp,new Executor()
|
||||
_channel = new HttpChannel(connector, new HttpConfiguration(null, false), endp, new HttpTransport()
|
||||
{
|
||||
@Override
|
||||
public void execute(Runnable command)
|
||||
{
|
||||
command.run();
|
||||
}
|
||||
})
|
||||
{
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
super.onOpen();
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFillable()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
_channel = new HttpChannel(_connector,new HttpConfiguration(null,false),endp,null,null)
|
||||
{
|
||||
@Override
|
||||
public ScheduledExecutorService getScheduler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(Runnable task)
|
||||
public void commit(HttpGenerator.ResponseInfo info, ByteBuffer content, boolean lastContent) throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connector getConnector()
|
||||
public void write(ByteBuffer content, boolean lastContent) throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void completed()
|
||||
{
|
||||
}
|
||||
}, input);
|
||||
}
|
||||
|
||||
@After
|
||||
@ -216,7 +182,6 @@ public class ResponseTest
|
||||
response.setCharacterEncoding(null);
|
||||
response.setContentType("foo/bar");
|
||||
assertEquals("foo/bar", response.getContentType());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -268,7 +233,6 @@ public class ResponseTest
|
||||
assertEquals("text/xml;charset=UTF-8", response.getContentType());
|
||||
response.setCharacterEncoding("ISO-8859-1");
|
||||
assertEquals("text/xml;charset=UTF-8", response.getContentType());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -296,7 +260,6 @@ public class ResponseTest
|
||||
assertEquals("text/xml;charset=UTF-8", response.getContentType());
|
||||
response.setCharacterEncoding("iso-8859-1");
|
||||
assertEquals("text/xml;charset=UTF-8", response.getContentType());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -325,7 +288,6 @@ public class ResponseTest
|
||||
assertEquals("text/xml;charset=UTF-8", response.getContentType());
|
||||
response.setCharacterEncoding("iso-8859-1");
|
||||
assertEquals("text/xml;charset=UTF-8", response.getContentType());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -377,7 +339,6 @@ public class ResponseTest
|
||||
assertEquals("foo/bar; other=pq charset=utf-8 other=xyz;charset=UTF-16", response.getContentType());
|
||||
response.getWriter();
|
||||
assertEquals("foo/bar; other=pq charset=utf-8 other=xyz;charset=UTF-16", response.getContentType());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -455,7 +416,6 @@ public class ResponseTest
|
||||
assertEquals("/;jsessionid=12345", response.encodeURL("/"));
|
||||
assertEquals("/foo.html;jsessionid=12345#target", response.encodeURL("/foo.html#target"));
|
||||
assertEquals(";jsessionid=12345", response.encodeURL(""));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -464,7 +424,7 @@ public class ResponseTest
|
||||
{
|
||||
String[][] tests = {
|
||||
{"/other/location?name=value", "http://myhost:8888/other/location;jsessionid=12345?name=value"},
|
||||
/* {"/other/location","http://myhost:8888/other/location"},
|
||||
{"/other/location", "http://myhost:8888/other/location"},
|
||||
{"/other/l%20cation", "http://myhost:8888/other/l%20cation"},
|
||||
{"location", "http://myhost:8888/path/location"},
|
||||
{"./location", "http://myhost:8888/path/location"},
|
||||
@ -472,7 +432,7 @@ public class ResponseTest
|
||||
{"/other/l%20cation", "http://myhost:8888/other/l%20cation"},
|
||||
{"l%20cation", "http://myhost:8888/path/l%20cation"},
|
||||
{"./l%20cation", "http://myhost:8888/path/l%20cation"},
|
||||
{"../l%20cation","http://myhost:8888/l%20cation"},*/
|
||||
{"../l%20cation", "http://myhost:8888/l%20cation"},
|
||||
{"../locati%C3%abn", "http://myhost:8888/locati%C3%ABn"},
|
||||
};
|
||||
|
||||
@ -501,7 +461,7 @@ public class ResponseTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetBufferSize () throws Exception
|
||||
public void testSetBufferSizeAfterHavingWrittenContent() throws Exception
|
||||
{
|
||||
Response response = newResponse();
|
||||
response.setBufferSize(20 * 1024);
|
||||
@ -517,8 +477,6 @@ public class ResponseTest
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Why are there 2 response instances?
|
||||
@Ignore
|
||||
@Test
|
||||
public void testZeroContent() throws Exception
|
||||
{
|
||||
@ -532,7 +490,6 @@ public class ResponseTest
|
||||
assertTrue(response.isCommitted());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHead() throws Exception
|
||||
{
|
||||
@ -608,9 +565,8 @@ public class ResponseTest
|
||||
|
||||
private Response newResponse()
|
||||
{
|
||||
_channel.getResponse().getHttpOutput().reset();
|
||||
Response response = new Response(_channel,_channel.getResponse().getHttpOutput());
|
||||
return response;
|
||||
_channel.reset();
|
||||
return new Response(_channel, _channel.getResponse().getHttpOutput());
|
||||
}
|
||||
|
||||
private static class TestSession extends HashedSession
|
||||
@ -620,5 +576,4 @@ public class ResponseTest
|
||||
super(hashSessionManager, 0L, 0L, id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user