11package com .ibm .watson .developer_cloud .service ;
22
3+ import com .ibm .watson .developer_cloud .util .CredentialUtils ;
34import org .junit .Test ;
45
5- import java .lang .reflect .Field ;
6- import java .lang .reflect .Modifier ;
7- import java .util .Map ;
8-
96import static org .junit .Assert .assertTrue ;
107import 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