1616
1717public 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}
0 commit comments