Search in sources :

Example 71 with Test

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

the class HttpParserTest method testBadIPv6Host.

@Test
public void testBadIPv6Host() throws Exception {
    try (StacklessLogging s = new StacklessLogging(HttpParser.class)) {
        ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.1\r\n" + "Host: [::1\r\n" + "Connection: close\r\n" + "\r\n");
        HttpParser.RequestHandler handler = new Handler();
        HttpParser parser = new HttpParser(handler);
        parser.parseNext(buffer);
        Assert.assertThat(_bad, Matchers.containsString("Bad"));
    }
}
Also used : StacklessLogging(org.eclipse.jetty.util.log.StacklessLogging) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 72 with Test

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

the class HttpParserTest method testIPv6Host.

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

Example 73 with Test

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

the class HttpParserTest method testResponseParse3.

@Test
public void testResponseParse3() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("HTTP/1.1 200\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("200", _uriOrStatus);
    Assert.assertEquals(null, _versionOrReason);
    Assert.assertEquals(_content.length(), 10);
    Assert.assertTrue(_headerCompleted);
    Assert.assertTrue(_messageCompleted);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 74 with Test

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

the class HttpParserTest method testChunkEarlyEOF.

@Test
public void testChunkEarlyEOF() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET /chunk HTTP/1.0\r\n" + "Header1: value1\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "a;\r\n" + "0123456789\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parser.atEOF();
    parseAll(parser, buffer);
    Assert.assertEquals("GET", _methodOrVersion);
    Assert.assertEquals("/chunk", _uriOrStatus);
    Assert.assertEquals("HTTP/1.0", _versionOrReason);
    Assert.assertEquals(1, _headers);
    Assert.assertEquals("Header1", _hdr[0]);
    Assert.assertEquals("value1", _val[0]);
    Assert.assertEquals("0123456789", _content);
    Assert.assertTrue(_early);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 75 with Test

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

the class HttpParserTest method testCaseSensitiveLegacy.

@Test
public void testCaseSensitiveLegacy() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("gEt / http/1.0\r\n" + "HOST: localhost\r\n" + "cOnNeCtIoN: ClOsE\r\n" + "\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler, -1, HttpCompliance.LEGACY);
    parseAll(parser, buffer);
    Assert.assertNull(_bad);
    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("cOnNeCtIoN", _hdr[1]);
    Assert.assertEquals("ClOsE", _val[1]);
    Assert.assertEquals(1, _headers);
    Assert.assertThat(_complianceViolation, Matchers.containsString("case sensitive"));
}
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