Commit 0ea6b4b4 authored by Miguel Reboiro Jato's avatar Miguel Reboiro Jato

Improves format of HTTPRequest tests

The request has been reformated for a better readibility.
parent b8696138
...@@ -40,39 +40,54 @@ public class HTTPBadRequestsTest { ...@@ -40,39 +40,54 @@ public class HTTPBadRequestsTest {
arguments( arguments(
named( named(
"Missing method", "Missing method",
"/hello HTTP/1.1\r\n" + "Host: localhost\r\n" + "Accept: text/html\r\n" "/hello HTTP/1.1\r\n"
+ "Accept-Encoding: gzip,deflate\r\n" + "Host: localhost\r\n"
+ "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"
) )
), ),
arguments( arguments(
named( named(
"Missing resource", "Missing resource",
"GET HTTP/1.1\r\n" + "Host: localhost\r\n" + "Accept: text/html\r\n" + "Accept-Encoding: gzip,deflate\r\n" "GET HTTP/1.1\r\n"
+ "Host: localhost\r\n"
+ "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"
) )
), ),
arguments( arguments(
named( named(
"Missing version", "Missing version",
"GET /hello\r\n" + "Host: localhost\r\n" + "Accept: text/html\r\n" + "Accept-Encoding: gzip,deflate\r\n" "GET /hello\r\n"
+ "Host: localhost\r\n"
+ "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"
) )
), ),
arguments( arguments(
named( named(
"Missing first line", "Host: localhost\r\n" + "Accept: text/html\r\n" + "Accept-Encoding: gzip,deflate\r\n" "Missing first line",
"Host: localhost\r\n"
+ "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"
) )
), ),
arguments( arguments(
named( named(
"Invalid header", "Invalid header",
"GET /hello/world.html?country=Spain&province=Ourense&city=Ourense HTTP/1.1\r\n" + "Host\r\n" "GET /hello/world.html?country=Spain&province=Ourense&city=Ourense HTTP/1.1\r\n"
+ "Accept: text/html\r\n" + "Accept-Encoding: gzip,deflate\r\n" + "Host\r\n"
+ "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"
) )
), ),
arguments( arguments(
named( named(
"Missing new line after header", "Missing new line after header",
"GET /hello/world.html?country=Spain&province=Ourense&city=Ourense HTTP/1.1" + "Host: localhost\r\n" "GET /hello/world.html?country=Spain&province=Ourense&city=Ourense HTTP/1.1"
+ "Accept: text/html\r\n" + "Accept-Encoding: gzip,deflate\r\n" + "Host: localhost\r\n"
+ "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"
) )
) )
); );
......
...@@ -26,8 +26,10 @@ public class HTTPRequestGETParametersTest { ...@@ -26,8 +26,10 @@ public class HTTPRequestGETParametersTest {
@BeforeEach @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
requestText = "GET /hello/world.html?country=Spain&province=Ourense&city=Ourense HTTP/1.1\r\n" requestText =
+ "Host: localhost\r\n" + "Accept: text/html\r\n" "GET /hello/world.html?country=Spain&province=Ourense&city=Ourense HTTP/1.1\r\n"
+ "Host: localhost\r\n"
+ "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"; + "Accept-Encoding: gzip,deflate\r\n";
request = new HTTPRequest(new StringReader(requestText + "\r\n")); request = new HTTPRequest(new StringReader(requestText + "\r\n"));
......
...@@ -27,7 +27,8 @@ public class HTTPRequestGETResourceTest { ...@@ -27,7 +27,8 @@ public class HTTPRequestGETResourceTest {
@BeforeEach @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
this.requestText = "GET /hello HTTP/1.1\r\n" this.requestText =
"GET /hello HTTP/1.1\r\n"
+ "Host: localhost\r\n" + "Host: localhost\r\n"
+ "Accept: text/html\r\n" + "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"; + "Accept-Encoding: gzip,deflate\r\n";
......
...@@ -27,7 +27,8 @@ public class HTTPRequestGETResourcesTest { ...@@ -27,7 +27,8 @@ public class HTTPRequestGETResourcesTest {
@BeforeEach @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
this.requestText = "GET /hello/world.html HTTP/1.1\r\n" this.requestText =
"GET /hello/world.html HTTP/1.1\r\n"
+ "Host: localhost\r\n" + "Host: localhost\r\n"
+ "Accept: text/html\r\n" + "Accept: text/html\r\n"
+ "Accept-Encoding: gzip,deflate\r\n"; + "Accept-Encoding: gzip,deflate\r\n";
......
...@@ -27,7 +27,8 @@ public class HTTPRequestGETRootTest { ...@@ -27,7 +27,8 @@ public class HTTPRequestGETRootTest {
@BeforeEach @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
this.requestText = "GET / HTTP/1.1\r\n" this.requestText =
"GET / HTTP/1.1\r\n"
+ "Host: localhost\r\n"; + "Host: localhost\r\n";
this.request = new HTTPRequest(new StringReader(this.requestText + "\r\n")); this.request = new HTTPRequest(new StringReader(this.requestText + "\r\n"));
......
...@@ -27,16 +27,20 @@ public class HTTPRequestPOSTEncodedTest { ...@@ -27,16 +27,20 @@ public class HTTPRequestPOSTEncodedTest {
@BeforeEach @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
this.requestText = "POST / HTTP/1.1\r\n" this.requestText =
"POST / HTTP/1.1\r\n"
+ "Host: localhost\r\n" + "Host: localhost\r\n"
+ "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Content-Length: 116\r\n\r\n" + "Content-Length: 116\r\n"
+ "\r\n"
+ "message=Hello world!!&mensaje=¡¡Hola mundo!!&mensaxe=Ola mundo!!&mensagem=Olá mundo!!"; + "message=Hello world!!&mensaje=¡¡Hola mundo!!&mensaxe=Ola mundo!!&mensagem=Olá mundo!!";
this.encodedRequestText = "POST / HTTP/1.1\r\n" this.encodedRequestText =
"POST / HTTP/1.1\r\n"
+ "Host: localhost\r\n" + "Host: localhost\r\n"
+ "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Content-Length: 116\r\n\r\n" + "Content-Length: 116\r\n"
+ "\r\n"
+ "message=Hello+world%21%21&mensaje=%C2%A1%C2%A1Hola+mundo%21%21&mensaxe=Ola+mundo%21%21&mensagem=Ol%C3%A1+mundo%21%21"; + "message=Hello+world%21%21&mensaje=%C2%A1%C2%A1Hola+mundo%21%21&mensaxe=Ola+mundo%21%21&mensagem=Ol%C3%A1+mundo%21%21";
this.request = new HTTPRequest(new StringReader(this.encodedRequestText)); this.request = new HTTPRequest(new StringReader(this.encodedRequestText));
......
...@@ -25,9 +25,11 @@ public class HTTPRequestPOSTMultipleParametersTest { ...@@ -25,9 +25,11 @@ public class HTTPRequestPOSTMultipleParametersTest {
@BeforeEach @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
this.requestText = "POST /resource HTTP/1.1\r\n" this.requestText =
"POST /resource HTTP/1.1\r\n"
+ "Host: localhost\r\n" + "Host: localhost\r\n"
+ "Content-Length: 85\r\n\r\n" + "Content-Length: 85\r\n"
+ "\r\n"
+ "message=Hello world!!&mensaje=¡¡Hola mundo!!&mensaxe=Ola mundo!!&mensagem=Olá mundo!!"; + "message=Hello world!!&mensaje=¡¡Hola mundo!!&mensaxe=Ola mundo!!&mensagem=Olá mundo!!";
this.request = new HTTPRequest(new StringReader(this.requestText)); this.request = new HTTPRequest(new StringReader(this.requestText));
......
...@@ -26,9 +26,11 @@ public class HTTPRequestPOSTOneParameterTest { ...@@ -26,9 +26,11 @@ public class HTTPRequestPOSTOneParameterTest {
@BeforeEach @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
this.requestText = "POST / HTTP/1.1\r\n" this.requestText =
"POST / HTTP/1.1\r\n"
+ "Host: localhost\r\n" + "Host: localhost\r\n"
+ "Content-Length: 21\r\n\r\n" + "Content-Length: 21\r\n"
+ "\r\n"
+ "message=Hello world!!"; + "message=Hello world!!";
this.request = new HTTPRequest(new StringReader(this.requestText)); this.request = new HTTPRequest(new StringReader(this.requestText));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment