File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
client/src/test/java/io/split/telemetry/utils Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 5
5
import org .mockito .Mockito ;
6
6
import org .slf4j .Logger ;
7
7
8
+ import java .lang .reflect .Field ;
9
+ import java .lang .reflect .Modifier ;
10
+
8
11
public class AtomicLongArrayTest {
9
12
10
13
private static final int SIZE = 23 ;
@@ -30,10 +33,18 @@ public void testIncrement() {
30
33
Assert .assertEquals (1 , atomicLongArray .fetchAndClearAll ().stream ().mapToInt (Long ::intValue ).sum ());
31
34
}
32
35
33
- @ Test (expected = ArrayIndexOutOfBoundsException .class )
34
- public void testIncrementError () {
36
+ @ Test
37
+ public void testIncrementError () throws NoSuchFieldException , IllegalAccessException {
38
+ Logger log = Mockito .mock (Logger .class );
35
39
AtomicLongArray atomicLongArray = new AtomicLongArray (SIZE );
40
+ Field logAssert = AtomicLongArray .class .getDeclaredField ("_log" );
41
+ logAssert .setAccessible (true );
42
+ Field modifiersField = Field .class .getDeclaredField ("modifiers" );
43
+ modifiersField .setAccessible (true );
44
+ modifiersField .setInt (logAssert , logAssert .getModifiers () & ~Modifier .FINAL );
45
+ logAssert .set (atomicLongArray , log );
36
46
atomicLongArray .increment (25 );
47
+ Mockito .verify (log , Mockito .times (1 )).error (Mockito .anyString ());
37
48
}
38
49
39
50
}
You can’t perform that action at this time.
0 commit comments