diff options
author | 2005-05-25 21:26:10 +0000 | |
---|---|---|
committer | 2005-05-25 21:26:10 +0000 | |
commit | 00608fd3c4dee40477f5e99c94062713a89c9746 (patch) | |
tree | 8e47a1fa32e2f63d08be7987ac19d6915b808813 /bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration | |
parent | 0f241fe2b22f022c6c4d8a4d9a4a4b7009bac8ef (diff) | |
download | rt.equinox.framework-00608fd3c4dee40477f5e99c94062713a89c9746.tar.gz rt.equinox.framework-00608fd3c4dee40477f5e99c94062713a89c9746.tar.xz rt.equinox.framework-00608fd3c4dee40477f5e99c94062713a89c9746.zip |
moved ConfigurationSessionTestSuite to o.e.c.tests.harness
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration')
4 files changed, 15 insertions, 247 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ConfigurationSessionTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ConfigurationSessionTest.java deleted file mode 100644 index 605f606eb..000000000 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ConfigurationSessionTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.tests.configuration; - -import java.io.File; -import java.net.URL; -import org.eclipse.core.runtime.Platform; -import org.eclipse.osgi.service.datalocation.Location; -import org.eclipse.osgi.tests.OSGiTest; - -public class ConfigurationSessionTest extends OSGiTest { - public ConfigurationSessionTest(String name) { - super(name); - // TODO Auto-generated constructor stub - } - - protected File getConfigurationDir() { - Location configurationLocation = Platform.getConfigurationLocation(); - URL configurationURL = configurationLocation.getURL(); - assertEquals(configurationURL.toExternalForm(), "file", configurationURL.getProtocol()); - File configurationDir = new File(configurationURL.getFile()); - return configurationDir; - } -} diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ConfigurationSessionTestSuite.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ConfigurationSessionTestSuite.java deleted file mode 100644 index a21b1c54e..000000000 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ConfigurationSessionTestSuite.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.osgi.tests.configuration; - -import java.io.*; -import java.net.URL; -import java.util.*; -import junit.framework.*; -import org.eclipse.core.internal.runtime.InternalPlatform; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.tests.harness.CoreTest; -import org.eclipse.core.tests.harness.FileSystemHelper; -import org.eclipse.core.tests.session.*; -import org.eclipse.core.tests.session.SetupManager.SetupException; -import org.osgi.framework.Bundle; - -public class ConfigurationSessionTestSuite extends SessionTestSuite { - private static final String PROP_CONFIG_AREA_READ_ONLY = InternalPlatform.PROP_CONFIG_AREA + ".readOnly"; - private static final String PROP_CONFIG_CASCADED = "osgi.configuration.cascaded"; - private static final String PROP_SHARED_CONFIG_AREA = "osgi.sharedConfiguration.area"; - private Collection bundles = new ArrayList(); - private boolean cascaded; - - // by default we clean-up after ourselves - private boolean cleanUp = true; - - private IPath configurationPath = FileSystemHelper.getRandomLocation(FileSystemHelper.getTempDir()); - private boolean prime = true; - private boolean readOnly; - // should the test cases be run in alphabetical order? - private boolean shouldSort; - - public ConfigurationSessionTestSuite(String pluginId) { - super(pluginId); - } - - public ConfigurationSessionTestSuite(String pluginId, Class theClass) { - super(pluginId, theClass); - this.shouldSort = true; - } - - public ConfigurationSessionTestSuite(String pluginId, Class theClass, String name) { - super(pluginId, theClass, name); - this.shouldSort = true; - } - - public ConfigurationSessionTestSuite(String pluginId, String name) { - super(pluginId, name); - } - - public void addBundle(String id) { - bundles.add(getURL(id)); - } - - private void createConfigINI() throws IOException { - Assert.assertTrue("1.0", !bundles.isEmpty()); - Properties contents = new Properties(); - StringBuffer osgiBundles = new StringBuffer(); - for (Iterator i = this.bundles.iterator(); i.hasNext();) { - osgiBundles.append(i.next()); - osgiBundles.append(','); - } - osgiBundles.deleteCharAt(osgiBundles.length() - 1); - contents.put("osgi.bundles", osgiBundles.toString()); - String osgiFramework = getURL("org.eclipse.osgi"); - contents.put("osgi.framework", osgiFramework); - contents.put("osgi.bundles.defaultStartLevel", "4"); - contents.put("osgi.install.area", Platform.getInstallLocation().getURL().toExternalForm()); - contents.put(PROP_CONFIG_CASCADED, Boolean.toString(cascaded)); - if (cascaded) - contents.put(PROP_SHARED_CONFIG_AREA, Platform.getConfigurationLocation().getURL().toExternalForm()); - contents.put(PROP_CONFIG_AREA_READ_ONLY, Boolean.toString(readOnly)); - // save the properties - File configINI = configurationPath.append("config.ini").toFile(); - OutputStream out = null; - try { - out = new BufferedOutputStream(new FileOutputStream(configINI)); - contents.store(out, null); - } finally { - if (out != null) - out.close(); - } - } - - protected void fillTestDescriptor(TestDescriptor test) throws SetupException { - super.fillTestDescriptor(test); - if (prime) { - test.getSetup().setSystemProperty(PROP_CONFIG_AREA_READ_ONLY, Boolean.FALSE.toString()); - prime = false; - } - } - - public IPath getConfigurationPath() { - return configurationPath; - } - - private String getURL(String id) { - String suffix = ""; - int atIndex = id.indexOf("@"); - if (atIndex >= 0) { - suffix = id.substring(atIndex); - id = id.substring(0, atIndex); - } - Bundle bundle = Platform.getBundle(id); - Assert.assertNotNull("0.1 " + id, bundle); - URL url = bundle.getEntry("/"); - Assert.assertNotNull("0.2 " + id, url); - try { - url = Platform.resolve(url); - } catch (IOException e) { - CoreTest.fail("0.3 " + url, e); - } - String externalForm; - if (url.getProtocol().equals("jar")) { - // if it is a JAR'd plug-in, URL is jar:file:/path/file.jar!/ - see bug 86195 - String path = url.getPath(); - // change it to be file:/path/file.jar - externalForm = path.substring(0, path.length() - 2); - } else - externalForm = url.toExternalForm(); - // workaround for bug 88070 - externalForm = "reference:" + externalForm; - return externalForm + suffix; - } - - public boolean isCascaded() { - return cascaded; - } - - public boolean isReadOnly() { - return readOnly; - } - - /** - * Ensures setup uses this suite's instance location. - * @throws SetupException - */ - protected Setup newSetup() throws SetupException { - Setup base = super.newSetup(); - // the base implementation will have set this to the host configuration - base.setEclipseArgument(Setup.CONFIGURATION, null); - base.setSystemProperty(InternalPlatform.PROP_CONFIG_AREA, configurationPath.toOSString()); - return base; - } - - /** - * Ensures workspace location is empty before running the first test, and after - * running the last test. Also sorts the test cases to be run if this suite was - * created by reifying a test case class. - */ - public void run(TestResult result) { - configurationPath.toFile().mkdirs(); - try { - if (prime) - try { - createConfigINI(); - } catch (IOException e) { - CoreTest.fail("0.1", e); - } - if (!shouldSort) { - super.run(result); - return; - } - // we have to sort the tests cases - Test[] allTests = getTests(true); - // now run the tests in order - for (int i = 0; i < allTests.length && !result.shouldStop(); i++) - runTest(allTests[i], result); - } finally { - if (cleanUp) - FileSystemHelper.clear(configurationPath.toFile()); - }; - - } - - public void setCascaded(boolean cascaded) { - this.cascaded = cascaded; - } - - public void setCleanup(boolean cleanUp) { - this.cleanUp = cleanUp; - } - - public void setConfigurationPath(IPath configurationPath) { - this.configurationPath = configurationPath; - } - - public void setPrime(boolean prime) { - this.prime = prime; - } - - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - -} diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java index 63de1b7e7..80b0fd1e3 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java @@ -16,11 +16,13 @@ import java.net.MalformedURLException; import junit.framework.*; import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.harness.*; +import org.eclipse.core.tests.session.ConfigurationSessionTestSuite; +import org.eclipse.osgi.tests.OSGiTest; import org.eclipse.osgi.tests.OSGiTestsActivator; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; -public class MovableConfigurationAreaTest extends ConfigurationSessionTest { +public class MovableConfigurationAreaTest extends OSGiTest { static void doMove(final IPath sourcePath, final IPath destinationPath) { assertTrue("Failed moving " + sourcePath + " to " + destinationPath, sourcePath.toFile().renameTo(destinationPath.toFile())); @@ -41,10 +43,11 @@ public class MovableConfigurationAreaTest extends ConfigurationSessionTest { public static Test suite() { TestSuite suite = new TestSuite(MovableConfigurationAreaTest.class.getName()); - String[] ids = {"org.eclipse.core.runtime@2:start", "org.eclipse.core.runtime.compatibility", "org.eclipse.update.configurator", "org.eclipse.core.tests.harness", "org.eclipse.osgi.tests", "org.eclipse.jdt.junit.runtime", "org.eclipse.pde.junit.runtime", "org.junit", "org.eclipse.test.performance"}; ConfigurationSessionTestSuite initialization = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, MovableConfigurationAreaTest.class.getName()); + String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; for (int i = 0; i < ids.length; i++) initialization.addBundle(ids[i]); + initialization.addBundle(PI_OSGI_TESTS); initialization.setReadOnly(true); // disable clean-up, we want to reuse the configuration initialization.setCleanup(false); @@ -116,7 +119,7 @@ public class MovableConfigurationAreaTest extends ConfigurationSessionTest { public void testVerifySnapshot() throws IOException { FileSystemComparator comparator = new FileSystemComparator(); - File configurationDir = getConfigurationDir(); + File configurationDir = ConfigurationSessionTestSuite.getConfigurationDir(); Object oldSnaphot = comparator.loadSnapshot(configurationDir); Object newSnapshot = comparator.takeSnapshot(configurationDir, true); comparator.compareSnapshots("1.0", oldSnaphot, newSnapshot); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java index 96b4808f6..538475cd7 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java @@ -16,19 +16,21 @@ import java.net.MalformedURLException; import junit.framework.Test; import org.eclipse.core.tests.harness.BundleTestingHelper; import org.eclipse.core.tests.harness.FileSystemComparator; +import org.eclipse.core.tests.session.ConfigurationSessionTestSuite; +import org.eclipse.osgi.tests.OSGiTest; import org.eclipse.osgi.tests.OSGiTestsActivator; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; -public class ReadOnlyConfigurationAreaTest extends ConfigurationSessionTest { +public class ReadOnlyConfigurationAreaTest extends OSGiTest { public static Test suite() { - // include configurator as it is required by compatibility, but do not set it to start - String[] ids = {"org.eclipse.core.runtime@2:start", "org.eclipse.core.runtime.compatibility", "org.eclipse.update.configurator", "org.eclipse.core.tests.harness", "org.eclipse.osgi.tests", "org.eclipse.jdt.junit.runtime", "org.eclipse.pde.junit.runtime", "org.junit", "org.eclipse.test.performance"}; ConfigurationSessionTestSuite suite = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, ReadOnlyConfigurationAreaTest.class); suite.setReadOnly(true); + String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; for (int i = 0; i < ids.length; i++) suite.addBundle(ids[i]); + suite.addBundle(PI_OSGI_TESTS); return suite; } @@ -52,7 +54,7 @@ public class ReadOnlyConfigurationAreaTest extends ConfigurationSessionTest { */ public void test1stSession() { // compute and save tree image - File configurationDir = getConfigurationDir(); + File configurationDir = ConfigurationSessionTestSuite.getConfigurationDir(); FileSystemComparator comparator = new FileSystemComparator(); Object snapshot = comparator.takeSnapshot(configurationDir, true); try { @@ -64,7 +66,7 @@ public class ReadOnlyConfigurationAreaTest extends ConfigurationSessionTest { public void test1stSessionFollowUp() throws IOException { FileSystemComparator comparator = new FileSystemComparator(); - File configurationDir = getConfigurationDir(); + File configurationDir = ConfigurationSessionTestSuite.getConfigurationDir(); Object oldSnaphot = comparator.loadSnapshot(configurationDir); Object newSnapshot = comparator.takeSnapshot(configurationDir, true); comparator.compareSnapshots("1.0", oldSnaphot, newSnapshot); @@ -93,7 +95,7 @@ public class ReadOnlyConfigurationAreaTest extends ConfigurationSessionTest { public void test2ndSessionFollowUp() throws IOException { FileSystemComparator comparator = new FileSystemComparator(); - File configurationDir = getConfigurationDir(); + File configurationDir = ConfigurationSessionTestSuite.getConfigurationDir(); Object oldSnaphot = comparator.loadSnapshot(configurationDir); Object newSnapshot = comparator.takeSnapshot(configurationDir, true); comparator.compareSnapshots("1.0", oldSnaphot, newSnapshot); @@ -122,7 +124,7 @@ public class ReadOnlyConfigurationAreaTest extends ConfigurationSessionTest { public void test3rdSessionFollowUp() throws IOException { FileSystemComparator comparator = new FileSystemComparator(); - File configurationDir = getConfigurationDir(); + File configurationDir = ConfigurationSessionTestSuite.getConfigurationDir(); Object oldSnaphot = comparator.loadSnapshot(configurationDir); Object newSnapshot = comparator.takeSnapshot(configurationDir, true); comparator.compareSnapshots("1.0", oldSnaphot, newSnapshot); |