-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add showcase test for endpoint context
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.google.showcase.v1beta1.it; | ||
|
||
import com.google.common.truth.Truth; | ||
import com.google.showcase.v1beta1.EchoClient; | ||
import com.google.showcase.v1beta1.EchoSettings; | ||
import com.google.showcase.v1beta1.it.util.TestClientInitializer; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** This IT tests the different user configurations allowed and their effects on | ||
* endpoint and universe domain resolution. | ||
* | ||
* <p>This test will be enhanced in the future when the settings are able to return | ||
* the resolved endpoint and universe domain values. | ||
*/ | ||
public class ITEndpointContext { | ||
public static final String SHOWCASE_DEFAULT_ENDPOINT = "localhost:7469"; | ||
|
||
// Default (no configuration) | ||
@Test | ||
public void endpointResolution_default() throws InterruptedException, IOException { | ||
EchoClient echoClient = null; | ||
try { | ||
echoClient = EchoClient.create(); | ||
Truth.assertThat(echoClient.getSettings().getEndpoint()).isEqualTo(SHOWCASE_DEFAULT_ENDPOINT); | ||
} finally { | ||
if (echoClient != null) { | ||
echoClient.close(); | ||
echoClient.awaitTermination(TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS); | ||
} | ||
} | ||
} | ||
|
||
// User configuration | ||
@Test | ||
public void endpointResolution_userConfiguration() throws InterruptedException, IOException { | ||
String customEndpoint = "test.com:123"; | ||
EchoClient echoClient = null; | ||
try { | ||
EchoSettings echoSettings = EchoSettings.newBuilder().setEndpoint(customEndpoint).build(); | ||
echoClient = EchoClient.create(echoSettings); | ||
Truth.assertThat(echoClient.getSettings().getEndpoint()).isEqualTo(customEndpoint); | ||
} finally { | ||
if (echoClient != null) { | ||
echoClient.close(); | ||
echoClient.awaitTermination(TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS); | ||
} | ||
} | ||
} | ||
|
||
// Default in Builder (no configuration) | ||
@Test | ||
public void endpointResolution_defaultBuilder() { | ||
EchoSettings.Builder echoSettingsBuilder = EchoSettings.newBuilder(); | ||
Truth.assertThat(echoSettingsBuilder.getEndpoint()).isEqualTo(SHOWCASE_DEFAULT_ENDPOINT); | ||
} | ||
|
||
// User configuration in Builder | ||
@Test | ||
public void endpointResolution_userConfigurationBuilder() { | ||
String customEndpoint = "test.com:123"; | ||
EchoSettings.Builder echoSettingsBuilder = EchoSettings.newBuilder().setEndpoint(customEndpoint); | ||
Truth.assertThat(echoSettingsBuilder.getEndpoint()).isEqualTo(customEndpoint); | ||
} | ||
} |