Add additional unit tests to show that singletons can be created in single thread environment and multithread environment. Also add a test to demonstrate a whole with Singleton when instantiating using reflection

Add some logging. Tests pass locally but not on github?
This commit is contained in:
Richard Jones
2015-10-11 21:54:45 -03:00
parent 6ba7f5ea04
commit 45b0ac386e

View File

@ -75,6 +75,9 @@ public class LazyLoadedSingletonThreadSafetyTest {
@SuppressWarnings("unchecked")
public void test_HoleInSingletonCreationIfUsingReflection() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
Field[] f = ThreadSafeLazyLoadedIvoryTower.class.getDeclaredFields();
for (Field ff : f) {
System.out.println(ff.getDeclaringClass());
}
assertEquals("One field only in ThreadSafeLazyLoadedIvoryTower", 1, f.length);
f[0].setAccessible(true);