Comments for r766.
This commit is contained in:
parent
52bf144859
commit
b4eb810347
|
@ -38,8 +38,8 @@ final class DefaultConstructorAllocator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for testing purpose
|
// for testing purpose
|
||||||
final Cache<Class<?>, Constructor<?>> getConstructorCache() {
|
final boolean isInCache(Class<?> cacheKey) {
|
||||||
return constructorCache;
|
return constructorCache.getElement(cacheKey) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Constructor<Null> createNullConstructor() {
|
private static final Constructor<Null> createNullConstructor() {
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package com.google.gson;
|
package com.google.gson;
|
||||||
|
|
||||||
import com.google.gson.DefaultConstructorAllocator;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -41,20 +39,16 @@ public class DefaultConstructorAllocatorTest extends TestCase {
|
||||||
public void testObjectConstructor() throws Exception {
|
public void testObjectConstructor() throws Exception {
|
||||||
ArrayList<Object> arrayList = allocator.newInstance(ArrayList.class);
|
ArrayList<Object> arrayList = allocator.newInstance(ArrayList.class);
|
||||||
assertTrue(arrayList.isEmpty());
|
assertTrue(arrayList.isEmpty());
|
||||||
assertInCache(ArrayList.class);
|
assertTrue(allocator.isInCache(ArrayList.class));
|
||||||
|
|
||||||
LinkedList<Object> linkedList = allocator.newInstance(LinkedList.class);
|
LinkedList<Object> linkedList = allocator.newInstance(LinkedList.class);
|
||||||
assertTrue(linkedList.isEmpty());
|
assertTrue(linkedList.isEmpty());
|
||||||
assertInCache(LinkedList.class);
|
assertTrue(allocator.isInCache(LinkedList.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMissingDefaultConstructor() throws Exception {
|
public void testMissingDefaultConstructor() throws Exception {
|
||||||
assertNull(allocator.newInstance(NoDefaultConstructor.class));
|
assertNull(allocator.newInstance(NoDefaultConstructor.class));
|
||||||
assertInCache(NoDefaultConstructor.class);
|
assertTrue(allocator.isInCache(NoDefaultConstructor.class));
|
||||||
}
|
|
||||||
|
|
||||||
private void assertInCache(Class<?> clazz) {
|
|
||||||
assertNotNull(allocator.getConstructorCache().getElement(clazz));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NoDefaultConstructor {
|
private static class NoDefaultConstructor {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user