switched from accessing field to an accessor method for access in tests.

Strangely, this fixes the broken tests in the continuous build.
This commit is contained in:
Inderjeet Singh 2011-03-31 18:57:55 +00:00
parent 5bc80cd693
commit 9c894c7485
2 changed files with 8 additions and 4 deletions

View File

@ -24,11 +24,10 @@ import java.lang.reflect.Constructor;
* *
* @author Joel Leitch * @author Joel Leitch
*/ */
class DefaultConstructorAllocator { final class DefaultConstructorAllocator {
private static final Constructor<Null> NULL_CONSTRUCTOR = createNullConstructor(); private static final Constructor<Null> NULL_CONSTRUCTOR = createNullConstructor();
// Package private for testing purposes. private final Cache<Class<?>, Constructor<?>> constructorCache;
final Cache<Class<?>, Constructor<?>> constructorCache;
public DefaultConstructorAllocator() { public DefaultConstructorAllocator() {
this(200); this(200);
@ -38,6 +37,11 @@ class DefaultConstructorAllocator {
constructorCache = new LruCache<Class<?>, Constructor<?>>(cacheSize); constructorCache = new LruCache<Class<?>, Constructor<?>>(cacheSize);
} }
// for testing purpose
final Cache<Class<?>, Constructor<?>> getConstructorCache() {
return constructorCache;
}
private static final Constructor<Null> createNullConstructor() { private static final Constructor<Null> createNullConstructor() {
try { try {
return getNoArgsConstructor(Null.class); return getNoArgsConstructor(Null.class);

View File

@ -54,7 +54,7 @@ public class DefaultConstructorAllocatorTest extends TestCase {
} }
private void assertInCache(Class<?> clazz) { private void assertInCache(Class<?> clazz) {
assertNotNull(allocator.constructorCache.getElement(clazz)); assertNotNull(allocator.getConstructorCache().getElement(clazz));
} }
private static class NoDefaultConstructor { private static class NoDefaultConstructor {