@Test public void useToken() { if (!"false".equals(System.getenv("JVM_SDK_IT_SSL_VALIDATION"))) { final SphereClientFactory sphereClientFactory = SphereClientFactory.of(); final SphereApiConfig sphereClientConfig = getSphereClientConfig(); try(final SphereClient client = sphereClientFactory.createClientOfApiConfigAndAccessToken(sphereClientConfig, accessToken())){ final Project project = client.execute(ProjectGet.of()).toCompletableFuture().join(); assertThat(project.getKey()).isEqualTo(getSphereClientConfig().getProjectKey()); } } }
@Test public void useTokenAndReuseClient() { if (!"false".equals(System.getenv("JVM_SDK_IT_SSL_VALIDATION"))) { final SphereClientFactory sphereClientFactory = SphereClientFactory.of(); final SphereApiConfig sphereClientConfig = getSphereClientConfig(); final StateHttpClient httpClient = new StateHttpClient(newHttpClient()); try(final SphereClient client = sphereClientFactory.createClientOfApiConfigAndAccessToken(sphereClientConfig, accessToken(), httpClient)){ final Project project = client.execute(ProjectGet.of()).toCompletableFuture().join(); assertThat(project.getKey()).isEqualTo(getSphereClientConfig().getProjectKey()); assertThat(httpClient.isClosed()).isFalse(); } assertThat(httpClient.isClosed()).isFalse(); httpClient.close(); assertThat(httpClient.isClosed()).isTrue(); } }