Hi,

I found another solution: I wrote a ModuleManager subclass that loads the required module definitions by starting off a root module definition (here the STK), and then traverses the module's dependency hierarchy, loading the dependencies' definitions along the way. Then the .xml file names are known in advance and can be loaded from classpath even with the surefire classloader, instead of trying to find all .xml files in the classpath by traversing all .jar files.

Maybe this approach can be reused when coming across the same problem again. You can find it as info.magnolia.module.templatingkit.util.SureFireModuleManager in the patch provided for http://jira.magnolia-cms.com/browse/MGNLSTK-690

Cheers,
Jörg

On 21.10.2010 15:36, Grégory Joseph wrote:

On Oct 21, 2010, at 15:17, Jörg von Frantzius wrote:

Hi,

when running tests from maven, it seems that 
info.magnolia.cms.util.ClasspathResourcesUtil.findResources(Filter) won't find resources 
from any jars. I just saw in the debugger that it treats the classloader as a 
URLClassLoader, asks it for URLs, gets 
"[file:/tmp/surefirebooter2965883144735553843.jar]", and tries to find 
resources only in there.

I want to run a RepositoryTestCase from within the STK module, which fails because it 
won't find any module descriptors. I'm not sure how to go about with this problem, maybe 
fix ClassPathResourcesUtil to test for "surefire" to occur within 
urls[0].getPath(), like it is done for JBoss 5 already?
Yeah, that's an ugly one.
The workaround you mention checks for "WEB-INF/classes/" which seem a little sounder than 
checking for "surefire" - we can't introduce workarounds for each and every build 
system's temporary files in there.

The way we do this at moment: we fake the module loading. See for instance 
http://svn.magnolia-cms.com/svn/community/modules/forum/trunk/magnolia-module-forum/src/test/java/info/magnolia/module/forum/ForumRepositoryTestCase.java

Another approach to this sort of problem would be to refactor ClasspathResourcesUtil so 
that it becomes "pluggable". In tests, you'd work with a ClasspathResourcesUtil 
implementation that knows about the specific classpath workarounds it needs to do (and 
we'd probably have a couple of JBoss*ClasspathResourcesUtil, 
WebSphereClasspathResourcesUtil, etc implementations too ...)

hth,

-g

Regards,
Jörg

--
Dipl. inf. Jörg von Frantzius, System Architect
Email mailto:[email protected]
Phone +49 30 283921-318
Fax +49 30 283921-29
Aperto AG - In der Pianofabrik
Chausseestraße 5, D-10115 Berlin-Mitte
Web http://www.aperto.de
HRB 77049, AG Berlin Charlottenburg
Vorstand: Dirk Buddensiek


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to:<[email protected]>
----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to:<[email protected]>
----------------------------------------------------------------



--
Dipl. inf. Jörg von Frantzius, System Architect
Email mailto:[email protected]
Phone +49 30 283921-318
Fax +49 30 283921-29
Aperto AG - In der Pianofabrik
Chausseestraße 5, D-10115 Berlin-Mitte
Web http://www.aperto.de
HRB 77049, AG Berlin Charlottenburg
Vorstand: Dirk Buddensiek


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to