Search in sources :

Example 6 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project wildfly by wildfly.

the class BeanValidationConfiguredGloballyTestCase method testInvalidRequestsAreAcceptedDependingOnGlobalValidationConfiguration.

@Test
public void testInvalidRequestsAreAcceptedDependingOnGlobalValidationConfiguration() throws Exception {
    DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());
    HttpGet get = new HttpGet(url + "myjaxrs/globally-configured-validate/3/disabled");
    HttpResponse result = client.execute(get);
    Assert.assertEquals("No constraint violated", 200, result.getStatusLine().getStatusCode());
    EntityUtils.consume(result.getEntity());
    get = new HttpGet(url + "myjaxrs/globally-configured-validate/3/enabled");
    result = client.execute(get);
    Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode());
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) Test(org.junit.Test)

Example 7 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project wildfly by wildfly.

the class BeanValidationIntegrationTestCase method testInvalidRequestCausingPropertyConstraintViolation.

@Test
public void testInvalidRequestCausingPropertyConstraintViolation() throws Exception {
    DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());
    HttpGet get = new HttpGet(url + "myjaxrs/another-validate/3");
    HttpResponse result = client.execute(get);
    Assert.assertEquals("Property constraint violated", 400, result.getStatusLine().getStatusCode());
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) Test(org.junit.Test)

Example 8 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project wildfly by wildfly.

the class BeanValidationIntegrationTestCase method testInvalidRequest.

@Test
public void testInvalidRequest() throws Exception {
    DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());
    HttpGet get = new HttpGet(url + "myjaxrs/validate/3");
    HttpResponse result = client.execute(get);
    Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode());
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) Test(org.junit.Test)

Example 9 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project wildfly by wildfly.

the class BeanValidationIntegrationTestCase method testInvalidResponse.

@Test
public void testInvalidResponse() throws Exception {
    DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());
    HttpGet get = new HttpGet(url + "myjaxrs/validate/11");
    HttpResponse result = client.execute(get);
    Assert.assertEquals("Return value constraint violated", 500, result.getStatusLine().getStatusCode());
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) Test(org.junit.Test)

Example 10 with PoolingClientConnectionManager

use of org.apache.http.impl.conn.PoolingClientConnectionManager in project wildfly by wildfly.

the class BeanValidationIntegrationTestCase method testInvalidRequestsAreAcceptedDependingOnValidationConfiguration.

@Test
public void testInvalidRequestsAreAcceptedDependingOnValidationConfiguration() throws Exception {
    DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());
    HttpGet get = new HttpGet(url + "myjaxrs/yet-another-validate/3/disabled");
    HttpResponse result = client.execute(get);
    Assert.assertEquals("No constraint violated", 200, result.getStatusLine().getStatusCode());
    EntityUtils.consume(result.getEntity());
    get = new HttpGet(url + "myjaxrs/yet-another-validate/3/enabled");
    result = client.execute(get);
    Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode());
}
Also used : PoolingClientConnectionManager(org.apache.http.impl.conn.PoolingClientConnectionManager) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) Test(org.junit.Test)

Aggregations

PoolingClientConnectionManager (org.apache.http.impl.conn.PoolingClientConnectionManager)22 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)19 HttpResponse (org.apache.http.HttpResponse)9 HttpGet (org.apache.http.client.methods.HttpGet)9 Test (org.junit.Test)9 Scheme (org.apache.http.conn.scheme.Scheme)7 ClientConnectionManager (org.apache.http.conn.ClientConnectionManager)6 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)6 SSLSocketFactory (org.apache.http.conn.ssl.SSLSocketFactory)6 IOException (java.io.IOException)4 CertificateException (java.security.cert.CertificateException)4 X509Certificate (java.security.cert.X509Certificate)3 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)3 TrustStrategy (org.apache.http.conn.ssl.TrustStrategy)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Activate (org.apache.felix.scr.annotations.Activate)2 ClientProtocolException (org.apache.http.client.ClientProtocolException)2 PlainSocketFactory (org.apache.http.conn.scheme.PlainSocketFactory)2