just scan your mock or provide a fallback injector if you don't lookup directly the class but only inject it through @EJB. BTW using arquillian make it easier: http://svn.apache.org/repos/asf/tomee/tomee/trunk/arquillian/arquillian-openejb-embedded-4/src/test/java/org/apache/openejb/arquillian/openejb/ArquillianAndMockitoTest.java Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau
2014/1/14 Michiel De Smet <[email protected]>: > I find a result for ctx.lookup("openejb/localFooImplLocal"). Now I want to > rebind that to my mocked class. How would I do that? > > If I don't scan that class I would still have to bind it right? > > > On Tue, Jan 14, 2014 at 5:20 PM, Romain Manni-Bucau > <[email protected]>wrote: > >> binding doesn't use this context, and not sure it will use this name >> (well no in fact). The context can be accessed through >> SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext() >> btw. >> >> But not using scanning would make it smoother >> Romain Manni-Bucau >> Twitter: @rmannibucau >> Blog: http://rmannibucau.wordpress.com/ >> LinkedIn: http://fr.linkedin.com/in/rmannibucau >> Github: https://github.com/rmannibucau >> >> >> >> 2014/1/14 Michiel De Smet <[email protected]>: >> > I want to rebind some EJB's to their mock counterparts after initializing >> > the initial context trough class path scanning. >> > >> > I tried following but this did not work: >> > @LocalClient >> > class MyTestClass() { >> > ... >> > initialContext = new InitialContext(properties); >> > IFoo foo = EasyMock.createNiceMock(IFoo.class); >> > ... >> > initialContext.rebind("FooImplLocal", foo); >> > initialContext.bind("inject", this); >> > ... >> > } >> > >> > The binding succeeds without a NamingException but however the original >> EJB >> > is injected in the MyTestClass... >> > >> > >> > Any ideas? >>
