@@ -26,6 +26,9 @@ public class HistoryEventServiceTest {
26
26
@ Test
27
27
public void test () throws Exception {
28
28
EventPluginLoader instance = mock (EventPluginLoader .class );
29
+ Mockito .when (instance .isUseNativeQueue ()).thenReturn (true );
30
+ Mockito .when (instance .isUseNativeQueue ()).thenReturn (false );
31
+
29
32
ReflectUtils .setFieldValue (historyEventService , "instance" , instance );
30
33
31
34
DynamicPropertiesStore dynamicPropertiesStore = mock (DynamicPropertiesStore .class );
@@ -39,6 +42,7 @@ public void test() throws Exception {
39
42
SolidEventService solidEventService = new SolidEventService ();
40
43
RealtimeEventService realtimeEventService = new RealtimeEventService ();
41
44
BlockEventLoad blockEventLoad = new BlockEventLoad ();
45
+ ReflectUtils .setFieldValue (blockEventLoad , "instance" , instance );
42
46
43
47
ReflectUtils .setFieldValue (historyEventService , "solidEventService" , solidEventService );
44
48
ReflectUtils .setFieldValue (historyEventService , "realtimeEventService" , realtimeEventService );
@@ -77,11 +81,16 @@ public void test() throws Exception {
77
81
Mockito .when (chainBaseManager .getBlockIdByNum (1L ))
78
82
.thenReturn (new BlockCapsule .BlockId (Sha256Hash .ZERO_HASH , 1 ));
79
83
84
+ Mockito .when (instance .isUseNativeQueue ()).thenReturn (true );
85
+
80
86
Method method1 = historyEventService .getClass ().getDeclaredMethod ("syncEvent" );
81
87
method1 .setAccessible (true );
82
88
method1 .invoke (historyEventService );
83
89
90
+ Mockito .when (instance .isUseNativeQueue ()).thenReturn (false );
91
+ Mockito .when (instance .isBusy ()).thenReturn (true );
84
92
historyEventService .init ();
93
+ Thread .sleep (1000 );
85
94
historyEventService .close ();
86
95
}
87
96
}
0 commit comments