1414
1515package com .cloudant .tests ;
1616
17+ import static com .cloudant .http .internal .interceptors .IamCookieInterceptor .IAM_TOKEN_SERVER_URL_PROPERTY_KEY ;
1718import static com .cloudant .tests .util .MockWebServerResources .IAM_API_KEY ;
1819import static com .cloudant .tests .util .MockWebServerResources .IAM_TOKEN ;
1920import static com .cloudant .tests .util .MockWebServerResources .OK_IAM_COOKIE ;
2324import com .cloudant .client .api .ClientBuilder ;
2425import com .cloudant .client .api .CloudantClient ;
2526import com .cloudant .tests .extensions .MockWebServerExtension ;
26- import com .cloudant .tests .util .IamSystemPropertyMock ;
2727import com .cloudant .tests .util .MockWebServerResources ;
2828import com .google .gson .GsonBuilder ;
2929
30+ import org .junit .jupiter .api .AfterEach ;
3031import org .junit .jupiter .api .Assertions ;
31- import org .junit .jupiter .api .BeforeAll ;
3232import org .junit .jupiter .api .BeforeEach ;
3333import org .junit .jupiter .api .Test ;
3434import org .junit .jupiter .api .extension .RegisterExtension ;
4646
4747public class CloudFoundryServiceTest {
4848
49- public static IamSystemPropertyMock iamSystemPropertyMock ;
50-
5149 private static String TEST_HOST = "https://cloudant.example" ;
5250 private static String TEST_USER = "user" ;
5351 private static String TEST_PASSWORD = "pass" ;
@@ -63,25 +61,23 @@ public class CloudFoundryServiceTest {
6361 public MockWebServer server ;
6462 public MockWebServer mockIamServer ;
6563
66- /**
67- * Before running this test class setup the property mock.
68- */
69- @ BeforeAll
70- public static void setupIamSystemPropertyMock () {
71- iamSystemPropertyMock = new IamSystemPropertyMock ();
72- }
73-
7464 @ BeforeEach
7565 public void beforeEach () {
7666 server = mockWebServerExt .get ();
7767 server .useHttps (MockWebServerResources .getSSLSocketFactory (), false );
7868 mockServerHostPort = String .format ("%s:%s/" , server .getHostName (), server .getPort ());
7969 //setup mock IAM server
8070 mockIamServer = mockIamServerExt .get ();
81- iamSystemPropertyMock .setMockIamTokenEndpointUrl (mockIamServer .url (iamTokenEndpoint )
71+ // Override the default IAM token server with our test mock server
72+ System .setProperty (IAM_TOKEN_SERVER_URL_PROPERTY_KEY , mockIamServer .url (iamTokenEndpoint )
8273 .toString ());
8374 }
8475
76+ @ AfterEach
77+ public void clearIAMMock () {
78+ System .clearProperty (IAM_TOKEN_SERVER_URL_PROPERTY_KEY );
79+ }
80+
8581 private static class VCAPGenerator {
8682
8783 private Map <String , Object > vcap ;
0 commit comments