[
https://issues.apache.org/jira/browse/SLING-4757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14566541#comment-14566541
]
Petr Shypila edited comment on SLING-4757 at 5/31/15 1:03 PM:
--------------------------------------------------------------
I'm faced with problems during creation integration tests for these classes.
I try to inject services into my test using @javax.inject.Inject annotation.
However it doesn't work for me and every time my test throws
ClassNotFoundException.
{noformat}
at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2397)
at java.lang.Class.getDeclaredFields(Class.java:1806)
at org.junit.runners.model.TestClass.<init>(TestClass.java:49)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:75)
at
org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)
at
org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunner.<init>(ContainerTestRunner.java:53)
at
org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunnerBuilder.runnerForClass(ContainerTestRunnerBuilder.java:50)
at
org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at
org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunnerClassRequest.getRunner(ContainerTestRunnerClassRequest.java:61)
at
org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:31)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
at
org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.invokeViaJUnit(JUnitProbeInvoker.java:123)
at
org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.findAndInvoke(JUnitProbeInvoker.java:96)
at
org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.call(JUnitProbeInvoker.java:72)
at
org.ops4j.pax.exam.nat.internal.NativeTestContainer.call(NativeTestContainer.java:108)
at
org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:84)
at org.ops4j.pax.exam.junit.PaxExam$2.evaluate(PaxExam.java:294)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:111)
at
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
at
org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
at
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
{noformat}
But injection of standard org.osgi.framework.BundleContext looks like works
fine.
I did everything very same with
org.apache.sling.i18n.it.ResourceBundleProviderIT but it still doesn't work.
I have also attached a patch
FileNameExtractorImpl_Injection_failed__ClassNotFoundException with this test.
Could you please help me to find where the problem is?
Thank you.
was (Author: petr.shypila):
I'm faced with problems during creation integration tests for these classes.
I try to inject services into my test using @javax.inject.Inject annotation.
However it doesn't work for me and every time my test throws
ClassNotFoundException. But injection of standard
org.osgi.framework.BundleContext looks like works fine.
I did everything very same with
org.apache.sling.i18n.it.ResourceBundleProviderIT but it still doesn't work.
I have also attached a patch
FileNameExtractorImpl_Injection_failed__ClassNotFoundException with this test.
Could you please help me to find where the problem is?
Thank you.
> Improve test coverage and add integration tests to the contentdetection module
> ------------------------------------------------------------------------------
>
> Key: SLING-4757
> URL: https://issues.apache.org/jira/browse/SLING-4757
> Project: Sling
> Issue Type: Improvement
> Components: Commons
> Reporter: Bertrand Delacretaz
> Assignee: Petr Shypila
> Attachments:
> FileNameExtractorImpl_Injection_failed__ClassNotFoundException.patch,
> week2-part1-unit-tests.patch
>
>
> The new SLING-4694 contentdetection module has reasonable test coverage but
> there are some gaps, and it's also missing some integration tests to verify
> that the services provided by the bundle are correctly made available in an
> OSGI environment.
> I'll take this opportunity to ask our GSoC student [~petr.shypila] to expand
> these tests, as that's a good example of what we're trying to do with his
> tests improvement project.
> So [~petr.shypila] here's your "mission" ;-)
> Buliding bundles/commons/contentdetection with with -Pjacoco-report and
> looking at target/site/jacoco/index.html shows that a few things are not
> tested. The first step is to add the missing unit tests to improve that,
> maybe provide a first patch with just that.
> Then, we'd like to add integration tests that start this bundle in an OSGi
> environment and verify that the ContentAwareMimeTypeService and
> FileNameExtractor services are available and work. No need to duplicate the
> unit tests, just verify that the services are here and work in a simple case.
> The best way to do this is probably with Pax Exam, the
> ResourceBundleProviderIT. is a good example of that and there are other
> examples in our codebase if you search for *IT.java files that contain
> "pax.exam".
> As usual, try to minimize changes to the pom (except for what's directly
> related to testing) and to non-test code.
> Feel free to ask if you have any questions of course, either here for minor
> ones or on the dev list for larger discussions.
> [1]
> https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)