コード例 #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
   }
 }
コード例 #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
   }
 }