Hi Bram, everything that you need should be provided by Options derived from CoreOptions.* factory class. for example url(<String>) or mavenBundle() etc.
Your test probe (the bundle that contains your test classes) is generated out of your test classes only For a longer explanation, read: http://tonimenzel.com/blog/2011/1/18/understanding-pax-exam-1x-part-i.html (the mechanics on how a probe is made is still the same in exam2). So question: What is your CoreFixture.provisionWithFsStorage() doing exactly ? Toni On Mon, May 2, 2011 at 1:10 PM, Bram de Kruijff <[email protected]>wrote: > Hi, > > On Thu, Apr 28, 2011 at 2:05 PM, Toni Menzel <[email protected]> wrote: > > Quick annswer (on mobile): > > @Inject public BundleContext m_bundleContext; > > is not support in 2.0.0. There is just parameter injection into the test > > method (see examples). > > Same for @Before/After. Its because Exam2 is pretty much independent of > > JUnit4 now. > > We will add support for @Before in the subsequent release, but not in > stock > > 2.0.0. > > Long explanation possibly on a real computer later. ;) > > Thanks for that reply Toni. Working around that I'm running into a > strange (to me at least) issue :S The plan was to put some generic > provision configuration options in a utility class called CoreFixture > is a seperate (reusable) library, so in my test I am able to do... > > @Configuration > public Option[] config() { > return options( > junitBundles(), > CoreFixture.provisionWithFsStorage(), > } > > > My maven test project has a dependecy on that library, it compiles but > at test time things go bad because the classes can not be found. The > problem seems to be that the classes from the library are not included > in the probe even though the package is mentioned in both > Import-Package and Export-Package statements when it is generated. > > So, is there a way to include stuff into the probe or am I going about > this in the wrong way? > > > Thanks again, > Bram de Kruijff > > > Toni > > On Thu, Apr 28, 2011 at 1:56 PM, Bram de Kruijff <[email protected]> > > wrote: > >> > >> Hi list, > >> > >> trying to get up to speed on paxexam 2 I quickly got hello world to > >> run in the native container. Very fast and elegant! Now I would like > >> to do some more advanced testing that require more comprehensive > >> "fixtures". Eg bundles active, services available, configurations > >> registered etc. I'm not entirely clear in the lifecycle yet and am > >> wondering what would be the best practice/place of doing so without > >> poluting every test with boilerplate. Eg. in the outline of my code > >> below I do not seem to have access to the BundleContext in @Before and > >> only recieve it in the tests themselves. Any pointers would be much > >> appreciated! > >> > >> thanks, > >> Bram de Kruijff > >> > >> >> sample test code << > >> > >> @RunWith(JUnit4TestRunner.class) > >> @ExamReactorStrategy(AllConfinedStagedReactorFactory.class) > >> public class InitialTest { > >> > >> @Inject > >> public BundleContext m_bundleContext; > >> > >> @Configuration > >> public Option[] config() { > >> return options( > >> junitBundles(), > >> provision( > >> myLogService(), > >> myTestBundle() > >> )); > >> } > >> > >> > >> @BeforeClass > >> public static void setUpOne() throws Exception { > >> // no bundleContext here > >> } > >> > >> @Before > >> public void setUp() throws Exception { > >> // no bundleContext here > >> } > >> > >> @Test > >> public void testLogServiceAvailable(BundleContext bundleContext) > >> throws Exception { > >> assertThat(bundleContext, is(notNullValue())); > >> ServiceReference logServiceReference = > >> bundleContext.getServiceReference(LogService.class.getName()); > >> assertThat(logServiceReference, is(notNullValue())); > >> try { > >> Object logServiceObject = > >> bundleContext.getService(logServiceReference); > >> assertThat(logServiceObject, is(notNullValue())); > >> assertThat(logServiceObject, > is(instanceOf(LogService.class))); > >> } > >> finally { > >> bundleContext.ungetService(logServiceReference); > >> } > >> } > >> > >> @Test > >> public void testMyService1(BundleContext bundleContext) throws > >> Exception { > >> // how can be sure that services are registered / configuration set > >> etc? > >> } > >> > >> @Test > >> public void testMyService2(BundleContext bundleContext) throws > >> Exception { > >> // how can be sure that services are registered / configuration set > >> etc? > >> } > >> } > >> > >> _______________________________________________ > >> general mailing list > >> [email protected] > >> http://lists.ops4j.org/mailman/listinfo/general > > > > > > > > -- > > Toni Menzel Source > > > > > > _______________________________________________ > > general mailing list > > [email protected] > > http://lists.ops4j.org/mailman/listinfo/general > > > > > > _______________________________________________ > general mailing list > [email protected] > http://lists.ops4j.org/mailman/listinfo/general > -- Toni Menzel Source <http://tonimenzel.com>
_______________________________________________ general mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/general
