import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.internal.WhiteboxImpl;
+import java.util.concurrent.TimeUnit;
+
@RunWith(PowerMockRunner.class)
@PrepareForTest(MicroServiceConfig.class)
public class InitializerTest {
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