Comments for r766.

This commit is contained in:
Joel Leitch 2011-04-06 00:02:40 +00:00
parent 52bf144859
commit b4eb810347
2 changed files with 5 additions and 11 deletions

View File

@ -38,8 +38,8 @@ final class DefaultConstructorAllocator {
}
// for testing purpose
final Cache<Class<?>, Constructor<?>> getConstructorCache() {
return constructorCache;
final boolean isInCache(Class<?> cacheKey) {
return constructorCache.getElement(cacheKey) != null;
}
private static final Constructor<Null> createNullConstructor() {

View File

@ -16,8 +16,6 @@
package com.google.gson;
import com.google.gson.DefaultConstructorAllocator;
import junit.framework.TestCase;
import java.util.ArrayList;
@ -41,20 +39,16 @@ public class DefaultConstructorAllocatorTest extends TestCase {
public void testObjectConstructor() throws Exception {
ArrayList<Object> arrayList = allocator.newInstance(ArrayList.class);
assertTrue(arrayList.isEmpty());
assertInCache(ArrayList.class);
assertTrue(allocator.isInCache(ArrayList.class));
LinkedList<Object> linkedList = allocator.newInstance(LinkedList.class);
assertTrue(linkedList.isEmpty());
assertInCache(LinkedList.class);
assertTrue(allocator.isInCache(LinkedList.class));
}
public void testMissingDefaultConstructor() throws Exception {
assertNull(allocator.newInstance(NoDefaultConstructor.class));
assertInCache(NoDefaultConstructor.class);
}
private void assertInCache(Class<?> clazz) {
assertNotNull(allocator.getConstructorCache().getElement(clazz));
assertTrue(allocator.isInCache(NoDefaultConstructor.class));
}
private static class NoDefaultConstructor {