use of jodd.petite.tst.Foo in project jodd by oblac.
the class MiscTest method testAdd.
@Test
public void testAdd() {
PetiteContainer pc = new PetiteContainer();
Foo foo = new Foo();
pc.addBean("foo", foo);
Foo foo2 = (Foo) pc.getBean("foo");
assertNotNull(foo2);
assertSame(foo, foo2);
}
use of jodd.petite.tst.Foo in project jodd by oblac.
the class ParamTest method testProperties.
@Test
public void testProperties() {
PetiteContainer pc = new PetiteContainer();
pc.registerPetiteBean(Foo.class, null, null, null, false);
Properties p = new Properties();
p.setProperty("foo.name", "${name}");
p.setProperty("name", "${name2}");
p.setProperty("name2", "FOONAME");
pc.defineParameters(p);
Foo foo = (Foo) pc.getBean("foo");
assertNotNull(foo);
assertEquals("FOONAME", foo.getName());
}
use of jodd.petite.tst.Foo in project jodd by oblac.
the class ParamTest method testRefParams.
@Test
public void testRefParams() {
PetiteContainer pc = new PetiteContainer();
pc.registerPetiteBean(Foo.class, null, null, null, false);
pc.defineParameter("foo.name", "$${name}");
pc.defineParameter("name", "${name${num}}");
pc.defineParameter("num", "2");
pc.defineParameter("name2", "FOONAME");
pc.defineParameter("FOONAME", "aaa");
Foo foo = (Foo) pc.getBean("foo");
assertNotNull(foo);
assertEquals("$FOONAME", foo.getName());
}
use of jodd.petite.tst.Foo in project jodd by oblac.
the class ParamTest method testRefParamsEscape.
@Test
public void testRefParamsEscape() {
PetiteContainer pc = new PetiteContainer();
pc.registerPetiteBean(Foo.class, null, null, null, false);
pc.defineParameter("foo.name", "\\${name}");
Foo foo = (Foo) pc.getBean("foo");
assertNotNull(foo);
assertEquals("${name}", foo.getName());
}
use of jodd.petite.tst.Foo in project jodd by oblac.
the class ScopeTest method testThreadLocalScope.
@Test
public void testThreadLocalScope() throws InterruptedException {
final PetiteContainer pc = new PetiteContainer();
pc.registerPetiteBean(Foo.class, "foo", null, null, false);
pc.registerPetiteBean(Zoo.class, null, null, null, false);
pc.registerPetiteBean(Boo.class, null, ThreadLocalScope.class, null, false);
assertEquals(3, pc.getTotalBeans());
assertEquals(2, pc.getTotalScopes());
final Boo boo = (Boo) pc.getBean("boo");
final Foo foo = (Foo) pc.getBean("foo");
assertSame(boo.getFoo(), foo);
final Semaphore sem = new Semaphore(1);
sem.acquire();
Thread thread = new Thread() {
@Override
public void run() {
Boo boo2 = (Boo) pc.getBean("boo");
Foo foo2 = (Foo) pc.getBean("foo");
assertSame(foo2, foo);
assertNotSame(boo2, boo);
assertSame(foo2, boo2.getFoo());
sem.release();
}
};
thread.start();
sem.acquire();
sem.release();
}