當前位置: 首頁>>代碼示例>>Java>>正文


Java JerseyClientBuilder類代碼示例

本文整理匯總了Java中io.dropwizard.client.JerseyClientBuilder的典型用法代碼示例。如果您正苦於以下問題:Java JerseyClientBuilder類的具體用法?Java JerseyClientBuilder怎麽用?Java JerseyClientBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JerseyClientBuilder類屬於io.dropwizard.client包,在下文中一共展示了JerseyClientBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Override
public void run(final BloopServerConfiguration configuration,
                final Environment environment) {
    final DBIFactory factory = new DBIFactory();
    final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "postgresql");
    final FlagDAO flagDAO = jdbi.onDemand(FlagDAO.class);
    final NearbyFlagDAO nearbyFlagDAO = jdbi.onDemand(NearbyFlagDAO.class);
    final PlayerDAO playerDAO = jdbi.onDemand(PlayerDAO.class);
    
    final Client client = new JerseyClientBuilder(environment).using(configuration.getJerseyClientConfiguration())
            .build(getName());
    final String firebaseKey = configuration.getFirebaseKey();
    
    environment.jersey().register(new FlagResource(flagDAO, nearbyFlagDAO, playerDAO, client, firebaseKey));
    environment.jersey().register(new PlayerResource(playerDAO, flagDAO));
}
 
開發者ID:BloopApp,項目名稱:BloopServer,代碼行數:17,代碼來源:BloopServerApplication.java

示例2: getNewSecureClient

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
protected Client getNewSecureClient(String keyStoreResourcePath) throws Exception {
    TlsConfiguration tlsConfiguration = new TlsConfiguration();
    tlsConfiguration.setKeyStorePath(new File(resourceFilePath(keyStoreResourcePath)));
    tlsConfiguration.setKeyStorePassword("notsecret");

    tlsConfiguration.setTrustStorePath(new File(resourceFilePath("tls/test-truststore.jks")));
    tlsConfiguration.setTrustStorePassword("notsecret");

    tlsConfiguration.setVerifyHostname(false);

    tlsConfiguration.setSupportedCiphers(Lists.newArrayList("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"));
    tlsConfiguration.setSupportedProtocols(Lists.newArrayList("TLSv1.2"));

    JerseyClientConfiguration configuration = new JerseyClientConfiguration();
    configuration.setTlsConfiguration(tlsConfiguration);
    configuration.setTimeout(Duration.seconds(30));
    configuration.setConnectionTimeout(Duration.seconds(30));
    configuration.setConnectionRequestTimeout(Duration.seconds(30));

    return new JerseyClientBuilder(USER_INFO_APP_RULE.getEnvironment())
            .using(configuration)
            .build(UUID.randomUUID().toString());
}
 
開發者ID:wdawson,項目名稱:dropwizard-auth-example,代碼行數:24,代碼來源:IntegrationTest.java

示例3: shouldReturn400WhenPassedNoEntityIdForMultiTenantApplication

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void shouldReturn400WhenPassedNoEntityIdForMultiTenantApplication() throws Exception {
    multiTenantApplication.before();
    Client client = new JerseyClientBuilder(multiTenantApplication.getEnvironment()).build("Test Client");

    setupComplianceToolWithEntityId(client, MULTI_ENTITY_ID_1);

    Response authnResponse = client
        .target(URI.create(String.format("http://localhost:%d/generate-request", multiTenantApplication.getLocalPort())))
        .request()
        .buildPost(Entity.json(new RequestGenerationBody(LevelOfAssurance.LEVEL_2, null)))
        .invoke();

    assertThat(authnResponse.getStatus()).isEqualTo(BAD_REQUEST.getStatusCode());

    multiTenantApplication.after();
}
 
開發者ID:alphagov,項目名稱:verify-service-provider,代碼行數:18,代碼來源:AuthnRequestAcceptanceTest.java

示例4: shouldReturn400WhenPassedInvalidEntityIdForMultiTenantApplication

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void shouldReturn400WhenPassedInvalidEntityIdForMultiTenantApplication() throws Exception {
    multiTenantApplication.before();
    Client client = new JerseyClientBuilder(multiTenantApplication.getEnvironment()).build("Test Client");

    setupComplianceToolWithEntityId(client, MULTI_ENTITY_ID_1);

    Response authnResponse = client
        .target(URI.create(String.format("http://localhost:%d/generate-request", multiTenantApplication.getLocalPort())))
        .request()
        .buildPost(Entity.json(new RequestGenerationBody(LevelOfAssurance.LEVEL_2, "not a valid entityID")))
        .invoke();

    assertThat(authnResponse.getStatus()).isEqualTo(BAD_REQUEST.getStatusCode());

    multiTenantApplication.after();
}
 
開發者ID:alphagov,項目名稱:verify-service-provider,代碼行數:18,代碼來源:AuthnRequestAcceptanceTest.java

示例5: shouldFailHealthcheckWhenMsaMetadataUnavailable

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void shouldFailHealthcheckWhenMsaMetadataUnavailable() {
    wireMockServer.stubFor(
        get(urlEqualTo("/matching-service/metadata"))
            .willReturn(aResponse()
                .withStatus(500)
            )
    );

    applicationTestSupport.before();
    Client client = new JerseyClientBuilder(applicationTestSupport.getEnvironment()).build("test client");

    Response response = client
        .target(URI.create(String.format(HEALTHCHECK_URL, applicationTestSupport.getLocalPort())))
        .request()
        .buildGet()
        .invoke();

    String expectedResult = "\"msaMetadata\":{\"healthy\":false";

    wireMockServer.verify(getRequestedFor(urlEqualTo("/matching-service/metadata")));

    assertThat(response.getStatus()).isEqualTo(INTERNAL_SERVER_ERROR.getStatusCode());
    assertThat(response.readEntity(String.class)).contains(expectedResult);
}
 
開發者ID:alphagov,項目名稱:verify-service-provider,代碼行數:26,代碼來源:MsaMetadataFeatureTest.java

示例6: shouldPassHealthcheckWhenMsaMetadataAvailable

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void shouldPassHealthcheckWhenMsaMetadataAvailable() {
    wireMockServer.stubFor(
        get(urlEqualTo("/matching-service/metadata"))
            .willReturn(aResponse()
                .withStatus(200)
                .withBody(MockMsaServer.msaMetadata())
            )
    );

    applicationTestSupport.before();
    Client client = new JerseyClientBuilder(applicationTestSupport.getEnvironment()).build("test client");

    Response response = client
        .target(URI.create(String.format(HEALTHCHECK_URL, applicationTestSupport.getLocalPort())))
        .request()
        .buildGet()
        .invoke();

    String expectedResult = "\"msaMetadata\":{\"healthy\":true";

    wireMockServer.verify(getRequestedFor(urlEqualTo("/matching-service/metadata")));

    assertThat(response.getStatus()).isEqualTo(OK.getStatusCode());
    assertThat(response.readEntity(String.class)).contains(expectedResult);
}
 
開發者ID:alphagov,項目名稱:verify-service-provider,代碼行數:27,代碼來源:MsaMetadataFeatureTest.java

示例7: shouldFailHealthcheckWhenHubMetadataUnavailable

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void shouldFailHealthcheckWhenHubMetadataUnavailable() {
    wireMockServer.stubFor(
        get(urlEqualTo("/SAML2/metadata"))
            .willReturn(aResponse()
                .withStatus(500)
            )
    );

    applicationTestSupport.before();
    Client client = new JerseyClientBuilder(applicationTestSupport.getEnvironment()).build("test client");

    Response response = client
        .target(URI.create(String.format(HEALTHCHECK_URL, applicationTestSupport.getLocalPort())))
        .request()
        .buildGet()
        .invoke();

    String expectedResult = "\"hubMetadata\":{\"healthy\":false";

    wireMockServer.verify(getRequestedFor(urlEqualTo("/SAML2/metadata")));

    assertThat(response.getStatus()).isEqualTo(INTERNAL_SERVER_ERROR.getStatusCode());
    assertThat(response.readEntity(String.class)).contains(expectedResult);
}
 
開發者ID:alphagov,項目名稱:verify-service-provider,代碼行數:26,代碼來源:HubMetadataFeatureTest.java

示例8: run

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Override
public void run(HelloWorldConfiguration configuration,
        Environment environment) throws Exception {

    final Optional<HttpTracing> tracing = configuration.getZipkinFactory()
            .build(environment);

    final Client client;
    if (tracing.isPresent()) {
        client = new ZipkinClientBuilder(environment, tracing.get())
                .build(configuration.getZipkinClient());
    } else {
        final ZipkinClientConfiguration clientConfig = configuration
                .getZipkinClient();
        client = new JerseyClientBuilder(environment).using(clientConfig)
                .build(clientConfig.getServiceName());
    }

    // Register resources
    final HelloWorldResource resource = new HelloWorldResource(client);
    environment.jersey().register(resource);
}
 
開發者ID:smoketurner,項目名稱:dropwizard-zipkin,代碼行數:23,代碼來源:HelloWorldApplication.java

示例9: testHandleForward

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void testHandleForward() {
    Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test forward client");

    client.property(ClientProperties.CONNECT_TIMEOUT, 100000);
    client.property(ClientProperties.READ_TIMEOUT, 100000);

    Response response = client.target(
            String.format("http://localhost:%d/nominatim?q=berlin", RULE.getLocalPort()))
            .request()
            .get();

    assertThat(response.getStatus()).isEqualTo(200);
    GHResponse entry = response.readEntity(GHResponse.class);
    assertTrue(entry.getLocale().equals("en"));
}
 
開發者ID:graphhopper,項目名稱:geocoder-converter,代碼行數:17,代碼來源:ConverterResourceTest.java

示例10: testCorrectLocale

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void testCorrectLocale() {
    Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("testCorrectLocale");

    client.property(ClientProperties.CONNECT_TIMEOUT, 100000);
    client.property(ClientProperties.READ_TIMEOUT, 100000);

    Response response = client.target(
            String.format("http://localhost:%d/nominatim?q=berlin&locale=de", RULE.getLocalPort()))
            .request()
            .get();

    assertThat(response.getStatus()).isEqualTo(200);
    GHResponse entry = response.readEntity(GHResponse.class);
    assertTrue(entry.getLocale().equals("de"));
}
 
開發者ID:graphhopper,項目名稱:geocoder-converter,代碼行數:17,代碼來源:ConverterResourceTest.java

示例11: testCorrectLocaleCountry

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void testCorrectLocaleCountry() {
    Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("testCorrectLocaleCountry");

    client.property(ClientProperties.CONNECT_TIMEOUT, 100000);
    client.property(ClientProperties.READ_TIMEOUT, 100000);

    Response response = client.target(
            String.format("http://localhost:%d/nominatim?q=berlin&locale=de-ch", RULE.getLocalPort()))
            .request()
            .get();

    assertThat(response.getStatus()).isEqualTo(200);
    GHResponse entry = response.readEntity(GHResponse.class);
    assertTrue(entry.getLocale().equals("de-CH"));
}
 
開發者ID:graphhopper,項目名稱:geocoder-converter,代碼行數:17,代碼來源:ConverterResourceTest.java

示例12: testIncorrectLocale

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void testIncorrectLocale() {
    Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("testIncorrectLocale");

    client.property(ClientProperties.CONNECT_TIMEOUT, 100000);
    client.property(ClientProperties.READ_TIMEOUT, 100000);

    Response response = client.target(
            String.format("http://localhost:%d/nominatim?q=berlin&locale=IAmNotValid", RULE.getLocalPort()))
            .request()
            .get();

    assertThat(response.getStatus()).isEqualTo(200);
    GHResponse entry = response.readEntity(GHResponse.class);
    assertTrue(entry.getLocale().equals("en"));
}
 
開發者ID:graphhopper,項目名稱:geocoder-converter,代碼行數:17,代碼來源:ConverterResourceTest.java

示例13: testIncorrectLocaleCountry

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Test
public void testIncorrectLocaleCountry() {
    Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("testIncorrectLocaleCountry");

    client.property(ClientProperties.CONNECT_TIMEOUT, 100000);
    client.property(ClientProperties.READ_TIMEOUT, 100000);

    Response response = client.target(
            String.format("http://localhost:%d/nominatim?q=berlin&locale=de-zz", RULE.getLocalPort()))
            .request()
            .get();

    assertThat(response.getStatus()).isEqualTo(200);
    GHResponse entry = response.readEntity(GHResponse.class);
    assertTrue(entry.getLocale().equals("en"));
}
 
開發者ID:graphhopper,項目名稱:geocoder-converter,代碼行數:17,代碼來源:ConverterResourceTest.java

示例14: run

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
@Override
public void run(HaraHachiBuConfiguration config, Environment environment) throws Exception {
	// Set up the Jersey client - required for HTTP client interactions
	final Client client = new JerseyClientBuilder(environment)
			.using(config.getJerseyClient())
			.build(getName());
	// Build the disk space checker instance -
	// this may add new resources and healthchecks to the environment.
	final DiskSpaceChecker checker = new DiskSpaceCheckerBuilder(environment, client, config.getDiskSpace()).build();

	// Set up the disk space filter
	environment.servlets()
			.addFilter("diskSpaceFilter", new DiskSpaceFilter(checker, config.getProxy(), "/setSpace"))
			.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

	// Set up the proxy servlet - requires some additional configuration
	ServletRegistration.Dynamic diskSpaceProxyServlet = environment.servlets().addServlet("diskSpaceProxyServlet", new DiskSpaceProxyServlet());
	diskSpaceProxyServlet.setInitParameter(DiskSpaceProxyServlet.DESTINATION_SERVER_PARAM, config.getProxy().getDestinationServer());
	diskSpaceProxyServlet.addMapping(DiskSpaceProxyServlet.PROXY_PATH_PREFIX + "/*");

	// Add healthcheck
	environment.healthChecks().register("Generic disk space checker", new DiskSpaceCheckerHealthCheck(checker));
}
 
開發者ID:flaxsearch,項目名稱:harahachibu,代碼行數:24,代碼來源:HaraHachiBuApplication.java

示例15: BaseClient

import io.dropwizard.client.JerseyClientBuilder; //導入依賴的package包/類
public BaseClient(Environment environment, ClientConfiguration clientConfiguration,
                        JerseyClientConfiguration jerseyClientConfiguration, String clientName) {
    httpClient = new JerseyClientBuilder(environment)
            .using(jerseyClientConfiguration)
            .build(clientName);

    StringBuilder targetBuilder = new StringBuilder();

    String target = targetBuilder.append(clientConfiguration.host)
            .append(':')
            .append(clientConfiguration.port)
            .append('/')
            .append(clientConfiguration.serviceContext).toString();

    webTarget = httpClient.target(target);
}
 
開發者ID:KainosSoftwareLtd,項目名稱:sample-dropwizard-service,代碼行數:17,代碼來源:BaseClient.java


注:本文中的io.dropwizard.client.JerseyClientBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。