MentaContainer

Rev

Rev 51 | Rev 91 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
24 soliveira 1
package org.mentacontainer.impl;
2
 
3
import junit.framework.Assert;
4
 
5
import org.junit.Test;
88 soliveira 6
import org.mentacontainer.Factory;
24 soliveira 7
 
88 soliveira 8
public class ClassFactoryTest {
24 soliveira 9
 
10
        private static class User {
11
 
12
                private String username;
13
 
14
                public User() { }
15
 
16
                public User(String username) {
17
                        this.username = username;
18
                }
19
 
20
                public String getUsername() {
21
                        return username;
22
                }
23
 
24
                public void setUsername(String username) {
25
                        this.username = username;
26
                }
27
        }
28
 
29
        @Test
40 soliveira 30
        public void testComponent() {
24 soliveira 31
 
88 soliveira 32
                Factory c1 = new ClassFactory(User.class).addInitValue("saoj");
24 soliveira 33
 
88 soliveira 34
                Factory c2 = new ClassFactory(User.class).addProperty("username", "soliveira");
24 soliveira 35
 
41 soliveira 36
                User u1 = c1.getInstance();
24 soliveira 37
 
41 soliveira 38
                User u2 = c2.getInstance();
24 soliveira 39
 
40
                Assert.assertTrue(u1 != u2);
41
 
42
                Assert.assertTrue(!u1.getUsername().equals(u2.getUsername()));
43
        }
44
}