@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 } }
@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 } }