Package org.glassfish.jersey.client

Examples of org.glassfish.jersey.client.ClientConfig


public class Main {
 
  public static void main( String[] args ) {
    String baseUrl = "https://api.github.com";
    ClientConfig config = new ClientConfig().register( new GitHubUserProvider() );
    GitHubUsers users = ConsumerFactory.createConsumer( baseUrl,
                                                        config,
                                                        GitHubUsers.class );
    System.out.println( users.getUser( "hstaudacher" ) );
  }
View Full Code Here


  public void testSimpleGetWithConfiguration() {
    driver.addExpectation( onRequestTo( "/test" ).withMethod( GET ),
                           giveResponse( "get", "text/plain" ).withStatus( 200 ) );
   
    FakeResource resource = ConsumerFactory.createConsumer( driver.getBaseUrl(),
                                                            new ClientConfig(),
                                                            FakeResource.class );
   
    assertEquals( "get", resource.getContent() );
  }
View Full Code Here

    ConsumerFactory.createConsumer( "http://localhost", null, IFakeResource.class );
  }
 
  @Test
  public void testRegistersMultipartFeature() {
    ClientConfig configuration = spy( new ClientConfig() );
   
    ConsumerFactory.createConsumer( "http://localhost", configuration, FakeFormDataResource.class );
   
    verify( configuration ).register( MultiPartFeature.class );
  }
View Full Code Here

    String postContent( String content );
  }
 
  @Before
  public void setUp() {
    ClientConfig config = new ClientConfig().register( new CustomProvider() );
    resource = ConsumerFactory.createConsumer( driver.getBaseUrl(), config, FakeResource.class );
  }
View Full Code Here

            this.appHandler = new ApplicationHandler(context.getResourceConfig());
        }

        @Override
        public ClientConfig getClientConfig() {
            return new ClientConfig().connectorProvider(new InMemoryConnector.Provider(baseUri, appHandler));
        }
View Full Code Here

        credentialsProvider.setCredentials(
                AuthScope.ANY,
                new UsernamePasswordCredentials("name", "password")
        );

        ClientConfig cc = new ClientConfig();
        cc.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider);
        cc.connectorProvider(new ApacheConnectorProvider());
        Client client = ClientBuilder.newClient(cc);
        WebTarget r = client.target(getBaseUri()).path("test");

        assertEquals("GET", r.request().get(String.class));
    }
View Full Code Here

        assertEquals("GET", r.request().get(String.class));
    }

    @Test
    public void testAuthGetWithClientFilter() {
        ClientConfig cc = new ClientConfig();
        cc.connectorProvider(new ApacheConnectorProvider());
        Client client = ClientBuilder.newClient(cc);
        client.register(HttpAuthenticationFeature.basic("name", "password"));
        WebTarget r = client.target(getBaseUri()).path("test/filter");

        assertEquals("GET", r.request().get(String.class));
View Full Code Here

        credentialsProvider.setCredentials(
                AuthScope.ANY,
                new UsernamePasswordCredentials("name", "password")
        );

        ClientConfig cc = new ClientConfig();
        cc.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider);
        cc.connectorProvider(new ApacheConnectorProvider());
        Client client = ClientBuilder.newClient(cc);
        WebTarget r = client.target(getBaseUri()).path("test");

        assertEquals("POST", r.request().post(Entity.text("POST"), String.class));
    }
View Full Code Here

        assertEquals("POST", r.request().post(Entity.text("POST"), String.class));
    }

    @Test
    public void testAuthPostWithClientFilter() {
        ClientConfig cc = new ClientConfig();
        cc.connectorProvider(new ApacheConnectorProvider());
        Client client = ClientBuilder.newClient(cc);
        client.register(HttpAuthenticationFeature.basic("name", "password"));
        WebTarget r = client.target(getBaseUri()).path("test/filter");

        assertEquals("POST", r.request().post(Entity.text("POST"), String.class));
View Full Code Here

        CredentialsProvider credentialsProvider = new org.apache.http.impl.client.BasicCredentialsProvider();
        credentialsProvider.setCredentials(
                AuthScope.ANY,
                new UsernamePasswordCredentials("name", "password")
        );
        ClientConfig cc = new ClientConfig();
        cc.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentialsProvider);
        cc.connectorProvider(new ApacheConnectorProvider());
        Client client = ClientBuilder.newClient(cc);
        WebTarget r = client.target(getBaseUri()).path("test");

        Response response = r.request().delete();
        assertEquals(response.getStatus(), 204);
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.client.ClientConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.