bugfix - fixed the healthcheck problem
[holmes/rule-management.git] / rulemgt / src / test / java / org / onap / holmes / rulemgt / InitializerTest.java
index 3f071b3..8e4a6fe 100644 (file)
@@ -26,9 +26,11 @@ import org.powermock.core.classloader.annotations.SuppressStaticInitializationFo
 import org.powermock.modules.junit4.PowerMockRunner;
 import org.powermock.reflect.internal.WhiteboxImpl;
 
+import java.util.concurrent.TimeUnit;
+
 @RunWith(PowerMockRunner.class)
 @PrepareForTest(MicroServiceConfig.class)
-@SuppressStaticInitializationFor("org.onap.holmes.common.utils.HttpsUtils")
+@SuppressStaticInitializationFor("org.onap.holmes.common.utils.CommonUtils")
 public class InitializerTest {
 
     @Test
@@ -38,15 +40,30 @@ public class InitializerTest {
 
         PowerMock.mockStaticPartial(MicroServiceConfig.class, "getMicroServiceIpAndPort", "getEnv");
         EasyMock.expect(MicroServiceConfig.getMicroServiceIpAndPort()).andReturn(new String[]{"127.0.0.1", "443"});
-        EasyMock.expect(MicroServiceConfig.getEnv("ENABLE_ENCRYPT")).andReturn("true");
+        System.setProperty("ENABLE_ENCRYPT", "true");
 
         mockedMsbRegister.register2Msb(EasyMock.anyObject(MicroServiceInfo.class));
         EasyMock.expectLastCall();
 
         PowerMock.replayAll();
 
+        setReadyFlagAfter(3);
+
         WhiteboxImpl.invokeMethod(initializer, "init");
 
+        TimeUnit.SECONDS.sleep(6);
+
         PowerMock.verifyAll();
     }
+
+    private void setReadyFlagAfter(final int second) {
+        new Thread(() -> {
+            try {
+                TimeUnit.SECONDS.sleep(second);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            Initializer.setReadyForMsbReg(true);
+        }).start();
+    }
 }
\ No newline at end of file