Search in sources :

Example 76 with Test

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

the class HttpParserTest method testIPv6HostPort.

@Test
public void testIPv6HostPort() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.1\r\n" + "Host: [::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("[::1]", _host);
    Assert.assertEquals(8888, _port);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 77 with Test

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

the class HttpParserTest method testResponseParse2.

@Test
public void testResponseParse2() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("HTTP/1.1 204 No-Content\r\n" + "Header: value\r\n" + "\r\n" + "HTTP/1.1 200 Correct\r\n" + "Content-Length: 10\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "0123456789\r\n");
    HttpParser.ResponseHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parser.parseNext(buffer);
    Assert.assertEquals("HTTP/1.1", _methodOrVersion);
    Assert.assertEquals("204", _uriOrStatus);
    Assert.assertEquals("No-Content", _versionOrReason);
    Assert.assertTrue(_headerCompleted);
    Assert.assertTrue(_messageCompleted);
    parser.reset();
    init();
    parser.parseNext(buffer);
    parser.atEOF();
    Assert.assertEquals("HTTP/1.1", _methodOrVersion);
    Assert.assertEquals("200", _uriOrStatus);
    Assert.assertEquals("Correct", _versionOrReason);
    Assert.assertEquals(_content.length(), 10);
    Assert.assertTrue(_headerCompleted);
    Assert.assertTrue(_messageCompleted);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 78 with Test

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

the class HttpParserTest method testNoValue.

@Test
public void testNoValue() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.0\r\n" + "Host: localhost\r\n" + "Name0: \r\n" + "Name1:\r\n" + "\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parseAll(parser, buffer);
    Assert.assertTrue(_headerCompleted);
    Assert.assertTrue(_messageCompleted);
    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("Name0", _hdr[1]);
    Assert.assertEquals("", _val[1]);
    Assert.assertEquals("Name1", _hdr[2]);
    Assert.assertEquals("", _val[2]);
    Assert.assertEquals(2, _headers);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 79 with Test

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

the class HttpParserTest method testLineParse1.

@Test
public void testLineParse1() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET /999\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parseAll(parser, buffer);
    Assert.assertEquals("HTTP/0.9 not supported", _bad);
    Assert.assertNull(_complianceViolation);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 80 with Test

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

the class HttpParserTest method testIPHost.

@Test
public void testIPHost() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.1\r\n" + "Host: 192.168.0.1\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(0, _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