TestReflectionUtilspublic class TestReflectionUtils extends TestCase Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. |
Methods Summary |
---|
public void | testCanCreateInstance()
assertTrue(ReflectionUtils.canCreateInstance(String.class));
assertFalse(ReflectionUtils.canCreateInstance(Integer.class));
assertFalse(ReflectionUtils.canCreateInstance(Integer.TYPE));
assertFalse(ReflectionUtils.canCreateInstance(null));
| public void | testExtendsType()
assertTrue(ReflectionUtils.isTypeOf(Integer.class,Number.class));
assertFalse(ReflectionUtils.isTypeOf(null,CharSequence.class));
| public void | testGetDefaultInstance()
assertEquals(new String(),ReflectionUtils.getDefaultInstance(String.class));
try{
ReflectionUtils.getDefaultInstance(Integer.class);
fail("can not create instance");
}catch (ReflectionException e) {
}
try{
ReflectionUtils.getDefaultInstance(null);
fail("can not create instance");
}catch (ReflectionException e) {
}
| public void | testGetPrimitiveWrapper()
assertEquals(Integer.class,ReflectionUtils.getPrimitiveWrapper(Integer.TYPE));
assertEquals(Long.class,ReflectionUtils.getPrimitiveWrapper(Long.TYPE));
assertEquals(Float.class,ReflectionUtils.getPrimitiveWrapper(Float.TYPE));
assertEquals(Byte.class,ReflectionUtils.getPrimitiveWrapper(Byte.TYPE));
assertEquals(Double.class,ReflectionUtils.getPrimitiveWrapper(Double.TYPE));
assertEquals(Short.class,ReflectionUtils.getPrimitiveWrapper(Short.TYPE));
assertEquals(Boolean.class,ReflectionUtils.getPrimitiveWrapper(Boolean.TYPE));
try {
ReflectionUtils.getPrimitiveWrapper(null);
fail("type is null");
}catch (ReflectionException e) {
}
try {
ReflectionUtils.getPrimitiveWrapper(String.class);
fail("type is not a primitive");
}catch (ReflectionException e) {
}
| public void | testHasdesiredconstructor()
assertFalse(ReflectionUtils.hasDesiredConstructor(PlainTextStrategy.class, new Class[]{IndexSchemaField.class}));
assertFalse(ReflectionUtils.hasDesiredConstructor(PlainTextStrategy.class, new Class[]{}));
assertTrue(ReflectionUtils.hasDesiredConstructor(String.class, new Class[]{String.class}));
| public void | testImplementsType()
| public void | testIsTypeOf()
assertTrue(ReflectionUtils.isTypeOf(String.class,CharSequence.class));
assertTrue(ReflectionUtils.isTypeOf(Integer.class,Number.class));
assertFalse(ReflectionUtils.isTypeOf(Integer.class,CharSequence.class));
assertFalse(ReflectionUtils.isTypeOf(null,CharSequence.class));
assertFalse(ReflectionUtils.isTypeOf(Integer.class,null));
|
|