Fix for #308854 (Update test suite to JUnit4 - Module jetty-http).
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1752 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
cddf630426
commit
15dc2319d1
|
@ -5,6 +5,7 @@ jetty-7.1.1-SNAPSHOT
|
|||
+ 308860 Update test suite to JUnit4 - Module jetty-rewrite
|
||||
+ 308850 Update test suite to JUnit4 - Module jetty-annotations
|
||||
+ 308853 Update test suite to JUnit4 - Module jetty-deploy
|
||||
+ 308854 Update test suite to JUnit4 - Module jetty-http
|
||||
|
||||
jetty-7.1.0 5 May 2010
|
||||
+ 306353 fixed cross context dispatch to root context.
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -17,21 +17,24 @@ import java.util.Enumeration;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.View;
|
||||
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HttpFieldsTest extends TestCase
|
||||
public class HttpFieldsTest
|
||||
{
|
||||
public void testPut()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testPut() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
|
@ -54,15 +57,14 @@ public class HttpFieldsTest extends TestCase
|
|||
}
|
||||
assertEquals(2, matches);
|
||||
|
||||
matches=0;
|
||||
e = header.getValues("name0");
|
||||
assertEquals(true, e.hasMoreElements());
|
||||
assertEquals(e.nextElement(), "value0");
|
||||
assertEquals(false, e.hasMoreElements());
|
||||
}
|
||||
|
||||
public void testCRLF()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testCRLF() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
|
@ -77,8 +79,8 @@ public class HttpFieldsTest extends TestCase
|
|||
assertTrue(buffer.toString().contains("name2: value:2"));
|
||||
}
|
||||
|
||||
public void testCachedPut()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testCachedPut() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
|
@ -96,12 +98,10 @@ public class HttpFieldsTest extends TestCase
|
|||
matches++;
|
||||
}
|
||||
assertEquals(1, matches);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void testRePut()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testRePut() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
|
@ -134,15 +134,14 @@ public class HttpFieldsTest extends TestCase
|
|||
}
|
||||
assertEquals(3, matches);
|
||||
|
||||
matches=0;
|
||||
e = header.getValues("name1");
|
||||
assertEquals(true, e.hasMoreElements());
|
||||
assertEquals(e.nextElement(), "value1");
|
||||
assertEquals(false, e.hasMoreElements());
|
||||
}
|
||||
|
||||
public void testRemovePut()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testRemovePut() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
|
@ -175,14 +174,12 @@ public class HttpFieldsTest extends TestCase
|
|||
}
|
||||
assertEquals(2, matches);
|
||||
|
||||
matches=0;
|
||||
e = header.getValues("name1");
|
||||
assertEquals(false, e.hasMoreElements());
|
||||
}
|
||||
|
||||
|
||||
public void testAdd()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testAdd() throws Exception
|
||||
{
|
||||
HttpFields fields = new HttpFields();
|
||||
|
||||
|
@ -215,7 +212,6 @@ public class HttpFieldsTest extends TestCase
|
|||
}
|
||||
assertEquals(3, matches);
|
||||
|
||||
matches=0;
|
||||
e = fields.getValues("name1");
|
||||
assertEquals(true, e.hasMoreElements());
|
||||
assertEquals(e.nextElement(), "valueA");
|
||||
|
@ -224,8 +220,8 @@ public class HttpFieldsTest extends TestCase
|
|||
assertEquals(false, e.hasMoreElements());
|
||||
}
|
||||
|
||||
public void testReuse()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testReuse() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
Buffer n1=new ByteArrayBuffer("name1");
|
||||
|
@ -266,15 +262,14 @@ public class HttpFieldsTest extends TestCase
|
|||
}
|
||||
assertEquals(3, matches);
|
||||
|
||||
matches=0;
|
||||
e = header.getValues("name1");
|
||||
assertEquals(true, e.hasMoreElements());
|
||||
assertEquals(e.nextElement(), "value1");
|
||||
assertEquals(false, e.hasMoreElements());
|
||||
}
|
||||
|
||||
public void testDestroy()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testDestroy() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
|
@ -288,11 +283,10 @@ public class HttpFieldsTest extends TestCase
|
|||
assertNull(header.getStringField("name0"));
|
||||
}
|
||||
|
||||
public void testCase()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testCase() throws Exception
|
||||
{
|
||||
HttpFields fields= new HttpFields();
|
||||
Enumeration e;
|
||||
Set s;
|
||||
// 0123456789012345678901234567890
|
||||
byte[] b ="Message-IDmessage-idvalueVALUE".getBytes();
|
||||
|
@ -352,16 +346,16 @@ public class HttpFieldsTest extends TestCase
|
|||
|
||||
}
|
||||
|
||||
public void testHttpHeaderValues()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testHttpHeaderValues() throws Exception
|
||||
{
|
||||
assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("unknown value")).getOrdinal()<0);
|
||||
assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("close")).getOrdinal()>=0);
|
||||
assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)")).getOrdinal()>=0);
|
||||
}
|
||||
|
||||
public void testSetCookie()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testSetCookie() throws Exception
|
||||
{
|
||||
HttpFields fields = new HttpFields();
|
||||
fields.addSetCookie("minimal","value",null,null,-1,null,false,false,-1);
|
||||
|
@ -394,16 +388,16 @@ public class HttpFieldsTest extends TestCase
|
|||
assertEquals("foo=bob;Domain=domain",e.nextElement());
|
||||
}
|
||||
|
||||
private Set enum2set(Enumeration e)
|
||||
private Set<String> enum2set(Enumeration<String> e)
|
||||
{
|
||||
HashSet s=new HashSet();
|
||||
Set<String> s=new HashSet<String>();
|
||||
while(e.hasMoreElements())
|
||||
s.add(e.nextElement().toString().toLowerCase());
|
||||
s.add(e.nextElement().toLowerCase());
|
||||
return s;
|
||||
}
|
||||
|
||||
public void testDateFields()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testDateFields() throws Exception
|
||||
{
|
||||
HttpFields fields = new HttpFields();
|
||||
|
||||
|
@ -444,8 +438,8 @@ public class HttpFieldsTest extends TestCase
|
|||
assertEquals("Fri, 31 Dec 1999 23:59:59 GMT",fields.getStringField("D2"));
|
||||
}
|
||||
|
||||
public void testLongFields()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLongFields() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
|
@ -491,8 +485,8 @@ public class HttpFieldsTest extends TestCase
|
|||
|
||||
}
|
||||
|
||||
public void testToString()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testToString() throws Exception
|
||||
{
|
||||
HttpFields header = new HttpFields();
|
||||
|
||||
|
|
|
@ -15,26 +15,23 @@ package org.eclipse.jetty.http;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.SimpleBuffers;
|
||||
import org.eclipse.jetty.io.View;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HttpGeneratorClientTest extends TestCase
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
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"};
|
||||
|
||||
public HttpGeneratorClientTest(String arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public void testContentLength()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testContentLength() throws Exception
|
||||
{
|
||||
Buffer bb=new ByteArrayBuffer(8096);
|
||||
Buffer sb=new ByteArrayBuffer(1500);
|
||||
|
@ -61,8 +58,8 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Content-Length: 44||"+content,result);
|
||||
}
|
||||
|
||||
public void testAutoContentLength()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testAutoContentLength() throws Exception
|
||||
{
|
||||
Buffer bb=new ByteArrayBuffer(8096);
|
||||
Buffer sb=new ByteArrayBuffer(1500);
|
||||
|
@ -88,8 +85,8 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Content-Length: 44||"+content,result);
|
||||
}
|
||||
|
||||
public void testChunked()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testChunked() throws Exception
|
||||
{
|
||||
Buffer bb=new ByteArrayBuffer(8096);
|
||||
Buffer sb=new ByteArrayBuffer(1500);
|
||||
|
@ -115,8 +112,8 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Transfer-Encoding: chunked||2C|"+content+"|0||",result);
|
||||
}
|
||||
|
||||
public void testHTTP()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testHTTP() throws Exception
|
||||
{
|
||||
Buffer bb=new ByteArrayBuffer(8096);
|
||||
Buffer sb=new ByteArrayBuffer(1500);
|
||||
|
@ -195,15 +192,13 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"};
|
||||
class TR
|
||||
private static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"};
|
||||
private class TR
|
||||
{
|
||||
String[] values=new String[headers.length];
|
||||
String body;
|
||||
private String[] values=new String[headers.length];
|
||||
private String body;
|
||||
|
||||
TR(String ct, String cl ,String content)
|
||||
private TR(String ct, String cl ,String content)
|
||||
{
|
||||
values[0]=ct;
|
||||
values[1]=cl;
|
||||
|
@ -211,7 +206,7 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
this.body=content;
|
||||
}
|
||||
|
||||
void build(int version,HttpGenerator hb, String connection, String te, int chunks, HttpFields fields)
|
||||
private void build(int version,HttpGenerator hb, String connection, String te, int chunks, HttpFields fields)
|
||||
throws Exception
|
||||
{
|
||||
values[2]=connection;
|
||||
|
@ -270,7 +265,7 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
private TR[] tr =
|
||||
private final TR[] tr =
|
||||
{
|
||||
/* 0 */ new TR(null,null,null),
|
||||
/* 1 */ new TR(null,null,CONTENT),
|
||||
|
@ -281,17 +276,17 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
};
|
||||
|
||||
|
||||
String content;
|
||||
String f0;
|
||||
String f1;
|
||||
String f2;
|
||||
String[] hdr;
|
||||
String[] val;
|
||||
int h;
|
||||
private String content;
|
||||
private String f0;
|
||||
private String f1;
|
||||
private String f2;
|
||||
private String[] hdr;
|
||||
private String[] val;
|
||||
private int h;
|
||||
|
||||
class Handler extends HttpParser.EventHandler
|
||||
private class Handler extends HttpParser.EventHandler
|
||||
{
|
||||
int index=0;
|
||||
private int index=0;
|
||||
|
||||
@Override
|
||||
public void content(Buffer ref)
|
||||
|
@ -302,7 +297,6 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
index+=ref.length();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2)
|
||||
{
|
||||
|
@ -319,7 +313,6 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
// System.out.println(f0+" "+f1+" "+f2);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jetty.EventHandler#startResponse(org.eclipse.io.Buffer, int, org.eclipse.io.Buffer)
|
||||
*/
|
||||
|
@ -355,8 +348,5 @@ public class HttpGeneratorClientTest extends TestCase
|
|||
public void messageComplete(long contentLength)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,16 +13,18 @@
|
|||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.SimpleBuffers;
|
||||
import org.eclipse.jetty.io.View;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -30,18 +32,13 @@ import org.eclipse.jetty.io.View;
|
|||
* To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class HttpGeneratorTest extends TestCase
|
||||
public class HttpGeneratorTest
|
||||
{
|
||||
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","TE, close"};
|
||||
|
||||
public HttpGeneratorTest(String arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public void testRequest()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testRequest() throws Exception
|
||||
{
|
||||
Buffer bb=new ByteArrayBuffer(8096);
|
||||
Buffer sb=new ByteArrayBuffer(1500);
|
||||
|
@ -59,11 +56,10 @@ public class HttpGeneratorTest extends TestCase
|
|||
|
||||
assertTrue(endp.getOut().toString().indexOf("GET /index.html HTTP/1.1")==0);
|
||||
assertTrue(endp.getOut().toString().indexOf("Content-Length")==-1);
|
||||
|
||||
}
|
||||
|
||||
public void testHTTP()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testHTTP() throws Exception
|
||||
{
|
||||
Buffer bb=new ByteArrayBuffer(8096);
|
||||
Buffer sb=new ByteArrayBuffer(1500);
|
||||
|
@ -134,16 +130,14 @@ public class HttpGeneratorTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"};
|
||||
class TR
|
||||
private static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"};
|
||||
private class TR
|
||||
{
|
||||
int code;
|
||||
String[] values=new String[headers.length];
|
||||
String body;
|
||||
private int code;
|
||||
private String[] values=new String[headers.length];
|
||||
private String body;
|
||||
|
||||
TR(int code,String ct, String cl ,String content)
|
||||
private TR(int code,String ct, String cl ,String content)
|
||||
{
|
||||
this.code=code;
|
||||
values[0]=ct;
|
||||
|
@ -152,8 +146,7 @@ public class HttpGeneratorTest extends TestCase
|
|||
this.body=content;
|
||||
}
|
||||
|
||||
void build(int version,HttpGenerator hb,String reason, String connection, String te, int chunks, HttpFields fields)
|
||||
throws Exception
|
||||
private void build(int version,HttpGenerator hb,String reason, String connection, String te, int chunks, HttpFields fields) throws Exception
|
||||
{
|
||||
values[2]=connection;
|
||||
values[3]=te;
|
||||
|
@ -206,7 +199,7 @@ public class HttpGeneratorTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
private TR[] tr =
|
||||
private final TR[] tr =
|
||||
{
|
||||
/* 0 */ new TR(200,null,null,null),
|
||||
/* 1 */ new TR(200,null,null,CONTENT),
|
||||
|
@ -218,17 +211,17 @@ public class HttpGeneratorTest extends TestCase
|
|||
/* 7 */ new TR(200,"text/html",""+CONTENT.length(),CONTENT),
|
||||
};
|
||||
|
||||
String content;
|
||||
String f0;
|
||||
String f1;
|
||||
String f2;
|
||||
String[] hdr;
|
||||
String[] val;
|
||||
int h;
|
||||
private String content;
|
||||
private String f0;
|
||||
private String f1;
|
||||
private String f2;
|
||||
private String[] hdr;
|
||||
private String[] val;
|
||||
private int h;
|
||||
|
||||
class Handler extends HttpParser.EventHandler
|
||||
private class Handler extends HttpParser.EventHandler
|
||||
{
|
||||
int index=0;
|
||||
private int index=0;
|
||||
|
||||
@Override
|
||||
public void content(Buffer ref)
|
||||
|
@ -239,7 +232,6 @@ public class HttpGeneratorTest extends TestCase
|
|||
index+=ref.length();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2)
|
||||
{
|
||||
|
@ -256,7 +248,6 @@ public class HttpGeneratorTest extends TestCase
|
|||
// System.out.println(f0+" "+f1+" "+f2);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jetty.EventHandler#startResponse(org.eclipse.io.Buffer, int, org.eclipse.io.Buffer)
|
||||
*/
|
||||
|
@ -292,8 +283,5 @@ public class HttpGeneratorTest extends TestCase
|
|||
public void messageComplete(long contentLength)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,56 +15,23 @@ package org.eclipse.jetty.http;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.SimpleBuffers;
|
||||
import org.eclipse.jetty.io.bio.StringEndPoint;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class HttpParserTest extends TestCase
|
||||
public class HttpParserTest
|
||||
{
|
||||
/**
|
||||
* Constructor for HttpParserTest.
|
||||
* @param arg0
|
||||
*/
|
||||
public HttpParserTest(String arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
junit.textui.TestRunner.run(HttpParserTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testLineParse0()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLineParse0() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput("POST /foo HTTP/1.0\015\012" + "\015\012");
|
||||
|
@ -80,8 +47,8 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals(-1, h);
|
||||
}
|
||||
|
||||
public void testLineParse1()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLineParse1() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput("GET /999\015\012");
|
||||
|
@ -98,8 +65,8 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals(-1, h);
|
||||
}
|
||||
|
||||
public void testLineParse2()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLineParse2() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput("POST /222 \015\012");
|
||||
|
@ -116,8 +83,8 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals(-1, h);
|
||||
}
|
||||
|
||||
public void testLineParse3()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLineParse3() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput("POST /fo\u0690 HTTP/1.0\015\012" + "\015\012");
|
||||
|
@ -133,8 +100,8 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals(-1, h);
|
||||
}
|
||||
|
||||
public void testLineParse4()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testLineParse4() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput("POST /foo?param=\u0690 HTTP/1.0\015\012" + "\015\012");
|
||||
|
@ -150,8 +117,8 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals(-1, h);
|
||||
}
|
||||
|
||||
public void testConnect()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testConnect() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput("CONNECT 192.168.1.2:80 HTTP/1.1\015\012" + "\015\012");
|
||||
|
@ -168,8 +135,8 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals(-1, h);
|
||||
}
|
||||
|
||||
public void testHeaderParse()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testHeaderParse() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput(
|
||||
|
@ -207,8 +174,8 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals(5, h);
|
||||
}
|
||||
|
||||
public void testChunkParse()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testChunkParse() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput(
|
||||
|
@ -237,8 +204,8 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", _content);
|
||||
}
|
||||
|
||||
public void testMultiParse()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testMultiParse() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput(
|
||||
|
@ -293,9 +260,9 @@ public class HttpParserTest extends TestCase
|
|||
assertEquals("Header3", hdr[0]);
|
||||
assertEquals("value3", val[0]);
|
||||
assertEquals("0123456789", _content);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamParse() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
|
@ -318,7 +285,6 @@ public class HttpParserTest extends TestCase
|
|||
+ "\015\012"
|
||||
+ "0123456789\015\012";
|
||||
|
||||
|
||||
int[] tests=
|
||||
{
|
||||
1024,
|
||||
|
@ -346,7 +312,6 @@ public class HttpParserTest extends TestCase
|
|||
Handler handler = new Handler();
|
||||
HttpParser parser= new HttpParser(buffers,io, handler);
|
||||
|
||||
|
||||
io.setInput(http);
|
||||
|
||||
parser.parse();
|
||||
|
@ -385,8 +350,8 @@ public class HttpParserTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public void testResponseParse0()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testResponseParse0() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput(
|
||||
|
@ -409,8 +374,8 @@ public class HttpParserTest extends TestCase
|
|||
assertTrue(messageCompleted);
|
||||
}
|
||||
|
||||
public void testResponseParse1()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testResponseParse1() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput(
|
||||
|
@ -430,8 +395,8 @@ public class HttpParserTest extends TestCase
|
|||
assertTrue(messageCompleted);
|
||||
}
|
||||
|
||||
public void testResponseParse2()
|
||||
throws Exception
|
||||
@Test
|
||||
public void testResponseParse2() throws Exception
|
||||
{
|
||||
StringEndPoint io=new StringEndPoint();
|
||||
io.setInput(
|
||||
|
@ -464,21 +429,21 @@ public class HttpParserTest extends TestCase
|
|||
assertTrue(messageCompleted);
|
||||
}
|
||||
|
||||
String _content;
|
||||
String f0;
|
||||
String f1;
|
||||
String f2;
|
||||
String[] hdr;
|
||||
String[] val;
|
||||
int h;
|
||||
private String _content;
|
||||
private String f0;
|
||||
private String f1;
|
||||
private String f2;
|
||||
private String[] hdr;
|
||||
private String[] val;
|
||||
private int h;
|
||||
|
||||
boolean headerCompleted;
|
||||
boolean messageCompleted;
|
||||
private boolean headerCompleted;
|
||||
private boolean messageCompleted;
|
||||
|
||||
class Handler extends HttpParser.EventHandler
|
||||
private class Handler extends HttpParser.EventHandler
|
||||
{
|
||||
HttpFields fields;
|
||||
boolean request;
|
||||
private HttpFields fields;
|
||||
private boolean request;
|
||||
|
||||
public void content(Buffer ref)
|
||||
{
|
||||
|
@ -487,7 +452,6 @@ public class HttpParserTest extends TestCase
|
|||
_content= _content + ref;
|
||||
}
|
||||
|
||||
|
||||
public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2)
|
||||
{
|
||||
try
|
||||
|
@ -507,8 +471,7 @@ public class HttpParserTest extends TestCase
|
|||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
messageCompleted = false;
|
||||
|
@ -541,7 +504,6 @@ public class HttpParserTest extends TestCase
|
|||
messageCompleted = true;
|
||||
}
|
||||
|
||||
|
||||
public void startResponse(Buffer version, int status, Buffer reason)
|
||||
{
|
||||
request=false;
|
||||
|
|
|
@ -12,11 +12,14 @@
|
|||
// ========================================================================
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class HttpStatusCodeTest extends TestCase
|
||||
public class HttpStatusCodeTest
|
||||
{
|
||||
@Test
|
||||
public void testInvalidGetCode()
|
||||
{
|
||||
assertNull("Invalid code: 800", HttpStatus.getCode(800));
|
||||
|
|
|
@ -14,43 +14,14 @@
|
|||
package org.eclipse.jetty.http;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Top level test harness.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PathMapTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Constructor for HttpParserTest.
|
||||
*
|
||||
* @param arg0
|
||||
*/
|
||||
public PathMapTest(String arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
@Test
|
||||
public void testPathMap() throws Exception
|
||||
{
|
||||
PathMap p = new PathMap();
|
||||
|
@ -84,9 +55,9 @@ public class PathMapTest extends TestCase
|
|||
{ "/animal/path.gz", "5"},
|
||||
{ "/Other/path", "8"},};
|
||||
|
||||
for (int i = 0; i < tests.length; i++)
|
||||
for (String[] test : tests)
|
||||
{
|
||||
assertEquals(tests[i][0], tests[i][1], p.getMatch(tests[i][0]).getValue());
|
||||
assertEquals(test[0], test[1], p.getMatch(test[0]).getValue());
|
||||
}
|
||||
|
||||
assertEquals("Get absolute path", "1", p.get("/abs/path"));
|
||||
|
@ -158,6 +129,7 @@ public class PathMapTest extends TestCase
|
|||
/**
|
||||
* See JIRA issue: JETTY-88.
|
||||
*/
|
||||
@Test
|
||||
public void testPathMappingsOnlyMatchOnDirectoryNames() throws Exception
|
||||
{
|
||||
String spec = "/xyz/*";
|
||||
|
|
Loading…
Reference in New Issue