see below.

On Tue, Aug 31, 2010 at 7:53 PM, Rossmanith, Philipp <
[email protected]> wrote:

>  Hi Toni,
>
>
>
> Thanks for your quick response. If I understood correctly, in order to
> resolve my error, I’d have to do the following:
>
> 1.       Identify the features/bundles which provide the missing classes
> in the same version as used in my JUnit test case.
>
yes

> 2.       Within the @Configuration method, within provision(...) or
> scanFeatures(...), add code for providing the features/bundles identified in
> 1.
>
yes

> 3.       Pax Exam/BND automatically adds import statements for all
> packages that are missing; if step 2. installed the bundles providing the
> missing classes, the problem is solved.
>
yes

>
>
> Correct?
>
>
>
> Basically, all I want to do is verify the successful installation and start
> of my bundle. What would be the recommended best practice for this?
>

Well, then your test itself just iterates over all bundles (using the
bundlecontext it got via injection) and checks their state. Thats the body
of your test.
You can do of cause additional checks like requesting services and so on. If
you do so, make sure to honor the fact that services might need some tome to
start, so put in some timeout based loop when "waiting" for the service.
Don't be afraid by the classes you use, bnd will take care of it.

In the Configuration part you need to add all the bundles. Yes, by putting
in raw urls to files/bundles. But in a maven ecosystem you can use things
like this:
provision(
  mavenBundle().artifact("myArtifact").groupId("group").version("1.0"),
  ..
)

There are plenty more ways to archive this, just check out the factory
methods you can find in CoreOptions.class and PaxRunnerOptions.class .

The configuration is basically a blueprint of the system you want to test.
So everything you have in your real system, you can stick into the
@Configuration part.

Let me know how it works for you.

If license allows feel free to share your example/problem/usecase.
cheers!
Toni




>
>
> Thanks,
>
> Ciao, Philipp
>
>
>
> *De:* [email protected] [mailto:[email protected]] *En
> nombre de *Toni Menzel
> *Enviado el:* martes, 31 de agosto de 2010 17:36
> *Para:* Rossmanith, Philipp
> *CC:* [email protected]
> *Asunto:* Re: NoClassDefFoundError when running a Pax-Exam JUnit test
>
>
>
> Hi Philipp,
>
>
>
> actually, no, exam does not put test dependencies into the probe (thats how
> we used to call the bundle containing your test).
>
> There is an algorithm that tried to find your test classes (physically by
> crawling the project filesystem), then "walk" back to the package root and
> include all resources/classes below that root.
>
> In essence, if you are in a maven project, it will find target/test-classes
> as your root. These are all resources that will go into the bundle.
>
> Everything else must be provided as bundles on their own.
>
> BND generates imports for all missing packages.
>
>
>
> This has mostly to do with the idea to not put any black magic or
> assumptions into the probe itself. Its really just your test class(es) and
> exam knows how to invoke the methods remotely (pax runner process under the
> hood).
>
> It is already out of your control what the manifest looks like, so it makes
> sense to put just the minimal amount of  resources in there.
>
>
>
> In order to let your probe resolve, you need to provide all the packages
> yourself of cause.
>
>
>
> Toni
>
> --
> *Toni Menzel || http://okidokiteam.com*
>
> On Tue, Aug 31, 2010 at 5:20 PM, Rossmanith, Philipp <
> [email protected]> wrote:
>
> Hi,
>
> I'm trying to run a simple JUnit test with Pax-Exam. I'm using Maven
> 2.2.1, POM, JUnit code and Maven output (Surfire and command line) are
> attached.
>
> The test should obtain an object for the interface ApplicationContext. I
> can deploy the bundles under test; both of them show in Karaf as
> providing the interface.*)
>
> When I run the test, I get a "java.lang.NoClassDefFoundError:
> org/springframework/context/ApplicationContext" error. This surprises
> me, as my understanding was that Pax Exam was creating a bundle from the
> test's dependencies which should include all of the required
> dependencies - and hence, the missing class file.
>
> Is there something obvious that I'm missing?
>
> Thanks in advance,
> Ciao, Philipp
>
> *)
> E.g.:
> org.springframework.context.service.name = tsisb-auto-osgi-wsdl-prov
> Bundle-SymbolicName = tsisb-auto-osgi-wsdl-prov Bundle-Version =
> 1.0.0.SNAPSHOT objectClass =
> org.springframework.osgi.context.DelegatedExecutionOsgiBundleApplication
> Context, org.springframework.osgi.
> context.ConfigurableOsgiBundleApplicationContext,
> org.springframework.context.ConfigurableApplicationContext, org.spring
> framework.context.ApplicationContext,
> org.springframework.context.Lifecycle,
> org.springframework.beans.factory.ListableB
> eanFactory, org.springframework.beans.factory.HierarchicalBeanFactory,
> org.springframework.context.MessageSource, org.sp
> ringframework.context.ApplicationEventPublisher,
> org.springframework.core.io.support.ResourcePatternResolver, org.spring
> framework.beans.factory.BeanFactory,
> org.springframework.core.io.ResourceLoader,
> org.springframework.beans.factory.Dispo
> sableBean
> service.id = 267
>
>
> http://www.Taglocity.com Tags: Pax Exam, Test, Issue, TSISB
>
>
> This e-mail and any attachments may contain confidential or privileged
> information.
> Any unauthorized copying, use or distribution of this information is
> strictly
> prohibited.
>
> _______________________________________________
> general mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/general
>
>
>
>
>
>
> This e-mail and any attachments may contain confidential or privileged
> information.
> Any unauthorized copying, use or distribution of this information is
> strictly
> prohibited.
>



-- 
*Toni Menzel || **http://okidokiteam.com*
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to