Skip to content

Conversation

@dscho
Copy link
Contributor

@dscho dscho commented Jun 18, 2014

When Maven's surefire plugin runs unit tests, the URLClassLoader does
actually not list the URLs corresponding to the dependencies. Instead,
surefire tries to be clever and hides those dependencies inside a
single, empty .jar file's manifest's Class-Path: entry.

We are not dumb, so surefire loses: we get the URLs anyway. Hah! Take
this, surefire! shakes-fist

This came up while working on a regression test for http://fiji.sc/bugzilla/show_bug.cgi?id=787.

Signed-off-by: Johannes Schindelin johannes.schindelin@gmx.de

When Maven's surefire plugin runs unit tests, the URLClassLoader does
actually not list the URLs corresponding to the dependencies. Instead,
surefire tries to be clever and hides those dependencies inside a
single, empty .jar file's manifest's Class-Path: entry.

We are not dumb, so surefire loses: we get the URLs anyway. Hah! Take
this, surefire! *shakes-fist*

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added 4 commits June 19, 2014 00:04
... even when run via surefire...

To that end, we piggy-back on the already existing test for bare .java
"scripts": as scijava-common is a dependency of scripting-java, let's
just use one of scijava-common's utility classes in the bare .java
"script".  That way, the test will only pass when scijava-common's class
is found on the compiler class path.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
If we ever limit which class loader we use as parent or to discover the
available dependencies by using the class loader that happened to load
MiniMaven, we will be in for a *lot* of trouble in the future, e.g. with
ImageJ 1.x' PluginClassLoader.

So let's not do that. Let's use the current thread's context class loader,
like everywhere else we need a class loader.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Contributor Author

dscho commented Jun 19, 2014

I re-tested, all is fine. I also added a couple of commits that do not technically have anything to do with surefire, but they fix issues discovered while working on this branch.

@ctrueden could you have a quick look again and merge if you don't see problems with the PR?

@ctrueden
Copy link
Member

Looks good!

ctrueden added a commit that referenced this pull request Jun 19, 2014
Allow running inside Maven unit tests
@ctrueden ctrueden merged commit f16d707 into master Jun 19, 2014
@ctrueden ctrueden deleted the surefire branch June 19, 2014 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants