You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by "l.penet@senat.fr" <l....@senat.fr> on 2016/10/27 06:55:30 UTC
Strange behaviour with @RunWith(CdiTestRunner.class)
Hi.
I am running tests with the help of
@RunWith(CdiTestRunner.class)
I am using in this project :
- DeltaSpike 1.7.0
- OpenWebBeans 1.6.2.
(among a lot of other stuff as almost always in java)
The target container is Tomcat 8.5.6, but it does not seem important there.
I have no problem as long as I inject only beans from dependencies.
However, in my current project, I have one bean injecting another from the
top level project and it fails.
So, I fired my debugger and noticed that :
- OWB uses a fake servlet context, as the servlet spec is detected ;
- classes from my war are not added, as this is a fake context and there
is no war
- in AbstractMetaDataDiscovery. registerBeanArchives, there is no
classpath containing my classes that is scanned for beans.xml, and so, my
classes are never added.
I can, as a workaround, put my beans in a dependency... But is there
something I can do to get it working there ?
Thanks in advance,
Ludovic
|
| AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
|
Re: Strange behaviour with @RunWith(CdiTestRunner.class)
Posted by "l.penet@senat.fr" <l....@senat.fr>.
On 27/10/2016 10:05, Gerhard Petracek wrote:
> hi ludovic,
>
> the classpath-scanner (in java-se mode) isn't aware of some locations.
> you can tweak e.g. your build-file - see e.g. [1].
>
> regards,
> gerhard
>
> [1]
> https://github.com/CDIatWork/IdeaFork/blob/master/ideafork_ee6/pom.xml#L526
Well, yes, I can do that and ended doing somethin like that...
<plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.7</version> <executions> <execution> <id>copy-resources</id> <!-- here the phase you need --> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.basedir}/target/test-classes</outputDirectory> <resources> <resource> <directory>${project.basedir}/src/main/resources/META-INF</directory> <filtering>false</filtering> </resource> <resource> <directory>${project.basedir}/target/classes</directory> <filtering>false</filtering> </resource> </resources> </configuration> </execution>
</executions> </plugin>
... but I would have prefered to be able to add a classpath to OWB scanner.
This way, I would have added target/classes, and zou.
Anyway, it is logical and quickly done. IMHO, it deserves to be added to
the test module FAQ.
Thanks !
Ludovic
|
| AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
|
Re: Strange behaviour with @RunWith(CdiTestRunner.class)
Posted by Gerhard Petracek <gp...@apache.org>.
hi ludovic,
the classpath-scanner (in java-se mode) isn't aware of some locations.
you can tweak e.g. your build-file - see e.g. [1].
regards,
gerhard
[1]
https://github.com/CDIatWork/IdeaFork/blob/master/ideafork_ee6/pom.xml#L526
2016-10-27 8:55 GMT+02:00 l.penet@senat.fr <l....@senat.fr>:
> Hi.
>
> I am running tests with the help of
>
> @RunWith(CdiTestRunner.class)
>
> I am using in this project :
>
> - DeltaSpike 1.7.0
>
> - OpenWebBeans 1.6.2.
>
> (among a lot of other stuff as almost always in java)
>
> The target container is Tomcat 8.5.6, but it does not seem important there.
>
>
> I have no problem as long as I inject only beans from dependencies.
>
> However, in my current project, I have one bean injecting another from the
> top level project and it fails.
>
> So, I fired my debugger and noticed that :
>
> - OWB uses a fake servlet context, as the servlet spec is detected ;
>
> - classes from my war are not added, as this is a fake context and there
> is no war
>
> - in AbstractMetaDataDiscovery. registerBeanArchives, there is no
> classpath containing my classes that is scanned for beans.xml, and so, my
> classes are never added.
>
> I can, as a workaround, put my beans in a dependency... But is there
> something I can do to get it working there ?
>
> Thanks in advance,
>
> Ludovic
>
>
> |
> | AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
> |
>
>