MentaContainer

Compare Revisions

Ignore whitespace Rev 31 → Rev 32

/trunk/src/test/java/org/mentacontainer/impl/GenericComponentTest.java
New file
0,0 → 1,41
package org.mentacontainer.impl;
 
import junit.framework.Assert;
 
import org.junit.Test;
import org.mentacontainer.Component;
import org.mentacontainer.Container;
 
public class GenericComponentTest {
public static class SomeFactory {
public String giveMeSomething() {
return String.valueOf(System.nanoTime());
}
}
@Test
public void testGenericComponent() throws Exception {
SomeFactory factory = new SomeFactory();
Container c = new MentaContainer();
Component generic = new GenericComponent("myFactory", factory, "giveMeSomething");
c.ioc(generic);
String s1 = (String) c.get("myFactory");
Thread.sleep(5);
String s2 = (String) c.get("myFactory");
Assert.assertNotNull(s1);
Assert.assertNotNull(s2);
Assert.assertTrue(s1 != s2);
Assert.assertTrue(!s1.equals(s2));
}
}