Skip to content

Commit ceaa187

Browse files
committed
fix test simplify.
1 parent 9bab32c commit ceaa187

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

core/src/test/java/com/ibm/watson/developer_cloud/service/AuthenticationTest.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.ibm.watson.developer_cloud.service;
22

3+
import com.ibm.watson.developer_cloud.util.CredentialUtils;
34
import org.junit.Test;
45

5-
import java.lang.reflect.Field;
6-
import java.lang.reflect.Modifier;
7-
import java.util.Map;
8-
96
import static org.junit.Assert.assertTrue;
107
import static org.junit.Assert.assertFalse;
118

@@ -38,22 +35,9 @@ public void authenticateWithIcp() {
3835
}
3936

4037
@Test
41-
public void multiAuthenticationWithMultiBindSameServiceOnVcapService()
42-
throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
43-
44-
Class<?> clazz = Class.forName("java.lang.ProcessEnvironment");
45-
46-
Field theCaseInsensitiveEnvironment = clazz.getDeclaredField("theCaseInsensitiveEnvironment");
38+
public void multiAuthenticationWithMultiBindSameServiceOnVcapService() {
4739

48-
theCaseInsensitiveEnvironment.setAccessible(true);
49-
50-
Field field = Field.class.getDeclaredField("modifiers");
51-
field.setAccessible(true);
52-
field.setInt(theCaseInsensitiveEnvironment,
53-
theCaseInsensitiveEnvironment.getModifiers() & ~Modifier.PRIVATE & ~Modifier.FINAL);
54-
55-
Map<String, String> systemEnv = (Map<String, String>) theCaseInsensitiveEnvironment.get(null);
56-
systemEnv.put("VCAP_SERVICES", "{\n"
40+
CredentialUtils.setServices("{\n"
5741
+ " \"test\": [\n"
5842
+ " {\n"
5943
+ " \"credentials\": {\n"
@@ -65,8 +49,6 @@ public void multiAuthenticationWithMultiBindSameServiceOnVcapService()
6549
+ " ]\n"
6650
+ "}\n");
6751

68-
theCaseInsensitiveEnvironment.set(null, systemEnv);
69-
7052
TestService serviceA = new TestService();
7153
serviceA.setUsernameAndPassword(APIKEY_USERNAME, APIKEY);
7254

0 commit comments

Comments
 (0)