Project

General

Profile

Download (1.67 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
package eu.etaxonomy.cdm.persistence.dao;
3

    
4
import static org.junit.Assert.assertNotNull;
5

    
6
import java.lang.reflect.Method;
7

    
8
import org.apache.log4j.Logger;
9
import org.junit.Before;
10
import org.junit.Test;
11

    
12
import eu.etaxonomy.cdm.model.name.IBotanicalName;
13
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
14
import eu.etaxonomy.cdm.model.reference.Reference;
15
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
16
import eu.etaxonomy.cdm.model.taxon.Taxon;
17

    
18
public class MethodCacheImplTest {
19
    @SuppressWarnings("unused")
20
	private static final Logger logger = Logger.getLogger(MethodCacheImplTest.class);
21
    private Taxon taxon;
22
    private IBotanicalName botanicalName;
23

    
24
    IMethodCache methodCache;
25
    private Reference nomenclaturalReference;
26

    
27
    @Before
28
    public void setUp() throws Exception {
29
        methodCache = new MethodCacheImpl();
30
        taxon = Taxon.NewInstance(null, null);
31
        botanicalName = TaxonNameFactory.NewBotanicalInstance(null);
32
        nomenclaturalReference = ReferenceFactory.newBook();
33
    }
34

    
35
    /**
36
     * Test for a method that is not declared by the class, but by the superclass
37
     * also the parameter of the matching method is more generic than the given parameter
38
     */
39
    @Test
40
    public void testGetMethod() {
41
        Method method = methodCache.getMethod(taxon.getClass(), "setName", botanicalName.getClass());
42
        assertNotNull("Method should exist", method);
43
    }
44

    
45
    @Test
46
    public void testGetMethodWhereMethodParameterIsInterface(){
47
        Method method = methodCache.getMethod(botanicalName.getClass(), "setNomenclaturalReference", nomenclaturalReference.getClass());
48
        assertNotNull("Method should exist", method);
49
    }
50

    
51
}
(2-2/2)