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:
Simone Bordet 2010-05-11 15:16:01 +00:00
parent cddf630426
commit 15dc2319d1
8 changed files with 341 additions and 430 deletions

View File

@ -5,6 +5,7 @@ jetty-7.1.1-SNAPSHOT
+ 308860 Update test suite to JUnit4 - Module jetty-rewrite + 308860 Update test suite to JUnit4 - Module jetty-rewrite
+ 308850 Update test suite to JUnit4 - Module jetty-annotations + 308850 Update test suite to JUnit4 - Module jetty-annotations
+ 308853 Update test suite to JUnit4 - Module jetty-deploy + 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 jetty-7.1.0 5 May 2010
+ 306353 fixed cross context dispatch to root context. + 306353 fixed cross context dispatch to root context.

View File

@ -20,6 +20,7 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>${junit4-version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@ -61,7 +62,7 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<archive> <archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive> </archive>
</configuration> </configuration>

View File

@ -4,11 +4,11 @@
// All rights reserved. This program and the accompanying materials // All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0 // are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution. // and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at // The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html // http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at // The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php // http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses. // You may elect to redistribute this code under either of these licenses.
// ======================================================================== // ========================================================================
package org.eclipse.jetty.http; package org.eclipse.jetty.http;
@ -17,31 +17,34 @@ import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import junit.framework.TestCase;
import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.View; 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() @Test
throws Exception public void testPut() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
header.put("name0", "value0"); header.put("name0", "value0");
header.put("name1", "value1"); header.put("name1", "value1");
assertEquals("value0",header.getStringField("name0")); assertEquals("value0",header.getStringField("name0"));
assertEquals("value1",header.getStringField("name1")); assertEquals("value1",header.getStringField("name1"));
assertNull(header.getStringField("name2")); assertNull(header.getStringField("name2"));
int matches=0; int matches=0;
Enumeration e = header.getFieldNames(); Enumeration e = header.getFieldNames();
while (e.hasMoreElements()) while (e.hasMoreElements())
@ -53,35 +56,34 @@ public class HttpFieldsTest extends TestCase
matches++; matches++;
} }
assertEquals(2, matches); assertEquals(2, matches);
matches=0;
e = header.getValues("name0"); e = header.getValues("name0");
assertEquals(true, e.hasMoreElements()); assertEquals(true, e.hasMoreElements());
assertEquals(e.nextElement(), "value0"); assertEquals(e.nextElement(), "value0");
assertEquals(false, e.hasMoreElements()); assertEquals(false, e.hasMoreElements());
} }
public void testCRLF() @Test
throws Exception public void testCRLF() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
header.put("name0", "value\r\n0"); header.put("name0", "value\r\n0");
header.put("name\r\n1", "value1"); header.put("name\r\n1", "value1");
header.put("name:2", "value:\r\n2"); header.put("name:2", "value:\r\n2");
ByteArrayBuffer buffer = new ByteArrayBuffer(1024); ByteArrayBuffer buffer = new ByteArrayBuffer(1024);
header.put(buffer); header.put(buffer);
assertTrue(buffer.toString().contains("name0: value0")); assertTrue(buffer.toString().contains("name0: value0"));
assertTrue(buffer.toString().contains("name1: value1")); assertTrue(buffer.toString().contains("name1: value1"));
assertTrue(buffer.toString().contains("name2: value:2")); assertTrue(buffer.toString().contains("name2: value:2"));
} }
public void testCachedPut() @Test
throws Exception public void testCachedPut() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
header.put("Connection", "keep-alive"); header.put("Connection", "keep-alive");
assertEquals(HttpHeaderValues.KEEP_ALIVE, header.getStringField(HttpHeaders.CONNECTION)); assertEquals(HttpHeaderValues.KEEP_ALIVE, header.getStringField(HttpHeaders.CONNECTION));
@ -96,15 +98,13 @@ public class HttpFieldsTest extends TestCase
matches++; matches++;
} }
assertEquals(1, matches); assertEquals(1, matches);
} }
public void testRePut() @Test
throws Exception public void testRePut() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
header.put("name0", "value0"); header.put("name0", "value0");
header.put("name1", "xxxxxx"); header.put("name1", "xxxxxx");
header.put("name2", "value2"); header.put("name2", "value2");
@ -112,14 +112,14 @@ public class HttpFieldsTest extends TestCase
assertEquals("value0",header.getStringField("name0")); assertEquals("value0",header.getStringField("name0"));
assertEquals("xxxxxx",header.getStringField("name1")); assertEquals("xxxxxx",header.getStringField("name1"));
assertEquals("value2",header.getStringField("name2")); assertEquals("value2",header.getStringField("name2"));
header.put("name1", "value1"); header.put("name1", "value1");
assertEquals("value0",header.getStringField("name0")); assertEquals("value0",header.getStringField("name0"));
assertEquals("value1",header.getStringField("name1")); assertEquals("value1",header.getStringField("name1"));
assertEquals("value2",header.getStringField("name2")); assertEquals("value2",header.getStringField("name2"));
assertNull(header.getStringField("name3")); assertNull(header.getStringField("name3"));
int matches=0; int matches=0;
Enumeration e = header.getFieldNames(); Enumeration e = header.getFieldNames();
while (e.hasMoreElements()) while (e.hasMoreElements())
@ -133,19 +133,18 @@ public class HttpFieldsTest extends TestCase
matches++; matches++;
} }
assertEquals(3, matches); assertEquals(3, matches);
matches=0;
e = header.getValues("name1"); e = header.getValues("name1");
assertEquals(true, e.hasMoreElements()); assertEquals(true, e.hasMoreElements());
assertEquals(e.nextElement(), "value1"); assertEquals(e.nextElement(), "value1");
assertEquals(false, e.hasMoreElements()); assertEquals(false, e.hasMoreElements());
} }
public void testRemovePut() @Test
throws Exception public void testRemovePut() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
header.put("name0", "value0"); header.put("name0", "value0");
header.put("name1", "value1"); header.put("name1", "value1");
header.put("name2", "value2"); header.put("name2", "value2");
@ -153,14 +152,14 @@ public class HttpFieldsTest extends TestCase
assertEquals("value0",header.getStringField("name0")); assertEquals("value0",header.getStringField("name0"));
assertEquals("value1",header.getStringField("name1")); assertEquals("value1",header.getStringField("name1"));
assertEquals("value2",header.getStringField("name2")); assertEquals("value2",header.getStringField("name2"));
header.remove("name1"); header.remove("name1");
assertEquals("value0",header.getStringField("name0")); assertEquals("value0",header.getStringField("name0"));
assertNull(header.getStringField("name1")); assertNull(header.getStringField("name1"));
assertEquals("value2",header.getStringField("name2")); assertEquals("value2",header.getStringField("name2"));
assertNull(header.getStringField("name3")); assertNull(header.getStringField("name3"));
int matches=0; int matches=0;
Enumeration e = header.getFieldNames(); Enumeration e = header.getFieldNames();
while (e.hasMoreElements()) while (e.hasMoreElements())
@ -174,18 +173,16 @@ public class HttpFieldsTest extends TestCase
matches++; matches++;
} }
assertEquals(2, matches); assertEquals(2, matches);
matches=0;
e = header.getValues("name1"); e = header.getValues("name1");
assertEquals(false, e.hasMoreElements()); assertEquals(false, e.hasMoreElements());
} }
@Test
public void testAdd() public void testAdd() throws Exception
throws Exception
{ {
HttpFields fields = new HttpFields(); HttpFields fields = new HttpFields();
fields.add("name0", "value0"); fields.add("name0", "value0");
fields.add("name1", "valueA"); fields.add("name1", "valueA");
fields.add("name2", "value2"); fields.add("name2", "value2");
@ -193,14 +190,14 @@ public class HttpFieldsTest extends TestCase
assertEquals("value0",fields.getStringField("name0")); assertEquals("value0",fields.getStringField("name0"));
assertEquals("valueA",fields.getStringField("name1")); assertEquals("valueA",fields.getStringField("name1"));
assertEquals("value2",fields.getStringField("name2")); assertEquals("value2",fields.getStringField("name2"));
fields.add("name1", "valueB"); fields.add("name1", "valueB");
assertEquals("value0",fields.getStringField("name0")); assertEquals("value0",fields.getStringField("name0"));
assertEquals("valueA",fields.getStringField("name1")); assertEquals("valueA",fields.getStringField("name1"));
assertEquals("value2",fields.getStringField("name2")); assertEquals("value2",fields.getStringField("name2"));
assertNull(fields.getStringField("name3")); assertNull(fields.getStringField("name3"));
int matches=0; int matches=0;
Enumeration e = fields.getFieldNames(); Enumeration e = fields.getFieldNames();
while (e.hasMoreElements()) while (e.hasMoreElements())
@ -214,8 +211,7 @@ public class HttpFieldsTest extends TestCase
matches++; matches++;
} }
assertEquals(3, matches); assertEquals(3, matches);
matches=0;
e = fields.getValues("name1"); e = fields.getValues("name1");
assertEquals(true, e.hasMoreElements()); assertEquals(true, e.hasMoreElements());
assertEquals(e.nextElement(), "valueA"); assertEquals(e.nextElement(), "valueA");
@ -223,9 +219,9 @@ public class HttpFieldsTest extends TestCase
assertEquals(e.nextElement(), "valueB"); assertEquals(e.nextElement(), "valueB");
assertEquals(false, e.hasMoreElements()); assertEquals(false, e.hasMoreElements());
} }
public void testReuse() @Test
throws Exception public void testReuse() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
Buffer n1=new ByteArrayBuffer("name1"); Buffer n1=new ByteArrayBuffer("name1");
@ -237,21 +233,21 @@ public class HttpFieldsTest extends TestCase
vb.put((byte)'u'); vb.put((byte)'u');
vb.put((byte)'e'); vb.put((byte)'e');
vb.put((byte)'1'); vb.put((byte)'1');
header.put("name0", "value0"); header.put("name0", "value0");
header.put(n1,va); header.put(n1,va);
header.put("name2", "value2"); header.put("name2", "value2");
assertEquals("value0",header.getStringField("name0")); assertEquals("value0",header.getStringField("name0"));
assertEquals("value1",header.getStringField("name1")); assertEquals("value1",header.getStringField("name1"));
assertEquals("value2",header.getStringField("name2")); assertEquals("value2",header.getStringField("name2"));
assertNull(header.getStringField("name3")); assertNull(header.getStringField("name3"));
header.remove(n1); header.remove(n1);
assertNull(header.getStringField("name1")); assertNull(header.getStringField("name1"));
header.put(n1,vb); header.put(n1,vb);
assertEquals("value1",header.getStringField("name1")); assertEquals("value1",header.getStringField("name1"));
int matches=0; int matches=0;
Enumeration e = header.getFieldNames(); Enumeration e = header.getFieldNames();
while (e.hasMoreElements()) while (e.hasMoreElements())
@ -265,40 +261,38 @@ public class HttpFieldsTest extends TestCase
matches++; matches++;
} }
assertEquals(3, matches); assertEquals(3, matches);
matches=0;
e = header.getValues("name1"); e = header.getValues("name1");
assertEquals(true, e.hasMoreElements()); assertEquals(true, e.hasMoreElements());
assertEquals(e.nextElement(), "value1"); assertEquals(e.nextElement(), "value1");
assertEquals(false, e.hasMoreElements()); assertEquals(false, e.hasMoreElements());
} }
public void testDestroy() @Test
throws Exception public void testDestroy() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
header.put(new ByteArrayBuffer("name0"), new View(new ByteArrayBuffer("value0"))); header.put(new ByteArrayBuffer("name0"), new View(new ByteArrayBuffer("value0")));
assertTrue(header.getFieldNames().hasMoreElements()); assertTrue(header.getFieldNames().hasMoreElements());
assertNotNull(header.getStringField("name0")); assertNotNull(header.getStringField("name0"));
assertNull(header.getStringField("name1")); assertNull(header.getStringField("name1"));
header.destroy(); header.destroy();
assertNull(header.getStringField("name0")); assertNull(header.getStringField("name0"));
} }
public void testCase() @Test
throws Exception public void testCase() throws Exception
{ {
HttpFields fields= new HttpFields(); HttpFields fields= new HttpFields();
Enumeration e;
Set s; Set s;
// 0123456789012345678901234567890 // 0123456789012345678901234567890
byte[] b ="Message-IDmessage-idvalueVALUE".getBytes(); byte[] b ="Message-IDmessage-idvalueVALUE".getBytes();
ByteArrayBuffer buf= new ByteArrayBuffer(512); ByteArrayBuffer buf= new ByteArrayBuffer(512);
buf.put(b); buf.put(b);
View headUC= new View.CaseInsensitive(buf); View headUC= new View.CaseInsensitive(buf);
View headLC= new View.CaseInsensitive(buf); View headLC= new View.CaseInsensitive(buf);
View valUC = new View(buf); View valUC = new View(buf);
@ -327,7 +321,7 @@ public class HttpFieldsTest extends TestCase
assertTrue(s.contains("message-id")); assertTrue(s.contains("message-id"));
assertEquals("value",fields.getStringField("Message-ID").toLowerCase()); assertEquals("value",fields.getStringField("Message-ID").toLowerCase());
assertEquals("value",fields.getStringField("message-id").toLowerCase()); assertEquals("value",fields.getStringField("message-id").toLowerCase());
fields.clear(); fields.clear();
fields.add("header","value"); fields.add("header","value");
@ -349,19 +343,19 @@ public class HttpFieldsTest extends TestCase
assertTrue(s.contains("message-id")); assertTrue(s.contains("message-id"));
assertEquals("value",fields.getStringField("Message-ID").toLowerCase()); assertEquals("value",fields.getStringField("Message-ID").toLowerCase());
assertEquals("value",fields.getStringField("message-id").toLowerCase()); assertEquals("value",fields.getStringField("message-id").toLowerCase());
} }
public void testHttpHeaderValues() @Test
throws Exception public void testHttpHeaderValues() throws Exception
{ {
assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("unknown value")).getOrdinal()<0); assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("unknown value")).getOrdinal()<0);
assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("close")).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); assertTrue(((CachedBuffer)HttpHeaderValues.CACHE.lookup("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)")).getOrdinal()>=0);
} }
public void testSetCookie() @Test
throws Exception public void testSetCookie() throws Exception
{ {
HttpFields fields = new HttpFields(); HttpFields fields = new HttpFields();
fields.addSetCookie("minimal","value",null,null,-1,null,false,false,-1); fields.addSetCookie("minimal","value",null,null,-1,null,false,false,-1);
@ -370,7 +364,7 @@ public class HttpFieldsTest extends TestCase
fields.clear(); fields.clear();
fields.addSetCookie("everything","value","domain","path",0,"comment",true,true,0); fields.addSetCookie("everything","value","domain","path",0,"comment",true,true,0);
assertEquals("everything=value;Path=path;Domain=domain;Expires=Thu, 01-Jan-1970 00:00:00 GMT;Secure;HttpOnly",fields.getStringField("Set-Cookie")); assertEquals("everything=value;Path=path;Domain=domain;Expires=Thu, 01-Jan-1970 00:00:00 GMT;Secure;HttpOnly",fields.getStringField("Set-Cookie"));
fields.clear(); fields.clear();
fields.addSetCookie("ev erything","va lue","do main","pa th",1,"co mment",true,true,2); fields.addSetCookie("ev erything","va lue","do main","pa th",1,"co mment",true,true,2);
assertEquals("\"ev erything\"=\"va lue\";Version=2;Comment=\"co mment\";Path=\"pa th\";Domain=\"do main\";Max-Age=1;Secure;HttpOnly",fields.getStringField("Set-Cookie")); assertEquals("\"ev erything\"=\"va lue\";Version=2;Comment=\"co mment\";Path=\"pa th\";Domain=\"do main\";Max-Age=1;Secure;HttpOnly",fields.getStringField("Set-Cookie"));
@ -388,22 +382,22 @@ public class HttpFieldsTest extends TestCase
fields.addSetCookie("foo","bar","domain",null,-1,null,false,false,-1); fields.addSetCookie("foo","bar","domain",null,-1,null,false,false,-1);
fields.addSetCookie("foo","bob","domain",null,-1,null,false,false,-1); fields.addSetCookie("foo","bob","domain",null,-1,null,false,false,-1);
assertEquals("name=more;Domain=domain",fields.getStringField("Set-Cookie")); assertEquals("name=more;Domain=domain",fields.getStringField("Set-Cookie"));
Enumeration e=fields.getValues("Set-Cookie"); Enumeration e=fields.getValues("Set-Cookie");
assertEquals("name=more;Domain=domain",e.nextElement()); assertEquals("name=more;Domain=domain",e.nextElement());
assertEquals("foo=bob;Domain=domain",e.nextElement()); 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()) while(e.hasMoreElements())
s.add(e.nextElement().toString().toLowerCase()); s.add(e.nextElement().toLowerCase());
return s; return s;
} }
public void testDateFields() @Test
throws Exception public void testDateFields() throws Exception
{ {
HttpFields fields = new HttpFields(); HttpFields fields = new HttpFields();
@ -427,7 +421,7 @@ public class HttpFieldsTest extends TestCase
assertEquals(d2,d3); assertEquals(d2,d3);
assertEquals(d3+2000,d4); assertEquals(d3+2000,d4);
assertEquals(951825600000L,d5); assertEquals(951825600000L,d5);
d1 = fields.getDateField("D1"); d1 = fields.getDateField("D1");
d2 = fields.getDateField("D2"); d2 = fields.getDateField("D2");
d3 = fields.getDateField("D3"); d3 = fields.getDateField("D3");
@ -439,28 +433,28 @@ public class HttpFieldsTest extends TestCase
assertEquals(d2,d3); assertEquals(d2,d3);
assertEquals(d3+2000,d4); assertEquals(d3+2000,d4);
assertEquals(951825600000L,d5); assertEquals(951825600000L,d5);
fields.putDateField("D2",d1); fields.putDateField("D2",d1);
assertEquals("Fri, 31 Dec 1999 23:59:59 GMT",fields.getStringField("D2")); assertEquals("Fri, 31 Dec 1999 23:59:59 GMT",fields.getStringField("D2"));
} }
public void testLongFields() @Test
throws Exception public void testLongFields() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
header.put("I1", "42"); header.put("I1", "42");
header.put("I2", " 43 99"); header.put("I2", " 43 99");
header.put("I3", "-44;"); header.put("I3", "-44;");
header.put("I4", " - 45abc"); header.put("I4", " - 45abc");
header.put("N1", " - "); header.put("N1", " - ");
header.put("N2", "xx"); header.put("N2", "xx");
long i1=header.getLongField("I1"); long i1=header.getLongField("I1");
long i2=header.getLongField("I2"); long i2=header.getLongField("I2");
long i3=header.getLongField("I3"); long i3=header.getLongField("I3");
long i4=header.getLongField("I4"); long i4=header.getLongField("I4");
try{ try{
header.getLongField("N1"); header.getLongField("N1");
assertTrue(false); assertTrue(false);
@ -469,7 +463,7 @@ public class HttpFieldsTest extends TestCase
{ {
assertTrue(true); assertTrue(true);
} }
try{ try{
header.getLongField("N2"); header.getLongField("N2");
assertTrue(false); assertTrue(false);
@ -478,24 +472,24 @@ public class HttpFieldsTest extends TestCase
{ {
assertTrue(true); assertTrue(true);
} }
assertEquals(42,i1); assertEquals(42,i1);
assertEquals(43,i2); assertEquals(43,i2);
assertEquals(-44,i3); assertEquals(-44,i3);
assertEquals(-45,i4); assertEquals(-45,i4);
header.putLongField("I5", 46); header.putLongField("I5", 46);
header.putLongField("I6",-47); header.putLongField("I6",-47);
assertEquals("46",header.getStringField("I5")); assertEquals("46",header.getStringField("I5"));
assertEquals("-47",header.getStringField("I6")); assertEquals("-47",header.getStringField("I6"));
} }
public void testToString() @Test
throws Exception public void testToString() throws Exception
{ {
HttpFields header = new HttpFields(); HttpFields header = new HttpFields();
header.put(new ByteArrayBuffer("name0"), new View(new ByteArrayBuffer("value0"))); header.put(new ByteArrayBuffer("name0"), new View(new ByteArrayBuffer("value0")));
header.put(new ByteArrayBuffer("name1"), new View(new ByteArrayBuffer("value1".getBytes()))); header.put(new ByteArrayBuffer("name1"), new View(new ByteArrayBuffer("value1".getBytes())));
String s1=header.toString(); String s1=header.toString();

View File

@ -4,119 +4,116 @@
// All rights reserved. This program and the accompanying materials // All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0 // are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution. // and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at // The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html // http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at // The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php // http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses. // You may elect to redistribute this code under either of these licenses.
// ======================================================================== // ========================================================================
package org.eclipse.jetty.http; package org.eclipse.jetty.http;
import java.io.IOException; import java.io.IOException;
import junit.framework.TestCase;
import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.ByteArrayEndPoint; import org.eclipse.jetty.io.ByteArrayEndPoint;
import org.eclipse.jetty.io.SimpleBuffers; import org.eclipse.jetty.io.SimpleBuffers;
import org.eclipse.jetty.io.View; 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 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 final static String[] connect={null,"keep-alive","close"};
public HttpGeneratorClientTest(String arg0) @Test
{ public void testContentLength() throws Exception
super(arg0);
}
public void testContentLength()
throws Exception
{ {
Buffer bb=new ByteArrayBuffer(8096); Buffer bb=new ByteArrayBuffer(8096);
Buffer sb=new ByteArrayBuffer(1500); Buffer sb=new ByteArrayBuffer(1500);
ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096); ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
HttpGenerator generator = new HttpGenerator(new SimpleBuffers(sb,bb),endp); HttpGenerator generator = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
generator.setRequest("GET","/usr"); generator.setRequest("GET","/usr");
HttpFields fields = new HttpFields(); HttpFields fields = new HttpFields();
fields.add("Header","Value"); fields.add("Header","Value");
fields.add("Content-Type","text/plain"); fields.add("Content-Type","text/plain");
String content = "The quick brown fox jumped over the lazy dog"; String content = "The quick brown fox jumped over the lazy dog";
fields.addLongField("Content-Length",content.length()); fields.addLongField("Content-Length",content.length());
generator.completeHeader(fields,false); generator.completeHeader(fields,false);
generator.addContent(new ByteArrayBuffer(content),true); generator.addContent(new ByteArrayBuffer(content),true);
generator.flushBuffer(); generator.flushBuffer();
generator.complete(); generator.complete();
generator.flushBuffer(); generator.flushBuffer();
String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|'); String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|');
assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Content-Length: 44||"+content,result); assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Content-Length: 44||"+content,result);
} }
public void testAutoContentLength() @Test
throws Exception public void testAutoContentLength() throws Exception
{ {
Buffer bb=new ByteArrayBuffer(8096); Buffer bb=new ByteArrayBuffer(8096);
Buffer sb=new ByteArrayBuffer(1500); Buffer sb=new ByteArrayBuffer(1500);
ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096); ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
HttpGenerator generator = new HttpGenerator(new SimpleBuffers(sb,bb),endp); HttpGenerator generator = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
generator.setRequest("GET","/usr"); generator.setRequest("GET","/usr");
HttpFields fields = new HttpFields(); HttpFields fields = new HttpFields();
fields.add("Header","Value"); fields.add("Header","Value");
fields.add("Content-Type","text/plain"); fields.add("Content-Type","text/plain");
String content = "The quick brown fox jumped over the lazy dog"; String content = "The quick brown fox jumped over the lazy dog";
generator.addContent(new ByteArrayBuffer(content),true); generator.addContent(new ByteArrayBuffer(content),true);
generator.completeHeader(fields,true); generator.completeHeader(fields,true);
generator.flushBuffer(); generator.flushBuffer();
generator.complete(); generator.complete();
generator.flushBuffer(); generator.flushBuffer();
String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|'); String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|');
assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Content-Length: 44||"+content,result); assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Content-Length: 44||"+content,result);
} }
public void testChunked() @Test
throws Exception public void testChunked() throws Exception
{ {
Buffer bb=new ByteArrayBuffer(8096); Buffer bb=new ByteArrayBuffer(8096);
Buffer sb=new ByteArrayBuffer(1500); Buffer sb=new ByteArrayBuffer(1500);
ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096); ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
HttpGenerator generator = new HttpGenerator(new SimpleBuffers(sb,bb),endp); HttpGenerator generator = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
generator.setRequest("GET","/usr"); generator.setRequest("GET","/usr");
HttpFields fields = new HttpFields(); HttpFields fields = new HttpFields();
fields.add("Header","Value"); fields.add("Header","Value");
fields.add("Content-Type","text/plain"); fields.add("Content-Type","text/plain");
String content = "The quick brown fox jumped over the lazy dog"; String content = "The quick brown fox jumped over the lazy dog";
generator.completeHeader(fields,false); generator.completeHeader(fields,false);
generator.addContent(new ByteArrayBuffer(content),false); generator.addContent(new ByteArrayBuffer(content),false);
generator.flushBuffer(); generator.flushBuffer();
generator.complete(); generator.complete();
generator.flushBuffer(); generator.flushBuffer();
String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|'); String result=endp.getOut().toString().replace("\r\n","|").replace('\r','|').replace('\n','|');
assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Transfer-Encoding: chunked||2C|"+content+"|0||",result); assertEquals("GET /usr HTTP/1.1|Header: Value|Content-Type: text/plain|Transfer-Encoding: chunked||2C|"+content+"|0||",result);
} }
public void testHTTP() @Test
throws Exception public void testHTTP() throws Exception
{ {
Buffer bb=new ByteArrayBuffer(8096); Buffer bb=new ByteArrayBuffer(8096);
Buffer sb=new ByteArrayBuffer(1500); Buffer sb=new ByteArrayBuffer(1500);
@ -125,7 +122,7 @@ public class HttpGeneratorClientTest extends TestCase
HttpGenerator hb = new HttpGenerator(new SimpleBuffers(sb,bb),endp); HttpGenerator hb = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
Handler handler = new Handler(); Handler handler = new Handler();
HttpParser parser=null; HttpParser parser=null;
// For HTTP version // For HTTP version
for (int v=9;v<=11;v++) for (int v=9;v<=11;v++)
{ {
@ -140,13 +137,13 @@ public class HttpGeneratorClientTest extends TestCase
{ {
String t="v="+v+",r="+r+",chunks="+chunks+",c="+c+",tr="+tr[r]; String t="v="+v+",r="+r+",chunks="+chunks+",c="+c+",tr="+tr[r];
// System.err.println(t); // System.err.println(t);
hb.reset(true); hb.reset(true);
endp.reset(); endp.reset();
fields.clear(); fields.clear();
// System.out.println("TEST: "+t); // System.out.println("TEST: "+t);
try try
{ {
tr[r].build(v,hb,connect[c],null,chunks, fields); tr[r].build(v,hb,connect[c],null,chunks, fields);
@ -160,15 +157,15 @@ public class HttpGeneratorClientTest extends TestCase
} }
String request=endp.getOut().toString(); String request=endp.getOut().toString();
// System.out.println(request+(hb.isPersistent()?"...\n":"---\n")); // System.out.println(request+(hb.isPersistent()?"...\n":"---\n"));
assertTrue(t,hb.isPersistent()); assertTrue(t,hb.isPersistent());
if (v==9) if (v==9)
{ {
assertEquals(t,"GET /context/path/info\r\n", request); assertEquals(t,"GET /context/path/info\r\n", request);
continue; continue;
} }
parser=new HttpParser(new ByteArrayBuffer(request.getBytes()), handler); parser=new HttpParser(new ByteArrayBuffer(request.getBytes()), handler);
try try
{ {
@ -180,14 +177,14 @@ public class HttpGeneratorClientTest extends TestCase
throw e; throw e;
continue; continue;
} }
if (tr[r].body!=null) if (tr[r].body!=null)
assertEquals(t,tr[r].body, this.content); assertEquals(t,tr[r].body, this.content);
if (v==10) if (v==10)
assertTrue(t,hb.isPersistent() || tr[r].values[1]==null || c==2 || c==0); assertTrue(t,hb.isPersistent() || tr[r].values[1]==null || c==2 || c==0);
else else
assertTrue(t,hb.isPersistent() || c==2); assertTrue(t,hb.isPersistent() || c==2);
assertTrue(t,tr[r].values[1]==null || content.length()==Integer.parseInt(tr[r].values[1])); assertTrue(t,tr[r].values[1]==null || content.length()==Integer.parseInt(tr[r].values[1]));
} }
} }
@ -195,23 +192,21 @@ public class HttpGeneratorClientTest extends TestCase
} }
} }
private static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"};
private class TR
static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"};
class TR
{ {
String[] values=new String[headers.length]; private String[] values=new String[headers.length];
String body; private String body;
TR(String ct, String cl ,String content) private TR(String ct, String cl ,String content)
{ {
values[0]=ct; values[0]=ct;
values[1]=cl; values[1]=cl;
values[4]="value"; values[4]="value";
this.body=content; 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 throws Exception
{ {
values[2]=connection; values[2]=connection;
@ -219,14 +214,14 @@ public class HttpGeneratorClientTest extends TestCase
hb.setRequest(HttpMethods.GET,"/context/path/info"); hb.setRequest(HttpMethods.GET,"/context/path/info");
hb.setVersion(version); hb.setVersion(version);
for (int i=0;i<headers.length;i++) for (int i=0;i<headers.length;i++)
{ {
if (values[i]==null) if (values[i]==null)
continue; continue;
fields.put(new ByteArrayBuffer(headers[i]),new ByteArrayBuffer(values[i])); fields.put(new ByteArrayBuffer(headers[i]),new ByteArrayBuffer(values[i]));
} }
if (body!=null) if (body!=null)
{ {
int inc=1+body.length()/chunks; int inc=1+body.length()/chunks;
@ -262,15 +257,15 @@ public class HttpGeneratorClientTest extends TestCase
} }
hb.complete(); hb.complete();
} }
@Override @Override
public String toString() public String toString()
{ {
return "["+values[0]+","+values[1]+","+(body==null?"none":"_content")+"]"; return "["+values[0]+","+values[1]+","+(body==null?"none":"_content")+"]";
} }
} }
private TR[] tr = private final TR[] tr =
{ {
/* 0 */ new TR(null,null,null), /* 0 */ new TR(null,null,null),
/* 1 */ new TR(null,null,CONTENT), /* 1 */ new TR(null,null,CONTENT),
@ -279,20 +274,20 @@ public class HttpGeneratorClientTest extends TestCase
/* 5 */ new TR("text/html",null,CONTENT), /* 5 */ new TR("text/html",null,CONTENT),
/* 7 */ new TR("text/html",""+CONTENT.length(),CONTENT), /* 7 */ new TR("text/html",""+CONTENT.length(),CONTENT),
}; };
String content;
String f0; private String content;
String f1; private String f0;
String f2; private String f1;
String[] hdr; private String f2;
String[] val; private String[] hdr;
int h; 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 @Override
public void content(Buffer ref) public void content(Buffer ref)
{ {
@ -302,7 +297,6 @@ public class HttpGeneratorClientTest extends TestCase
index+=ref.length(); index+=ref.length();
} }
@Override @Override
public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2) public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2)
{ {
@ -319,7 +313,6 @@ public class HttpGeneratorClientTest extends TestCase
// System.out.println(f0+" "+f1+" "+f2); // System.out.println(f0+" "+f1+" "+f2);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jetty.EventHandler#startResponse(org.eclipse.io.Buffer, int, org.eclipse.io.Buffer) * @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) public void messageComplete(long contentLength)
{ {
} }
} }
} }

View File

@ -4,66 +4,62 @@
// All rights reserved. This program and the accompanying materials // All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0 // are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution. // and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at // The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html // http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at // The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php // http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses. // You may elect to redistribute this code under either of these licenses.
// ======================================================================== // ========================================================================
package org.eclipse.jetty.http; package org.eclipse.jetty.http;
import java.io.IOException; import java.io.IOException;
import junit.framework.TestCase;
import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.ByteArrayEndPoint; import org.eclipse.jetty.io.ByteArrayEndPoint;
import org.eclipse.jetty.io.SimpleBuffers; import org.eclipse.jetty.io.SimpleBuffers;
import org.eclipse.jetty.io.View; 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;
/** /**
* *
* *
* To change the template for this generated type comment go to * To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments * 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 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 final static String[] connect={null,"keep-alive","close","TE, close"};
public HttpGeneratorTest(String arg0) @Test
{ public void testRequest() throws Exception
super(arg0);
}
public void testRequest()
throws Exception
{ {
Buffer bb=new ByteArrayBuffer(8096); Buffer bb=new ByteArrayBuffer(8096);
Buffer sb=new ByteArrayBuffer(1500); Buffer sb=new ByteArrayBuffer(1500);
HttpFields fields = new HttpFields(); HttpFields fields = new HttpFields();
ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096); ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
HttpGenerator hg = new HttpGenerator(new SimpleBuffers(sb,bb),endp); HttpGenerator hg = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
fields.add("Host","something"); fields.add("Host","something");
fields.add("User-Agent","test"); fields.add("User-Agent","test");
hg.setRequest("GET","/index.html"); hg.setRequest("GET","/index.html");
hg.setVersion(11); hg.setVersion(11);
hg.completeHeader(fields,true); hg.completeHeader(fields,true);
hg.complete(); hg.complete();
assertTrue(endp.getOut().toString().indexOf("GET /index.html HTTP/1.1")==0); assertTrue(endp.getOut().toString().indexOf("GET /index.html HTTP/1.1")==0);
assertTrue(endp.getOut().toString().indexOf("Content-Length")==-1); assertTrue(endp.getOut().toString().indexOf("Content-Length")==-1);
} }
public void testHTTP() @Test
throws Exception public void testHTTP() throws Exception
{ {
Buffer bb=new ByteArrayBuffer(8096); Buffer bb=new ByteArrayBuffer(8096);
Buffer sb=new ByteArrayBuffer(1500); Buffer sb=new ByteArrayBuffer(1500);
@ -72,7 +68,7 @@ public class HttpGeneratorTest extends TestCase
HttpGenerator hb = new HttpGenerator(new SimpleBuffers(sb,bb),endp); HttpGenerator hb = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
Handler handler = new Handler(); Handler handler = new Handler();
HttpParser parser=null; HttpParser parser=null;
// For HTTP version // For HTTP version
for (int v=9;v<=11;v++) for (int v=9;v<=11;v++)
{ {
@ -85,18 +81,18 @@ public class HttpGeneratorTest extends TestCase
// For none, keep-alive, close // For none, keep-alive, close
for (int c=0;c<(v==11?connect.length:(connect.length-1));c++) for (int c=0;c<(v==11?connect.length:(connect.length-1));c++)
{ {
String t="v="+v+",r="+r+",chunks="+chunks+",connect="+connect[c]+",tr="+tr[r]; String t="v="+v+",r="+r+",chunks="+chunks+",connect="+connect[c]+",tr="+tr[r];
// System.err.println(t); // System.err.println(t);
hb.reset(true); hb.reset(true);
endp.reset(); endp.reset();
fields.clear(); fields.clear();
tr[r].build(v,hb,"OK\r\nTest",connect[c],null,chunks, fields); tr[r].build(v,hb,"OK\r\nTest",connect[c],null,chunks, fields);
String response=endp.getOut().toString(); String response=endp.getOut().toString();
// System.out.println("RESPONSE: "+t+"\n"+response+(hb.isPersistent()?"...\n":"---\n")); // System.out.println("RESPONSE: "+t+"\n"+response+(hb.isPersistent()?"...\n":"---\n"));
if (v==9) if (v==9)
{ {
assertFalse(t,hb.isPersistent()); assertFalse(t,hb.isPersistent());
@ -104,7 +100,7 @@ public class HttpGeneratorTest extends TestCase
assertEquals(t,tr[r].body, response); assertEquals(t,tr[r].body, response);
continue; continue;
} }
parser=new HttpParser(new ByteArrayBuffer(response.getBytes()), handler); parser=new HttpParser(new ByteArrayBuffer(response.getBytes()), handler);
try try
{ {
@ -116,17 +112,17 @@ public class HttpGeneratorTest extends TestCase
throw e; throw e;
continue; continue;
} }
if (tr[r].body!=null) if (tr[r].body!=null)
assertEquals(t,tr[r].body, this.content); assertEquals(t,tr[r].body, this.content);
if (v==10) if (v==10)
assertTrue(t,hb.isPersistent() || tr[r].values[1]==null || c==2 || c==0); assertTrue(t,hb.isPersistent() || tr[r].values[1]==null || c==2 || c==0);
else else
assertTrue(t,hb.isPersistent() || c==2 || c==3); assertTrue(t,hb.isPersistent() || c==2 || c==3);
if (v>9) if (v>9)
assertEquals("OK Test",f2); assertEquals("OK Test",f2);
assertTrue(t,tr[r].values[1]==null || content.length()==Integer.parseInt(tr[r].values[1])); assertTrue(t,tr[r].values[1]==null || content.length()==Integer.parseInt(tr[r].values[1]));
} }
} }
@ -134,16 +130,14 @@ public class HttpGeneratorTest extends TestCase
} }
} }
private static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"};
private class TR
static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"};
class TR
{ {
int code; private int code;
String[] values=new String[headers.length]; private String[] values=new String[headers.length];
String body; 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; this.code=code;
values[0]=ct; values[0]=ct;
@ -151,22 +145,21 @@ public class HttpGeneratorTest extends TestCase
values[4]="value"; values[4]="value";
this.body=content; this.body=content;
} }
void build(int version,HttpGenerator hb,String reason, String connection, String te, int chunks, HttpFields fields) private void build(int version,HttpGenerator hb,String reason, String connection, String te, int chunks, HttpFields fields) throws Exception
throws Exception
{ {
values[2]=connection; values[2]=connection;
values[3]=te; values[3]=te;
hb.setVersion(version); hb.setVersion(version);
hb.setResponse(code,reason); hb.setResponse(code,reason);
for (int i=0;i<headers.length;i++) for (int i=0;i<headers.length;i++)
{ {
if (values[i]==null) if (values[i]==null)
continue; continue;
fields.put(new ByteArrayBuffer(headers[i]),new ByteArrayBuffer(values[i])); fields.put(new ByteArrayBuffer(headers[i]),new ByteArrayBuffer(values[i]));
} }
if (body!=null) if (body!=null)
{ {
int inc=1+body.length()/chunks; int inc=1+body.length()/chunks;
@ -198,15 +191,15 @@ public class HttpGeneratorTest extends TestCase
} }
hb.complete(); hb.complete();
} }
@Override @Override
public String toString() public String toString()
{ {
return "["+code+","+values[0]+","+values[1]+","+(body==null?"none":"_content")+"]"; return "["+code+","+values[0]+","+values[1]+","+(body==null?"none":"_content")+"]";
} }
} }
private TR[] tr = private final TR[] tr =
{ {
/* 0 */ new TR(200,null,null,null), /* 0 */ new TR(200,null,null,null),
/* 1 */ new TR(200,null,null,CONTENT), /* 1 */ new TR(200,null,null,CONTENT),
@ -217,19 +210,19 @@ public class HttpGeneratorTest extends TestCase
/* 6 */ new TR(200,"text/html",""+CONTENT.length(),null), /* 6 */ new TR(200,"text/html",""+CONTENT.length(),null),
/* 7 */ new TR(200,"text/html",""+CONTENT.length(),CONTENT), /* 7 */ new TR(200,"text/html",""+CONTENT.length(),CONTENT),
}; };
String content; private String content;
String f0; private String f0;
String f1; private String f1;
String f2; private String f2;
String[] hdr; private String[] hdr;
String[] val; private String[] val;
int h; private int h;
class Handler extends HttpParser.EventHandler private class Handler extends HttpParser.EventHandler
{ {
int index=0; private int index=0;
@Override @Override
public void content(Buffer ref) public void content(Buffer ref)
{ {
@ -239,7 +232,6 @@ public class HttpGeneratorTest extends TestCase
index+=ref.length(); index+=ref.length();
} }
@Override @Override
public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2) public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2)
{ {
@ -256,7 +248,6 @@ public class HttpGeneratorTest extends TestCase
// System.out.println(f0+" "+f1+" "+f2); // System.out.println(f0+" "+f1+" "+f2);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jetty.EventHandler#startResponse(org.eclipse.io.Buffer, int, org.eclipse.io.Buffer) * @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) public void messageComplete(long contentLength)
{ {
} }
} }
} }

View File

@ -4,67 +4,34 @@
// All rights reserved. This program and the accompanying materials // All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0 // are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution. // and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at // The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html // http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at // The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php // http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses. // You may elect to redistribute this code under either of these licenses.
// ======================================================================== // ========================================================================
package org.eclipse.jetty.http; package org.eclipse.jetty.http;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import junit.framework.TestCase;
import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.SimpleBuffers; import org.eclipse.jetty.io.SimpleBuffers;
import org.eclipse.jetty.io.bio.StringEndPoint; import org.eclipse.jetty.io.bio.StringEndPoint;
import org.eclipse.jetty.util.StringUtil; 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
{ {
/** @Test
* Constructor for HttpParserTest. public void testLineParse0() throws Exception
* @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
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput("POST /foo HTTP/1.0\015\012" + "\015\012"); io.setInput("POST /foo HTTP/1.0\015\012" + "\015\012");
@ -80,8 +47,8 @@ public class HttpParserTest extends TestCase
assertEquals(-1, h); assertEquals(-1, h);
} }
public void testLineParse1() @Test
throws Exception public void testLineParse1() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput("GET /999\015\012"); io.setInput("GET /999\015\012");
@ -98,8 +65,8 @@ public class HttpParserTest extends TestCase
assertEquals(-1, h); assertEquals(-1, h);
} }
public void testLineParse2() @Test
throws Exception public void testLineParse2() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput("POST /222 \015\012"); io.setInput("POST /222 \015\012");
@ -116,8 +83,8 @@ public class HttpParserTest extends TestCase
assertEquals(-1, h); assertEquals(-1, h);
} }
public void testLineParse3() @Test
throws Exception public void testLineParse3() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput("POST /fo\u0690 HTTP/1.0\015\012" + "\015\012"); io.setInput("POST /fo\u0690 HTTP/1.0\015\012" + "\015\012");
@ -133,8 +100,8 @@ public class HttpParserTest extends TestCase
assertEquals(-1, h); assertEquals(-1, h);
} }
public void testLineParse4() @Test
throws Exception public void testLineParse4() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput("POST /foo?param=\u0690 HTTP/1.0\015\012" + "\015\012"); 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); assertEquals(-1, h);
} }
public void testConnect() @Test
throws Exception public void testConnect() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput("CONNECT 192.168.1.2:80 HTTP/1.1\015\012" + "\015\012"); 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); assertEquals(-1, h);
} }
public void testHeaderParse() @Test
throws Exception public void testHeaderParse() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput( io.setInput(
@ -207,14 +174,14 @@ public class HttpParserTest extends TestCase
assertEquals(5, h); assertEquals(5, h);
} }
public void testChunkParse() @Test
throws Exception public void testChunkParse() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput( io.setInput(
"GET /chunk HTTP/1.0\015\012" "GET /chunk HTTP/1.0\015\012"
+ "Header1: value1\015\012" + "Header1: value1\015\012"
+ "Transfer-Encoding: chunked\015\012" + "Transfer-Encoding: chunked\015\012"
+ "\015\012" + "\015\012"
+ "a;\015\012" + "a;\015\012"
+ "0123456789\015\012" + "0123456789\015\012"
@ -237,14 +204,14 @@ public class HttpParserTest extends TestCase
assertEquals("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", _content); assertEquals("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", _content);
} }
public void testMultiParse() @Test
throws Exception public void testMultiParse() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput( io.setInput(
"GET /mp HTTP/1.0\015\012" "GET /mp HTTP/1.0\015\012"
+ "Header1: value1\015\012" + "Header1: value1\015\012"
+ "Transfer-Encoding: chunked\015\012" + "Transfer-Encoding: chunked\015\012"
+ "\015\012" + "\015\012"
+ "a;\015\012" + "a;\015\012"
+ "0123456789\015\012" + "0123456789\015\012"
@ -253,11 +220,11 @@ public class HttpParserTest extends TestCase
+ "0\015\012" + "0\015\012"
+ "POST /foo HTTP/1.0\015\012" + "POST /foo HTTP/1.0\015\012"
+ "Header2: value2\015\012" + "Header2: value2\015\012"
+ "Content-Length: 0\015\012" + "Content-Length: 0\015\012"
+ "\015\012" + "\015\012"
+ "PUT /doodle HTTP/1.0\015\012" + "PUT /doodle HTTP/1.0\015\012"
+ "Header3: value3\015\012" + "Header3: value3\015\012"
+ "Content-Length: 10\015\012" + "Content-Length: 10\015\012"
+ "\015\012" + "\015\012"
+ "0123456789\015\012"); + "0123456789\015\012");
@ -293,15 +260,15 @@ public class HttpParserTest extends TestCase
assertEquals("Header3", hdr[0]); assertEquals("Header3", hdr[0]);
assertEquals("value3", val[0]); assertEquals("value3", val[0]);
assertEquals("0123456789", _content); assertEquals("0123456789", _content);
} }
@Test
public void testStreamParse() throws Exception public void testStreamParse() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
String http="GET / HTTP/1.0\015\012" String http="GET / HTTP/1.0\015\012"
+ "Header1: value1\015\012" + "Header1: value1\015\012"
+ "Transfer-Encoding: chunked\015\012" + "Transfer-Encoding: chunked\015\012"
+ "\015\012" + "\015\012"
+ "a;\015\012" + "a;\015\012"
+ "0123456789\015\012" + "0123456789\015\012"
@ -314,11 +281,10 @@ public class HttpParserTest extends TestCase
+ "\015\012" + "\015\012"
+ "PUT /doodle HTTP/1.0\015\012" + "PUT /doodle HTTP/1.0\015\012"
+ "Header3: value3\015\012" + "Header3: value3\015\012"
+ "Content-Length: 10\015\012" + "Content-Length: 10\015\012"
+ "\015\012" + "\015\012"
+ "0123456789\015\012"; + "0123456789\015\012";
int[] tests= int[] tests=
{ {
1024, 1024,
@ -333,7 +299,7 @@ public class HttpParserTest extends TestCase
64, 64,
32 32
}; };
for (int t= 0; t < tests.length; t++) for (int t= 0; t < tests.length; t++)
{ {
String tst="t"+tests[t]; String tst="t"+tests[t];
@ -345,10 +311,9 @@ public class HttpParserTest extends TestCase
Handler handler = new Handler(); Handler handler = new Handler();
HttpParser parser= new HttpParser(buffers,io, handler); HttpParser parser= new HttpParser(buffers,io, handler);
io.setInput(http); io.setInput(http);
parser.parse(); parser.parse();
assertEquals(tst,"GET", f0); assertEquals(tst,"GET", f0);
assertEquals(tst,"/", f1); assertEquals(tst,"/", f1);
@ -357,7 +322,7 @@ public class HttpParserTest extends TestCase
assertEquals(tst,"Header1", hdr[0]); assertEquals(tst,"Header1", hdr[0]);
assertEquals(tst,"value1", val[0]); assertEquals(tst,"value1", val[0]);
assertEquals(tst,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", _content); assertEquals(tst,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", _content);
parser.parse(); parser.parse();
assertEquals(tst,"POST", f0); assertEquals(tst,"POST", f0);
assertEquals(tst,"/foo", f1); assertEquals(tst,"/foo", f1);
@ -366,7 +331,7 @@ public class HttpParserTest extends TestCase
assertEquals(tst,"Header2", hdr[0]); assertEquals(tst,"Header2", hdr[0]);
assertEquals(tst,"value2", val[0]); assertEquals(tst,"value2", val[0]);
assertEquals(tst,null, _content); assertEquals(tst,null, _content);
parser.parse(); parser.parse();
assertEquals(tst,"PUT", f0); assertEquals(tst,"PUT", f0);
assertEquals(tst,"/doodle", f1); assertEquals(tst,"/doodle", f1);
@ -385,16 +350,16 @@ public class HttpParserTest extends TestCase
} }
} }
public void testResponseParse0() @Test
throws Exception public void testResponseParse0() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput( io.setInput(
"HTTP/1.1 200 Correct\015\012" "HTTP/1.1 200 Correct\015\012"
+ "Content-Length: 10\015\012" + "Content-Length: 10\015\012"
+ "Content-Type: text/plain\015\012" + "Content-Type: text/plain\015\012"
+ "\015\012" + "\015\012"
+ "0123456789\015\012"); + "0123456789\015\012");
ByteArrayBuffer buffer= new ByteArrayBuffer(4096); ByteArrayBuffer buffer= new ByteArrayBuffer(4096);
SimpleBuffers buffers=new SimpleBuffers(buffer,null); SimpleBuffers buffers=new SimpleBuffers(buffer,null);
@ -404,19 +369,19 @@ public class HttpParserTest extends TestCase
assertEquals("HTTP/1.1", f0); assertEquals("HTTP/1.1", f0);
assertEquals("200", f1); assertEquals("200", f1);
assertEquals("Correct", f2); assertEquals("Correct", f2);
assertEquals(_content.length(), 10); assertEquals(_content.length(), 10);
assertTrue(headerCompleted); assertTrue(headerCompleted);
assertTrue(messageCompleted); assertTrue(messageCompleted);
} }
public void testResponseParse1() @Test
throws Exception public void testResponseParse1() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput( io.setInput(
"HTTP/1.1 304 Not-Modified\015\012" "HTTP/1.1 304 Not-Modified\015\012"
+ "Connection: close\015\012" + "Connection: close\015\012"
+ "\015\012"); + "\015\012");
ByteArrayBuffer buffer= new ByteArrayBuffer(4096); ByteArrayBuffer buffer= new ByteArrayBuffer(4096);
SimpleBuffers buffers=new SimpleBuffers(buffer,null); SimpleBuffers buffers=new SimpleBuffers(buffer,null);
@ -426,23 +391,23 @@ public class HttpParserTest extends TestCase
assertEquals("HTTP/1.1", f0); assertEquals("HTTP/1.1", f0);
assertEquals("304", f1); assertEquals("304", f1);
assertEquals("Not-Modified", f2); assertEquals("Not-Modified", f2);
assertTrue(headerCompleted); assertTrue(headerCompleted);
assertTrue(messageCompleted); assertTrue(messageCompleted);
} }
public void testResponseParse2() @Test
throws Exception public void testResponseParse2() throws Exception
{ {
StringEndPoint io=new StringEndPoint(); StringEndPoint io=new StringEndPoint();
io.setInput( io.setInput(
"HTTP/1.1 204 No-Content\015\012" "HTTP/1.1 204 No-Content\015\012"
+ "Connection: close\015\012" + "Connection: close\015\012"
+ "\015\012" + "\015\012"
+ "HTTP/1.1 200 Correct\015\012" + "HTTP/1.1 200 Correct\015\012"
+ "Content-Length: 10\015\012" + "Content-Length: 10\015\012"
+ "Content-Type: text/plain\015\012" + "Content-Type: text/plain\015\012"
+ "\015\012" + "\015\012"
+ "0123456789\015\012"); + "0123456789\015\012");
ByteArrayBuffer buffer= new ByteArrayBuffer(4096); ByteArrayBuffer buffer= new ByteArrayBuffer(4096);
SimpleBuffers buffers=new SimpleBuffers(buffer,null); SimpleBuffers buffers=new SimpleBuffers(buffer,null);
@ -452,34 +417,34 @@ public class HttpParserTest extends TestCase
assertEquals("HTTP/1.1", f0); assertEquals("HTTP/1.1", f0);
assertEquals("204", f1); assertEquals("204", f1);
assertEquals("No-Content", f2); assertEquals("No-Content", f2);
assertTrue(headerCompleted); assertTrue(headerCompleted);
assertTrue(messageCompleted); assertTrue(messageCompleted);
parser.parse(); parser.parse();
assertEquals("HTTP/1.1", f0); assertEquals("HTTP/1.1", f0);
assertEquals("200", f1); assertEquals("200", f1);
assertEquals("Correct", f2); assertEquals("Correct", f2);
assertEquals(_content.length(), 10); assertEquals(_content.length(), 10);
assertTrue(headerCompleted); assertTrue(headerCompleted);
assertTrue(messageCompleted); assertTrue(messageCompleted);
} }
String _content; private String _content;
String f0; private String f0;
String f1; private String f1;
String f2; private String f2;
String[] hdr; private String[] hdr;
String[] val; private String[] val;
int h; private int h;
boolean headerCompleted; private boolean headerCompleted;
boolean messageCompleted; private boolean messageCompleted;
private class Handler extends HttpParser.EventHandler
{
private HttpFields fields;
private boolean request;
class Handler extends HttpParser.EventHandler
{
HttpFields fields;
boolean request;
public void content(Buffer ref) public void content(Buffer ref)
{ {
if (_content==null) if (_content==null)
@ -487,7 +452,6 @@ public class HttpParserTest extends TestCase
_content= _content + ref; _content= _content + ref;
} }
public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2) public void startRequest(Buffer tok0, Buffer tok1, Buffer tok2)
{ {
try try
@ -507,12 +471,11 @@ public class HttpParserTest extends TestCase
} }
catch (UnsupportedEncodingException e) catch (UnsupportedEncodingException e)
{ {
// TODO Auto-generated catch block throw new RuntimeException(e);
e.printStackTrace();
} }
messageCompleted = false; messageCompleted = false;
headerCompleted = false; headerCompleted = false;
} }
public void parsedHeader(Buffer name, Buffer value) public void parsedHeader(Buffer name, Buffer value)
@ -533,28 +496,27 @@ public class HttpParserTest extends TestCase
throw new IllegalStateException(); throw new IllegalStateException();
} }
headerCompleted = true; headerCompleted = true;
} }
public void messageComplete(long contentLength) public void messageComplete(long contentLength)
{ {
messageCompleted = true; messageCompleted = true;
} }
public void startResponse(Buffer version, int status, Buffer reason) public void startResponse(Buffer version, int status, Buffer reason)
{ {
request=false; request=false;
f0 = version.toString(); f0 = version.toString();
f1 = Integer.toString(status); f1 = Integer.toString(status);
f2 = reason.toString(); f2 = reason.toString();
fields=new HttpFields(); fields=new HttpFields();
hdr= new String[9]; hdr= new String[9];
val= new String[9]; val= new String[9];
messageCompleted = false; messageCompleted = false;
headerCompleted = false; headerCompleted = false;
} }
} }
} }

View File

@ -4,19 +4,22 @@
// All rights reserved. This program and the accompanying materials // All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0 // are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution. // and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at // The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html // http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at // The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php // http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses. // You may elect to redistribute this code under either of these licenses.
// ======================================================================== // ========================================================================
package org.eclipse.jetty.http; 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() public void testInvalidGetCode()
{ {
assertNull("Invalid code: 800", HttpStatus.getCode(800)); assertNull("Invalid code: 800", HttpStatus.getCode(800));

View File

@ -4,53 +4,24 @@
// All rights reserved. This program and the accompanying materials // All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0 // are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution. // and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at // The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html // http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at // The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php // http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses. // You may elect to redistribute this code under either of these licenses.
// ======================================================================== // ========================================================================
package org.eclipse.jetty.http; package org.eclipse.jetty.http;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.junit.Test;
/* ------------------------------------------------------------ */
/** /**
* Top level test harness. *
*
*
*/ */
public class PathMapTest extends TestCase public class PathMapTest extends TestCase
{ {
/** @Test
* 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();
}
/* --------------------------------------------------------------- */
public void testPathMap() throws Exception public void testPathMap() throws Exception
{ {
PathMap p = new PathMap(); PathMap p = new PathMap();
@ -65,28 +36,28 @@ public class PathMapTest extends TestCase
p.put("/", "8"); p.put("/", "8");
p.put("/XXX:/YYY", "9"); p.put("/XXX:/YYY", "9");
String[][] tests = { String[][] tests = {
{ "/abs/path", "1"}, { "/abs/path", "1"},
{ "/abs/path/xxx", "8"},
{ "/abs/pith", "8"},
{ "/abs/path/longer", "2"},
{ "/abs/path/", "8"},
{ "/abs/path/xxx", "8"}, { "/abs/path/xxx", "8"},
{ "/animal/bird/eagle/bald", "3"}, { "/abs/pith", "8"},
{ "/abs/path/longer", "2"},
{ "/abs/path/", "8"},
{ "/abs/path/xxx", "8"},
{ "/animal/bird/eagle/bald", "3"},
{ "/animal/fish/shark/grey", "4"}, { "/animal/fish/shark/grey", "4"},
{ "/animal/insect/bug", "5"}, { "/animal/insect/bug", "5"},
{ "/animal", "5"}, { "/animal", "5"},
{ "/animal/", "5"}, { "/animal/", "5"},
{ "/animal/x", "5"}, { "/animal/x", "5"},
{ "/animal/*", "5"}, { "/animal/*", "5"},
{ "/suffix/path.tar.gz", "6"}, { "/suffix/path.tar.gz", "6"},
{ "/suffix/path.gz", "7"}, { "/suffix/path.gz", "7"},
{ "/animal/path.gz", "5"}, { "/animal/path.gz", "5"},
{ "/Other/path", "8"},}; { "/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")); assertEquals("Get absolute path", "1", p.get("/abs/path"));
@ -158,10 +129,11 @@ public class PathMapTest extends TestCase
/** /**
* See JIRA issue: JETTY-88. * See JIRA issue: JETTY-88.
*/ */
@Test
public void testPathMappingsOnlyMatchOnDirectoryNames() throws Exception public void testPathMappingsOnlyMatchOnDirectoryNames() throws Exception
{ {
String spec = "/xyz/*"; String spec = "/xyz/*";
assertMatch(spec, "/xyz"); assertMatch(spec, "/xyz");
assertMatch(spec, "/xyz/"); assertMatch(spec, "/xyz/");
assertMatch(spec, "/xyz/123"); assertMatch(spec, "/xyz/123");