Ejemplo n.º 1
0
 @Test
 public void testException() throws Exception {
   ObjectFactory<Object> factory = new SingletonObjectFactory<Object>("foo");
   MethodInjector<Foo> injector = new MethodInjector<Foo>(exceptionMethod, factory);
   try {
     injector.inject(new Foo());
     fail();
   } catch (RuntimeException e) {
     // expected
   }
 }
Ejemplo n.º 2
0
 @Test
 public void testIllegalArgument() throws Exception {
   ObjectFactory<Object> factory = new SingletonObjectFactory<Object>(new Object());
   MethodInjector<Foo> injector = new MethodInjector<Foo>(fooMethod, factory);
   try {
     injector.inject(new Foo());
     fail();
   } catch (ObjectCreationException e) {
     // expected
   }
 }