diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.frameworkadmin.test/src/org')
34 files changed, 0 insertions, 2946 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java deleted file mode 100644 index 27b5c2902..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java +++ /dev/null @@ -1,437 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.equinox.frameworkadmin.tests; - -import java.io.*; -import java.net.URI; -import java.net.URL; -import java.util.List; -import java.util.Properties; -import junit.framework.TestCase; -import org.eclipse.core.runtime.*; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.frameworkadmin.equinox.ParserUtils; -import org.eclipse.equinox.internal.frameworkadmin.equinox.utils.FileUtils; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.eclipse.osgi.service.datalocation.Location; -import org.osgi.framework.*; -import org.osgi.util.tracker.ServiceTracker; - -public abstract class AbstractFwkAdminTest extends TestCase { - private ServiceTracker fwAdminTracker; - private File testFolder; - - public AbstractFwkAdminTest(String name) { - super(name); - } - - /** - * Copy an input stream to an output stream. - * Optionally close the streams when done. - * Return the number of bytes written. - */ - public static int copyStream(InputStream in, boolean closeIn, OutputStream out, boolean closeOut) throws IOException { - try { - int written = 0; - byte[] buffer = new byte[16 * 1024]; - int len; - while ((len = in.read(buffer)) != -1) { - out.write(buffer, 0, len); - written += len; - } - return written; - } finally { - try { - if (closeIn) { - in.close(); - } - } finally { - if (closeOut) { - out.close(); - } - } - } - } - - public static boolean delete(File file) { - if (!file.exists()) - return true; - if (file.isDirectory()) { - File[] children = file.listFiles(); - for (int i = 0; i < children.length; i++) - delete(children[i]); - } - return file.delete(); - } - - public FrameworkAdmin getEquinoxFrameworkAdmin() throws BundleException { - final String FILTER_OBJECTCLASS = "(" + Constants.OBJECTCLASS + "=" + FrameworkAdmin.class.getName() + ")"; - final String filterFwName = "(" + FrameworkAdmin.SERVICE_PROP_KEY_FW_NAME + "=Equinox)"; - final String filterLauncherName = "(" + FrameworkAdmin.SERVICE_PROP_KEY_LAUNCHER_NAME + "=Eclipse.exe)"; - final String filterFwAdmin = "(&" + FILTER_OBJECTCLASS + filterFwName + filterLauncherName + ")"; - - String FWK_ADMIN_EQ = "org.eclipse.equinox.frameworkadmin.equinox"; - Bundle b = Platform.getBundle(FWK_ADMIN_EQ); - if (b == null) - throw new IllegalStateException("Bundle: " + FWK_ADMIN_EQ + " is required for this test"); - b.start(); - - if (fwAdminTracker == null) { - Filter filter; - try { - filter = Activator.getContext().createFilter(filterFwAdmin); - fwAdminTracker = new ServiceTracker(Activator.getContext(), filter, null); - fwAdminTracker.open(); - } catch (InvalidSyntaxException e) { - // never happens - e.printStackTrace(); - } - } - return (FrameworkAdmin) fwAdminTracker.getService(); - } - - protected File getTestFolder(String name) { - return getTestFolder(name, true); - } - - protected File getTestFolder(String name, boolean clean) { - Location instanceLocation = Platform.getInstanceLocation(); - URL url = instanceLocation != null ? instanceLocation.getURL() : null; - if (instanceLocation == null || !instanceLocation.isSet() || url == null) { - testFolder = Activator.getContext().getDataFile(name); - } else { - testFolder = new File(url.getFile(), name); - } - - if (clean && testFolder.exists()) - delete(testFolder); - testFolder.mkdirs(); - return testFolder; - } - - protected void runTest() throws Throwable { - super.runTest(); - - //clean up after success - if (testFolder != null && testFolder.exists()) { - delete(testFolder); - testFolder = null; - } - } - - protected void tearDown() throws Exception { - super.tearDown(); - if (fwAdminTracker != null) { - fwAdminTracker.close(); - } - } - - public void assertIsFile(File file) { - if (!file.exists()) - fail("File: " + file.toString() + " can't be found."); - if (!file.isFile()) - fail("File: " + file.toString() + " is expected to be a file."); - } - - public void assertIsDirectory(File file) { - if (!file.exists()) - fail("Directory: " + file.toString() + " can't be found."); - if (!file.isDirectory()) - fail("Directory: " + file.toString() + " is expected to be a directory."); - } - - public void assertNothing(File file) { - if (file.exists()) - fail("No file or directory should be there: " + file); - } - - public void assertNotContent(File file, String search) { - if (!file.exists()) - fail("File: " + file.toString() + " can't be found."); - try { - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(file)); - while (reader.ready()) { - String line = reader.readLine(); - if (line.indexOf(search) >= 0) - fail("The string: " + search + " was not expected in this file: " + file.getAbsolutePath()); - } - } finally { - if (reader != null) - reader.close(); - } - } catch (FileNotFoundException e) { - //ignore, caught before - } catch (IOException e) { - fail("String: " + search + " not found in " + file.getAbsolutePath()); - } - } - - public void assertIniFileNotContain(File file, String argument, String value) { - List args = null; - try { - args = FileUtils.loadFile(file); - } catch (IOException e) { - fail("Can't read file " + file); - } - String tmp = ParserUtils.getValueForArgument(argument, args); - if (tmp == null) - return; - - assertTrue(tmp.indexOf(value) == -1); - } - - private String getProperty(File file, String property) { - Properties p = new Properties(); - FileInputStream fis = null; - try { - fis = new FileInputStream(file); - p.load(fis); - } catch (FileNotFoundException e) { - fail("Can't find file " + file); - } catch (IOException e) { - fail("Error reading " + file); - } finally { - if (fis != null) - try { - fis.close(); - } catch (IOException e) { - //ignore - } - } - return p.getProperty(property); - } - - public void assertPropertyContains(File file, String property, String text) { - String value = getProperty(file, property); - if (value == null) - fail("property: " + property + " not found in: " +file); - - int index = value.indexOf(text); - if (index == -1) - fail(text + " not found in property:" + property + " for file: " +file); - } - - public void assertNotPropertyContains(File file, String property, String text) { - String value = getProperty(file, property); - if (value == null) - return; - - int index = value.indexOf(text); - if (index != -1) - fail(text + " found in property:" + property + " for file: " +file); - } - - public void assertEquals(String[] array1, String[] array2) { - if (array1 == null || array2 == null) { - if (array1 == array2) - return; - fail(array1 + " not equal to " + array2); - } - assertEquals(array1.length, array2.length); - for (int i = 0; i < array1.length; i++) { - assertEquals(array1[i], array2[i]); - } - } - - public void assertContent(File file, String search) { - assertContents(file, new String [] { search } ); - } - public void assertContents(File file, String [] lines) { - if (!file.exists()) - fail("File: " + file.toString() + " can't be found."); - int idx = 0; - try { - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(file)); - while (reader.ready()) { - String line = reader.readLine(); - if (line.indexOf(lines[idx]) >= 0) { - if(++idx >= lines.length) - return; - } - } - } finally { - if (reader != null) - reader.close(); - } - } catch (FileNotFoundException e) { - //ignore, caught before - } catch (IOException e) { - fail("String: " + lines[idx] + " not found in " + file.getAbsolutePath()); - } - fail("String:" + lines[idx] + " not found"); - } - - public void startSimpleConfiguratorManipulator() { - final String SIMPLECONFIGURATOR_MANIPULATOR = "org.eclipse.equinox.simpleconfigurator.manipulator"; - Bundle manipulatorBundle = Platform.getBundle(SIMPLECONFIGURATOR_MANIPULATOR); - if (manipulatorBundle == null) - fail("Bundle: " + SIMPLECONFIGURATOR_MANIPULATOR + " is required for this test"); - try { - manipulatorBundle.start(); - } catch (BundleException e) { - fail("Exception while starting up " + SIMPLECONFIGURATOR_MANIPULATOR + ' ' + e.getMessage()); - } - } - - public void stopSimpleConfiguratorManipulator() { - final String SIMPLECONFIGURATOR_MANIPULATOR = "org.eclipse.equinox.simpleconfigurator.manipulator"; - Bundle manipulatorBundle = Platform.getBundle(SIMPLECONFIGURATOR_MANIPULATOR); - if (manipulatorBundle == null) - return; - try { - manipulatorBundle.stop(); - } catch (BundleException e) { - fail("Exception while starting up " + SIMPLECONFIGURATOR_MANIPULATOR + ' ' + e.getMessage()); - } - } - - /* - * Copy - * - if we have a file, then copy the file - * - if we have a directory then merge - */ - public static void copy(String message, File source, File target) { - if (!source.exists()) - return; - target.getParentFile().mkdirs(); - if (source.isDirectory()) { - if (target.exists() && target.isFile()) - target.delete(); - if (!target.exists()) - target.mkdirs(); - File[] children = source.listFiles(); - for (int i = 0; i < children.length; i++) - copy(message, children[i], new File(target, children[i].getName())); - return; - } - InputStream input = null; - OutputStream output = null; - try { - input = new BufferedInputStream(new FileInputStream(source)); - output = new BufferedOutputStream(new FileOutputStream(target)); - - byte[] buffer = new byte[8192]; - int bytesRead = 0; - while ((bytesRead = input.read(buffer)) != -1) - output.write(buffer, 0, bytesRead); - } catch (IOException e) { - fail(message + ": " + e); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - System.err.println("Exception while trying to close input stream on: " + source.getAbsolutePath()); - e.printStackTrace(); - } - } - if (output != null) { - try { - output.close(); - } catch (IOException e) { - System.err.println("Exception while trying to close output stream on: " + target.getAbsolutePath()); - e.printStackTrace(); - } - } - } - } - - /* - * Look up and return a file handle to the given entry in the bundle. - */ - protected File getTestData(String message, String entry) { - if (entry == null) - fail(message + " entry is null."); - URL base = Activator.getContext().getBundle().getEntry(entry); - if (base == null) - fail(message + " entry not found in bundle: " + entry); - try { - String osPath = new Path(FileLocator.toFileURL(base).getPath()).toOSString(); - File result = new File(osPath); - if (!result.getCanonicalPath().equals(result.getPath())) - fail(message + " result path: " + result.getPath() + " does not match canonical path: " + result.getCanonicalFile().getPath()); - return result; - } catch (IOException e) { - fail(message + ": " + e); - } - // avoid compile error... should never reach this code - return null; - } - - protected Manipulator getFrameworkManipulator(File configuration, File launcher) throws BundleException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configuration); - launcherData.setLauncher(launcher); - - return manipulator; - } - - //This is a dumb helper writing out the values as they have been passed to it. - protected void writeEclipseIni(File location, String[] lines) { - location.getParentFile().mkdirs(); - BufferedWriter bw = null; - try { - bw = new BufferedWriter(new FileWriter(location)); - for (int j = 0; j < lines.length; j++) { - bw.write(lines[j]); - bw.newLine(); - } - bw.flush(); - - } catch (IOException e) { - fail("Fail writing eclipse.ini file"); - } finally { - if (bw != null) - try { - bw.close(); - } catch (IOException e) { - fail("Fail writing eclipse.ini file in " + location); - } - } - } - - //This is a dumb helper writing out the values as they have been passed to it - protected void writeConfigIni(File location, Properties properties) { - location.getParentFile().mkdirs(); - FileOutputStream out = null; - try { - out = new FileOutputStream(location); - properties.store(out, "#header"); - } catch (IOException e) { - fail("Faile writing config.ini in" + location); - } finally { - try { - out.flush(); - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - out = null; - } - } - - public void assertContains(String message, BundleInfo[] bundles, URI location) { - for (int i = 0; i < bundles.length; i++) { - if (bundles[i].getLocation().equals(location)) - return; - } - fail(message + " Can't find the bundle info " + location); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Activator.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Activator.java deleted file mode 100644 index bed2838eb..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Activator.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; - -public class Activator implements BundleActivator { - private static BundleContext ctx; - - public void start(BundleContext context) throws Exception { - ctx = context; - - } - - public void stop(BundleContext context) throws Exception { - ctx = null; - } - - public static BundleContext getContext() { - return ctx; - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AllTests.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AllTests.java deleted file mode 100644 index 0af378a55..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AllTests.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.equinox.frameworkadmin.tests; - - -import junit.framework.*; - -/** - * Performs all automated director tests. - */ -public class AllTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(AllTests.class.getName()); - suite.addTestSuite(Bug196525.class); - suite.addTestSuite(Bug258370.class); - suite.addTestSuite(CleanupTest.class); - suite.addTestSuite(FrameworkExtensionTest.class); - suite.addTestSuite(LauncherConfigLocationTest.class); - suite.addTestSuite(LauncherDataTest.class); - suite.addTestSuite(ManipulatorTests.class); - suite.addTestSuite(NoConfigurationValueInEclipseIni.class); - suite.addTestSuite(NoRenamingLauncherIni.class); - suite.addTestSuite(OSGiVersionChange.class); - suite.addTestSuite(ParserUtilsTest.class); - suite.addTestSuite(ReaderTest1.class); - suite.addTestSuite(ReaderTest2.class); - suite.addTestSuite(ReaderTest3.class); - suite.addTestSuite(ReaderTest4.class); - suite.addTestSuite(ReaderTest5.class); - suite.addTestSuite(ReaderTestBug267850.class); - suite.addTestSuite(ReaderTestBug285935.class); - suite.addTestSuite(RelativePathTest.class); - suite.addTestSuite(RemovingABundle.class); - suite.addTestSuite(RemovingAllBundles.class); - suite.addTestSuite(RenamingLauncherIni.class); - suite.addTestSuite(SharedConfigurationTest.class); - suite.addTestSuite(SimpleConfiguratorComingAndGoing.class); - suite.addTestSuite(SimpleConfiguratorTest.class); - suite.addTestSuite(TestEclipseDataArea.class); - suite.addTestSuite(TestRunningInstance.class); - suite.addTestSuite(TestVMArg.class); - suite.addTestSuite(UtilsTest.class); - return suite; - } - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Bug196525.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Bug196525.java deleted file mode 100644 index 69a2d6877..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Bug196525.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class Bug196525 extends AbstractFwkAdminTest { - private File installFolder = null; - private File configurationFolder = null; - private String launcherName = "eclipse"; - private File bundleTXT; - private File configINI; - - public Bug196525(String name) { - super(name); - } - - protected void setUp() throws Exception { - startSimpleConfiguratorManipulator(); - //create a configuration with osgi and simpleconfigurator in it - - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - installFolder = Activator.getContext().getDataFile(Bug196525.class.getName()); - configurationFolder = new File(installFolder, "configuration"); - - bundleTXT = new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"); - configINI = new File(configurationFolder, "config.ini"); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - manipulator.save(false); - } - - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - try { - assertContains("1.0", manipulator.getConfigData().getBundles(), URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar")))); - assertContains("2.0", manipulator.getConfigData().getBundles(), URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar")))); - } catch (URISyntaxException e) { - fail("Unexpected failure while creating URI"); - } - BundleInfo bundle1Bi = new BundleInfo("bundle_1", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, true); - - manipulator.getConfigData().addBundle(bundle1Bi); - - manipulator.save(false); - - assertContent(bundleTXT, "org.eclipse.osgi"); - assertContent(configINI, "org.eclipse.osgi"); - assertContent(bundleTXT, "org.eclipse.equinox.simpleconfigurator"); - assertContent(configINI, "org.eclipse.equinox.simpleconfigurator"); - assertContent(bundleTXT, "bundle_1"); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Bug258370.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Bug258370.java deleted file mode 100644 index 151c893a6..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/Bug258370.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class Bug258370 extends FwkAdminAndSimpleConfiguratorTest { - public Bug258370(String name) { - super(name); - // TODO Auto-generated constructor stub - } - - public void testComma() { - FrameworkAdmin fwkAdmin = null; - try { - fwkAdmin = getEquinoxFrameworkAdmin(); - } catch (BundleException e1) { - fail("0.0"); - } - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(SimpleConfiguratorTest.class.getName()); - File configurationFolder = new File(installFolder, "configuration"); - String launcherName = "eclipse"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - try { - manipulator.load(); - } catch (FrameworkAdminRuntimeException e) { - fail("1.0"); - } catch (IOException e) { - fail("2.0"); - } - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo osgiBi = null; - BundleInfo bundle1Bi = null; - BundleInfo bundle2Bi = null; - - try { - osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - bundle1Bi = new BundleInfo("bundle_1", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, true); - bundle2Bi = new BundleInfo("bundle_2", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_2"))), 2, true); - } catch (URISyntaxException e) { - fail("3.0"); - } catch (IOException e) { - fail("4.0"); - } - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(bundle1Bi); - manipulator.getConfigData().addBundle(bundle2Bi); - try { - manipulator.save(false); - } catch (FrameworkAdminRuntimeException e) { - fail("5.0"); - } catch (IOException e) { - fail("6.0"); - } - - File configINI = new File(configurationFolder, "config.ini"); - assertContent(configINI, "org.eclipse.osgi"); - assertContent(configINI, "bundle_1"); - assertContent(configINI, "bundle_2"); - assertContent(configINI, "start,reference"); //This test for the presence of the comma. - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/CleanupTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/CleanupTest.java deleted file mode 100644 index d0cc6829a..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/CleanupTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; - -public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest { - - public CleanupTest(String name) { - super(name); - } - - Manipulator m = null; - - protected void setUp() throws Exception { - super.setUp(); - m = createMinimalConfiguration(CleanupTest.class.getName()); - } - - public void testSimpleConfiguratorRemoval() { - BundleInfo[] bis = m.getConfigData().getBundles(); - for (int i = 0; i < bis.length; i++) { - if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) - m.getConfigData().removeBundle(bis[i]); - } - try { - m.save(false); - } catch (IOException e) { - fail("Error while saving"); - } - assertNothing(new File(getConfigurationFolder(), "org.eclipse.equinox.simpleconfigurator")); - assertIsDirectory(getConfigurationFolder()); - - //Now remove osgi - bis = m.getConfigData().getBundles(); - for (int i = 0; i < bis.length; i++) { - if (bis[i].getSymbolicName().equals("org.eclipse.osgi")) - m.getConfigData().removeBundle(bis[i]); - } - try { - m.save(false); - } catch (IOException e) { - fail("Error while saving"); - } - assertNothing(getConfigurationFolder()); - assertNothing(new File(getInstallFolder(), getLauncherName() + ".ini")); - } - - public void testOSGiRemoval() { - BundleInfo[] bis = m.getConfigData().getBundles(); - for (int i = 0; i < bis.length; i++) { - if (bis[i].getSymbolicName().equals("org.eclipse.osgi")) - m.getConfigData().removeBundle(bis[i]); - } - try { - m.save(false); - } catch (IOException e) { - fail("Error while saving"); - } - assertIsDirectory(new File(getConfigurationFolder(), "org.eclipse.equinox.simpleconfigurator")); - assertIsDirectory(getConfigurationFolder()); - assertNotContent(new File(getConfigurationFolder(), "org.eclipse.equinox.simpleconfigurator/bundles.info"), "org.eclipse.osgi"); - - bis = m.getConfigData().getBundles(); - for (int i = 0; i < bis.length; i++) { - if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) - m.getConfigData().removeBundle(bis[i]); - } - try { - m.save(false); - } catch (IOException e) { - fail("Error while saving"); - } - assertNothing(getConfigurationFolder()); - assertNothing(new File(getInstallFolder(), getLauncherName() + ".ini")); - } - - public void testWithMutipleBundles() throws IOException, URISyntaxException { - BundleInfo bi = new BundleInfo(URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, false); - m.getConfigData().addBundle(bi); - m.save(false); - - BundleInfo[] bis = m.getConfigData().getBundles(); - for (int i = 0; i < bis.length; i++) { - if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) - m.getConfigData().removeBundle(bis[i]); - } - m.save(false); - - assertNothing(getBundleTxt()); - assertContent(getConfigIni(), "bundle_1"); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FrameworkExtensionTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FrameworkExtensionTest.java deleted file mode 100644 index aecb53309..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FrameworkExtensionTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.equinox.frameworkadmin.tests; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.osgi.framework.Constants; - -public class FrameworkExtensionTest extends FwkAdminAndSimpleConfiguratorTest { - - public FrameworkExtensionTest(String name) { - super(name); - } - - public void testAddRemoveFrameworkExtension() throws Exception { - Manipulator manipulator = createMinimalConfiguration(FrameworkExtensionTest.class.getName()); - BundleInfo bundleInfo = new BundleInfo("dummy.frameworkextension", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/dummy.frameworkextension_1.0.0.jar"))), 4, false); - bundleInfo.setFragmentHost(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); - manipulator.getConfigData().addBundle(bundleInfo); - manipulator.save(false); - assertContent(getBundleTxt(), "dummy.frameworkextension"); - assertPropertyContains(getConfigIni(),"osgi.framework.extensions", "dummy.frameworkextension"); - assertNotPropertyContains(getConfigIni(),"osgi.bundles", "dummy.frameworkextension"); - - BundleInfo basicBundleInfo = new BundleInfo("dummy.frameworkextension", "1.0.0", null, -1, false); - manipulator.getConfigData().removeBundle(basicBundleInfo); - manipulator.save(false); - assertNotContent(getBundleTxt(), "dummy.frameworkextension"); - assertNotPropertyContains(getConfigIni(),"osgi.framework.extensions", "dummy.frameworkextension"); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FwkAdminAndSimpleConfiguratorTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FwkAdminAndSimpleConfiguratorTest.java deleted file mode 100644 index c8b314a93..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/FwkAdminAndSimpleConfiguratorTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public abstract class FwkAdminAndSimpleConfiguratorTest extends AbstractFwkAdminTest { - private File installFolder; - private File configurationFolder; - private String launcherName; - - public FwkAdminAndSimpleConfiguratorTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - startSimpleConfiguratorManipulator(); - } - - protected Manipulator getNewManipulator(String workArea) throws FrameworkAdminRuntimeException, IOException, BundleException { - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - installFolder = getTestFolder(workArea, false); - configurationFolder = new File(installFolder, "configuration"); - launcherName = "eclipse"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - return manipulator; - } - - protected Manipulator createMinimalConfiguration(String workArea) throws Exception { - Manipulator manipulator = getNewManipulator(workArea); - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - try { - manipulator.save(false); - } catch (IOException e) { - fail("Error while persisting"); - } catch (FrameworkAdminRuntimeException e) { - fail("Error while persisting"); - } - return manipulator; - } - - protected void tearDown() throws Exception { - super.tearDown(); - if (installFolder != null) - delete(installFolder); - } - - public File getInstallFolder() { - return installFolder; - } - - public File getConfigurationFolder() { - return configurationFolder; - } - - public File getBundleTxt() { - return new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"); - } - - public File getConfigIni() { - return new File(configurationFolder, "config.ini"); - } - - public String getLauncherName() { - return launcherName; - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/LauncherConfigLocationTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/LauncherConfigLocationTest.java deleted file mode 100644 index a01e523a1..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/LauncherConfigLocationTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class LauncherConfigLocationTest extends AbstractFwkAdminTest { - - public LauncherConfigLocationTest(String name) { - super(name); - } - - public void testCustomLauncherConfig() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(LauncherConfigLocationTest.class.getName()); - if(installFolder.exists()) - delete(installFolder); - - File configurationFolder = new File(installFolder, "configuration"); - String launcherName = "foo"; - - LauncherData launcherData = manipulator.getLauncherData(); - assertNotNull("Null launcher data" + launcherData, launcherData); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - - File defaultlaunchConfig = new File(installFolder, launcherName + ".ini"); - assertEquals(defaultlaunchConfig.exists(), false); - File launchConfig = new File(installFolder, "mylaunch.ini"); - assertEquals(launchConfig.exists(), false); - launcherData.setLauncherConfigLocation(launchConfig); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - manipulator.save(false); - - assertEquals(launchConfig.exists(), true); - assertEquals(defaultlaunchConfig.exists(), false); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/LauncherDataTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/LauncherDataTest.java deleted file mode 100644 index 021b5a8d0..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/LauncherDataTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.equinox.frameworkadmin.tests; - -import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; - -/** - * @since 1.0 - */ -public class LauncherDataTest extends TestCase { - - /* - * Constructor for the class. - */ - public LauncherDataTest(String name) { - super(name); - } - - public void testRemoveProgramArg() { - LauncherData data = new LauncherData("equinox", "1.0", "eclipse", "1.0"); - data.setProgramArgs(new String[] {"-console", "-startup", "foo"}); - data.removeProgramArg("-startup"); - assertEquals("1.0", new String[] {"-console"}, data.getProgramArgs()); - - data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "-bar"}); - data.removeProgramArg("-startup"); - assertEquals("2.0", new String[] {"-console", "-bar"}, data.getProgramArgs()); - - data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-startup", "foo"}); - data.removeProgramArg("-startup"); - assertEquals("3.0", new String[0], data.getProgramArgs()); - - data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "bar"}); - data.removeProgramArg("-startup"); - assertEquals("4.0", new String[] {"-console"}, data.getProgramArgs()); - - data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "bar", "-xxx"}); - data.removeProgramArg("-startup"); - assertEquals("5.0", new String[] {"-console", "-xxx"}, data.getProgramArgs()); - - // arg which doesn't start with a dash - dont' consume anything but that specific arg - data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "bar", "-xxx"}); - data.removeProgramArg("foo"); - assertEquals("6.0", new String[] {"-console", "-startup", "foo", "bar", "-xxx"}, data.getProgramArgs()); - - // non-matching arg - data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "bar", "-xxx"}); - data.removeProgramArg("zzz"); - assertEquals("7.0", new String[] {"-console", "-startup", "foo", "bar", "-xxx"}, data.getProgramArgs()); - - // empty string - data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "bar", "-xxx"}); - data.removeProgramArg("foo"); - assertEquals("8.0", new String[] {"-console", "-startup", "foo", "bar", "-xxx"}, data.getProgramArgs()); - - // just whitespace - data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "bar", "-xxx"}); - data.removeProgramArg(" "); - assertEquals("9.0", new String[] {"-console", "-startup", "foo", "bar", "-xxx"}, data.getProgramArgs()); - - } - - /* - * Compare the give 2 arrays and assert whether or not they should be considered equal. - */ - public static void assertEquals(String message, String[] one, String[] two) { - if (one == null) - assertNull(message, two); - if (two == null) - fail(message); - assertEquals(message, one.length, two.length); - for (int i = 0; i < one.length; i++) - assertEquals(message, one[i], two[i]); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/MacOSLikeSetup.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/MacOSLikeSetup.java deleted file mode 100644 index f3153e05f..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/MacOSLikeSetup.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxConstants; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.eclipse.osgi.service.environment.Constants; -import org.osgi.framework.BundleException; - -public class MacOSLikeSetup extends FwkAdminAndSimpleConfiguratorTest { - - public MacOSLikeSetup(String name) { - super(name); - } - - public void testMacOSSetup() throws FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = new File(Activator.getContext().getDataFile(MacOSLikeSetup.class.getName()), "eclipse"); - File configurationFolder = new File(installFolder, "configuration"); - File launcherFolder = new File(installFolder, "Eclipse.app/Contents/MacOS/"); - File launcherName = new File(launcherFolder, "eclipse"); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(launcherName); - launcherData.setLauncherConfigLocation(new File(launcherFolder, "eclipse.ini")); - launcherData.setOS(Constants.OS_MACOSX); - - //Setup the plugins as they should - File osgiJar = new File(installFolder, "plugins/org.eclipse.osgi.jar"); - File scJar = new File(installFolder, "plugins/org.eclipse.equinox.simpleconfigurator.jar"); - File launcherJar = new File(installFolder, "plugins/org.eclipse.equinox.launcher.jar"); - copy("OSGi", new File(FileLocator.toFileURL(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar")).getPath()), osgiJar); - copy("SC", new File(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar")).getPath()), scJar); - copy("Startup", new File(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.launcher.jar")).getPath()), launcherJar); - - manipulator.getConfigData().addBundle(new BundleInfo(osgiJar.toURI())); - manipulator.getConfigData().addBundle(new BundleInfo(scJar.toURI(), 1, true)); - manipulator.getConfigData().addBundle(new BundleInfo(launcherJar.toURI())); - - manipulator.getLauncherData().addProgramArg(EquinoxConstants.OPTION_STARTUP); - manipulator.getLauncherData().addProgramArg(launcherJar.toURI().toString()); - - manipulator.getLauncherData().setFwJar(osgiJar); - - try { - manipulator.save(false); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - File launcherIni = new File(launcherFolder, "eclipse.ini"); - assertNotContent(launcherIni, "-configuration"); - assertNotContent(launcherIni, "-install"); - assertContent(launcherIni, "-startup"); - assertContent(launcherIni, "../../../plugins/org.eclipse.equinox.launcher.jar"); - assertNotContent(launcherIni, MacOSLikeSetup.class.getName()); - assertNotContent(new File(configurationFolder, "config.ini"), MacOSLikeSetup.class.getName()); - assertTrue("bundles.info missing", new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info").exists()); - - } - - public void testMacWithoutStartupOrFw() throws Exception { - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = new File(Activator.getContext().getDataFile(MacOSLikeSetup.class.getName()), "eclipse"); - File configurationFolder = new File(installFolder, "configuration"); - File launcherFolder = new File(installFolder, "Eclipse.app/Contents/MacOS/"); - File launcherName = new File(launcherFolder, "eclipse"); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(launcherName); - launcherData.setOS(Constants.OS_MACOSX); - - File osgiJar = new File(installFolder, "plugins/org.eclipse.osgi.jar"); - File scJar = new File(installFolder, "plugins/org.eclipse.equinox.simpleconfigurator.jar"); - File bundle = new File(installFolder, "plugins/bundle_1"); - copy("OSGi", new File(FileLocator.toFileURL(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar")).getPath()), osgiJar); - copy("SC", new File(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar")).getPath()), scJar); - copy("bundle", new File(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1")).getPath()), bundle); - - manipulator.getConfigData().addBundle(new BundleInfo(osgiJar.toURI())); - manipulator.getConfigData().addBundle(new BundleInfo(scJar.toURI(), 1, true)); - manipulator.getConfigData().addBundle(new BundleInfo(bundle.toURI())); - manipulator.save(false); - - File launcherIni = new File(launcherFolder, "eclipse.ini"); - File bundleInfo = new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"); - assertNotContent(launcherIni, "-configuration"); - assertNotContent(launcherIni, "../../../configuration"); - assertContent(bundleInfo, "file:plugins/bundle_1/"); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ManipulatorTests.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ManipulatorTests.java deleted file mode 100644 index d758c92e3..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ManipulatorTests.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.*; -import java.util.Properties; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; - -public class ManipulatorTests extends AbstractFwkAdminTest { - - public ManipulatorTests(String name) { - super(name); - } - - public void testBug212361_osgiInBundlesList() throws Exception { - File installFolder = Activator.getContext().getDataFile("212361"); - File configurationFolder = new File(installFolder, "configuration"); - Manipulator manipulator = getFrameworkManipulator(configurationFolder, new File(installFolder, "foo")); - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - manipulator.save(false); - - Properties configIni = new Properties(); - InputStream in = new BufferedInputStream(new FileInputStream(new File(configurationFolder, "config.ini"))); - configIni.load(in); - in.close(); - - String bundles = (String) configIni.get("osgi.bundles"); - assertTrue(bundles.indexOf("org.eclipse.osgi") == -1); - } - - public void testBug277553_installAreaFromFwJar() throws Exception { - File folder = getTestFolder("installAreaFromFwJar"); - File fwJar = new File(folder, "plugins/org.eclipse.osgi.jar"); - fwJar.getParentFile().mkdirs(); - - copyStream(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar").openStream(), true, new FileOutputStream(fwJar), true); - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", fwJar.toURI(), 0, true); - - File ini = new File(folder, "eclipse.ini"); - writeEclipseIni(ini, new String[] {"-foo", "bar", "-vmargs", "-Xmx256m"}); - - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - - Manipulator manipulator = fwkAdmin.getManipulator(); - manipulator.getConfigData().addBundle(osgiBi); - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwJar(fwJar); - launcherData.setLauncher(new File(folder, "eclipse")); - - manipulator.load(); - - assertEquals(manipulator.getLauncherData().getFwPersistentDataLocation(), new File(folder, "configuration")); - } - - public void testBug258126_ProgramArgs_VMArgs() throws Exception { - File installFolder = getTestFolder("258126"); - File ini = new File(installFolder, "eclipse.ini"); - writeEclipseIni(ini, new String[] {"-foo", "bar", "-vmargs", "-Xmx256m"}); - - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setLauncher(new File(installFolder, "eclipse")); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - assertEquals(launcherData.getJvmArgs(), new String[] {"-Xmx256m"}); - assertEquals(launcherData.getProgramArgs(), new String[] {"-foo", "bar"}); - - launcherData.addJvmArg("-Xms64m"); - launcherData.addProgramArg("-console"); - - //eclipse.ini won't save unless we actually have something in the configuration - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - manipulator.getConfigData().addBundle(osgiBi); - manipulator.save(false); - - assertContents(ini, new String[] {"-foo", "bar", "-console", "-vmargs", "-Xmx256m", "-Xms64m"}); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/NoConfigurationValueInEclipseIni.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/NoConfigurationValueInEclipseIni.java deleted file mode 100644 index 4cf664dcc..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/NoConfigurationValueInEclipseIni.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class NoConfigurationValueInEclipseIni extends FwkAdminAndSimpleConfiguratorTest { - - public NoConfigurationValueInEclipseIni(String name) { - super(name); - } - - public void testAbsenceOfConfigurationInEclipseINI() throws Exception { - createMinimalConfiguration(NoConfigurationValueInEclipseIni.class.getName()); - File launcherIni = new File(getInstallFolder(), getLauncherName() + ".ini"); - assertNotContent(launcherIni, "-configuration"); - } - - public void testPresenceOfConfigurationInEclipseINI() throws FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile("bis" + NoConfigurationValueInEclipseIni.class.getName()); - File configurationFolder = new File(installFolder, "config2"); - String launcherName = "eclipse"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - try { - manipulator.save(false); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - File launcherIni = new File(installFolder, launcherName + ".ini"); - assertContent(launcherIni, "-configuration"); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/NoRenamingLauncherIni.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/NoRenamingLauncherIni.java deleted file mode 100644 index a1966044e..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/NoRenamingLauncherIni.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class NoRenamingLauncherIni extends AbstractFwkAdminTest { - - public NoRenamingLauncherIni(String name) { - super(name); - } - - public void testConfigFiles() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(NoRenamingLauncherIni.class.getName()); - File configurationFolder = new File(installFolder, "configuration"); - String launcherName = "foo"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - manipulator.save(false); - - File fooINI = new File(installFolder, "foo.ini"); - assertEquals(fooINI.exists(), true); - - Manipulator m2 = fwkAdmin.getManipulator(); - - LauncherData launcherData2 = m2.getLauncherData(); - launcherData2.setFwConfigLocation(configurationFolder); - launcherData2.setLauncher(new File(installFolder, launcherName)); - - try { - m2.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - launcherData2.setLauncher(new File(installFolder, "bar")); - m2.save(false); - - assertEquals(fooINI.exists(), false); - assertEquals(new File(installFolder, "bar.ini").exists(), true); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java deleted file mode 100644 index 9c57a9f05..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.equinox.frameworkadmin.tests; - -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdminRuntimeException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.osgi.framework.BundleException; - -public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest { - private Manipulator defaultManipulator = null; - private String workArea = OSGiVersionChange.class.getName(); - - public OSGiVersionChange(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - defaultManipulator = createMinimalConfiguration(workArea); - } - - public void testRemovalUsingSameManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException { - BundleInfo[] infos = defaultManipulator.getConfigData().getBundles(); - BundleInfo osgi = null; - for (int i = 0; i < infos.length; i++) { - if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) { - osgi = infos[i]; - break; - } - } - assertEquals(true, defaultManipulator.getConfigData().removeBundle(osgi)); - defaultManipulator.save(false); - assertNotContent(getBundleTxt(), "org.eclipse.osgi"); - assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi"); - } - - public void testRemovalUsingOtherManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { - Manipulator newManipulator = getNewManipulator(workArea); - BundleInfo[] infos = newManipulator.getConfigData().getBundles(); - BundleInfo osgi = null; - for (int i = 0; i < infos.length; i++) { - if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) { - osgi = infos[i]; - break; - } - } - newManipulator.getConfigData().removeBundle(osgi); - newManipulator.save(false); - assertNotContent(getBundleTxt(), "org.eclipse.osgi"); - assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi"); - } - - public void testAdditionUsingOtherManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { - BundleInfo[] infos = defaultManipulator.getConfigData().getBundles(); - BundleInfo osgi = null; - for (int i = 0; i < infos.length; i++) { - if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) { - osgi = infos[i]; - break; - } - } - assertEquals(true, defaultManipulator.getConfigData().removeBundle(osgi)); - defaultManipulator.save(false); - - Manipulator newManipulator = getNewManipulator(workArea); - - newManipulator.getConfigData().addBundle(osgi); - newManipulator.save(false); - assertContent(getBundleTxt(), "org.eclipse.osgi"); - assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi"); - } - - public void testChangeVersion() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, URISyntaxException { - BundleInfo[] infos = defaultManipulator.getConfigData().getBundles(); - BundleInfo osgi = null; - for (int i = 0; i < infos.length; i++) { - if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) { - osgi = infos[i]; - break; - } - } - defaultManipulator.getConfigData().removeBundle(osgi); - defaultManipulator.save(false); - - //These two constants describe the data file used in the test - final String FILENAME = "org.eclipse.osgi_3.4.0.jar"; - final String VERSION = "3.4.0.v20071105"; - BundleInfo newOSGi = new BundleInfo("org.eclipse.osgi", "3.4.0.v20071105", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/" + FILENAME))), 0, true); - defaultManipulator.getConfigData().addBundle(newOSGi); - defaultManipulator.save(false); - assertContent(getBundleTxt(), VERSION); - assertContent(getConfigIni(), FILENAME); - } - - public void testReadConfigWithoutOSGi() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { - //First Create a configuration that does not contain OSGi - BundleInfo[] infos = defaultManipulator.getConfigData().getBundles(); - BundleInfo osgi = null; - for (int i = 0; i < infos.length; i++) { - if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) { - osgi = infos[i]; - break; - } - } - defaultManipulator.getConfigData().removeBundle(osgi); - defaultManipulator.save(false); - assertNotContent(getBundleTxt(), "org.eclipse.osgi"); - assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi"); - - Manipulator newManipulator = getNewManipulator(workArea); - assertEquals(1, newManipulator.getConfigData().getBundles().length); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ParserUtilsTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ParserUtilsTest.java deleted file mode 100644 index 88b77bc32..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ParserUtilsTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.util.*; -import org.eclipse.equinox.internal.frameworkadmin.equinox.ParserUtils; - -/** - * Tests for {@link ParserUtils}. - */ -public class ParserUtilsTest extends AbstractFwkAdminTest { - - public ParserUtilsTest(String name) { - super(name); - } - public void testGetValueForArgument() throws Exception { - List args = new ArrayList(); - args.add("-foo"); - args.add("bar"); - assertEquals( "bar", ParserUtils.getValueForArgument("-foo", args)); - - args.set(1, "-bar"); - assertEquals(null, ParserUtils.getValueForArgument("-foo", args)); - } - - public void testRemoveArgument() throws Exception { - String [] args = new String [] { "-bar", "-foo", "-other"}; - ParserUtils.removeArgument("-foo", Arrays.asList(args)); - assertEquals(args, new String [] {"-bar", null, "-other"}); - - args = new String [] { "-bar", "-foo", "other"}; - ParserUtils.removeArgument("-foo", Arrays.asList(args)); - assertEquals(args, new String [] {"-bar", null, null}); - - args = new String [] { "-bar", "-foo", "s-pecial"}; - ParserUtils.removeArgument("-foo", Arrays.asList(args)); - assertEquals(args, new String [] {"-bar", null, null}); - } - - public void testSetValueForArgument() throws Exception { - List args = new ArrayList(); - ParserUtils.setValueForArgument("-foo", "bar", args); - assertTrue(args.size() == 2); - assertEquals(args.get(0), "-foo"); - assertEquals(args.get(1), "bar"); - - args.add("-other"); - args.set(1, "s-pecial"); - ParserUtils.setValueForArgument("-foo", "bas", args); - assertTrue(args.size() == 3); - assertEquals(args.get(0), "-foo"); - assertEquals(args.get(1), "bas"); - assertEquals(args.get(2), "-other"); - - args.remove(1); - ParserUtils.setValueForArgument("-foo", "bas", args); - assertTrue(args.size() == 3); - assertEquals(args.get(0), "-foo"); - assertEquals(args.get(1), "bas"); - assertEquals(args.get(2), "-other"); - } - - public void testFromOSGiJarToOSGiInstallArea() { - String path = ""; - File result =ParserUtils.fromOSGiJarToOSGiInstallArea(path); - assertNotNull("1.0", result); - - path = "osgi.jar"; - result =ParserUtils.fromOSGiJarToOSGiInstallArea(path); - assertNotNull("1.0", result); - assertEquals("1.1", "", result.toString()); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest1.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest1.java deleted file mode 100644 index d0fb71596..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest1.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class ReaderTest1 extends AbstractFwkAdminTest { - private File installFolder = null; - private String launcherName = "eclipse"; - - public ReaderTest1(String name) { - super(name); - } - - - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - installFolder = getTestData(ReaderTest1.class.getName(),"dataFile/readerTest1"); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - assertEquals(new File(installFolder, "conf"), manipulator.getLauncherData().getFwConfigLocation()); - assertEquals("bar", manipulator.getConfigData().getProperty("foo")); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest2.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest2.java deleted file mode 100644 index fac583e0e..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest2.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Properties; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class ReaderTest2 extends AbstractFwkAdminTest { - private File installFolder = null; - private File configurationFolder = null; - private String launcherName = "eclipse"; - - public ReaderTest2(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - startSimpleConfiguratorManipulator(); - - installFolder = Activator.getContext().getDataFile(ReaderTest2.class.getName()); - configurationFolder = new File(installFolder, "conf"); - writeEclipseIni(new File(installFolder, "eclipse.ini"), new String[] { "-configuration", configurationFolder.getAbsolutePath() }); - Properties properties = new Properties(); - properties.setProperty("foo", "bar"); - writeConfigIni(new File(configurationFolder, "config.ini"), properties); - } - - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - assertEquals(new File(installFolder, "conf"), manipulator.getLauncherData().getFwConfigLocation()); - assertEquals("bar", manipulator.getConfigData().getProperty("foo")); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest3.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest3.java deleted file mode 100644 index 4def4fd63..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest3.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class ReaderTest3 extends AbstractFwkAdminTest { - private File installFolder = null; - private String launcherName = "eclipse"; - - public ReaderTest3(String name) { - super(name); - } - - - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - installFolder = getTestData(ReaderTest3.class.getName(),"dataFile/readerTest3"); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - assertEquals(new File(installFolder, "configuration"), manipulator.getLauncherData().getFwConfigLocation()); - assertEquals("bar", manipulator.getConfigData().getProperty("foo")); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest4.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest4.java deleted file mode 100644 index dd08dccdd..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest4.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Properties; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class ReaderTest4 extends AbstractFwkAdminTest { - private File installFolder = null; - private File configurationFolder = null; - private String launcherName = "eclipse"; - - public ReaderTest4(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - startSimpleConfiguratorManipulator(); - - installFolder = Activator.getContext().getDataFile(ReaderTest4.class.getName()); - configurationFolder = new File(installFolder, "conf"); - writeEclipseIni(new File(installFolder, "eclipse.ini"), new String[] { "-install", installFolder.getAbsolutePath(), "-configuration", URIUtil.toUnencodedString(URIUtil.makeRelative(configurationFolder.toURI(), installFolder.toURI())) }); - Properties properties = new Properties(); - properties.setProperty("foo", "bar"); - writeConfigIni(new File(configurationFolder, "config.ini"), properties); - } - - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - assertEquals(new File(installFolder, "conf"), manipulator.getLauncherData().getFwConfigLocation()); - assertEquals("bar", manipulator.getConfigData().getProperty("foo")); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest5.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest5.java deleted file mode 100644 index 8363f41df..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTest5.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Properties; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class ReaderTest5 extends AbstractFwkAdminTest { - private File installFolder = null; - private File configurationFolder = null; - private String launcherName = "eclipse"; - - public ReaderTest5(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - startSimpleConfiguratorManipulator(); - - installFolder = Activator.getContext().getDataFile(ReaderTest5.class.getName()); - configurationFolder = new File(installFolder, "configuration"); - writeEclipseIni(new File(installFolder, "eclipse.ini"), new String[] { "-install", installFolder.getAbsolutePath()}); - Properties properties = new Properties(); - properties.setProperty("foo", "bar"); - writeConfigIni(new File(configurationFolder, "config.ini"), properties); - } - - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - assertEquals(configurationFolder, manipulator.getLauncherData().getFwConfigLocation()); - assertEquals("bar", manipulator.getConfigData(). getProperty("foo")); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTestBug267850.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTestBug267850.java deleted file mode 100644 index f41cc5d09..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTestBug267850.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class ReaderTestBug267850 extends AbstractFwkAdminTest { - private File installFolder = null; - private String launcherName = "eclipse"; - - public ReaderTestBug267850(String name) { - super(name); - } - - - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - installFolder = getTestData(ReaderTestBug267850.class.getName(),"dataFile/readerTestBug267850"); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - LauncherData data = manipulator.getLauncherData(); - String[] args = data.getProgramArgs(); - assertEquals("-startup", args[0]); -// assertEquals("file:/C:/1target/provmiddle/org.eclipse.equinox.frameworkadmin.test/dataFile/readerTestBug267850/plugins/org.eclipse.equinox.launcher_1.0.200.v20090306-1900.jar", args[1]); - assertEquals("--launcher.library", args[2]); -// assertEquals("file:/C:/1target/provmiddle/org.eclipse.equinox.frameworkadmin.test/dataFile/readerTestBug267850/plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090306-1900", args[3]); - assertEquals("-showsplash", args[4]); - assertEquals("org.eclipse.platform", args[5]); - assertEquals("--launcher.XXMaxPermSize", args[6]); - assertEquals("256m", args[7]); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTestBug285935.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTestBug285935.java deleted file mode 100644 index 2c1f0dd0f..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/ReaderTestBug285935.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class ReaderTestBug285935 extends AbstractFwkAdminTest { - private File installFolder = null; - private String launcherName = "eclipse"; - - public ReaderTestBug285935(String name) { - super(name); - } - - - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - installFolder = getTestData(ReaderTestBug285935.class.getName(),"dataFile/readerTestBug285935"); - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - assertEquals(new File(installFolder, "conf"), manipulator.getLauncherData().getFwConfigLocation()); - assertEquals("bar", manipulator.getConfigData().getProperty("foo")); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RelativePathTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RelativePathTest.java deleted file mode 100644 index 43ea1f12e..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RelativePathTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.equinox.frameworkadmin.tests; - -import java.io.*; -import java.net.MalformedURLException; -import java.net.URL; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxManipulatorImpl; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; - -public class RelativePathTest extends FwkAdminAndSimpleConfiguratorTest { - /** Constant value indicating if the current platform is Windows */ - private static final boolean WINDOWS = java.io.File.separatorChar == '\\'; - - public RelativePathTest(String name) throws Exception { - super(name); - } - - public void testRelativePaths() throws Exception { - File installFolder = Activator.getContext().getDataFile(RelativePathTest.class.getName()); - - //First we copy some jars into a well - File osgiJar = new File(installFolder, "plugins/org.eclipse.osgi.jar"); - osgiJar.getParentFile().mkdirs(); - File scJar = new File(installFolder, "plugins/org.eclipse.equinox.simpleconfigurator.jar"); - - copyStream(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar").openStream(), true, new FileOutputStream(osgiJar), true); - copyStream(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar").openStream(), true, new FileOutputStream(scJar), true); - - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File configurationFolder = new File(installFolder, "configuration"); - String launcherName = "eclipse"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", osgiJar.toURI(), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", scJar.toURI(), 1, true); - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - try { - manipulator.save(false); - } catch (IOException e) { - fail("Error while persisting"); - } catch (FrameworkAdminRuntimeException e) { - fail("Error while persisting"); - } - - //":path.jar" is a poor man approach to test relative paths - assertNotContent(new File(configurationFolder, "config.ini"), installFolder.getAbsolutePath()); - assertNotContent(new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"), installFolder.getAbsolutePath()); - assertContent(new File(configurationFolder, "config.ini"), ":org.eclipse.equinox.simpleconfigurator.jar"); - //Note: This is testing for old style bundle locations - assertContent(new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"), "file:plugins/org.eclipse.equinox.simpleconfigurator.jar"); - assertContent(new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"), "file:plugins/org.eclipse.osgi.jar"); - - BundleInfo bi = new BundleInfo(URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, false); - manipulator.getConfigData().addBundle(bi); - manipulator.save(false); - // assertContent(new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"), FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1")).toExternalForm()); - - Manipulator newManipulator = fwkAdmin.getManipulator(); - LauncherData newLauncherData = newManipulator.getLauncherData(); - newLauncherData.setFwConfigLocation(configurationFolder); - newLauncherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - } - - public void testMakeRelative_NonWindows() { - if (WINDOWS) - return; - URL base = null; - try { - base = new URL("file:/eclipse/"); - } catch (MalformedURLException e) { - e.printStackTrace(); - fail("0.98"); - } - // data - [0] is the test data and [1] is the expected result - String[][] data = new String[][] { // - new String[] {"file:/home/eclipse/foo.jar", "file:../home/eclipse/foo.jar"}, // - new String[] {"file:///home/eclipse/foo.jar", "file:../home/eclipse/foo.jar"}, // - }; - for (int i = 0; i < data.length; i++) - assertEquals("1." + i, data[i][1], EquinoxManipulatorImpl.makeRelative(data[i][0], base)); - } - - public void testMakeRelative_Windows() { - if (!WINDOWS) - return; - URL base = null; - // platform specific data - try { - base = new URL("file:/c:/a/eclipse/"); - } catch (MalformedURLException e) { - e.printStackTrace(); - fail("0.99"); - } - // data - [0] is the test data and [1] is the expected result - String[][] data = new String[][] {new String[] {"file:c:/b/shared/plugins/bar.jar", "file:../../b/shared/plugins/bar.jar"}, // - new String[] {"file:d:/b/shared/plugins/bar.jar", "file:d:/b/shared/plugins/bar.jar"}, // - new String[] {"file:/c:/a/eclipse/plugins/bar.jar", "file:plugins/bar.jar"}, // - new String[] {"file:c:/a/eclipse/plugins/bar.jar", "file:plugins/bar.jar"}, // - new String[] {"file:/c:/a/shared/plugins/bar.jar", "file:../shared/plugins/bar.jar"}, // - new String[] {"file:/d:/a/eclipse/plugins/bar.jar", "file:/d:/a/eclipse/plugins/bar.jar"}, // - new String[] {"file:/c:/x/eclipse/plugins/bar.jar", "file:../../x/eclipse/plugins/bar.jar"}, // - }; - for (int i = 0; i < data.length; i++) - assertEquals("2." + i, data[i][1], EquinoxManipulatorImpl.makeRelative(data[i][0], base)); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingABundle.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingABundle.java deleted file mode 100644 index 4dc54b55c..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingABundle.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class RemovingABundle extends FwkAdminAndSimpleConfiguratorTest { - - public RemovingABundle(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - Manipulator manipulator = createMinimalConfiguration(RemovingABundle.class.getName()); - manipulator.getConfigData().addBundle(new BundleInfo("bundle_1", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 4, false)); - manipulator.save(false); - - File fooINI = new File(getInstallFolder(), getLauncherName() +".ini"); - assertEquals(fooINI.exists(), true); - assertContent(getBundleTxt(), "bundle_1"); - } - - public void testRemoveBundleWithoutURL() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { - Manipulator m2 = getEquinoxFrameworkAdmin().getManipulator(); - - LauncherData launcherData2 = m2.getLauncherData(); - launcherData2.setFwConfigLocation(getConfigurationFolder()); - launcherData2.setLauncher(new File(getInstallFolder(), "eclipse")); - - try { - m2.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - BundleInfo info = new BundleInfo("bundle_1", "1.0.0", null, 0, false); - m2.getConfigData().removeBundle(info); - m2.save(false); - - assertNotContent(getBundleTxt(), "bundle_1"); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingAllBundles.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingAllBundles.java deleted file mode 100644 index f30a39f0d..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingAllBundles.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class RemovingAllBundles extends AbstractFwkAdminTest { - - public RemovingAllBundles(String name) { - super(name); - } - - public void testConfigFiles() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(RemovingAllBundles.class.getName()); - File configurationFolder = new File(installFolder, "configuration"); - String launcherName = "foo"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - manipulator.save(false); - - File fooINI = new File(installFolder, "foo.ini"); - assertEquals(fooINI.exists(), true); - - Manipulator m2 = fwkAdmin.getManipulator(); - - LauncherData launcherData2 = m2.getLauncherData(); - launcherData2.setFwConfigLocation(configurationFolder); - launcherData2.setLauncher(new File(installFolder, launcherName)); - - try { - m2.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo[] infos = m2.getConfigData().getBundles(); - for (int i = 0; i < infos.length; i++) { - m2.getConfigData().removeBundle(infos[i]); - } - m2.save(false); - - assertEquals(new File(configurationFolder + "/org.eclipse.equinox.simpleconfigurator", "bundles.info").exists(), false); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RenamingLauncherIni.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RenamingLauncherIni.java deleted file mode 100644 index 23e1ae849..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RenamingLauncherIni.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class RenamingLauncherIni extends AbstractFwkAdminTest { - - public RenamingLauncherIni(String name) { - super(name); - } - - public void testConfigFiles() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(RenamingLauncherIni.class.getName()); - File configurationFolder = new File(installFolder, "configuration"); - String launcherName = "foo"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - manipulator.save(false); - - File fooINI = new File(installFolder, "foo.ini"); - assertEquals(fooINI.exists(), true); - - Manipulator m2 = fwkAdmin.getManipulator(); - - LauncherData launcherData2 = m2.getLauncherData(); - launcherData2.setFwConfigLocation(configurationFolder); - launcherData2.setLauncher(new File(installFolder, launcherName)); - - try { - m2.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - launcherData2.setLauncher(new File(installFolder, "foo")); - m2.save(false); - - assertEquals(new File(installFolder, "foo.ini").exists(), true); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java deleted file mode 100644 index 0bbf5e755..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class SharedConfigurationTest extends AbstractFwkAdminTest { - - public SharedConfigurationTest(String name) { - super(name); - } - - public void testDefaultConfiguration() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(SharedConfigurationTest.class.getName()); - File defaultConfigurationFolder = new File(installFolder, "configuration"); - defaultConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini")); - - String launcherName = "foo"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(defaultConfigurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - assertEquals("false", manipulator.getConfigData().getProperty("config.shared")); - assertEquals("true", manipulator.getConfigData().getProperty("from.parent")); - } - - public void testSharedConfiguration() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(SharedConfigurationTest.class.getName()); - File defaultConfigurationFolder = new File(installFolder, "configuration"); - defaultConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini")); - File userConfigurationFolder = new File(installFolder, "user/configuration"); - userConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/user-config.ini"), new File(userConfigurationFolder, "config.ini")); - - String launcherName = "foo"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(userConfigurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - assertEquals("true", manipulator.getConfigData().getProperty("config.shared")); - assertEquals("true", manipulator.getConfigData().getProperty("from.parent")); - } - - public void testNotSharedConfiguration() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(SharedConfigurationTest.class.getName()); - File defaultConfigurationFolder = new File(installFolder, "configuration"); - defaultConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini")); - File userConfigurationFolder = new File(installFolder, "user/configuration"); - userConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/user-noshare-config.ini"), new File(userConfigurationFolder, "config.ini")); - - String launcherName = "foo"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(userConfigurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - assertEquals("false", manipulator.getConfigData().getProperty("config.shared")); - assertEquals(null, manipulator.getConfigData().getProperty("from.parent")); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorComingAndGoing.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorComingAndGoing.java deleted file mode 100644 index 56286d16b..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorComingAndGoing.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class SimpleConfiguratorComingAndGoing extends FwkAdminAndSimpleConfiguratorTest { - Manipulator m = null; - - public SimpleConfiguratorComingAndGoing(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - m = createMinimalConfiguration(SimpleConfiguratorComingAndGoing.class.getName()); - } - - public void testWithMutipleBundles() throws IOException, BundleException, URISyntaxException { - BundleInfo bi = new BundleInfo(URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, false); - m.getConfigData().addBundle(bi); - m.save(false); - - BundleInfo[] bis = m.getConfigData().getBundles(); - for (int i = 0; i < bis.length; i++) { - if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) - m.getConfigData().removeBundle(bis[i]); - } - m.save(false); - - assertNothing(getBundleTxt()); - assertContent(getConfigIni(), "bundle_1"); - assertContent(getConfigIni(), "org.eclipse.osgi"); - - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator newManipulator = fwkAdmin.getManipulator(); - - LauncherData launcherData = newManipulator.getLauncherData(); - launcherData.setFwConfigLocation(getConfigurationFolder()); - launcherData.setLauncher(new File(getInstallFolder(), getLauncherName())); - try { - newManipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - newManipulator.getConfigData().addBundle(new BundleInfo(URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true)); - newManipulator.save(false); - - assertContent(getBundleTxt(), "org.eclipse.osgi"); - assertContent(getBundleTxt(), "bundle_1"); - assertContent(getBundleTxt(), "org.eclipse.equinox.simpleconfigurator"); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorTest.java deleted file mode 100644 index 7cc535eaa..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.equinox.frameworkadmin.tests; - -import java.net.URI; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.framework.BundleException; - -public class SimpleConfiguratorTest extends AbstractFwkAdminTest { - - public SimpleConfiguratorTest(String name) { - super(name); - } - - public void testConfigFiles() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { - startSimpleConfiguratorManipulator(); - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator manipulator = fwkAdmin.getManipulator(); - - File installFolder = Activator.getContext().getDataFile(SimpleConfiguratorTest.class.getName()); - File configurationFolder = new File(installFolder, "configuration"); - String launcherName = "eclipse"; - - LauncherData launcherData = manipulator.getLauncherData(); - launcherData.setFwConfigLocation(configurationFolder); - launcherData.setLauncher(new File(installFolder, launcherName)); - try { - manipulator.load(); - } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception - } - - BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true); - BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true); - - manipulator.getConfigData().addBundle(osgiBi); - manipulator.getConfigData().addBundle(configuratorBi); - - manipulator.save(false); - - File bundleTXT = new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"); - File configINI = new File(configurationFolder, "config.ini"); - assertContent(bundleTXT, "org.eclipse.osgi"); - assertContent(configINI, "org.eclipse.osgi"); - assertContent(bundleTXT, "org.eclipse.equinox.simpleconfigurator"); - assertContent(configINI, "org.eclipse.equinox.simpleconfigurator"); - } - - public void testBundleInfoEquals() throws Exception { - BundleInfo b1 = new BundleInfo("org.foo", "3.1.0", new URI("plugins/org.foo_3.1.0"), -1, false); - BundleInfo b2 = new BundleInfo("org.foo", "3.1.0", null, -1, false); - BundleInfo b3 = new BundleInfo("org.foo", "3.1.0", URIUtil.fromString("C:/sp ace/plugins/org.foo_3.1.0"), -1, false); - - assertEquals(b1, b2); - assertFalse(b1.equals(b3)); - - b1.setBaseLocation(URIUtil.fromString("C:/sp ace")); - assertEquals(b1, b3); - - b3.setBaseLocation(URIUtil.fromString("C:/sp ace")); - assertEquals(b1, b3); - - b3.setVersion(null); - b1.setVersion("0.0.0"); - assertEquals(b1, b3); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestEclipseDataArea.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestEclipseDataArea.java deleted file mode 100644 index 9a0babf45..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestEclipseDataArea.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; - -public class TestEclipseDataArea extends FwkAdminAndSimpleConfiguratorTest { - Manipulator m = null; - - public TestEclipseDataArea(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - m = createMinimalConfiguration(TestEclipseDataArea.class.getName()); - } - - public void testp2DataArea() throws IOException { - m.getConfigData().setProperty("eclipse.p2.data.area", "@config.dir/../p2"); - m.save(false); - assertContent(getConfigIni(), "@config.dir/../p2"); - m.load(); - m.save(false); - assertContent(getConfigIni(), "@config.dir/../p2"); - - m.getConfigData().setProperty("eclipse.p2.data.area", new File(getConfigurationFolder(), "p2").getAbsoluteFile().toURI().toString()); - m.save(false); - assertContent(getConfigIni(), "@config.dir/p2"); - m.load(); - m.save(false); - assertContent(getConfigIni(), "@config.dir/p2"); - - m.getConfigData().setProperty("eclipse.p2.data.area", new File(getConfigurationFolder(), "../p2").getAbsoluteFile().toURI().toString()); - m.save(false); - assertContent(getConfigIni(), "@config.dir/../p2"); - m.load(); - m.save(false); - assertContent(getConfigIni(), "@config.dir/../p2"); - - m.getConfigData().setProperty("eclipse.p2.data.area", "file:/d:/tmp/fo%20o/bar/p2"); - m.save(false); - assertContent(getConfigIni(), "/tmp/fo o/bar/p2"); - assertNotContent(getConfigIni(), "@config.dir"); - m.load(); - m.save(false); - assertContent(getConfigIni(), "/tmp/fo o/bar/p2"); - assertNotContent(getConfigIni(), "@config.dir"); - - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java deleted file mode 100644 index e10e2c929..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 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.equinox.frameworkadmin.tests; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdmin; -import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.osgi.framework.*; - -public class TestRunningInstance extends AbstractFwkAdminTest { - - public TestRunningInstance(String name) { - super(name); - } - - public void testRunningInstance() throws BundleException { - //TODO Commented out due to NPE failure on Windows on test machines only - if (Platform.OS_WIN32.equals(Platform.getOS())) - return; - FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - Manipulator m = fwkAdmin.getRunningManipulator(); - BundleInfo[] infos = m.getConfigData().getBundles(); - - Bundle[] bundles = Activator.getContext().getBundles(); - - assertEquals(bundles.length, infos.length); - for (int i = 0; i < bundles.length; i++) { - boolean found = false; - for (int j = 0; j < infos.length && found == false; j++) { - found = same(infos[j], bundles[i]); - } - if (found == false) { - fail("Can't find: " + bundles[i]); - } - } - } - - private boolean same(BundleInfo info, Bundle bundle) { - if (info.getSymbolicName().equals(bundle.getSymbolicName())) { - if (new Version((String) bundle.getHeaders().get(Constants.BUNDLE_VERSION)).equals(new Version(info.getVersion()))) - return true; - } - return false; - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestVMArg.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestVMArg.java deleted file mode 100644 index ae3aa39b7..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestVMArg.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 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.equinox.frameworkadmin.tests; - -import java.io.File; -import java.io.IOException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdminRuntimeException; -import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; - -public class TestVMArg extends FwkAdminAndSimpleConfiguratorTest { - private Manipulator m; - - public TestVMArg(String name) { - super(name); - } - - protected void setUp() throws Exception { - super.setUp(); - m = createMinimalConfiguration(TestEclipseDataArea.class.getName()); - } - - public void testVMInsideInstall() throws FrameworkAdminRuntimeException, IOException { - //Test VM path in the install folder - File jreLocation = new File(m.getLauncherData().getLauncher().getParentFile(), "jre"); - m.getLauncherData().setJvm(jreLocation); - m.save(false); - assertNotContent(new File(getInstallFolder(), "eclipse.ini"), jreLocation.getAbsolutePath()); - assertContent(new File(getInstallFolder(), "eclipse.ini"), "jre"); - assertContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); - assertContent(m.getLauncherData().getLauncherConfigLocation(), "jre"); - assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "file:"); - m.load(); - assertEquals(jreLocation, m.getLauncherData().getJvm()); - - m.getLauncherData().setJvm(null); - m.save(false); - assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); - assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "jre"); - } - - public void testVMOutsideInstall() throws FrameworkAdminRuntimeException, IOException { - //Test VM path in the install folder - File jreLocation = new File(m.getLauncherData().getLauncher().getParentFile(), "../../jre").getCanonicalFile(); - m.getLauncherData().setJvm(jreLocation); - m.save(false); - assertContent(new File(getInstallFolder(), "eclipse.ini"), jreLocation.getAbsolutePath().replace('\\','/')); - assertContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); - assertContent(m.getLauncherData().getLauncherConfigLocation(), "jre"); - assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "file:"); - m.load(); - assertEquals(jreLocation, m.getLauncherData().getJvm()); - } - - public void test269502() throws FrameworkAdminRuntimeException, IOException { - //Test VM path in the install folder - String winPath = "c:/ibm5sr3/bin"; - String linuxPath = "/Users/Pascal/ibm5sr3/bin"; - String chosenPath = Platform.getOS().equals("win32") ? winPath : linuxPath; - File jreLocation = new File(chosenPath); - m.getLauncherData().setJvm(jreLocation); - m.save(false); - assertContent(new File(getInstallFolder(), "eclipse.ini"), chosenPath); - assertContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); - assertContent(m.getLauncherData().getLauncherConfigLocation(), chosenPath); - assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "file:"); - m.load(); - assertEquals(jreLocation, m.getLauncherData().getJvm()); - } - /** - * But 282303: - * Have -vm ../jre as program arguments. - * See them vanish during the save operation of the manipulator - * - * @throws FrameworkAdminRuntimeException - * @throws IOException - */ - public void test282303() throws FrameworkAdminRuntimeException, IOException { - assertNotContent(new File(getInstallFolder(), "eclipse.ini"), "-vm"); - assertNotContent(new File(getInstallFolder(), "eclipse.ini"), "../mylocation"); - assertNotContent(new File(getInstallFolder(), "eclipse.ini"), "-otherarg"); - m.getLauncherData().addProgramArg("-vm"); - m.getLauncherData().addProgramArg("../mylocation"); - m.getLauncherData().addProgramArg("-otherarg"); - m.getLauncherData().setJvm(new File("../mylocation")); - m.save(false); - m.load(); - String[] args = m.getLauncherData().getProgramArgs(); - boolean found = false; - for(int i = 0; i < args.length; i++) { - if("-vm".equals(args[i]) && i != args.length - 1) { - if("../mylocation".equals(args[++i])) { - found = true; - break; - } - } - } - assertTrue("Can't find vm argument.", found); - } -} diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/UtilsTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/UtilsTest.java deleted file mode 100644 index 0841eb48b..000000000 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/UtilsTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 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.equinox.frameworkadmin.tests; - -import java.io.File; -import org.eclipse.equinox.internal.frameworkadmin.equinox.utils.FileUtils; -import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.osgi.service.environment.Constants; - -public class UtilsTest extends AbstractFwkAdminTest { - - /** - * @param name - */ - public UtilsTest(String name) { - super(name); - } - - public void test_getEclipseRealLocation() throws Exception { - File installFolder = Activator.getContext().getDataFile("212361"); - - File plugins = new File(installFolder, "plugins"); - File foo1 = new File(plugins, "org.foo_1.2.3.abc"); - File foo2 = new File(plugins, "org.foo_1.2.4.xyz"); - File foo_64 = new File(plugins, "org.foo.x86_64_1.2.3"); - File fooWithSpaces = new File(plugins, "alotof/s p a c e s/org.foo_1.2.3.abc"); - foo1.mkdirs(); - foo2.mkdirs(); - foo_64.mkdirs(); - fooWithSpaces.mkdirs(); - - Manipulator manipulator = getFrameworkManipulator(new File(installFolder, "configuration"), new File(installFolder, "eclipse")); - - - assertEquals(FileUtils.getEclipseRealLocation(manipulator, "org.foo"), foo2.toURI()); - assertEquals(FileUtils.getEclipseRealLocation(manipulator, "org.foo_1.2.3.abc"), foo1.toURI()); - assertEquals(FileUtils.getEclipseRealLocation(manipulator, "org.foo.x86_64"), foo_64.toURI()); - - assertEquals(FileUtils.getEclipseRealLocation(manipulator, plugins.toURI().toString() + "alotof/s%20p%20a%20c%20e%20s/org.foo_1.2.3.abc/"), fooWithSpaces.toURI()); - - File other = new File(installFolder, "other/org.foo_1.2.4"); - other.mkdirs(); - manipulator.getConfigData().setProperty("osgi.syspath", other.getParentFile().getAbsolutePath()); - assertEquals(FileUtils.getEclipseRealLocation(manipulator, "org.foo"), other.toURI()); - } - - public void testMacRealLocation() throws Exception { - File installFolder = Activator.getContext().getDataFile("280007"); - - File plugins = new File(installFolder, "plugins"); - File foo = new File(plugins, "org.foo_1.2.3.abc"); - foo.mkdirs(); - - Manipulator manipulator = getFrameworkManipulator(new File(installFolder, "configuration"), new File(installFolder, "Eclipse.app/Contents/MacOS/eclipse")); - manipulator.getLauncherData().setOS(Constants.OS_MACOSX); - assertEquals(FileUtils.getEclipseRealLocation(manipulator, "org.foo"), foo.toURI()); - } -} |