Search in sources :

Example 66 with Test

use of org.junit.Test in project jetty.project by eclipse.

the class HttpParserTest method testContentLengthThenTransferEncodingChunked.

@Test
public void testContentLengthThenTransferEncodingChunked() {
    ByteBuffer buffer = BufferUtil.toBuffer("POST /chunk HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Length: 1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "1\r\n" + "X\r\n" + "0\r\n" + "\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parseAll(parser, buffer);
    Assert.assertEquals("POST", _methodOrVersion);
    Assert.assertEquals("/chunk", _uriOrStatus);
    Assert.assertEquals("HTTP/1.1", _versionOrReason);
    Assert.assertEquals("X", _content);
    Assert.assertTrue(_headerCompleted);
    Assert.assertTrue(_messageCompleted);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 67 with Test

use of org.junit.Test in project jetty.project by eclipse.

the class HttpParserTest method testLineParse3.

@Test
public void testLineParse3() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("POST /foڐ HTTP/1.0\r\n" + "\r\n", StandardCharsets.UTF_8);
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parseAll(parser, buffer);
    Assert.assertEquals("POST", _methodOrVersion);
    Assert.assertEquals("/foڐ", _uriOrStatus);
    Assert.assertEquals("HTTP/1.0", _versionOrReason);
    Assert.assertEquals(-1, _headers);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 68 with Test

use of org.junit.Test in project jetty.project by eclipse.

the class HttpParserTest method testResponseParse1.

@Test
public void testResponseParse1() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("HTTP/1.1 304 Not-Modified\r\n" + "Connection: close\r\n" + "\r\n");
    HttpParser.ResponseHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parser.parseNext(buffer);
    Assert.assertEquals("HTTP/1.1", _methodOrVersion);
    Assert.assertEquals("304", _uriOrStatus);
    Assert.assertEquals("Not-Modified", _versionOrReason);
    Assert.assertTrue(_headerCompleted);
    Assert.assertTrue(_messageCompleted);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 69 with Test

use of org.junit.Test in project jetty.project by eclipse.

the class HttpParserTest method testHeaderParseLF.

@Test
public void testHeaderParseLF() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.0\n" + "Host: localhost\n" + "Header1: value1\n" + "Header2:   value 2a value 2b  \n" + "Header3: 3\n" + "Header4:value4\n" + "Server5: notServer\n" + "HostHeader: notHost\n" + "Connection: close\n" + "Accept-Encoding: gzip, deflated\n" + "Accept: unknown\n" + "\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parseAll(parser, buffer);
    Assert.assertEquals("GET", _methodOrVersion);
    Assert.assertEquals("/", _uriOrStatus);
    Assert.assertEquals("HTTP/1.0", _versionOrReason);
    Assert.assertEquals("Host", _hdr[0]);
    Assert.assertEquals("localhost", _val[0]);
    Assert.assertEquals("Header1", _hdr[1]);
    Assert.assertEquals("value1", _val[1]);
    Assert.assertEquals("Header2", _hdr[2]);
    Assert.assertEquals("value 2a value 2b", _val[2]);
    Assert.assertEquals("Header3", _hdr[3]);
    Assert.assertEquals("3", _val[3]);
    Assert.assertEquals("Header4", _hdr[4]);
    Assert.assertEquals("value4", _val[4]);
    Assert.assertEquals("Server5", _hdr[5]);
    Assert.assertEquals("notServer", _val[5]);
    Assert.assertEquals("HostHeader", _hdr[6]);
    Assert.assertEquals("notHost", _val[6]);
    Assert.assertEquals("Connection", _hdr[7]);
    Assert.assertEquals("close", _val[7]);
    Assert.assertEquals("Accept-Encoding", _hdr[8]);
    Assert.assertEquals("gzip, deflated", _val[8]);
    Assert.assertEquals("Accept", _hdr[9]);
    Assert.assertEquals("unknown", _val[9]);
    Assert.assertEquals(9, _headers);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 70 with Test

use of org.junit.Test in project jetty.project by eclipse.

the class HttpParserTest method testIPHostPort.

@Test
public void testIPHostPort() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.1\r\n" + "Host: 192.168.0.1:8888\r\n" + "Connection: close\r\n" + "\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parser.parseNext(buffer);
    Assert.assertEquals("192.168.0.1", _host);
    Assert.assertEquals(8888, _port);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)597324 ArrayList (java.util.ArrayList)32672 QuickTest (com.hazelcast.test.annotation.QuickTest)27910 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)25464 File (java.io.File)24462 HashMap (java.util.HashMap)21030 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)19416 List (java.util.List)16717 IOException (java.io.IOException)13352 Map (java.util.Map)9238 Date (java.util.Date)9014 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8368 InputStream (java.io.InputStream)7753 Properties (java.util.Properties)7445 CountDownLatch (java.util.concurrent.CountDownLatch)7403 ByteArrayInputStream (java.io.ByteArrayInputStream)7401 HashSet (java.util.HashSet)7165 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6707 Response (javax.ws.rs.core.Response)6154 Ignore (org.junit.Ignore)5936