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 55import org .mockito .Mockito ;
66import org .slf4j .Logger ;
77
8+ import java .lang .reflect .Field ;
9+ import java .lang .reflect .Modifier ;
10+
811public class AtomicLongArrayTest {
912
1013 private static final int SIZE = 23 ;
@@ -30,10 +33,18 @@ public void testIncrement() {
3033 Assert .assertEquals (1 , atomicLongArray .fetchAndClearAll ().stream ().mapToInt (Long ::intValue ).sum ());
3134 }
3235
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 );
3539 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 );
3646 atomicLongArray .increment (25 );
47+ Mockito .verify (log , Mockito .times (1 )).error (Mockito .anyString ());
3748 }
3849
3950}
You can’t perform that action at this time.
0 commit comments