File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
lazy-loading/src/test/java/com/iluwatar/lazy/loading Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change 44
55import java .lang .reflect .Field ;
66
7- import static org .junit .Assert .assertEquals ;
87import static org .junit .Assert .assertNotNull ;
98import static org .junit .Assert .assertNull ;
109
@@ -20,22 +19,24 @@ public void test() throws IllegalAccessException {
2019 HolderThreadSafe hts = new HolderThreadSafe ();
2120
2221 {//first call is null
23- Field [] f = HolderThreadSafe .class .getDeclaredFields ();
24- assertEquals ("One field only in HolderThreadSafe" , 1 , f .length );
25- f [0 ].setAccessible (true );
22+ Field [] ff = HolderThreadSafe .class .getDeclaredFields ();
23+ for (Field f : ff ) {
24+ f .setAccessible (true );
25+ }
2626
27- assertNull (f [0 ].get (hts ));
27+ assertNull (ff [0 ].get (hts ));
2828 }
2929
3030 // now it is lazily loaded
3131 hts .getHeavy ();
3232
3333 {//now it is not null - call via reflection so that the test is the same before and after
34- Field [] f = HolderThreadSafe .class .getDeclaredFields ();
35- assertEquals ("One field only in HolderThreadSafe" , 1 , f .length );
36- f [0 ].setAccessible (true );
34+ Field [] ff = HolderThreadSafe .class .getDeclaredFields ();
35+ for (Field f : ff ) {
36+ f .setAccessible (true );
37+ }
3738
38- assertNotNull (f [0 ].get (hts ));
39+ assertNotNull (ff [0 ].get (hts ));
3940 }
4041 }
4142}
You can’t perform that action at this time.
0 commit comments