I tried changing the Logger to being a static field as I'm not sure how Onami would assign that field before the object was constructed (and I'm using the logger in the constructor), but that didn't work.
Any ideas? Bill- On Sat, Jun 15, 2013 at 4:55 PM, William Speirs <[email protected]> wrote: > I'm trying to use Slf4jLoggingModule in a unit test with an > AssistedInject. Here is my basic setup: > > > public class BaseClass { > private @InjectLogger Logger LOG; > > public BaseClass() { > LOG.debug("Calling constructor"); // dies with NPE > } > > public class ClassA extends BaseClass { > private @InjectLogger Logger LOG; > > @Inject > public ClassA(@Assisted Bean bean) { > super(); > } > > public interface ClassAFactory { > public ClassA create(Bean bean); > } > } > > @RunWith( OnamiRunner.class ) > @MockFramework( MockType.MOCKITO ) > public class ClassATest extends AbstractModule { > > @Inject ClassAFactory factory; > > @GuiceProvidedModules > public static Module createComplexModule() { > return new Slf4jLoggingModule(); > } > > @Override > public void configure() { > install(new FactoryModuleBuilder() > .implement(ClassA.class, ClassA.class) > .build(ClassAFactory.class)); > } > > @Test > public void test() throws Exception { > ClassA a = factory.create(bean); > } > } > > > What am I doing wrong? This is my first time using Onami and so I'm > sure I'm missing something obvious/stupid. > > Thanks... > > Bill- >
