Project

General

Profile

Download (1.61 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.BotanicalName;
13
import eu.etaxonomy.cdm.model.reference.Reference;
14
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
15
import eu.etaxonomy.cdm.model.taxon.Taxon;
16

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

    
23
    IMethodCache methodCache;
24
    private Reference nomenclaturalReference;
25

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

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

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

    
50
}
(2-2/2)