Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Tycho » IllegalAccessErrors Running JUnit Tests During Build(Tests pass using JUnit Runner but fail when doing maven/tycho/surefire build.)
IllegalAccessErrors Running JUnit Tests During Build [message #634067] Wed, 20 October 2010 12:54 Go to next message
elvisisking is currently offline elvisiskingFriend
Messages: 8
Registered: October 2010
Junior Member
I have a plugin (org.a.test) that is used to test another plugin (org.a). Both plugins have the same Java packages defined. The classes being tested in org.a have "protected" and package private methods. When I do a build using Tycho both jars (org.a, org.a.test) build fine.

However, during the build when the JUnit tests are run I get a runtime java.lang.IllegalAccessError whenever a test plugin class calls one of these protected methods. All the tests run successfully within Eclipse using the JUnit runner. I have Eclipse's compiler setting for "forbidden reference access rules" set to be an error.

Any ideas?

Thanks!
Re: IllegalAccessErrors Running JUnit Tests During Build [message #634156 is a reply to message #634067] Wed, 20 October 2010 15:52 Go to previous messageGo to next message
Jan Sievers is currently offline Jan SieversFriend
Messages: 23
Registered: July 2009
Junior Member
you need to use a test fragment instead of a test plugin in order to access
package-private members
This is not a tycho issue but rather how OSGi behaves at runtime

Regards
Jan

"elvisisking" <dflorian@redhat.com> wrote in message
news:i9mojo$m85$1@news.eclipse.org...
>I have a plugin (org.a.test) that is used to test another plugin (org.a).
>Both plugins have the same Java packages defined. The classes being tested
>in org.a have "protected" and package private methods. When I do a build
>using Tycho both jars (org.a, org.a.test) build fine.
> However, during the build when the JUnit tests are run I get a runtime
> java.lang.IllegalAccessError whenever a test plugin class calls one of
> these protected methods. All the tests run successfully within Eclipse
> using the JUnit runner. I have Eclipse's compiler setting for "forbidden
> reference access rules" set to be an error.
>
> Any ideas?
>
> Thanks!
Re: IllegalAccessErrors Running JUnit Tests During Build [message #634453 is a reply to message #634156] Thu, 21 October 2010 18:39 Go to previous messageGo to next message
elvisisking is currently offline elvisiskingFriend
Messages: 8
Registered: October 2010
Junior Member
So by your response you're saying when I use the JUnit runner within Eclipse to run the tests (which all pass), that OSGi is not being used then. I thought Eclipse used the OSGi framework. Is that not the case?

Does anyone know the steps to convert a plugin to a fragment?

Thanks!
Re: IllegalAccessErrors Running JUnit Tests During Build [message #634630 is a reply to message #634453] Fri, 22 October 2010 13:25 Go to previous message
Jan Sievers is currently offline Jan SieversFriend
Messages: 23
Registered: July 2009
Junior Member
Run As > Junit test runs plain Junit tests, Run As > Junit plugin tests runs Junit inside OSGI (which is what tycho also does)
Previous Topic:Downloading Tycho / Maven
Next Topic:Has anyone successfully built a RAP app using Maven Tycho?
Goto Forum:
  


Current Time: Thu Apr 25 06:49:34 GMT 2024

Powered by FUDForum. Page generated in 0.04149 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top