Skip to content

Commit f46d200

Browse files
committed
Changed: Use ALGOLIA_ prefixed environment variables for consistency
1 parent a20e216 commit f46d200

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

algoliasearch-tests/src/test/java/com/algolia/search/ApacheHttpClientTest.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616

1717
public class ApacheHttpClientTest {
1818

19-
private static String APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
20-
private static String API_KEY = System.getenv("ALGOLIA_API_KEY");
19+
private static String ALGOLIA_APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
20+
private static String ALGOLIA_API_KEY = System.getenv("ALGOLIA_API_KEY");
2121
private APIClientConfiguration defaultConfig;
2222

2323
@Before
2424
public void checkEnvVariables() throws Exception {
25-
if (APPLICATION_ID == null || APPLICATION_ID.isEmpty()) {
25+
if (ALGOLIA_APPLICATION_ID == null || ALGOLIA_APPLICATION_ID.isEmpty()) {
2626
throw new Exception("ALGOLIA_APPLICATION_ID is not defined or empty");
2727
}
28-
if (API_KEY == null || API_KEY.isEmpty()) {
28+
if (ALGOLIA_API_KEY == null || ALGOLIA_API_KEY.isEmpty()) {
2929
throw new Exception("ALGOLIA_API_KEY is not defined or empty");
3030
}
3131
}
@@ -34,15 +34,15 @@ public void checkEnvVariables() throws Exception {
3434
public void before() {
3535
defaultConfig =
3636
new APIClientConfiguration(
37-
APPLICATION_ID,
38-
API_KEY,
37+
ALGOLIA_APPLICATION_ID,
38+
ALGOLIA_API_KEY,
3939
Defaults.DEFAULT_OBJECT_MAPPER,
4040
Defaults.ANALYTICS_HOST,
41-
Collections.singletonList(APPLICATION_ID + ".algolia.net"),
42-
Collections.singletonList(APPLICATION_ID + "-dsn.algolia.net"),
41+
Collections.singletonList(ALGOLIA_APPLICATION_ID + ".algolia.net"),
42+
Collections.singletonList(ALGOLIA_APPLICATION_ID + "-dsn.algolia.net"),
4343
ImmutableMap.of(
44-
"X-Algolia-Application-Id", APPLICATION_ID,
45-
"X-Algolia-API-Key", API_KEY),
44+
"X-Algolia-Application-Id", ALGOLIA_APPLICATION_ID,
45+
"X-Algolia-API-Key", ALGOLIA_API_KEY),
4646
1000,
4747
2000,
4848
1000,
@@ -53,15 +53,15 @@ public void before() {
5353
private APIClient build(String... hosts) {
5454
APIClientConfiguration configuration =
5555
new APIClientConfiguration(
56-
APPLICATION_ID,
57-
API_KEY,
56+
ALGOLIA_APPLICATION_ID,
57+
ALGOLIA_API_KEY,
5858
Defaults.DEFAULT_OBJECT_MAPPER,
5959
Defaults.ANALYTICS_HOST,
6060
Arrays.asList(hosts),
6161
Arrays.asList(hosts),
6262
ImmutableMap.of(
63-
"X-Algolia-Application-Id", APPLICATION_ID,
64-
"X-Algolia-API-Key", API_KEY),
63+
"X-Algolia-Application-Id", ALGOLIA_APPLICATION_ID,
64+
"X-Algolia-API-Key", ALGOLIA_API_KEY),
6565
1000,
6666
2000,
6767
1000,
@@ -84,14 +84,15 @@ private <T> void assertThatItTookLessThan(long duration, Callable<T> callable) t
8484

8585
@Test
8686
public void shouldHandleTimeoutsInDns() throws Exception {
87-
APIClient client = build("java-dsn.algolia.biz", APPLICATION_ID + "-dsn.algolia.net");
87+
APIClient client = build("java-dsn.algolia.biz", ALGOLIA_APPLICATION_ID + "-dsn.algolia.net");
8888

8989
assertThatItTookLessThan(3 * 1000, () -> assertThat(client.listIndexes()).isNotNull());
9090
}
9191

9292
@Test
9393
public void shouldHandleConnectTimeout() throws Exception {
94-
APIClient client = build("notcp-xx-1.algolianet.com", APPLICATION_ID + "-dsn.algolia.net");
94+
APIClient client =
95+
build("notcp-xx-1.algolianet.com", ALGOLIA_APPLICATION_ID + "-dsn.algolia.net");
9596

9697
assertThatItTookLessThan(3 * 1000, () -> assertThat(client.listIndexes()).isNotNull());
9798
}
@@ -121,14 +122,14 @@ public void shouldHandleConnectionResetException() throws Exception {
121122

122123
runnable.start();
123124

124-
APIClient client = build("localhost:8080", APPLICATION_ID + "-1.algolianet.com");
125+
APIClient client = build("localhost:8080", ALGOLIA_APPLICATION_ID + "-1.algolianet.com");
125126

126127
assertThatItTookLessThan(2 * 1000, client::listIndexes);
127128
}
128129

129130
@Test
130131
public void shouldHandleSNI() throws Exception {
131-
APIClient client = build(APPLICATION_ID + "-1.algolianet.com");
132+
APIClient client = build(ALGOLIA_APPLICATION_ID + "-1.algolianet.com");
132133
assertThat(client.listIndexes()).isNotEmpty();
133134
}
134135
}

algoliasearch-tests/src/test/java/com/algolia/search/AsyncAlgoliaIntegrationTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public abstract class AsyncAlgoliaIntegrationTest {
2020

2121
protected static final long WAIT_TIME_IN_SECONDS = 60 * 5; // 5 minutes
2222
protected static AsyncAPIClient client;
23-
private String APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
24-
private String API_KEY = System.getenv("ALGOLIA_API_KEY");
23+
protected String ALGOLIA_APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
24+
protected String ALGOLIA_API_KEY = System.getenv("ALGOLIA_API_KEY");
2525

2626
private static List<String> indexNameToDeleteAfterTheTests = new ArrayList<>();
2727

@@ -52,13 +52,13 @@ protected static AsyncIndex<Object> createIndex() {
5252

5353
@Before
5454
public void checkEnvVariables() throws Exception {
55-
if (APPLICATION_ID == null || APPLICATION_ID.isEmpty()) {
56-
throw new Exception("APPLICATION_ID is not defined or empty");
55+
if (ALGOLIA_APPLICATION_ID == null || ALGOLIA_APPLICATION_ID.isEmpty()) {
56+
throw new Exception("ALGOLIA_APPLICATION_ID is not defined or empty");
5757
}
58-
if (API_KEY == null || API_KEY.isEmpty()) {
59-
throw new Exception("API_KEY is not defined or empty");
58+
if (ALGOLIA_API_KEY == null || ALGOLIA_API_KEY.isEmpty()) {
59+
throw new Exception("ALGOLIA_API_KEY is not defined or empty");
6060
}
61-
client = createInstance(APPLICATION_ID, API_KEY);
61+
client = createInstance(ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY);
6262
}
6363

6464
public abstract AsyncAPIClient createInstance(String appId, String apiKey);

algoliasearch-tests/src/test/java/com/algolia/search/SyncAlgoliaIntegrationTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public abstract class SyncAlgoliaIntegrationTest {
2121

2222
protected static APIClient client;
2323
private static List<String> indexNameToDeleteAfterTheTests = new ArrayList<>();
24-
protected String APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
25-
protected String API_KEY = System.getenv("ALGOLIA_API_KEY");
24+
protected String ALGOLIA_APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
25+
protected String ALGOLIA_API_KEY = System.getenv("ALGOLIA_API_KEY");
2626
protected static final long WAIT_TIME_IN_SECONDS = 60 * 5; // 5 minutes
2727

2828
@AfterClass
@@ -55,14 +55,14 @@ protected static Index<?> createIndex() {
5555

5656
@Before
5757
public void checkEnvVariables() throws Exception {
58-
if (APPLICATION_ID == null || APPLICATION_ID.isEmpty()) {
59-
throw new Exception("APPLICATION_ID is not defined or empty");
58+
if (ALGOLIA_APPLICATION_ID == null || ALGOLIA_APPLICATION_ID.isEmpty()) {
59+
throw new Exception("ALGOLIA_APPLICATION_ID is not defined or empty");
6060
}
61-
if (API_KEY == null || API_KEY.isEmpty()) {
62-
throw new Exception("API_KEY is not defined or empty");
61+
if (ALGOLIA_API_KEY == null || ALGOLIA_API_KEY.isEmpty()) {
62+
throw new Exception("ALGOLIA_API_KEY is not defined or empty");
6363
}
6464

65-
client = createInstance(APPLICATION_ID, API_KEY);
65+
client = createInstance(ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY);
6666
}
6767

6868
public abstract APIClient createInstance(String appId, String apiKey);

algoliasearch-tests/src/test/java/com/algolia/search/integration/common/sync/SyncBrowseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void browseEmptyWithException() throws AlgoliaException {
100100
DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
101101

102102
APIClient clientWithSpecificObjectMapper =
103-
createInstance(APPLICATION_ID, API_KEY, objectMapper);
103+
createInstance(ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY, objectMapper);
104104

105105
Index<BadClass> indexWithWrongClass =
106106
clientWithSpecificObjectMapper.initIndex("whatever", BadClass.class);

algoliasearch-tests/src/test/java/com/algolia/search/integration/common/sync/SyncMultiClusterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ private static String createUniqueUserID() {
2727

2828
@Before
2929
public void checkEnvVariables() throws Exception {
30-
APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID_MCM");
31-
API_KEY = System.getenv("ALGOLIA_API_KEY_MCM");
30+
ALGOLIA_APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID_MCM");
31+
ALGOLIA_API_KEY = System.getenv("ALGOLIA_API_KEY_MCM");
3232

3333
super.checkEnvVariables();
3434
}

0 commit comments

Comments
 (0)