Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-06-13 12:45:42 +0000
committervlorenzo2012-06-13 12:45:42 +0000
commitacd33e87d2e25dbd3ba2a2b161134efa20549f90 (patch)
treeef7da881cc6a7f638d4489faa96d4c02314cf0f9 /tests/junit/plugins/developer
parentc5ff25a0839067edd7740e579a5a69b8c210690a (diff)
downloadorg.eclipse.papyrus-acd33e87d2e25dbd3ba2a2b161134efa20549f90.tar.gz
org.eclipse.papyrus-acd33e87d2e25dbd3ba2a2b161134efa20549f90.tar.xz
org.eclipse.papyrus-acd33e87d2e25dbd3ba2a2b161134efa20549f90.zip
378990: [Tests] Add JUnit tests to test informations of builded plugins and features
- Replaces the used Assert by the Junit Assert - Add a test to test the java version only when the bundle contains java sources
Diffstat (limited to 'tests/junit/plugins/developer')
-rw-r--r--tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundleTestsUtils.java16
-rw-r--r--tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java25
2 files changed, 30 insertions, 11 deletions
diff --git a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundleTestsUtils.java b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundleTestsUtils.java
index 18768e12524..0e8e8a533ae 100644
--- a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundleTestsUtils.java
+++ b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundleTestsUtils.java
@@ -1,5 +1,6 @@
package org.eclipse.papyrus.bundles.tests;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -30,7 +31,7 @@ public class BundleTestsUtils {
public static final String BUNDLE_IMPORT_PACKAGE = "Import-Package"; //$NON-NLS-1$
public static final String JAVA_VERSION_5 = "J2SE-1.5"; //$NON-NLS-1$
-
+
public static final String REQUIRE_BUNDLE = "Require-Bundle"; //$NON-NLS-1$
private BundleTestsUtils() {
@@ -55,4 +56,17 @@ public class BundleTestsUtils {
return papyrusBundle;
}
+
+ /**
+ *
+ * @param bundle
+ * a bundle
+ * @return
+ * <code>true</code> if the bundle represents a Java Project
+ */
+ public static boolean isJavaProject(final Bundle bundle) {
+ //we are looking for folders "org/eclipse/papyrus" that contains classes. If not, it is not a Java project
+ URL res = bundle.getResource("org/eclipse/papyrus");
+ return res != null;
+ }
}
diff --git a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java
index a87268c2f9b..becc91052be 100644
--- a/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java
+++ b/tests/junit/plugins/developer/org.eclipse.papyrus.bundles.tests/src/org/eclipse/papyrus/bundles/tests/BundlesTests.java
@@ -16,9 +16,9 @@ package org.eclipse.papyrus.bundles.tests;
import java.net.URL;
import java.util.Enumeration;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.osgi.framework.internal.core.BundleFragment;
import org.eclipse.osgi.util.NLS;
+import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -29,7 +29,7 @@ public class BundlesTests {
*/
@Test
public void incubationTest() {
- testManifestProperty(BundleTestsUtils.BUNDLE_NAME, ".*\\(Incubation\\)", false); //$NON-NLS-1$
+ testManifestProperty(BundleTestsUtils.BUNDLE_NAME, ".*\\(Incubation\\)", false, false); //$NON-NLS-1$
}
/**
@@ -37,7 +37,7 @@ public class BundlesTests {
*/
@Test
public void vendorTest() {
- testManifestProperty(BundleTestsUtils.BUNDLE_VENDOR, BundleTestsUtils.VENDOR_NAME, false);
+ testManifestProperty(BundleTestsUtils.BUNDLE_VENDOR, BundleTestsUtils.VENDOR_NAME, false, false);
}
/**
@@ -45,7 +45,7 @@ public class BundlesTests {
*/
@Test
public void versionTest() {
- testManifestProperty(BundleTestsUtils.BUNDLE_VERSION, "0\\.9\\.0\\..*", false); //$NON-NLS-1$
+ testManifestProperty(BundleTestsUtils.BUNDLE_VERSION, "0\\.9\\.0\\..*", false, false); //$NON-NLS-1$
}
/**
@@ -61,7 +61,7 @@ public class BundlesTests {
*/
@Test
public void javaVersionTest() {
- testManifestProperty(BundleTestsUtils.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, BundleTestsUtils.JAVA_VERSION_5, false);
+ testManifestProperty(BundleTestsUtils.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, BundleTestsUtils.JAVA_VERSION_5, false, true);
}
/**
@@ -69,7 +69,7 @@ public class BundlesTests {
*/
@Test
public void importPackage() {
- testManifestProperty(BundleTestsUtils.BUNDLE_IMPORT_PACKAGE, "", true); //$NON-NLS-1$
+ testManifestProperty(BundleTestsUtils.BUNDLE_IMPORT_PACKAGE, "", true, false); //$NON-NLS-1$
}
/**
@@ -102,7 +102,7 @@ public class BundlesTests {
message += localMessage + "\n"; //$NON-NLS-1$
}
}
- Assert.isTrue(message == null, nb + " problems! " + message); //$NON-NLS-1$
+ Assert.assertNull(message, nb + " problems! " + message);
}
/**
@@ -114,11 +114,16 @@ public class BundlesTests {
* the regular expression to test the property
* @param mustBeNull
* indicates that the value for the property must be <code>null</code>
+ * @param onlyOnJavaProject
+ * boolean indicating if the tests should only be done on JavaProject
*/
- private void testManifestProperty(final String property, final String regex, boolean mustBeNull) {
+ private void testManifestProperty(final String property, final String regex, boolean mustBeNull, boolean onlyOnJavaProject) {
String message = null;
int nb = 0;
for(Bundle current : BundleTestsUtils.getPapyrusBundles()) {
+ if(onlyOnJavaProject && !BundleTestsUtils.isJavaProject(current)) {
+ continue; //useful for oep.infra.gmfdiag.css.theme for example
+ }
final String value = current.getHeaders().get(property);
boolean result = false;
if(mustBeNull) {
@@ -135,7 +140,7 @@ public class BundlesTests {
nb++;
}
}
- Assert.isTrue(message == null, nb + " problems! " + message); //$NON-NLS-1$
+ Assert.assertNull(message, nb + " problems! " + message);
}
/**
@@ -169,7 +174,7 @@ public class BundlesTests {
nb++;
}
}
- Assert.isTrue(message == null, nb + " problems!" + message); //$NON-NLS-1$
+ Assert.assertNull(message, nb + " problems! " + message);
}
}

Back to the top