Fixes #308848 (Update test suite to JUnit4 - Module jetty-ajp).
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1594 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
dcca9fe13d
commit
9245ebff82
|
@ -54,7 +54,7 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
|
||||
with a snapshot. -->
|
||||
<plugin>
|
||||
|
@ -73,6 +73,7 @@
|
|||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit4-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// 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
|
||||
// The Apache License v2.0 is available at
|
||||
// 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.ajp;
|
||||
|
@ -18,26 +18,31 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Ajp13ConnectionTest extends TestCase
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class Ajp13ConnectionTest
|
||||
{
|
||||
private Server _server;
|
||||
private Ajp13SocketConnector _connector;
|
||||
private static Server _server;
|
||||
private static Ajp13SocketConnector _connector;
|
||||
private Socket _client;
|
||||
|
||||
protected void setUp() throws Exception
|
||||
@BeforeClass
|
||||
public static void startServer() throws Exception
|
||||
{
|
||||
_server=new Server();
|
||||
_connector=new Ajp13SocketConnector();
|
||||
|
@ -47,18 +52,28 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
_server.setConnectors(new Connector[] { _connector });
|
||||
_server.setHandler(new Handler());
|
||||
_server.start();
|
||||
|
||||
_client=new Socket("localhost",_connector.getLocalPort());
|
||||
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception
|
||||
@AfterClass
|
||||
public static void stopServer() throws Exception
|
||||
{
|
||||
_client.close();
|
||||
_connector.close();
|
||||
_server.stop();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void openSocket() throws Exception
|
||||
{
|
||||
_client=new Socket("localhost",_connector.getLocalPort());
|
||||
}
|
||||
|
||||
@After
|
||||
public void closeSocket() throws Exception
|
||||
{
|
||||
_client.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPacket1() throws Exception
|
||||
{
|
||||
OutputStream os=_client.getOutputStream();
|
||||
|
@ -71,6 +86,7 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPacket2() throws Exception
|
||||
{
|
||||
OutputStream os=_client.getOutputStream();
|
||||
|
@ -83,6 +99,7 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPacket3() throws Exception
|
||||
{
|
||||
OutputStream os=_client.getOutputStream();
|
||||
|
@ -95,6 +112,7 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSSLPacketWithIntegerKeySize() throws Exception
|
||||
{
|
||||
OutputStream os=_client.getOutputStream();
|
||||
|
@ -107,6 +125,7 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSSLPacketWithStringKeySize() throws Exception
|
||||
{
|
||||
OutputStream os=_client.getOutputStream();
|
||||
|
@ -119,19 +138,21 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPacketWithBody() throws Exception
|
||||
{
|
||||
OutputStream os=_client.getOutputStream();
|
||||
|
||||
os.write(TypeUtil.fromHexString(getTestHeader()));
|
||||
os.write(TypeUtil.fromHexString(getTestHeader()));
|
||||
os.write(TypeUtil.fromHexString(getTestShortBody()));
|
||||
os.write(TypeUtil.fromHexString(getTestTinyBody()));
|
||||
|
||||
|
||||
readResponse(_client);
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPacketWithChunkedBody() throws Exception
|
||||
{
|
||||
OutputStream os=_client.getOutputStream();
|
||||
|
@ -261,13 +282,13 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
private String getTestTinyBody()
|
||||
{
|
||||
StringBuffer body = new StringBuffer("");
|
||||
|
||||
|
||||
body.append("123400042d2d0d0a");
|
||||
|
||||
|
||||
return body.toString();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO: char array instead of string?
|
||||
private String readResponse(Socket _client) throws IOException
|
||||
{
|
||||
|
@ -284,7 +305,7 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
sb.append(line);
|
||||
sb.append('\n');
|
||||
}
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
finally
|
||||
|
@ -295,7 +316,7 @@ public class Ajp13ConnectionTest extends TestCase
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Handler extends AbstractHandler
|
||||
{
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
|
|
|
@ -4,48 +4,51 @@
|
|||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// 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
|
||||
// The Apache License v2.0 is available at
|
||||
// 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.ajp;
|
||||
|
||||
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.EndPoint;
|
||||
import org.eclipse.jetty.io.SimpleBuffers;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestAjpParser extends TestCase
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TestAjpParser
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testPacket1() throws Exception
|
||||
{
|
||||
String packet = "123401070202000f77696474683d20485454502f312e300000122f636f6e74726f6c2f70726f647563742f2200000e3230382e32372e3230332e31323800ffff000c7777772e756c74612e636f6d000050000005a006000a6b6565702d616c69766500a00b000c7777772e756c74612e636f6d00a00e002b4d6f7a696c6c612f342e302028636f6d70617469626c653b20426f726465724d616e6167657220332e302900a0010043696d6167652f6769662c20696d6167652f782d786269746d61702c20696d6167652f6a7065672c20696d6167652f706a7065672c20696d6167652f706d672c202a2f2a00a008000130000600067570726f64310008000a4145533235362d53484100ff";
|
||||
byte[] src = TypeUtil.fromHexString(packet);
|
||||
|
||||
|
||||
ByteArrayBuffer buffer= new ByteArrayBuffer(Ajp13Packet.MAX_PACKET_SIZE);
|
||||
SimpleBuffers buffers=new SimpleBuffers(buffer,null);
|
||||
|
||||
|
||||
EndPoint endp = new ByteArrayEndPoint(src,Ajp13Packet.MAX_PACKET_SIZE);
|
||||
|
||||
|
||||
Ajp13Parser parser = new Ajp13Parser(buffers,endp);
|
||||
parser.setEventHandler(new EH());
|
||||
parser.setGenerator(new Ajp13Generator(buffers,endp));
|
||||
|
||||
|
||||
parser.parseAvailable();
|
||||
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPacket2() throws Exception
|
||||
{
|
||||
String packet="1234020102020008485454502f312e3100000f2f6363632d7777777777772f61616100000c38382e3838382e38382e383830ffff00116363632e6363636363636363632e636f6d0001bb010009a00b00116363632e6363636363636363632e636f6d00a00e005a4d6f7a696c6c612f352e30202857696e646f77733b20553b2057696e646f7773204e5420352e313b20656e2d55533b2072763a312e382e312e3129204765636b6f2f32303036313230342046697265666f782f322e302e302e3100a0010063746578742f786d6c2c6170706c69636174696f6e2f786d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c746578742f68746d6c3b713d302e392c746578742f706c61696e3b713d302e382c696d6167652f706e672c2a2f2a3b713d302e3500a004000e656e2d75732c656e3b713d302e3500a003000c677a69702c6465666c61746500a002001e49534f2d383835392d312c7574662d383b713d302e372c2a3b713d302e3700000a4b6565702d416c69766500000333303000a006000a6b6565702d616c69766500000c4d61782d466f7277617264730000023130000800124448452d5253412d4145533235362d5348410009004039324643303544413043444141443232303137413743443141453939353132413330443938363838423843433041454643364231363035323543433232353341000b0100ff";
|
||||
|
@ -58,8 +61,9 @@ public class TestAjpParser extends TestCase
|
|||
parser.setGenerator(new Ajp13Generator(buffers,endp));
|
||||
parser.parse();
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPacket3() throws Exception
|
||||
{
|
||||
String packet="1234028f02020008485454502f312e3100000d2f666f726d746573742e6a737000000d3139322e3136382e342e31383000ffff00107777772e777265636b6167652e6f726700005000000aa0010063746578742f786d6c2c6170706c69636174696f6e2f786d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c746578742f68746d6c3b713d302e392c746578742f706c61696e3b713d302e382c696d6167652f706e672c2a2f2a3b713d302e3500a00200075554462d382c2a00a003000c677a69702c6465666c61746500a004000e656e2d67622c656e3b713d302e3500a006000a6b6565702d616c69766500a00900f95048505345535349443d37626361383232616638333466316465373663633630336366636435313938633b20667041757468436f6f6b69653d433035383430394537393344364245434633324230353234344242303039343230383344443645443533304230454637464137414544413745453231313538333745363033454435364332364446353531383635333335423433374531423637414641343533364345304546323342333642323133374243423932333943363631433131443330393842333938414546334546334146454344423746353842443b204a53455353494f4e49443d7365366331623864663432762e6a657474793300a00b00107777772e777265636b6167652e6f726700000a6b6565702d616c69766500000333303000a00e00654d6f7a696c6c612f352e3020285831313b20553b204c696e7578207838365f36343b20656e2d55533b2072763a312e382e302e3929204765636b6f2f3230303631323035202844656269616e2d312e382e302e392d3129204570697068616e792f322e313400a008000130000600066a657474793300ff";
|
||||
|
@ -73,79 +77,80 @@ public class TestAjpParser extends TestCase
|
|||
parser.parse();
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSSLPacketWithIntegerKeySize() throws Exception
|
||||
{
|
||||
String packet = "1234025002020008485454502f312e3100000f2f746573742f64756d702f696e666f00000e3139322e3136382e3130302e343000ffff000c776562746964652d746573740001bb01000ca00b000c776562746964652d7465737400a00e005a4d6f7a696c6c612f352e30202857696e646f77733b20553b2057696e646f7773204e5420352e313b20656e2d55533b2072763a312e382e312e3129204765636b6f2f32303036313230342046697265666f782f322e302e302e3100a0010063746578742f786d6c2c6170706c69636174696f6e2f786d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c746578742f68746d6c3b713d302e392c746578742f706c61696e3b713d302e382c696d6167652f706e672c2a2f2a3b713d302e3500a004000e656e2d75732c656e3b713d302e3500a003000c677a69702c6465666c61746500a002001e49534f2d383835392d312c7574662d383b713d302e372c2a3b713d302e3700000a4b6565702d416c69766500000333303000a006000a6b6565702d616c69766500a00d001a68747470733a2f2f776562746964652d746573742f746573742f00a00900174a53455353494f4e49443d69326c6e307539773573387300000d43616368652d436f6e74726f6c0000096d61782d6167653d3000000c4d61782d466f7277617264730000023130000800124448452d5253412d4145533235362d5348410009004032413037364245323330433238393130383941414132303631344139384441443131314230323132343030374130363642454531363742303941464337383942000b0100ff";
|
||||
byte[] src = TypeUtil.fromHexString(packet);
|
||||
|
||||
|
||||
ByteArrayBuffer buffer= new ByteArrayBuffer(Ajp13Packet.MAX_PACKET_SIZE);
|
||||
SimpleBuffers buffers=new SimpleBuffers(buffer,null);
|
||||
|
||||
|
||||
EndPoint endp = new ByteArrayEndPoint(src,Ajp13Packet.MAX_PACKET_SIZE);
|
||||
|
||||
|
||||
Ajp13Parser parser = new Ajp13Parser(buffers,endp);
|
||||
parser.setEventHandler(new EH());
|
||||
parser.setGenerator(new Ajp13Generator(buffers,endp));
|
||||
|
||||
|
||||
parser.parseAvailable();
|
||||
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSSLPacketWithStringKeySize() throws Exception
|
||||
{
|
||||
String packet = "1234025002020008485454502f312e3100000f2f746573742f64756d702f696e666f00000e3139322e3136382e3130302e343000ffff000c776562746964652d746573740001bb01000ca00b000c776562746964652d7465737400a00e005a4d6f7a696c6c612f352e30202857696e646f77733b20553b2057696e646f7773204e5420352e313b20656e2d55533b2072763a312e382e312e3129204765636b6f2f32303036313230342046697265666f782f322e302e302e3100a0010063746578742f786d6c2c6170706c69636174696f6e2f786d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c746578742f68746d6c3b713d302e392c746578742f706c61696e3b713d302e382c696d6167652f706e672c2a2f2a3b713d302e3500a004000e656e2d75732c656e3b713d302e3500a003000c677a69702c6465666c61746500a002001e49534f2d383835392d312c7574662d383b713d302e372c2a3b713d302e3700000a4b6565702d416c69766500000333303000a006000a6b6565702d616c69766500a00d001a68747470733a2f2f776562746964652d746573742f746573742f00a00900174a53455353494f4e49443d69326c6e307539773573387300000d43616368652d436f6e74726f6c0000096d61782d6167653d3000000c4d61782d466f7277617264730000023130000800124448452d5253412d4145533235362d5348410009004032413037364245323330433238393130383941414132303631344139384441443131314230323132343030374130363642454531363742303941464337383942000b000332353600ff";
|
||||
byte[] src = TypeUtil.fromHexString(packet);
|
||||
|
||||
|
||||
ByteArrayBuffer buffer= new ByteArrayBuffer(Ajp13Packet.MAX_PACKET_SIZE);
|
||||
SimpleBuffers buffers=new SimpleBuffers(buffer,null);
|
||||
|
||||
|
||||
EndPoint endp = new ByteArrayEndPoint(src,Ajp13Packet.MAX_PACKET_SIZE);
|
||||
|
||||
|
||||
Ajp13Parser parser = new Ajp13Parser(buffers,endp);
|
||||
parser.setEventHandler(new EH());
|
||||
parser.setGenerator(new Ajp13Generator(buffers,endp));
|
||||
|
||||
|
||||
parser.parseAvailable();
|
||||
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSSLPacketFragment() throws Exception
|
||||
{
|
||||
String packet = "1234025002020008485454502f312e3100000f2f746573742f64756d702f696e666f00000e3139322e3136382e3130302e343000ffff000c776562746964652d746573740001bb01000ca00b000c776562746964652d7465737400a00e005a4d6f7a696c6c612f352e30202857696e646f77733b20553b2057696e646f7773204e5420352e313b20656e2d55533b2072763a312e382e312e3129204765636b6f2f32303036313230342046697265666f782f322e302e302e3100a0010063746578742f786d6c2c6170706c69636174696f6e2f786d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c746578742f68746d6c3b713d302e392c746578742f706c61696e3b713d302e382c696d6167652f706e672c2a2f2a3b713d302e3500a004000e656e2d75732c656e3b713d302e3500a003000c677a69702c6465666c61746500a002001e49534f2d383835392d312c7574662d383b713d302e372c2a3b713d302e3700000a4b6565702d416c69766500000333303000a006000a6b6565702d616c69766500a00d001a68747470733a2f2f776562746964652d746573742f746573742f00a00900174a53455353494f4e49443d69326c6e307539773573387300000d43616368652d436f6e74726f6c0000096d61782d6167653d3000000c4d61782d466f7277617264730000023130000800124448452d5253412d4145533235362d5348410009004032413037364245323330433238393130383941414132303631344139384441443131314230323132343030374130363642454531363742303941464337383942000b0100ff";
|
||||
byte[] src = TypeUtil.fromHexString(packet);
|
||||
|
||||
|
||||
for (int f=1;f<src.length;f++)
|
||||
{
|
||||
byte[] frag0=new byte[src.length-f];
|
||||
byte[] frag1=new byte[f];
|
||||
|
||||
|
||||
System.arraycopy(src,0,frag0,0,src.length-f);
|
||||
System.arraycopy(src,src.length-f,frag1,0,f);
|
||||
|
||||
|
||||
ByteArrayBuffer buffer= new ByteArrayBuffer(Ajp13Packet.MAX_PACKET_SIZE);
|
||||
SimpleBuffers buffers=new SimpleBuffers(buffer,null);
|
||||
|
||||
|
||||
ByteArrayEndPoint endp = new ByteArrayEndPoint(frag0,Ajp13Packet.MAX_PACKET_SIZE);
|
||||
endp.setNonBlocking(true);
|
||||
|
||||
|
||||
Ajp13Parser parser = new Ajp13Parser(buffers,endp);
|
||||
parser.setEventHandler(new EH());
|
||||
parser.setGenerator(new Ajp13Generator(buffers,endp));
|
||||
parser.parseNext();
|
||||
|
||||
|
||||
endp.setIn(new ByteArrayBuffer(frag1));
|
||||
parser.parseAvailable();
|
||||
}
|
||||
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testPacketWithBody() throws Exception
|
||||
{
|
||||
String packet=getTestHeader();
|
||||
|
@ -154,7 +159,7 @@ public class TestAjpParser extends TestCase
|
|||
SimpleBuffers buffers=new SimpleBuffers(buffer,null);
|
||||
ByteArrayEndPoint endp=new ByteArrayEndPoint(src,Ajp13Packet.MAX_PACKET_SIZE);
|
||||
endp.setNonBlocking(true);
|
||||
|
||||
|
||||
final int count[]={0};
|
||||
Ajp13Generator gen = new Ajp13Generator(buffers,endp)
|
||||
{
|
||||
|
@ -167,29 +172,28 @@ public class TestAjpParser extends TestCase
|
|||
Ajp13Parser parser = new Ajp13Parser(buffers,endp);
|
||||
parser.setEventHandler(new EH());
|
||||
parser.setGenerator(gen);
|
||||
|
||||
|
||||
parser.parseNext();
|
||||
assertEquals(1,parser.getState());
|
||||
assertEquals(0,count[0]);
|
||||
|
||||
|
||||
endp.setIn(new ByteArrayBuffer(TypeUtil.fromHexString(getTestShortBody())));
|
||||
|
||||
parser.parseNext();
|
||||
assertEquals(1,parser.getState());
|
||||
assertEquals(1,count[0]);
|
||||
|
||||
|
||||
endp.setIn(new ByteArrayBuffer(TypeUtil.fromHexString(getTestTinyBody())));
|
||||
|
||||
parser.parseNext();
|
||||
parser.parseNext();
|
||||
assertEquals(0,parser.getState());
|
||||
assertEquals(1,count[0]);
|
||||
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testPacketWithChunkedBody() throws Exception
|
||||
{
|
||||
String packet="123400ff02040008485454502f312e3100000f2f746573742f64756d702f696e666f0000093132372e302e302e3100ffff00096c6f63616c686f7374000050000007a00e000d4a6176612f312e352e305f313100a00b00096c6f63616c686f737400a0010034746578742f68746d6c2c20696d6167652f6769662c20696d6167652f6a7065672c202a3b20713d2e322c202a2f2a3b20713d2e3200a006000a6b6565702d616c69766500a00700216170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640000115472616e736665722d456e636f64696e670000076368756e6b656400000c4d61782d466f727761726473000002313000ff";
|
||||
|
@ -198,7 +202,7 @@ public class TestAjpParser extends TestCase
|
|||
SimpleBuffers buffers=new SimpleBuffers(buffer,null);
|
||||
ByteArrayEndPoint endp=new ByteArrayEndPoint(src,Ajp13Packet.MAX_PACKET_SIZE);
|
||||
endp.setNonBlocking(true);
|
||||
|
||||
|
||||
final int count[]={0};
|
||||
Ajp13Generator gen = new Ajp13Generator(buffers,endp)
|
||||
{
|
||||
|
@ -211,105 +215,100 @@ public class TestAjpParser extends TestCase
|
|||
Ajp13Parser parser = new Ajp13Parser(buffers,endp);
|
||||
parser.setEventHandler(new EH());
|
||||
parser.setGenerator(gen);
|
||||
|
||||
|
||||
parser.parseNext();
|
||||
assertEquals(1,parser.getState());
|
||||
assertEquals(1,count[0]);
|
||||
|
||||
|
||||
endp.setIn(new ByteArrayBuffer(TypeUtil.fromHexString("1234007e007c7468656e616d653d746865253230717569636b25323062726f776e253230666f782532306a756d70732532306f766572253230746f2532307468652532306c617a79253230646f67253230544845253230515549434b25323042524f574e253230464f582532304a554d50532532304f564552253230544f25323054")));
|
||||
|
||||
while (parser.parseNext()>0);
|
||||
assertEquals(1,parser.getState());
|
||||
assertEquals(2,count[0]);
|
||||
|
||||
|
||||
endp.setIn(new ByteArrayBuffer(TypeUtil.fromHexString("12340042004048452532304c415a59253230444f472532302676616c75656f66323d6162636465666768696a6b6c6d6e6f707172737475767778797a31323334353637383930")));
|
||||
|
||||
while (parser.parseNext()>0);
|
||||
assertEquals(1,parser.getState());
|
||||
assertEquals(3,count[0]);
|
||||
|
||||
|
||||
endp.setIn(new ByteArrayBuffer(TypeUtil.fromHexString("123400020000")));
|
||||
|
||||
while (parser.getState()!=0 && parser.parseNext()>0);
|
||||
assertEquals(0,parser.getState());
|
||||
assertEquals(3,count[0]);
|
||||
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testPacketFragment() throws Exception
|
||||
{
|
||||
String packet = "123401070202000f77696474683d20485454502f312e300000122f636f6e74726f6c2f70726f647563742f2200000e3230382e32372e3230332e31323800ffff000c7777772e756c74612e636f6d000050000005a006000a6b6565702d616c69766500a00b000c7777772e756c74612e636f6d00a00e002b4d6f7a696c6c612f342e302028636f6d70617469626c653b20426f726465724d616e6167657220332e302900a0010043696d6167652f6769662c20696d6167652f782d786269746d61702c20696d6167652f6a7065672c20696d6167652f706a7065672c20696d6167652f706d672c202a2f2a00a008000130000600067570726f64310008000a4145533235362d53484100ff";
|
||||
byte[] src = TypeUtil.fromHexString(packet);
|
||||
|
||||
|
||||
for (int f=1;f<src.length;f++)
|
||||
{
|
||||
byte[] frag0=new byte[src.length-f];
|
||||
byte[] frag1=new byte[f];
|
||||
|
||||
|
||||
System.arraycopy(src,0,frag0,0,src.length-f);
|
||||
System.arraycopy(src,src.length-f,frag1,0,f);
|
||||
|
||||
|
||||
ByteArrayBuffer buffer= new ByteArrayBuffer(Ajp13Packet.MAX_PACKET_SIZE);
|
||||
SimpleBuffers buffers=new SimpleBuffers(buffer,null);
|
||||
|
||||
|
||||
ByteArrayEndPoint endp = new ByteArrayEndPoint(frag0,Ajp13Packet.MAX_PACKET_SIZE);
|
||||
endp.setNonBlocking(true);
|
||||
|
||||
|
||||
Ajp13Parser parser = new Ajp13Parser(buffers,endp);
|
||||
parser.setEventHandler(new EH());
|
||||
parser.setGenerator(new Ajp13Generator(buffers,endp));
|
||||
parser.parseNext();
|
||||
|
||||
|
||||
endp.setIn(new ByteArrayBuffer(frag1));
|
||||
parser.parseAvailable();
|
||||
}
|
||||
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testPacketFragmentWithBody() throws Exception
|
||||
{
|
||||
String packet = getTestHeader()+getTestBody();
|
||||
byte[] src = TypeUtil.fromHexString(packet);
|
||||
|
||||
|
||||
for (int f=1;f<src.length;f++)
|
||||
{
|
||||
byte[] frag0=new byte[src.length-f];
|
||||
byte[] frag1=new byte[f];
|
||||
|
||||
|
||||
System.arraycopy(src,0,frag0,0,src.length-f);
|
||||
System.arraycopy(src,src.length-f,frag1,0,f);
|
||||
|
||||
|
||||
ByteArrayBuffer buffer= new ByteArrayBuffer(Ajp13Packet.MAX_PACKET_SIZE);
|
||||
SimpleBuffers buffers=new SimpleBuffers(buffer,null);
|
||||
|
||||
|
||||
ByteArrayEndPoint endp = new ByteArrayEndPoint(frag0,Ajp13Packet.MAX_PACKET_SIZE);
|
||||
endp.setNonBlocking(true);
|
||||
|
||||
|
||||
Ajp13Parser parser = new Ajp13Parser(buffers,endp);
|
||||
parser.setEventHandler(new EH());
|
||||
parser.setGenerator(new Ajp13Generator(buffers,endp));
|
||||
parser.parseNext();
|
||||
|
||||
|
||||
endp.setIn(new ByteArrayBuffer(frag1));
|
||||
parser.parseAvailable();
|
||||
}
|
||||
|
||||
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getTestHeader()
|
||||
{
|
||||
StringBuffer header = new StringBuffer("");
|
||||
|
||||
|
||||
|
||||
header.append("1234026902040008485454502f31");
|
||||
header.append("2e310000162f61646d696e2f496d6167");
|
||||
header.append("6555706c6f61642e68746d00000a3130");
|
||||
|
@ -350,17 +349,13 @@ public class TestAjpParser extends TestCase
|
|||
header.append("3130000500176964303d4974656d2669");
|
||||
header.append("64313d32266964323d696d673200ff");
|
||||
|
||||
|
||||
return header.toString();
|
||||
|
||||
}
|
||||
|
||||
private String getTestBody()
|
||||
{
|
||||
StringBuffer body = new StringBuffer("");
|
||||
|
||||
|
||||
|
||||
|
||||
body.append("123402f902f72d2d2d2d2d2d2d2d");
|
||||
body.append("2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d");
|
||||
body.append("2d2d2d2d2d3934333833323534323630");
|
||||
|
@ -409,17 +404,15 @@ public class TestAjpParser extends TestCase
|
|||
body.append("0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d");
|
||||
body.append("2d2d2d2d2d2d2d2d2d2d2d2d2d2d3934");
|
||||
body.append("33383332353432363038372d2d0d0a");
|
||||
|
||||
|
||||
|
||||
return body.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String getTestShortBody()
|
||||
{
|
||||
StringBuffer body = new StringBuffer("");
|
||||
|
||||
|
||||
body.append("123402f702f52d2d2d2d2d2d2d2d");
|
||||
body.append("2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d");
|
||||
body.append("2d2d2d2d2d3934333833323534323630");
|
||||
|
@ -468,25 +461,20 @@ public class TestAjpParser extends TestCase
|
|||
body.append("0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d");
|
||||
body.append("2d2d2d2d2d2d2d2d2d2d2d2d2d2d3934");
|
||||
body.append("33383332353432363038372d2d");
|
||||
|
||||
|
||||
|
||||
return body.toString();
|
||||
|
||||
}
|
||||
private String getTestTinyBody()
|
||||
{
|
||||
StringBuffer body = new StringBuffer("");
|
||||
|
||||
|
||||
body.append("123400042d2d0d0a");
|
||||
|
||||
|
||||
return body.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class EH implements Ajp13Parser.EventHandler
|
||||
{
|
||||
|
||||
public void content(Buffer ref) throws IOException
|
||||
{
|
||||
// System.err.println(ref);
|
||||
|
@ -515,7 +503,7 @@ public class TestAjpParser extends TestCase
|
|||
public void parsedProtocol(Buffer protocol) throws IOException
|
||||
{
|
||||
// System.err.println(protocol);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void parsedQueryString(Buffer value) throws IOException
|
||||
|
@ -526,13 +514,13 @@ public class TestAjpParser extends TestCase
|
|||
public void parsedRemoteAddr(Buffer addr) throws IOException
|
||||
{
|
||||
// System.err.println("addr="+addr);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void parsedRemoteHost(Buffer host) throws IOException
|
||||
{
|
||||
// System.err.println("host="+host);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void parsedRequestAttribute(String key, Buffer value) throws IOException
|
||||
|
@ -542,7 +530,7 @@ public class TestAjpParser extends TestCase
|
|||
|
||||
public void parsedServerName(Buffer name) throws IOException
|
||||
{
|
||||
// System.err.println("Server:: "+name);
|
||||
// System.err.println("Server:: "+name);
|
||||
}
|
||||
|
||||
public void parsedServerPort(int port) throws IOException
|
||||
|
@ -552,7 +540,7 @@ public class TestAjpParser extends TestCase
|
|||
|
||||
public void parsedSslSecure(boolean secure) throws IOException
|
||||
{
|
||||
// System.err.println("Secure:: "+secure);
|
||||
// System.err.println("Secure:: "+secure);
|
||||
}
|
||||
|
||||
public void parsedUri(Buffer uri) throws IOException
|
||||
|
@ -604,13 +592,10 @@ public class TestAjpParser extends TestCase
|
|||
{
|
||||
// System.err.println(key+":: "+value);
|
||||
}
|
||||
|
||||
|
||||
public void parsedRequestAttribute(String key, int value) throws IOException
|
||||
{
|
||||
// System.err.println(key+":: "+value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
11
pom.xml
11
pom.xml
|
@ -19,6 +19,7 @@
|
|||
<ant-version>1.6.5</ant-version>
|
||||
<jta-spec-version>1.1.1</jta-spec-version>
|
||||
<junit-version>3.8.2</junit-version>
|
||||
<junit4-version>4.8.1</junit4-version>
|
||||
<mail-version>1.4</mail-version>
|
||||
<slf4j-version>1.5.10</slf4j-version>
|
||||
<eclipse-compiler-version>3.1.1</eclipse-compiler-version>
|
||||
|
@ -65,7 +66,7 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- Build helper maven plugin sets the parsedVersion.osgiVersion property -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
|
@ -80,7 +81,7 @@
|
|||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
@ -110,7 +111,7 @@
|
|||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
|
||||
<Bundle-DocURL>${jetty.url}</Bundle-DocURL>
|
||||
|
@ -134,7 +135,7 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- source maven plugin creates the source bundle and adds manifest -->
|
||||
<plugin>
|
||||
<inherited>true</inherited>
|
||||
|
@ -254,7 +255,7 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<!--
|
||||
<!--
|
||||
Usage:
|
||||
configure settings.xml for jetty.eclipse.website server entry
|
||||
> mvn -Paggregate-site javadoc:aggregate jxr:jxr
|
||||
|
|
Loading…
Reference in New Issue