Author: dgolovin
Date: 2009-09-02 14:32:26 -0400 (Wed, 02 Sep 2009)
New Revision: 17426
Added:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java
Removed:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/ToolsAllTests.java
Modified:
trunk/tests/tests/org.jboss.tools.test/.project
trunk/tests/tests/org.jboss.tools.test/META-INF/MANIFEST.MF
Log:
base test added to verify that all plug-ins from particular feature are loaded
Modified: trunk/tests/tests/org.jboss.tools.test/.project
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/.project 2009-09-02 18:29:22 UTC (rev 17425)
+++ trunk/tests/tests/org.jboss.tools.test/.project 2009-09-02 18:32:26 UTC (rev 17426)
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.jboss.tools.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Modified: trunk/tests/tests/org.jboss.tools.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/META-INF/MANIFEST.MF 2009-09-02 18:29:22 UTC
(rev 17425)
+++ trunk/tests/tests/org.jboss.tools.test/META-INF/MANIFEST.MF 2009-09-02 18:32:26 UTC
(rev 17426)
@@ -8,7 +8,8 @@
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.junit,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ org.apache.xerces;bundle-version="2.9.0"
Provide-Package: org.jboss.ide.tests.util
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.test.util,
Copied:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java
(from rev 17384,
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java)
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java
(rev 0)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractPluginsLoadTest.java 2009-09-02
18:32:26 UTC (rev 17426)
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.tests;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.text.MessageFormat;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IBundleGroup;
+import org.eclipse.core.runtime.IBundleGroupProvider;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Abstract test is intended to test that all plug-ins of particular feature are loaded
at run-time
+ * @author eskimo
+ *
+ */
+public class AbstractPluginsLoadTest extends TestCase {
+
+ public static final String BUNDLE_GROUP_PROVIDER_NAME = "Update Manager
Configurator";
+ private static final String PLUGIN_TAG_NAME = "plugin";
+ private static final String ID_ATTRIBUTE_NAME = "id";
+
+ public void testBundlesAreLoadedFor(final String featureId) {
+ Bundle firstBundle = getFirstBundleFor(featureId);
+ File bundleLocation = null;
+ try {
+ bundleLocation = FileLocator.getBundleFile(firstBundle);
+ } catch (IOException e1) {
+ fail(MessageFormat.format("Cannot find location for feature
{0}",featureId));
+ }
+ File featuresFolder = new
File(bundleLocation.getParentFile().getParentFile(),"features");
+ String[] features = featuresFolder.list(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ File featureDescriptor = new File(new File(dir,name),"feature.xml");
+ return name.startsWith(featureId) && featureDescriptor.canRead();
+ }
+ });
+ assertEquals(1, features.length);
+ DocumentBuilder builder;
+ File featureDescriptor = new File(new
File(featuresFolder,features[0]),"feature.xml");
+ try {
+ builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document feature = builder.parse(featureDescriptor);
+ NodeList plugins = feature.getElementsByTagName(PLUGIN_TAG_NAME);
+ for (int i = 0; i < plugins.getLength(); i++) {
+ String pluginId =
plugins.item(i).getAttributes().getNamedItem(ID_ATTRIBUTE_NAME).getNodeValue();
+ isPluginResolved(pluginId);
+ System.out.println(MessageFormat.format("Plugn {0} was resolved and
activated", pluginId));
+ }
+ } catch (ParserConfigurationException e) {
+ fail(MessageFormat.format("Cannot configure parser to parse feature descriptor
''{0}''",featureDescriptor.getAbsolutePath()));
+ } catch (SAXException e) {
+ fail(MessageFormat.format("Cannot parse feature descriptor
''{0}''",featureDescriptor.getAbsolutePath()));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * @param featureId
+ */
+ private Bundle getFirstBundleFor(String featureId) {
+ IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
+ System.out.println(providers.length);
+ for (IBundleGroupProvider iBundleGroupProvider : providers) {
+ System.out.println(iBundleGroupProvider.getName());
+ IBundleGroup[] bundleGroups = iBundleGroupProvider.getBundleGroups();
+ if(BUNDLE_GROUP_PROVIDER_NAME.equals(iBundleGroupProvider.getName())) {
+ for (IBundleGroup iBundleGroup : bundleGroups) {
+ if(iBundleGroup.getIdentifier().equals(featureId)) {
+ Bundle[] bundles = iBundleGroup.getBundles();
+ for (Bundle bundle : bundles) {
+ return bundle;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private boolean isPluginResolved(String pluginId) {
+ Bundle bundle = Platform.getBundle(pluginId);
+ assertNotNull(pluginId + " failed to load.", bundle); //$NON-NLS-1$
+ try {
+ // this line is needed to to force plug-in loading and to change it state to ACTIVE
+ bundle.loadClass("fake class"); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ // It happens always because loaded class doesn't not exist
+ }
+ return ((bundle.getState() & Bundle.RESOLVED) > 0)
+ || ((bundle.getState() & Bundle.ACTIVE) > 0);
+ }
+
+ private void assertPluginsResolved(Bundle[] bundles) {
+ for (Bundle bundle : bundles) {
+ assertTrue("Plugin '" + bundle.getSymbolicName() + "' is not
resolved", //$NON-NLS-1$ //$NON-NLS-2$
+ isPluginResolved(bundle.getSymbolicName()));
+ System.out.println(bundle.getSymbolicName() + " was resolved and
activated");
+ }
+ }
+
+// public void testAsComp() throws IOException {
+// testBundlesAreLoadedFor("org.jboss.ide.eclipse.as.feature");
+// }
+//
+// public void testJdtComp() throws IOException {
+// testBundlesAreLoadedFor("org.eclipse.jdt");
+// }
+//
+// public void testRichfacesComp() throws IOException {
+// testBundlesAreLoadedFor("org.jboss.tools.richfaces.feature");
+// }
+}
Deleted:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java 2009-09-02
18:29:22 UTC (rev 17425)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/PlugInLoadTest.java 2009-09-02
18:32:26 UTC (rev 17426)
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.Platform;
-import org.osgi.framework.Bundle;
-/**
- *
- * //TODO try to refactor it to use Eclipse API to get plug-ins list in installed
feature
- * //
- *
- * @author eskimo
- *
- */
-public class PlugInLoadTest extends TestCase {
-
- public static final String rhdsNS = "org.jboss.tools."; //$NON-NLS-1$
- private static String jbideNS = "org.jboss.ide.eclipse."; //$NON-NLS-1$
- private static String hibNS = "org.hibernate.eclipse."; //$NON-NLS-1$
- private static String jbpmNS = "org.jbpm.gd.jpdl"; //$NON-NLS-1$
- private static String jbwsNS = "com.eviware.soapui."; //$NON-NLS-1$
-
- private boolean isPluginResolved(String pluginId) {
- Bundle bundle = Platform.getBundle(pluginId);
- assertNotNull(pluginId + " failed to load.", bundle); //$NON-NLS-1$
- try {
- // In 3.3 when test case is running plug-in.getState always returns
- // STARTING state
- // to move plug-in in ACTIVE state at one class should be loaded
- // from plug-in
- bundle.loadClass("fake class"); //$NON-NLS-1$
- } catch (Exception e) {
- // It happens always because loaded class doesn't not exist
- }
- return ((bundle.getState() & Bundle.RESOLVED) > 0)
- || ((bundle.getState() & Bundle.ACTIVE) > 0);
- }
-
- private void assertPluginsResolved(String[] pluginIds) {
- for (int i = 0; i < pluginIds.length; i++) {
- assertTrue("plugin '" + pluginIds[i] + "' is not
resolved", //$NON-NLS-1$ //$NON-NLS-2$
- isPluginResolved(pluginIds[i]));
- }
- }
-
- public void testCommonPluginsResolved() {
- assertPluginsResolved(new String[] {
- rhdsNS + "common", //$NON-NLS-1$
- rhdsNS + "common.gef", //$NON-NLS-1$
- rhdsNS + "common.kb", //$NON-NLS-1$
- rhdsNS + "common.model", //$NON-NLS-1$
- rhdsNS + "common.model.ui", //$NON-NLS-1$
- rhdsNS + "common.projecttemplates", //$NON-NLS-1$
- rhdsNS + "common.text.ext", //$NON-NLS-1$
- rhdsNS + "common.text.xml", //$NON-NLS-1$
- rhdsNS + "common.verification", //$NON-NLS-1$
- rhdsNS + "common.verification.ui", }); //$NON-NLS-1$
- }
-
- public void testJsfPluginsResolved() {
- assertPluginsResolved(new String[] {
- rhdsNS + "jsf", //$NON-NLS-1$
- rhdsNS + "jsf.text.ext", //$NON-NLS-1$
- rhdsNS + "jsf.text.ext.facelets", //$NON-NLS-1$
- rhdsNS + "jsf.ui", //$NON-NLS-1$
- rhdsNS + "jsf.verification", //$NON-NLS-1$
- rhdsNS + "jsf.vpe.ajax4jsf", //$NON-NLS-1$
- rhdsNS + "jsf.vpe.facelets", //$NON-NLS-1$
- rhdsNS + "jsf.vpe.richfaces", //$NON-NLS-1$
- rhdsNS + "jsf.vpe.seam" }); //$NON-NLS-1$
- }
-
- public void testJstPluginsResolved() {
- assertPluginsResolved(new String[] {
- rhdsNS + "jst.jsp", //$NON-NLS-1$
- rhdsNS + "jst.web", //$NON-NLS-1$
- rhdsNS + "jst.web.tiles", //$NON-NLS-1$
- rhdsNS + "jst.web.tiles.ui", //$NON-NLS-1$
- rhdsNS + "jst.web.ui", //$NON-NLS-1$
- rhdsNS + "jst.web.verification" }); //$NON-NLS-1$
- }
-
- public void testVpePluginsResolved() {
- assertPluginsResolved(new String[] {
- rhdsNS + "vpe", //$NON-NLS-1$
- rhdsNS + "vpe.ui.palette", //$NON-NLS-1$
- rhdsNS + "vpe.xulrunner" }); //$NON-NLS-1$
- }
-
- public void testStrutsPluginsResolved() {
- assertPluginsResolved(new String[] {
- rhdsNS + "struts", //$NON-NLS-1$
- rhdsNS + "struts.text.ext", //$NON-NLS-1$
- rhdsNS + "struts.ui", //$NON-NLS-1$
- rhdsNS + "struts.validator.ui", //$NON-NLS-1$
- rhdsNS + "struts.verification" }); //$NON-NLS-1$
- }
-
- public void testCorePluginsResolved() {
- assertPluginsResolved(new String[] {
- jbideNS + "archives.core", //$NON-NLS-1$
- jbideNS + "archives.ui"}); //$NON-NLS-1$
- }
-
- public void testASPluginsResolved() {
- assertPluginsResolved(new String[] {
- jbideNS + "as.core", //$NON-NLS-1$
- jbideNS + "as.ui", //$NON-NLS-1$
- jbideNS + "as.ui.mbeans" }); //$NON-NLS-1$
- }
-
- public void testHibernatePluginsResolved() {
- assertPluginsResolved(new String[] {
- "org.hibernate.eclipse", //$NON-NLS-1$
- hibNS + "console", //$NON-NLS-1$
- hibNS + "help", //$NON-NLS-1$
- hibNS + "mapper", //$NON-NLS-1$
- hibNS + "jdt.ui", //$NON-NLS-1$
- hibNS + "jdt.apt.ui" }); //$NON-NLS-1$
- }
-
-
- // TODO: Move this test to JBDS
-// public void testJbpmPluginsResolved() {
-// assertPluginsResolved(new String[] {
-// jbpmNS });
-// }
-
- public void testFreemarkerPluginsResolved() {
- assertPluginsResolved(new String[] {
- jbideNS + "freemarker" }); //$NON-NLS-1$
- }
-
- public void testDroolsPluginsResolved() {
- // Skipped until drools migartion to 3.3 is finished
- // assertPluginsResolved(new String[] {
- // "org.drools.ide"
- // });
- }
-
- public void testJBossWSPluginsResolved() {
- // assertPluginsResolved(new String[] {
- // jbwsNS+"core",
- // jbwsNS+"eclipse.core",
- // jbwsNS+"jbosside.wstools",
- // jbwsNS+"libs"
- // });
- }
-
-}
Deleted:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/ToolsAllTests.java
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/ToolsAllTests.java 2009-09-02
18:29:22 UTC (rev 17425)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/ToolsAllTests.java 2009-09-02
18:32:26 UTC (rev 17426)
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.tests;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class ToolsAllTests extends TestCase {
-
- public static Test suite ()
- {
- TestSuite suite = new TestSuite(ToolsAllTests.class.getName());
-
- suite.addTestSuite(PlugInLoadTest.class);
-
- return suite;
- }
-
-}
\ No newline at end of file