FileDocCategorySizeDatePackage
TestReflectionUtils.javaAPI DocApache Lucene 2.1.04574Wed Feb 14 10:46:02 GMT 2007org.apache.lucene.gdata.utils

TestReflectionUtils

public 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.

Fields Summary
Constructors Summary
Methods Summary
public voidtestCanCreateInstance()

        assertTrue(ReflectionUtils.canCreateInstance(String.class));
        assertFalse(ReflectionUtils.canCreateInstance(Integer.class));
        assertFalse(ReflectionUtils.canCreateInstance(Integer.TYPE));
        assertFalse(ReflectionUtils.canCreateInstance(null));
        
        
        
    
public voidtestExtendsType()

        assertTrue(ReflectionUtils.isTypeOf(Integer.class,Number.class));
        assertFalse(ReflectionUtils.isTypeOf(null,CharSequence.class));
    
public voidtestGetDefaultInstance()

        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 voidtestGetPrimitiveWrapper()

        
        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 voidtestHasdesiredconstructor()

        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 voidtestImplementsType()


    
public voidtestIsTypeOf()

        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));