Search in sources :

Example 1 with AjpIgnore

use of io.undertow.testutils.AjpIgnore in project undertow by undertow-io.

the class LotsOfQueryParametersTestCase method testLotsOfQueryParameters_MaxParameters_BadRequest.

@Test
@AjpIgnore
public void testLotsOfQueryParameters_MaxParameters_BadRequest() throws IOException {
    OptionMap existing = DefaultServer.getUndertowOptions();
    TestHttpClient client = new TestHttpClient();
    try {
        StringBuilder qs = new StringBuilder();
        // add query parameters more than specified MAX_PARAMETERS
        for (int i = 0; i < (TEST_MAX_PARAMETERS + 1); ++i) {
            qs.append(QUERY + i);
            qs.append("=");
            qs.append(URLEncoder.encode(MESSAGE + i, "UTF-8"));
            qs.append("&");
        }
        // delete last useless '&'
        qs.deleteCharAt(qs.length() - 1);
        HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path?" + qs.toString());
        DefaultServer.setUndertowOptions(OptionMap.create(UndertowOptions.MAX_PARAMETERS, TEST_MAX_PARAMETERS));
        HttpResponse result = client.execute(get);
        Assert.assertEquals(StatusCodes.BAD_REQUEST, result.getStatusLine().getStatusCode());
    } finally {
        DefaultServer.setUndertowOptions(existing);
        client.getConnectionManager().shutdown();
    }
}
Also used : OptionMap(org.xnio.OptionMap) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test) AjpIgnore(io.undertow.testutils.AjpIgnore)

Example 2 with AjpIgnore

use of io.undertow.testutils.AjpIgnore in project undertow by undertow-io.

the class LotsOfQueryParametersTestCase method testLotsOfQueryParameters_MaxParameters_Ok.

@Test
@AjpIgnore
public void testLotsOfQueryParameters_MaxParameters_Ok() throws IOException {
    OptionMap existing = DefaultServer.getUndertowOptions();
    TestHttpClient client = new TestHttpClient();
    try {
        StringBuilder qs = new StringBuilder();
        for (int i = 0; i < TEST_MAX_PARAMETERS; ++i) {
            qs.append(QUERY + i);
            qs.append("=");
            qs.append(URLEncoder.encode(MESSAGE + i, "UTF-8"));
            qs.append("&");
        }
        // delete last useless '&'
        qs.deleteCharAt(qs.length() - 1);
        HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path?" + qs.toString());
        DefaultServer.setUndertowOptions(OptionMap.create(UndertowOptions.MAX_PARAMETERS, TEST_MAX_PARAMETERS));
        HttpResponse result = client.execute(get);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        for (int i = 0; i < TEST_MAX_PARAMETERS; ++i) {
            Header[] header = result.getHeaders(QUERY + i);
            Assert.assertEquals(MESSAGE + i, header[0].getValue());
        }
    } finally {
        DefaultServer.setUndertowOptions(existing);
        client.getConnectionManager().shutdown();
    }
}
Also used : Header(org.apache.http.Header) OptionMap(org.xnio.OptionMap) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test) AjpIgnore(io.undertow.testutils.AjpIgnore)

Example 3 with AjpIgnore

use of io.undertow.testutils.AjpIgnore in project undertow by undertow-io.

the class LotsOfHeadersRequestTestCase method testLotsOfHeadersInRequest_MaxHeaders_Ok.

@Test
@AjpIgnore
public void testLotsOfHeadersInRequest_MaxHeaders_Ok() throws IOException {
    OptionMap existing = DefaultServer.getUndertowOptions();
    TestHttpClient client = new TestHttpClient();
    try {
        HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path");
        for (int i = 0; i < getTestMaxHeaders(); ++i) {
            get.addHeader(HEADER + i, MESSAGE + i);
        }
        DefaultServer.setUndertowOptions(OptionMap.create(UndertowOptions.MAX_HEADERS, TEST_MAX_HEADERS));
        HttpResponse result = client.execute(get);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        for (int i = 0; i < getTestMaxHeaders(); ++i) {
            Header[] header = result.getHeaders(HEADER + i);
            Assert.assertEquals(MESSAGE + i, header[0].getValue());
        }
    } finally {
        DefaultServer.setUndertowOptions(existing);
        client.getConnectionManager().shutdown();
    }
}
Also used : Header(org.apache.http.Header) OptionMap(org.xnio.OptionMap) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test) AjpIgnore(io.undertow.testutils.AjpIgnore)

Example 4 with AjpIgnore

use of io.undertow.testutils.AjpIgnore in project undertow by undertow-io.

the class LotsOfHeadersRequestTestCase method testLotsOfHeadersInRequest_Default_Ok.

@Test
@AjpIgnore
public void testLotsOfHeadersInRequest_Default_Ok() throws IOException {
    TestHttpClient client = new TestHttpClient();
    try {
        HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path");
        for (int i = 0; i < getDefaultMaxHeaders(); ++i) {
            get.addHeader(HEADER + i, MESSAGE + i);
        }
        HttpResponse result = client.execute(get);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        for (int i = 0; i < getDefaultMaxHeaders(); ++i) {
            Header[] header = result.getHeaders(HEADER + i);
            Assert.assertEquals(MESSAGE + i, header[0].getValue());
        }
    } finally {
        client.getConnectionManager().shutdown();
    }
}
Also used : Header(org.apache.http.Header) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test) AjpIgnore(io.undertow.testutils.AjpIgnore)

Example 5 with AjpIgnore

use of io.undertow.testutils.AjpIgnore in project undertow by undertow-io.

the class LotsOfQueryParametersTestCase method testLotsOfQueryParameters_Default_Ok.

@Test
@AjpIgnore
public void testLotsOfQueryParameters_Default_Ok() throws IOException {
    TestHttpClient client = new TestHttpClient();
    try {
        StringBuilder qs = new StringBuilder();
        for (int i = 0; i < DEFAULT_MAX_PARAMETERS; ++i) {
            qs.append(QUERY + i);
            qs.append("=");
            qs.append(URLEncoder.encode(MESSAGE + i, "UTF-8"));
            qs.append("&");
        }
        // delete last useless '&'
        qs.deleteCharAt(qs.length() - 1);
        HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path?" + qs.toString());
        HttpResponse result = client.execute(get);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        for (int i = 0; i < DEFAULT_MAX_PARAMETERS; ++i) {
            Header[] header = result.getHeaders(QUERY + i);
            Assert.assertEquals(MESSAGE + i, header[0].getValue());
        }
    } finally {
        client.getConnectionManager().shutdown();
    }
}
Also used : Header(org.apache.http.Header) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test) AjpIgnore(io.undertow.testutils.AjpIgnore)

Aggregations

AjpIgnore (io.undertow.testutils.AjpIgnore)5 TestHttpClient (io.undertow.testutils.TestHttpClient)5 HttpResponse (org.apache.http.HttpResponse)5 HttpGet (org.apache.http.client.methods.HttpGet)5 Test (org.junit.Test)5 Header (org.apache.http.Header)4 OptionMap (org.xnio.OptionMap)3