MentaContainer

Rev

Rev 88 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
89 soliveira 1
package org.mentacontainer;
24 soliveira 2
 
3
import java.lang.reflect.Method;
4
 
5
import junit.framework.Assert;
6
 
7
import org.junit.Test;
8
import org.mentacontainer.Dependency;
9
 
88 soliveira 10
public class DependencyTest {
24 soliveira 11
 
12
        private static class User {
13
 
14
                private String username;
15
 
16
                public User() { }
17
 
18
                public User(String username) {
19
                        this.username = username;
20
                }
21
 
22
                public String getUsername() {
23
                        return username;
24
                }
25
 
26
                public void setUsername(String username) {
27
                        this.username = username;
28
                }
29
        }
30
 
31
        @Test
32
        public void testDependency() {
33
 
88 soliveira 34
                Dependency d = new Dependency("username", String.class, "theUsername");
24 soliveira 35
 
36
                Assert.assertEquals("username", d.getTarget());
37
 
38
                Assert.assertEquals(String.class, d.getType());
39
 
40
                Assert.assertEquals("theUsername", d.getSource());
41
 
42
                Method m = d.check(User.class);
43
 
44
                Assert.assertNotNull(m);
45
 
46
                Assert.assertEquals("setUsername", m.getName());
47
 
48
                Assert.assertEquals(String.class, m.getParameterTypes()[0]);
49
        }
50
}