Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » org.eclipse.scout.mockito-all ???(Proposal for temporary solution to use Mockito in the Scout RT Build)
org.eclipse.scout.mockito-all ??? [message #1222779] Sat, 21 December 2013 05:47 Go to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 675
Registered: October 2011
Senior Member
=== Background ===
- We want to use Mockito in our tests for Scout RT (Bug 409461).

- Mockito relies on hamcrest and objenesis and is distributed as fat jar distribution (mockito-all-1.9.5.jar) or as separate-jars distribution (mockito-core-1.9.5.jar + hamcrest.core-1.1.0.jar and objenesis-1.0.0.jar)
- Approved CQ 7600 allows to use mockito-core-1.9.5
- Thanks to Stephan Leicht mockito-core-1.9.5 is already available in Orbit: org.mockito_1.9.5.201306061252.jar (Integration build).

=== Problem ===
It is not possible to use the Orbit mockito, hamcrest and objenesis Bundles together in a tycho build.

See the Maven stack trace at the end of this message.


=== Possible solution ===
- Create a new bundle org.eclipse.scout.mockito-all, containing:
* mockito-core-1.9.5.jar from mockito.org (Corresponding to the CQ 0000)
* org.hamcrest.core_1.1.0.v20090501071000.jar from Eclipse Orbit
* org.objenesis_1.0.0.v201105211943.jar from Eclipse Orbit

- org.eclipse.scout.mockito-all isn't in any scout feature, it will not be distributed from the Scout project to the outside (exactly like test fragments).
- all tests fragments that requires mockito declare an additional bundle dependency
- org.eclipse.scout.mockito-all is built with the "testing-build" profile of the Scout RT build.

I have pushed this solution on my feature branch. features/jbr/mockito_bug409461

Content of the org.eclipse.scout.mockito-all Bundle:
org.eclipse.scout.mockito-all 
|   .classpath
|   .project
|   build.properties
|   pom.xml
|   trace.txt
|
+---.settings
|       org.eclipse.jdt.core.prefs
|
+---bin
+---lib
|       mockito-core-1.9.5.jar
|       org.hamcrest.core_1.1.0.v20090501071000.jar
|       org.objenesis_1.0.0.v201105211943.jar
|
+---META-INF
|       MANIFEST.MF
|
\---src


=== Side Note 1 ===
I have tried to use the mockito version from orbit:
org.mockito-1.9.5.v201311280930.jar instead of mockito-core-1.9.5.jar

This should be the same, but with the version from Orbit, I get:

Caused by: java.lang.SecurityException: class "org.eclipse.scout.rt.client.ui.basic.cell.ICellObserver$$EnhancerByMockitoWithCGLIB$$d9869715"'s signer information does not match signer information of other classes in the same package


According to this stackoverflow question: Java SecurityException : signer information does not match, there is a problem with the cglib library.

If I unsign the Orbit jar, the SecurityException is gone.


=== Side Note 2 ===
As pointed out by Markus Keller (Bug 403676#c2) a good move could be to fix the hamcrest dendency problem in the mockito project itself.

This is something that is discussed on the mockito google group, and they have open issues that goes in this direction (for a version 2 of mockito).

=== Maven stack trace ===
Maven stacktrace if the Orbit bundle org.mockito-1.9.5.v201311280930.jar is in the target platform, without the proposed org.eclipse.scout.mockito-all bundle.

[ERROR] Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle org.eclipse.scout.rt.client.test cannot be resolved
[ERROR] Resolution errors:
[ERROR] Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
[ERROR] Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
[ERROR] Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
[ERROR] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle org.eclipse.scout.rt.client.test cannot be resolved
Resolution errors:
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"

        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle org.eclipse.scout.rt.client.test cannot be resolved
Resolution errors:
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"

        at org.eclipse.tycho.core.osgitools.OsgiBundleProject.getResolverState(OsgiBundleProject.java:258)
        at org.eclipse.tycho.core.osgitools.OsgiBundleProject.resolveClassPath(OsgiBundleProject.java:159)
        at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.resolveProject(DefaultTychoDependencyResolver.java:122)
        at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:75)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:274)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        ... 11 more
Caused by: org.osgi.framework.BundleException: Bundle org.eclipse.scout.rt.client.test cannot be resolved
Resolution errors:
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"
   Bundle org.eclipse.scout.rt.client.test - Missing Constraint: Import-Package: org.hamcrest; version="[1.3.0,2.0.0)"

        at org.eclipse.tycho.core.osgitools.EquinoxResolver.assertResolved(EquinoxResolver.java:286)
        at org.eclipse.tycho.core.osgitools.EquinoxResolver.newResolvedState(EquinoxResolver.java:72)
        at org.eclipse.tycho.core.osgitools.OsgiBundleProject.getResolverState(OsgiBundleProject.java:256)
        ... 16 more
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException

[Updated on: Sat, 21 December 2013 05:53]

Report message to a moderator

Re: org.eclipse.scout.mockito-all ??? [message #1225398 is a reply to message #1222779] Sun, 29 December 2013 12:57 Go to previous messageGo to next message
Judith Gull is currently offline Judith Gull
Messages: 49
Registered: February 2010
Member
I see no problem in creating the suggested plugin org.eclipse.scout.mockito-all for Scout RT without re-distributing it, until the Orbit problems are resolved.
Re: org.eclipse.scout.mockito-all ??? [message #1225568 is a reply to message #1225398] Mon, 30 December 2013 01:53 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 675
Registered: October 2011
Senior Member
I will wait for the feedback from Stephan Leicht Vogt, he has maybe an other idea involving Orbit.

About my implementation:
I could use maven-unzip using the jars on Orbit to produce my mockito-all project (instead of the binary jar file in the Git repo).
Re: org.eclipse.scout.mockito-all ??? [message #1228490 is a reply to message #1225568] Tue, 07 January 2014 05:40 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 675
Registered: October 2011
Senior Member
Input from Ken Lee:

Here is what Eclipse RAP is doing:
http://dev.eclipse.org/mhonarc/lists/rap-dev/msg01070.html
Re: org.eclipse.scout.mockito-all ??? [message #1234572 is a reply to message #1228490] Wed, 22 January 2014 04:40 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 675
Registered: October 2011
Senior Member
Overview of the versioning problem on StackOverflow:
http://stackoverflow.com/questions/18770943/mockito-junit-hamcrest-versioning
Re: org.eclipse.scout.mockito-all ??? [message #1250931 is a reply to message #1234572] Wed, 19 February 2014 13:54 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 675
Registered: October 2011
Senior Member
Update:

Proposal from Judith Gull:
https://git.eclipse.org/r/#/c/22250/
=> Check in the source.

A solution could be to use the Maven Dependency Plugin instead having to check in the source code (gerrit proposal) or the jars (feature branch proposal).

I am not sure how to realize it with Maven. I am not sure if this is the good direction, but see also this question on Stack-Overflow:
Tycho: maven artifact corresponding to a p2 installable unit in the active target platform.

Re: org.eclipse.scout.mockito-all ??? [message #1265745 is a reply to message #1250931] Thu, 06 March 2014 08:59 Go to previous message
Judith Gull is currently offline Judith Gull
Messages: 49
Registered: February 2010
Member
In the maven build mockito core works together with hamcrest.core and org.objenesis with the latest osgi (luna), e.g. :

<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>1.4</version>
</dependency>
</dependencies>

<repositories>
<repository>
<!-- Testing with Luna OSGi version -->
<id>Testing</id>
<layout>p2</layout>
<url>url to osgi from luna</url>
</repository>
</repositories>

However, if the tests are run in eclipse, the tests do not run, even if all necessary bundles are available.

Therefore we use mockito.all for the moment, even, if there might be problems with some hamcrest classes.
Previous Topic:When I follow the Tutorials of "HelloWorld" I get these Error
Next Topic:Rap Table field default menu visibility problem
Goto Forum:
  


Current Time: Fri Aug 29 10:24:07 EDT 2014

Powered by FUDForum. Page generated in 0.10457 seconds