Search in sources :

Example 56 with Test

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

the class HttpParserTest method testNoHost.

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

Example 57 with Test

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

the class HttpParserTest method testCachedField.

@Test
public void testCachedField() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.1\r\n" + "Host: www.smh.com.au\r\n" + "\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parseAll(parser, buffer);
    Assert.assertEquals("www.smh.com.au", parser.getFieldCache().get("Host: www.smh.com.au").getValue());
    HttpField field = _fields.get(0);
    buffer.position(0);
    parseAll(parser, buffer);
    Assert.assertTrue(field == _fields.get(0));
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 58 with Test

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

the class HttpParserTest method testEmptyHostPort.

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

Example 59 with Test

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

the class HttpParserTest method testFoldedField7230.

@Test
public void testFoldedField7230() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.0\r\n" + "Host: localhost\r\n" + "Name: value\r\n" + " extra\r\n" + "\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler, 4096, HttpCompliance.RFC7230);
    parseAll(parser, buffer);
    Assert.assertThat(_bad, Matchers.notNullValue());
    Assert.assertThat(_bad, Matchers.containsString("Header Folding"));
    Assert.assertNull(_complianceViolation);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 60 with Test

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

the class HttpParserTest method testBadContentLength1.

@Test
public void testBadContentLength1() throws Exception {
    ByteBuffer buffer = BufferUtil.toBuffer("GET / HTTP/1.0\r\n" + "Content-Length: 9999999999999999999999999999999999999999999999\r\n" + "Connection: close\r\n" + "\r\n");
    HttpParser.RequestHandler handler = new Handler();
    HttpParser parser = new HttpParser(handler);
    parser.parseNext(buffer);
    Assert.assertEquals("GET", _methodOrVersion);
    Assert.assertEquals("Invalid Content-Length Value", _bad);
    Assert.assertFalse(buffer.hasRemaining());
    Assert.assertEquals(HttpParser.State.CLOSE, parser.getState());
    parser.atEOF();
    parser.parseNext(BufferUtil.EMPTY_BUFFER);
    Assert.assertEquals(HttpParser.State.CLOSED, parser.getState());
}
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