Search in sources :

Example 6 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project jersey by jersey.

the class RestrictedHeaderTest method testForbiddenHeadersWithApacheConnector.

/**
     * Same as {@link #testForbiddenHeadersAllowed()} ()} but uses {@link org.glassfish.jersey.apache.connector
     * .ApacheConnector} connector
     * which allows modification of these headers.
     */
@Test
public void testForbiddenHeadersWithApacheConnector() {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.connectorProvider(new ApacheConnectorProvider());
    Client client = ClientBuilder.newClient(clientConfig);
    testHeaders(client);
}
Also used : ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) ClientConfig(org.glassfish.jersey.client.ClientConfig) Client(javax.ws.rs.client.Client) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 7 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project jersey by jersey.

the class AbortingFilterTest method testAbortingFilterWithApacheConnector.

/**
     * The original reproted scenario with a different Connector.
     */
@Test
public void testAbortingFilterWithApacheConnector() {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.connectorProvider(new ApacheConnectorProvider());
    Client client = ClientBuilder.newClient(clientConfig);
    final Response response = client.target(getBaseUri()).path("/simple").request().get();
    int status = response.getStatus();
    logger.info("Response status is: " + status);
    assertEquals(status, Response.Status.UNAUTHORIZED.getStatusCode());
}
Also used : Response(javax.ws.rs.core.Response) ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) ClientConfig(org.glassfish.jersey.client.ClientConfig) Client(javax.ws.rs.client.Client) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 8 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project jersey by jersey.

the class SslConnectorConfigurationTest method testHTTPBasicAuth1.

/**
     * Test to see that HTTP 401 is returned when client tries to GET without
     * proper credentials.
     *
     * @throws Exception in case of a test failure.
     */
@Test
public void testHTTPBasicAuth1() throws Exception {
    final SSLContext sslContext = getSslContext();
    final ClientConfig cc = new ClientConfig().connectorProvider(new ApacheConnectorProvider());
    final Client client = ClientBuilder.newBuilder().withConfig(cc).sslContext(sslContext).build();
    final WebTarget target = client.target(Server.BASE_URI).register(LoggingFeature.class);
    final Response response = target.path("/").request().get(Response.class);
    assertEquals(401, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) SSLContext(javax.net.ssl.SSLContext) WebTarget(javax.ws.rs.client.WebTarget) ClientConfig(org.glassfish.jersey.client.ClientConfig) Client(javax.ws.rs.client.Client) Test(org.junit.Test)

Example 9 with ApacheConnectorProvider

use of org.glassfish.jersey.apache.connector.ApacheConnectorProvider in project jersey by jersey.

the class ApacheOsgiIntegrationTest method testSimpleResource.

@Test
public void testSimpleResource() throws Exception {
    final ResourceConfig resourceConfig = new ResourceConfig(ApacheOsgiTestResource.class);
    final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
    final ClientConfig clientConfig = new ClientConfig();
    clientConfig.connectorProvider(new ApacheConnectorProvider());
    final Client c = ClientBuilder.newClient(clientConfig);
    final Response response = c.target(baseUri).path("/apacheOsgiTest").request().buildGet().invoke();
    final String result = response.readEntity(String.class);
    assertEquals("OK", result);
    server.shutdownNow();
}
Also used : Response(javax.ws.rs.core.Response) HttpServer(org.glassfish.grizzly.http.server.HttpServer) ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) ClientConfig(org.glassfish.jersey.client.ClientConfig) Client(javax.ws.rs.client.Client) Test(org.junit.Test)

Aggregations

ApacheConnectorProvider (org.glassfish.jersey.apache.connector.ApacheConnectorProvider)9 ClientConfig (org.glassfish.jersey.client.ClientConfig)6 Client (javax.ws.rs.client.Client)5 Test (org.junit.Test)5 Response (javax.ws.rs.core.Response)3 SSLContext (javax.net.ssl.SSLContext)2 WebTarget (javax.ws.rs.client.WebTarget)2 JerseyTest (org.glassfish.jersey.test.JerseyTest)2 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)1 HttpServer (org.glassfish.grizzly.http.server.HttpServer)1 SseFeature (org.glassfish.jersey.media.sse.SseFeature)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1