# HG changeset patch # User Severin Gehwolf # Date 1347525768 -7200 # Node ID c95ca376c9af3c83bd7e99cc1629ceb862909d39 # Parent 8516a3c7ed22e3847e9bc422084a5f0aa7248330 Enable Eclipse plug-in tests during build. What this patch does: * Wraps a few dependencies (hamcrest, objenenis, mockito). I had to do this in order to get a working mockito. This is using hamcrest 1.3 in order to avoid uses conflicts of packages imported from mockito via Import-Package. Eclipse ships junit, which depends on hamcrest 1.1.0. Since during Eclipse plug-in test runs those bundles are loaded I can only guess that this is what produced the uses conflict when using mockito-all or mockito from springsource. Unfortunately no good diagnostics from equinox. That's why I think mockito-all or mockito from com.springsource was a no-go. * Creates a local p2 repository with those wrapped bundles with proper metadata so they can be used during build. * The (only) eclipse plug-in which contains tests (com.redhat.thermostat.eclipse.test) optionally imports those wrapped bundles. This allows us to run tests on Fedora whith stock libs (bundles are resolved only via Import-Package there, optional bundles are ignored). * It attaches the tycho surefire "test" goal to the "package" lifecycle phase so that tests are actually run with "mvn clean package" (default is to attach to integration-test only). * Added README.building with instructions as to how to build and run tests. Building Eclipse bits and run tests works as follows: $ cd path/to/$THERMOSTAT_HOME $ mvn clean install $ cd eclipse/test-deps-bundle-wrapping $ mvn clean install $ cd .. $ mvn clean package Reviewed-by: vanaltj Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-September/003074.html diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/README.building --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse/README.building Thu Sep 13 10:42:48 2012 +0200 @@ -0,0 +1,7 @@ +# perhaps rm -rf ~/.m2 +cd path/to/thermostat/home +mvn clean install +cd eclipse/test-deps-bundle-wrapping +mvn clean install +cd .. +mvn clean package diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF Wed Sep 12 21:37:33 2012 +0200 +++ b/eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF Thu Sep 13 10:42:48 2012 +0200 @@ -1,12 +1,22 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Version: 0.4.0.qualifier -Fragment-Host: com.redhat.thermostat.eclipse;bundle-version="0.4.0.qualifier" Bundle-Name: Eclipse client tests -Bundle-SymbolicName: com.redhat.thermostat.eclipse.test +Bundle-Activator: com.redhat.thermostat.eclipse.test.Activator +Bundle-SymbolicName: com.redhat.thermostat.eclipse.test;singleton:=true Bundle-Vendor: Redhat Inc. -Require-Bundle: org.eclipse.jdt.core, - org.junit;bundle-version="3.8.2" +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.junit;bundle-version="4.10.0", + com.redhat.thermostat.bundles.org.hamcrest.core;resolution:=optional, + com.redhat.thermostat.bundles.org.objenesis;resolution:=optional, + com.redhat.thermostat.bundles.org.mockito.mockito-core;resolution:=optional Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: org.mockito, +Import-Package: com.redhat.thermostat.common, + com.redhat.thermostat.common.dao, + com.redhat.thermostat.eclipse.model, + org.eclipse.core.resources, + org.eclipse.ui.ide, + org.mockito, org.mockito.stubbing +Export-Package: com.redhat.thermostat.eclipse.test.model diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/com.redhat.thermostat.eclipse.test/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.test/pom.xml Wed Sep 12 21:37:33 2012 +0200 +++ b/eclipse/com.redhat.thermostat.eclipse.test/pom.xml Thu Sep 13 10:42:48 2012 +0200 @@ -20,6 +20,35 @@ thermostat-common-core 0.4.0-SNAPSHOT + + com.redhat.thermostat.eclipse.parent + com.redhat.thermostat.eclipse.test-deps-repo + 0.4.0-SNAPSHOT + pom + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + + + diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/model/HostVmsTreeContentProviderTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/model/HostVmsTreeContentProviderTest.java Wed Sep 12 21:37:33 2012 +0200 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/model/HostVmsTreeContentProviderTest.java Thu Sep 13 10:42:48 2012 +0200 @@ -34,7 +34,7 @@ * to do so, delete this exception statement from your version. */ -package com.redhat.thermostat.eclipse.model; +package com.redhat.thermostat.eclipse.test.model; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -53,6 +53,8 @@ import com.redhat.thermostat.common.HostsVMsLoader; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.eclipse.model.HostsVmsTreeContentProvider; +import com.redhat.thermostat.eclipse.model.HostsVmsTreeRoot; public class HostVmsTreeContentProviderTest { diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/model/HostsVmsLabelProviderTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/model/HostsVmsLabelProviderTest.java Wed Sep 12 21:37:33 2012 +0200 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/model/HostsVmsLabelProviderTest.java Thu Sep 13 10:42:48 2012 +0200 @@ -34,7 +34,7 @@ * to do so, delete this exception statement from your version. */ -package com.redhat.thermostat.eclipse.model; +package com.redhat.thermostat.eclipse.test.model; import org.junit.After; import org.junit.Before; @@ -47,6 +47,8 @@ import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.eclipse.model.HostsVmsLabelProvider; +import com.redhat.thermostat.eclipse.model.HostsVmsTreeRoot; public class HostsVmsLabelProviderTest { diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/Activator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/Activator.java Thu Sep 13 10:42:48 2012 +0200 @@ -0,0 +1,92 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.eclipse.test; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.redhat.thermostat.eclipse.test"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext + * ) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext + * ) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF Wed Sep 12 21:37:33 2012 +0200 +++ b/eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF Thu Sep 13 10:42:48 2012 +0200 @@ -7,8 +7,8 @@ Bundle-Vendor: Red Hat Inc. Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0", - org.eclipse.ui;bundle-version="3.103.0" +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ui Import-Package: com.mongodb, com.redhat.thermostat.common, com.redhat.thermostat.common.appctx, @@ -16,4 +16,6 @@ com.redhat.thermostat.common.dao, com.redhat.thermostat.common.model, com.redhat.thermostat.common.storage -Eclipse-ExtensibleAPI: true +Export-Package: com.redhat.thermostat.eclipse;x-friends:=com.redhat.thermostat.eclipse.test, + com.redhat.thermostat.eclipse.model;x-friends:=com.redhat.thermostat.eclipse.test, + com.redhat.thermostat.eclipse.views;x-friends:=com.redhat.thermostat.eclipse.test diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/composite-repo/pom.xml --- a/eclipse/composite-repo/pom.xml Wed Sep 12 21:37:33 2012 +0200 +++ b/eclipse/composite-repo/pom.xml Thu Sep 13 10:42:48 2012 +0200 @@ -53,7 +53,7 @@ ${project.basedir}/.. - Thermostat Eclipse Composite p2 Repo + Thermostat Eclipse :: Composite p2 Repo diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/pom.xml --- a/eclipse/pom.xml Wed Sep 12 21:37:33 2012 +0200 +++ b/eclipse/pom.xml Thu Sep 13 10:42:48 2012 +0200 @@ -95,6 +95,11 @@ com.redhat.thermostat.eclipse.feature com.redhat.thermostat.eclipse.p2-repo core-p2-repository + test-deps-bundle-wrapping + + test-deps-p2-repository composite-repo @@ -110,6 +115,11 @@ ${orbit-site} + local_eclipse_test_deps + p2 + file://${basedir}/../eclipse-test-deps-repo/target/repository/ + + maven.eclipse.org http://maven.eclipse.org/nexus/content/groups/public/ @@ -155,10 +165,29 @@ + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + + run-tests-during-package + package + + test + + + + + org.apache.felix + maven-bundle-plugin + 2.3.7 + + org.eclipse.tycho tycho-compiler-plugin ${tycho-version} @@ -171,7 +200,7 @@ tycho-surefire-plugin ${tycho-version} - false + true flase diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/test-deps-bundle-wrapping/org.hamcrest/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse/test-deps-bundle-wrapping/org.hamcrest/pom.xml Thu Sep 13 10:42:48 2012 +0200 @@ -0,0 +1,95 @@ + + + + + 4.0.0 + + + com.redhat.thermostat.eclipse.parent + thermostat-eclipse-test-deps + 0.4.0-SNAPSHOT + + + org.hamcrest + com.redhat.thermostat.bundles.org.hamcrest.core + bundle + 1.3 + Thermostat Eclipse :: Bundles :: ${pkgArtifactId} + + This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. + + + + org.hamcrest + hamcrest-core + 1.3 + + + + + ${pkgGroupId} + ${pkgArtifactId} + ${pkgVersion} + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + 1.3.0 + + org.hamcrest.core;uses:="org.hamcrest";version="1.3", + org.hamcrest;uses:="org.hamcrest.internal, + org.hamcrest.core";version="1.3" + + org.hamcrest.internal + * + + + + + + + diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/test-deps-bundle-wrapping/org.mockito/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse/test-deps-bundle-wrapping/org.mockito/pom.xml Thu Sep 13 10:42:48 2012 +0200 @@ -0,0 +1,135 @@ + + + + + 4.0.0 + + + com.redhat.thermostat.eclipse.parent + thermostat-eclipse-test-deps + 0.4.0-SNAPSHOT + + + org.mockito + com.redhat.thermostat.bundles.org.mockito.mockito-core + bundle + 1.9.0 + Thermostat Eclipse :: Bundles :: ${pkgArtifactId} + + This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. + + + + org.mockito + mockito-core + 1.9.0 + + + + + ${pkgGroupId} + ${pkgArtifactId} + ${pkgVersion} + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + + org.mockito.internal*, + org.mockito.cglib*, + org.mockito.asm*, + org.objenesis*, + org.hamcrest*, + + + org.mockito.exceptions.base;version="1.9", + org.mockito.exceptions; + uses:="org.mockito.exceptions.verification.junit,org.mockito.exceptions.base, + org.mockito.listeners,org.mockito.exceptions.misusing, + org.mockito.exceptions.verification";version="1.9", + org.mockito.exceptions.verification; + uses:="org.mockito.exceptions.base";version="1.9", + org.mockito.stubbing.answers; + uses:="org.mockito.exceptions.base,org.mockito.invocation,org.mockito.stubbing"; + version="1.9", + org.mockito.configuration; + uses:="org.mockito,org.mockito.stubbing";version="1.9", + org.mockito.invocation;version="1.9", + org.mockito.exceptions.verification.junit; + uses:="junit.framework,org.mockito.exceptions.verification";version="1.9", + org.mockito.listeners;uses:="org.mockito.exceptions";version="1.9", + org.mockito; + uses:="org.hamcrest,org.mockito.stubbing,org.mockito.verification, + org.mockito.listeners,org.mockito.exceptions.base,org.mockito.exceptions, + org.mockito.configuration,org.mockito.invocation";version="1.9", + org.mockito.runners; + uses:="org.junit.runner,org.junit.runner.notification,org.junit.runner.manipulation"; + version="1.9", + org.mockito.exceptions.misusing;uses:="org.mockito.exceptions.base";version="1.9", + org.mockito.verification;uses:="org.mockito.exceptions";version="1.9", + org.mockito.stubbing;uses:="org.mockito.invocation";version="1.9" + + + junit.*;resolution:=optional, + org.junit.*;resolution:=optional, + org.hamcrest;version="[1.3,2.0)", + org.objenesis;version="[1.0,2.0)", + org.apache.tools.ant;resolution:=optional, + org.apache.tools.ant.types;resolution:=optional, + COM.jrockit.reflect;resolution:=optional, + jrockit.vm;resolution:=optional, + sun.reflect;resolution:=optional, + org.mockito* + + <_removeheaders>Private-Package + + + + + + + diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/test-deps-bundle-wrapping/org.objenesis/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse/test-deps-bundle-wrapping/org.objenesis/pom.xml Thu Sep 13 10:42:48 2012 +0200 @@ -0,0 +1,107 @@ + + + + + 4.0.0 + + + com.redhat.thermostat.eclipse.parent + thermostat-eclipse-test-deps + 0.4.0-SNAPSHOT + + + org.objenesis + com.redhat.thermostat.bundles.org.objenesis + bundle + 1.0 + Thermostat Eclipse :: Bundles :: ${pkgArtifactId} + + This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. + + + + org.objenesis + objenesis + 1.0 + + + + + ${pkgGroupId} + ${pkgArtifactId} + ${pkgVersion} + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + + org.objenesis.instantiator.jrockit;version="1.0", + org.objenesis;version="1.0", + org.objenesis.strategy;version="1.0", + org.objenesis.instantiator;version="1.0", + org.objenesis.instantiator.basic;version="1.0", + org.objenesis.instantiator.sun;version="1.0", + org.objenesis.instantiator.gcj;version="1.0" + + + !COM.jrockit*,!jrockit.vm*,!sun.reflect, + org.objenesis.instantiator.jrockit;version="1.0", + org.objenesis;version="1.0", + org.objenesis.strategy;version="1.0", + org.objenesis.instantiator;version="1.0", + org.objenesis.instantiator.basic;version="1.0", + org.objenesis.instantiator.sun;version="1.0", + org.objenesis.instantiator.gcj;version="1.0" + + <_nouses>true + + + + + + + diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/test-deps-bundle-wrapping/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse/test-deps-bundle-wrapping/pom.xml Thu Sep 13 10:42:48 2012 +0200 @@ -0,0 +1,72 @@ + + + 4.0.0 + + + com.redhat.thermostat.eclipse.parent + thermostat-eclipse-parent + 0.4.0-SNAPSHOT + + + + thermostat-eclipse-test-deps + pom + + Thermostat Eclipse :: Test Deps :: Bundles + + + org.hamcrest + org.objenesis + org.mockito + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + true + + + + + + diff -r 8516a3c7ed22 -r c95ca376c9af eclipse/test-deps-p2-repository/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse/test-deps-p2-repository/pom.xml Thu Sep 13 10:42:48 2012 +0200 @@ -0,0 +1,121 @@ + + + + 4.0.0 + + thermostat-eclipse-parent + com.redhat.thermostat.eclipse.parent + 0.4.0-SNAPSHOT + + com.redhat.thermostat.eclipse.parent + com.redhat.thermostat.eclipse.test-deps-repo + 0.4.0-SNAPSHOT + + Thermostat Eclipse :: p2 repository for plain Java test deps + + + + + com.redhat.thermostat.eclipse.parent + thermostat-eclipse-test-deps + 0.4.0-SNAPSHOT + + pom + + + + + + + + org.eclipse.tycho.extras + tycho-p2-extras-plugin + ${tycho-version} + + + prepare-package + + publish-features-and-bundles + + + + + true + + + + maven-dependency-plugin + + + copy-bundles-for-publishing + process-resources + + copy + + + + + org.hamcrest + com.redhat.thermostat.bundles.org.hamcrest.core + 1.3 + + + org.mockito + com.redhat.thermostat.bundles.org.mockito.mockito-core + 1.9.0 + + + org.objenesis + com.redhat.thermostat.bundles.org.objenesis + 1.0 + + + ${project.basedir}/target/source/plugins + + + + + + + + pom +