diff options
author | Alexander Kurtakov | 2020-02-10 12:39:56 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2020-02-10 14:08:32 +0000 |
commit | d0df554371c182910dd1ce3a9a7a61d806019c93 (patch) | |
tree | 2f410d379258e4962a2315dbd527e05bcd8c5e29 | |
parent | 1d0a356bdb6a1148f6a1332989a6ea82411c9fca (diff) | |
download | rt.equinox.p2-d0df554371c182910dd1ce3a9a7a61d806019c93.tar.gz rt.equinox.p2-d0df554371c182910dd1ce3a9a7a61d806019c93.tar.xz rt.equinox.p2-d0df554371c182910dd1ce3a9a7a61d806019c93.zip |
Convert frameworkadmin.test bundle to JUnit 4.x.
Change-Id: I2667cfa1d0c8e0aaec10e7464d2289e061857e79
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
36 files changed, 647 insertions, 657 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.frameworkadmin.test/META-INF/MANIFEST.MF index 568179e4d..f9fd89084 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.frameworkadmin.test/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.equinox.frameworkadmin.test -Bundle-Version: 1.2.300.qualifier +Bundle-Version: 1.2.400.qualifier Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.core.runtime, org.eclipse.equinox.frameworkadmin, diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/pom.xml b/bundles/org.eclipse.equinox.frameworkadmin.test/pom.xml index dc760d1fd..8a1eec1a2 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/pom.xml +++ b/bundles/org.eclipse.equinox.frameworkadmin.test/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.frameworkadmin.test</artifactId> - <version>1.2.300-SNAPSHOT</version> + <version>1.2.400-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> 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 index fc71707bf..6bb86ff6b 100644 --- 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 @@ -13,30 +13,25 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.fail; + import java.io.*; import java.net.URI; import java.net.URL; -import java.util.Arrays; -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.junit.After; +import org.junit.Before; import org.osgi.framework.*; import org.osgi.util.tracker.ServiceTracker; -public abstract class AbstractFwkAdminTest extends TestCase { +public abstract class AbstractFwkAdminTest { private ServiceTracker<Object, FrameworkAdmin> fwAdminTracker; private File testFolder; - public AbstractFwkAdminTest(String name) { - super(name); - } - /** * Copy an input stream to an output stream. * Optionally close the streams when done. @@ -122,10 +117,8 @@ public abstract class AbstractFwkAdminTest extends TestCase { return testFolder; } - @Override - protected void runTest() throws Throwable { - super.runTest(); - + @Before + public void runTest() throws Throwable { //clean up after success if (testFolder != null && testFolder.exists()) { delete(testFolder); @@ -133,33 +126,13 @@ public abstract class AbstractFwkAdminTest extends TestCase { } } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { 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) { assertNotContent(null, file, search); } @@ -190,20 +163,6 @@ public abstract class AbstractFwkAdminTest extends TestCase { } } - public void assertIniFileNotContain(File file, String argument, String value) { - List<String> 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(); try (FileInputStream fis = new FileInputStream(file)) { @@ -236,18 +195,6 @@ public abstract class AbstractFwkAdminTest extends TestCase { 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(Arrays.toString(array1) + " not equal to " + Arrays.toString(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) { assertContent(null, file, search); } @@ -288,18 +235,6 @@ public abstract class AbstractFwkAdminTest extends TestCase { } } - 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 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 index 8ad205090..4e1835651 100644 --- 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 @@ -15,45 +15,44 @@ package org.eclipse.equinox.frameworkadmin.tests; -import junit.framework.*; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** * 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; - } - +@RunWith(Suite.class) +@Suite.SuiteClasses({ + Bug196525.class, + Bug258370.class, + CleanupTest.class, + FrameworkExtensionTest.class, + LauncherConfigLocationTest.class, + LauncherDataTest.class, + ManipulatorTests.class, + NoConfigurationValueInEclipseIni.class, + NoRenamingLauncherIni.class, + OSGiVersionChange.class, + ParserUtilsTest.class, + ReaderTest1.class, + ReaderTest2.class, + ReaderTest3.class, + ReaderTest4.class, + ReaderTest5.class, + ReaderTestBug267850.class, + ReaderTestBug285935.class, + RelativePathTest.class, + RemovingABundle.class, + RemovingAllBundles.class, + RenamingLauncherIni.class, + SharedConfigurationTest.class, + SimpleConfiguratorComingAndGoing.class, + SimpleConfiguratorTest.class, + TestEclipseDataArea.class, + TestRunningInstance.class, + TestVMArg.class, + UtilsTest.class +}) +public class AllTests { + // SuiteClasses }
\ 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 index 7e237713b..d6f25bf60 100644 --- 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 @@ -20,6 +20,8 @@ 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.junit.Before; +import org.junit.Test; import org.osgi.framework.BundleException; public class Bug196525 extends AbstractFwkAdminTest { @@ -29,14 +31,10 @@ public class Bug196525 extends AbstractFwkAdminTest { private File bundleTXT; private File configINI; - public Bug196525(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { startSimpleConfiguratorManipulator(); - //create a configuration with osgi and simpleconfigurator in it + // create a configuration with osgi and simpleconfigurator in it FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); @@ -53,11 +51,17 @@ public class Bug196525 extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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); + 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); @@ -65,7 +69,9 @@ public class Bug196525 extends AbstractFwkAdminTest { manipulator.save(false); } - public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { + @Test + public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, + BundleException, URISyntaxException { FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); @@ -75,16 +81,16 @@ public class Bug196525 extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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); + 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")))); + 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); 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 index 2c13e900e..d4aa23ccf 100644 --- 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 @@ -20,21 +20,14 @@ 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.junit.Test; 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"); - } + @Test + public void testComma() throws FrameworkAdminRuntimeException, IOException, URISyntaxException, BundleException { + FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); File installFolder = Activator.getContext().getDataFile(SimpleConfiguratorTest.class.getName()); @@ -45,46 +38,31 @@ public class Bug258370 extends FwkAdminAndSimpleConfiguratorTest { 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"); - } + manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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"); - } + 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 bundle1Bi = new BundleInfo("bundle_1", "1.0.0", + URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, + true); + BundleInfo bundle2Bi = new BundleInfo("bundle_2", "1.0.0", + URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_2"))), 2, + true); 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"); - } + manipulator.save(false); 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. + 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 index 878c6310b..f5f0b7656 100644 --- 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 @@ -13,74 +13,72 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + 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.FrameworkAdminRuntimeException; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; +import org.junit.Before; +import org.junit.Test; public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest { - public CleanupTest(String name) { - super(name); - } - Manipulator m = null; @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); m = createMinimalConfiguration(CleanupTest.class.getName()); } - public void testSimpleConfiguratorRemoval() { + @Test + public void testSimpleConfiguratorRemoval() throws FrameworkAdminRuntimeException, IOException { BundleInfo[] bis = m.getConfigData().getBundles(); for (BundleInfo bi : bis) { if (bi.getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) { m.getConfigData().removeBundle(bi); } } - try { - m.save(false); - } catch (IOException e) { - fail("Error while saving"); - } - assertNothing(new File(getConfigurationFolder(), "org.eclipse.equinox.simpleconfigurator")); - assertIsDirectory(getConfigurationFolder()); + m.save(false); + assertFalse(new File(getConfigurationFolder(), "org.eclipse.equinox.simpleconfigurator").exists()); + assertTrue(getConfigurationFolder().exists()); + assertTrue(getConfigurationFolder().isDirectory()); - //Now remove osgi + // Now remove osgi bis = m.getConfigData().getBundles(); for (BundleInfo bi : bis) { if (bi.getSymbolicName().equals("org.eclipse.osgi")) { m.getConfigData().removeBundle(bi); } } - try { - m.save(false); - } catch (IOException e) { - fail("Error while saving"); - } - assertNothing(getConfigurationFolder()); - assertNothing(new File(getInstallFolder(), getLauncherName() + ".ini")); + m.save(false); + assertFalse(getConfigurationFolder().exists()); + assertFalse(new File(getInstallFolder(), getLauncherName() + ".ini").exists()); } - public void testOSGiRemoval() { + @Test + public void testOSGiRemoval() throws FrameworkAdminRuntimeException, IOException { BundleInfo[] bis = m.getConfigData().getBundles(); for (BundleInfo bi : bis) { if (bi.getSymbolicName().equals("org.eclipse.osgi")) { m.getConfigData().removeBundle(bi); } } - 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"); + m.save(false); + File confFile = new File(getConfigurationFolder(), "org.eclipse.equinox.simpleconfigurator"); + assertTrue(confFile.exists()); + assertTrue(confFile.isDirectory()); + assertTrue(getConfigurationFolder().exists()); + assertTrue(getConfigurationFolder().isDirectory()); + assertNotContent(new File(getConfigurationFolder(), "org.eclipse.equinox.simpleconfigurator/bundles.info"), + "org.eclipse.osgi"); bis = m.getConfigData().getBundles(); for (BundleInfo bi : bis) { @@ -88,17 +86,16 @@ public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest { m.getConfigData().removeBundle(bi); } } - try { - m.save(false); - } catch (IOException e) { - fail("Error while saving"); - } - assertNothing(getConfigurationFolder()); - assertNothing(new File(getInstallFolder(), getLauncherName() + ".ini")); + m.save(false); + assertFalse(getConfigurationFolder().exists()); + assertFalse(new File(getInstallFolder(), getLauncherName() + ".ini").exists()); } + @Test public void testWithMutipleBundles() throws IOException, URISyntaxException { - BundleInfo bi = new BundleInfo(URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, false); + BundleInfo bi = new BundleInfo( + URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, + false); m.getConfigData().addBundle(bi); m.save(false); @@ -110,7 +107,7 @@ public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest { } m.save(false); - assertNothing(getBundleTxt()); + assertFalse(getBundleTxt().exists()); 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 index 2bab07edb..d78e734db 100644 --- 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 @@ -17,14 +17,12 @@ 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.junit.Test; import org.osgi.framework.Constants; public class FrameworkExtensionTest extends FwkAdminAndSimpleConfiguratorTest { - public FrameworkExtensionTest(String name) { - super(name); - } - + @Test 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); 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 index 85c56d78b..73e3b17be 100644 --- 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 @@ -19,6 +19,8 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; import org.eclipse.osgi.service.environment.Constants; +import org.junit.After; +import org.junit.Before; import org.osgi.framework.BundleException; public abstract class FwkAdminAndSimpleConfiguratorTest extends AbstractFwkAdminTest { @@ -27,21 +29,18 @@ public abstract class FwkAdminAndSimpleConfiguratorTest extends AbstractFwkAdmin private String launcherName; private IPath launcherPath; - public FwkAdminAndSimpleConfiguratorTest(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { startSimpleConfiguratorManipulator(); } - protected Manipulator getNewManipulator(String workArea) throws FrameworkAdminRuntimeException, IOException, BundleException { + protected Manipulator getNewManipulator(String workArea) + throws FrameworkAdminRuntimeException, IOException, BundleException { return getNewManipulator(workArea, null); } - protected Manipulator getNewManipulator(String workArea, String os) throws FrameworkAdminRuntimeException, IOException, BundleException { + protected Manipulator getNewManipulator(String workArea, String os) + throws FrameworkAdminRuntimeException, IOException, BundleException { FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); @@ -60,7 +59,7 @@ public abstract class FwkAdminAndSimpleConfiguratorTest extends AbstractFwkAdmin try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } return manipulator; } @@ -72,24 +71,25 @@ public abstract class FwkAdminAndSimpleConfiguratorTest extends AbstractFwkAdmin protected Manipulator createMinimalConfiguration(String workArea, String os) throws Exception { Manipulator manipulator = getNewManipulator(workArea, os); - 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); + 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"); - } + manipulator.save(false); return manipulator; } @Override - protected void tearDown() throws Exception { + @After + public void tearDown() throws Exception { super.tearDown(); if (installFolder != null) delete(installFolder); 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 index 38d8b5ba5..d1f50e5ea 100644 --- 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 @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.*; + import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -20,14 +22,12 @@ 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.junit.Test; import org.osgi.framework.BundleException; public class LauncherConfigLocationTest extends AbstractFwkAdminTest { - public LauncherConfigLocationTest(String name) { - super(name); - } - + @Test public void testCustomLauncherConfig() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); @@ -46,9 +46,9 @@ public class LauncherConfigLocationTest extends AbstractFwkAdminTest { launcherData.setLauncher(new File(installFolder, launcherName)); File defaultlaunchConfig = new File(installFolder, launcherName + ".ini"); - assertEquals(defaultlaunchConfig.exists(), false); + assertFalse(defaultlaunchConfig.exists()); File launchConfig = new File(installFolder, "mylaunch.ini"); - assertEquals(launchConfig.exists(), false); + assertFalse(launchConfig.exists()); launcherData.setLauncherConfigLocation(launchConfig); try { manipulator.load(); @@ -64,7 +64,7 @@ public class LauncherConfigLocationTest extends AbstractFwkAdminTest { manipulator.save(false); - assertEquals(launchConfig.exists(), true); - assertEquals(defaultlaunchConfig.exists(), false); + assertTrue(launchConfig.exists()); + assertFalse(defaultlaunchConfig.exists()); } } 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 index 9332f77b4..e5803dbe1 100644 --- 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 @@ -13,83 +13,67 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; -import junit.framework.TestCase; +import static org.junit.Assert.assertArrayEquals; + import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; +import org.junit.Test; /** * @since 1.0 */ -public class LauncherDataTest extends TestCase { - - /* - * Constructor for the class. - */ - public LauncherDataTest(String name) { - super(name); - } +public class LauncherDataTest { + @Test public void testRemoveProgramArg() { LauncherData data = new LauncherData("equinox", "1.0", "eclipse", "1.0"); - data.setProgramArgs(new String[] {"-console", "-startup", "foo"}); + data.setProgramArgs(new String[] { "-console", "-startup", "foo" }); data.removeProgramArg("-startup"); - assertEquals("1.0", new String[] {"-console"}, data.getProgramArgs()); + assertArrayEquals("1.0", new String[] { "-console" }, data.getProgramArgs()); data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "-bar"}); + data.setProgramArgs(new String[] { "-console", "-startup", "foo", "-bar" }); data.removeProgramArg("-startup"); - assertEquals("2.0", new String[] {"-console", "-bar"}, data.getProgramArgs()); + assertArrayEquals("2.0", new String[] { "-console", "-bar" }, data.getProgramArgs()); data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-startup", "foo"}); + data.setProgramArgs(new String[] { "-startup", "foo" }); data.removeProgramArg("-startup"); - assertEquals("3.0", new String[0], data.getProgramArgs()); + assertArrayEquals("3.0", new String[0], data.getProgramArgs()); data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "bar"}); + data.setProgramArgs(new String[] { "-console", "-startup", "foo", "bar" }); data.removeProgramArg("-startup"); - assertEquals("4.0", new String[] {"-console"}, data.getProgramArgs()); + assertArrayEquals("4.0", new String[] { "-console" }, data.getProgramArgs()); data.setProgramArgs(null); - data.setProgramArgs(new String[] {"-console", "-startup", "foo", "bar", "-xxx"}); + data.setProgramArgs(new String[] { "-console", "-startup", "foo", "bar", "-xxx" }); data.removeProgramArg("-startup"); - assertEquals("5.0", new String[] {"-console", "-xxx"}, data.getProgramArgs()); + assertArrayEquals("5.0", new String[] { "-console", "-xxx" }, data.getProgramArgs()); - // arg which doesn't start with a dash - dont' consume anything but that specific arg + // 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.setProgramArgs(new String[] { "-console", "-startup", "foo", "bar", "-xxx" }); data.removeProgramArg("foo"); - assertEquals("6.0", new String[] {"-console", "-startup", "foo", "bar", "-xxx"}, data.getProgramArgs()); + assertArrayEquals("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.setProgramArgs(new String[] { "-console", "-startup", "foo", "bar", "-xxx" }); data.removeProgramArg("zzz"); - assertEquals("7.0", new String[] {"-console", "-startup", "foo", "bar", "-xxx"}, data.getProgramArgs()); + assertArrayEquals("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.setProgramArgs(new String[] { "-console", "-startup", "foo", "bar", "-xxx" }); data.removeProgramArg("foo"); - assertEquals("8.0", new String[] {"-console", "-startup", "foo", "bar", "-xxx"}, data.getProgramArgs()); + assertArrayEquals("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.setProgramArgs(new String[] { "-console", "-startup", "foo", "bar", "-xxx" }); data.removeProgramArg(" "); - assertEquals("9.0", new String[] {"-console", "-startup", "foo", "bar", "-xxx"}, data.getProgramArgs()); - - } + assertArrayEquals("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 index 336b9342a..84ef80367 100644 --- 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 @@ -13,6 +13,9 @@ ******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.IOException; import org.eclipse.core.runtime.FileLocator; @@ -20,21 +23,23 @@ 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.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; import org.osgi.framework.BundleException; public class MacOSLikeSetup extends FwkAdminAndSimpleConfiguratorTest { + @Rule + public TestName name = new TestName(); - public MacOSLikeSetup(String name) { - super(name); - } - + @Test public void testMacOSSetup() throws FrameworkAdminRuntimeException, IOException, BundleException { FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); - File installFolder = new File(Activator.getContext().getDataFile(getName()), "Eclipse.app/Contents/Eclipse"); + File installFolder = new File(Activator.getContext().getDataFile(name.getMethodName()), "Eclipse.app/Contents/Eclipse"); File configurationFolder = new File(installFolder, "configuration"); - File launcherFolder = new File(installFolder, "../MacOS/"); + File launcherFolder = new File(installFolder, "../MacOS/"); File launcherName = new File(launcherFolder, "eclipse"); LauncherData launcherData = manipulator.getLauncherData(); @@ -43,27 +48,35 @@ public class MacOSLikeSetup extends FwkAdminAndSimpleConfiguratorTest { launcherData.setLauncherConfigLocation(new File(installFolder, "eclipse.ini")); launcherData.setOS(Constants.OS_MACOSX); - //Setup the plugins as they should + // 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); - + 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 + // TODO We ignore the framework JAR location not set exception } File launcherIni = new File(installFolder, "eclipse.ini"); assertNotContent(launcherIni, "-configuration"); @@ -72,36 +85,44 @@ public class MacOSLikeSetup extends FwkAdminAndSimpleConfiguratorTest { assertContent(launcherIni, "../Eclipse/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()); - + assertTrue("bundles.info missing", + new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info").exists()); + } - + + @Test public void testMacWithoutStartupOrFw() throws Exception { FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); - File installFolder = new File(Activator.getContext().getDataFile(getName()), "Eclipse.app/Contents/Eclipse"); + File installFolder = new File(Activator.getContext().getDataFile(name.getMethodName()), "Eclipse.app/Contents/Eclipse"); File configurationFolder = new File(installFolder, "configuration"); - File launcherFolder = new File(installFolder, "../MacOS/"); + File launcherFolder = new File(installFolder, "../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); - + 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(installFolder, "eclipse.ini"); File bundleInfo = new File(configurationFolder, "org.eclipse.equinox.simpleconfigurator/bundles.info"); assertFalse(launcherIni.exists()); 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 index e23b00c48..9cf6bd947 100644 --- 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 @@ -14,26 +14,32 @@ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.*; + 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.*; +import org.junit.Test; public class ManipulatorTests extends AbstractFwkAdminTest { - public ManipulatorTests(String name) { - super(name); - } - + @Test 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); + 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); @@ -41,28 +47,31 @@ public class ManipulatorTests extends AbstractFwkAdminTest { manipulator.save(false); Properties configIni = new Properties(); - try (InputStream in = new BufferedInputStream(new FileInputStream(new File(configurationFolder, "config.ini")))) { + try (InputStream in = new BufferedInputStream( + new FileInputStream(new File(configurationFolder, "config.ini")))) { configIni.load(in); } String bundles = (String) configIni.get("osgi.bundles"); - assertTrue(bundles.indexOf("org.eclipse.osgi") == -1); + assertEquals(-1 , bundles.indexOf("org.eclipse.osgi")); } + @Test 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); + 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"}); - + writeEclipseIni(ini, new String[] { "-foo", "bar", "-vmargs", "-Xmx256m" }); + startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); - + Manipulator manipulator = fwkAdmin.getManipulator(); manipulator.getConfigData().addBundle(osgiBi); LauncherData launcherData = manipulator.getLauncherData(); @@ -70,14 +79,15 @@ public class ManipulatorTests extends AbstractFwkAdminTest { launcherData.setLauncher(new File(folder, "eclipse")); manipulator.load(); - + assertEquals(manipulator.getLauncherData().getFwPersistentDataLocation(), new File(folder, "configuration")); } - + + @Test 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"}); + writeEclipseIni(ini, new String[] { "-foo", "bar", "-vmargs", "-Xmx256m" }); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); @@ -86,21 +96,24 @@ public class ManipulatorTests extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } - assertEquals(launcherData.getJvmArgs(), new String[] {"-Xmx256m"}); - assertEquals(launcherData.getProgramArgs(), new String[] {"-foo", "bar"}); + assertArrayEquals(launcherData.getJvmArgs(), new String[] { "-Xmx256m" }); + assertArrayEquals(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); + // 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); assertContent(ini, "-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 index 14ef9a626..5858e5777 100644 --- 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 @@ -20,20 +20,19 @@ 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.junit.Test; import org.osgi.framework.BundleException; public class NoConfigurationValueInEclipseIni extends FwkAdminAndSimpleConfiguratorTest { - public NoConfigurationValueInEclipseIni(String name) { - super(name); - } - + @Test public void testAbsenceOfConfigurationInEclipseINI() throws Exception { createMinimalConfiguration(NoConfigurationValueInEclipseIni.class.getName()); File launcherIni = new File(getInstallFolder(), getLauncherName() + ".ini"); assertNotContent(launcherIni, "-configuration"); } + @Test public void testPresenceOfConfigurationInEclipseINI() throws FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); 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 index 3ceeecc58..9f68a5a85 100644 --- 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 @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -20,14 +22,12 @@ 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.junit.Test; import org.osgi.framework.BundleException; public class NoRenamingLauncherIni extends AbstractFwkAdminTest { - public NoRenamingLauncherIni(String name) { - super(name); - } - + @Test public void testConfigFiles() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); 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 index ea24a2f6d..3f0572e84 100644 --- 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 @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.IOException; import java.net.URISyntaxException; import org.eclipse.core.runtime.FileLocator; @@ -20,22 +22,22 @@ 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.junit.Before; +import org.junit.Test; 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); - } - @Override - protected void setUp() throws Exception { + @Override @Before + public void setUp() throws Exception { super.setUp(); defaultManipulator = createMinimalConfiguration(workArea); } + @Test public void testRemovalUsingSameManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException { BundleInfo[] infos = defaultManipulator.getConfigData().getBundles(); BundleInfo osgi = null; @@ -50,7 +52,7 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest { assertNotContent(getBundleTxt(), "org.eclipse.osgi"); assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi"); } - + @Test public void testRemovalUsingOtherManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { Manipulator newManipulator = getNewManipulator(workArea); BundleInfo[] infos = newManipulator.getConfigData().getBundles(); @@ -66,7 +68,7 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest { assertNotContent(getBundleTxt(), "org.eclipse.osgi"); assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi"); } - + @Test public void testAdditionUsingOtherManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { BundleInfo[] infos = defaultManipulator.getConfigData().getBundles(); BundleInfo osgi = null; @@ -86,7 +88,7 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest { assertContent(getBundleTxt(), "org.eclipse.osgi"); assertNotPropertyContains(getConfigIni(),"osgi.bundles", "org.eclipse.osgi"); } - + @Test public void testChangeVersion() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, URISyntaxException { BundleInfo[] infos = defaultManipulator.getConfigData().getBundles(); BundleInfo osgi = null; @@ -108,7 +110,7 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest { assertContent(getBundleTxt(), VERSION); assertContent(getConfigIni(), FILENAME); } - + @Test public void testReadConfigWithoutOSGi() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { //First Create a configuration that does not contain OSGi BundleInfo[] infos = defaultManipulator.getConfigData().getBundles(); 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 index 2dadddc5b..9051d7aa4 100644 --- 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 @@ -13,18 +13,19 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.*; + import java.io.File; import java.util.*; import org.eclipse.equinox.internal.frameworkadmin.equinox.ParserUtils; +import org.junit.Test; /** * Tests for {@link ParserUtils}. */ public class ParserUtilsTest extends AbstractFwkAdminTest { - public ParserUtilsTest(String name) { - super(name); - } + @Test public void testGetValueForArgument() throws Exception { List<String> args = new ArrayList<>(); args.add("-foo"); @@ -34,44 +35,44 @@ public class ParserUtilsTest extends AbstractFwkAdminTest { args.set(1, "-bar"); assertEquals(null, ParserUtils.getValueForArgument("-foo", args)); } - + @Test 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"}); + assertArrayEquals(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}); + assertArrayEquals(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}); + assertArrayEquals(args, new String [] {"-bar", null, null}); } - + @Test public void testSetValueForArgument() throws Exception { List<String> args = new ArrayList<>(); ParserUtils.setValueForArgument("-foo", "bar", args); - assertTrue(args.size() == 2); + assertEquals(2, args.size()); 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(3, args.size()); 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(3, args.size()); assertEquals(args.get(0), "-foo"); assertEquals(args.get(1), "bas"); assertEquals(args.get(2), "-other"); } - + @Test public void testFromOSGiJarToOSGiInstallArea() { String path = ""; File result =ParserUtils.fromOSGiJarToOSGiInstallArea(path); 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 index 81366bca1..e1f14a814 100644 --- 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 @@ -13,20 +13,19 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.junit.Test; import org.osgi.framework.BundleException; public class ReaderTest1 extends AbstractFwkAdminTest { private File installFolder = null; private String launcherName = "eclipse"; - public ReaderTest1(String name) { - super(name); - } - - + @Test public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { startSimpleConfiguratorManipulator(); 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 index 965a82e3a..45e456bc8 100644 --- 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 @@ -13,10 +13,14 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import java.util.Properties; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.junit.Before; +import org.junit.Test; import org.osgi.framework.BundleException; public class ReaderTest2 extends AbstractFwkAdminTest { @@ -24,24 +28,22 @@ public class ReaderTest2 extends AbstractFwkAdminTest { private File configurationFolder = null; private String launcherName = "eclipse"; - public ReaderTest2(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { startSimpleConfiguratorManipulator(); installFolder = Activator.getContext().getDataFile(ReaderTest2.class.getName()); configurationFolder = new File(installFolder, "conf"); - writeEclipseIni(new File(installFolder, "eclipse.ini"), new String[] { "-configuration", configurationFolder.getAbsolutePath() }); + 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 { + @Test + public void testConfigContent() + throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); LauncherData launcherData = manipulator.getLauncherData(); @@ -49,10 +51,10 @@ public class ReaderTest2 extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } - - assertEquals(new File(installFolder, "conf"), manipulator.getLauncherData().getFwConfigLocation()); + + assertEquals(new File(installFolder, "conf"), manipulator.getLauncherData().getFwConfigLocation()); assertEquals("bar", manipulator.getConfigData().getProperty("foo")); } 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 index 565e8ca50..d7268bb84 100644 --- 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 @@ -13,19 +13,19 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.junit.Test; import org.osgi.framework.BundleException; public class ReaderTest3 extends AbstractFwkAdminTest { private File installFolder = null; private String launcherName = "eclipse"; - public ReaderTest3(String name) { - super(name); - } - + @Test public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { startSimpleConfiguratorManipulator(); 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 index 6e36d9bf5..e31a6a360 100644 --- 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 @@ -13,11 +13,15 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import java.util.Properties; import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.junit.Before; +import org.junit.Test; import org.osgi.framework.BundleException; public class ReaderTest4 extends AbstractFwkAdminTest { @@ -25,24 +29,23 @@ public class ReaderTest4 extends AbstractFwkAdminTest { private File configurationFolder = null; private String launcherName = "eclipse"; - public ReaderTest4(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { 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())) }); + 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 { + @Test + public void testConfigContent() + throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); LauncherData launcherData = manipulator.getLauncherData(); @@ -50,10 +53,10 @@ public class ReaderTest4 extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } - - assertEquals(new File(installFolder, "conf"), manipulator.getLauncherData().getFwConfigLocation()); + + assertEquals(new File(installFolder, "conf"), manipulator.getLauncherData().getFwConfigLocation()); assertEquals("bar", manipulator.getConfigData().getProperty("foo")); } } 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 index 97dd19d12..3f9d9d9bb 100644 --- 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 @@ -13,10 +13,14 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import java.util.Properties; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.junit.Before; +import org.junit.Test; import org.osgi.framework.BundleException; public class ReaderTest5 extends AbstractFwkAdminTest { @@ -24,24 +28,22 @@ public class ReaderTest5 extends AbstractFwkAdminTest { private File configurationFolder = null; private String launcherName = "eclipse"; - public ReaderTest5(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { startSimpleConfiguratorManipulator(); installFolder = Activator.getContext().getDataFile(ReaderTest5.class.getName()); configurationFolder = new File(installFolder, "configuration"); - writeEclipseIni(new File(installFolder, "eclipse.ini"), new String[] { "-install", installFolder.getAbsolutePath()}); + 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 { + @Test + public void testConfigContent() + throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); LauncherData launcherData = manipulator.getLauncherData(); @@ -49,16 +51,11 @@ public class ReaderTest5 extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } - - assertEquals(configurationFolder, manipulator.getLauncherData().getFwConfigLocation()); - assertEquals("bar", manipulator.getConfigData(). getProperty("foo")); - } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + assertEquals(configurationFolder, manipulator.getLauncherData().getFwConfigLocation()); + assertEquals("bar", manipulator.getConfigData().getProperty("foo")); } } 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 index 394c9b3d6..0e2b8a066 100644 --- 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 @@ -13,19 +13,19 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.junit.Test; import org.osgi.framework.BundleException; public class ReaderTestBug267850 extends AbstractFwkAdminTest { private File installFolder = null; private String launcherName = "eclipse"; - public ReaderTestBug267850(String name) { - super(name); - } - + @Test public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { startSimpleConfiguratorManipulator(); 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 index 3963a9c25..e143edf32 100644 --- 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 @@ -13,19 +13,19 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.IOException; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; +import org.junit.Test; import org.osgi.framework.BundleException; public class ReaderTestBug285935 extends AbstractFwkAdminTest { private File installFolder = null; private String launcherName = "eclipse"; - public ReaderTestBug285935(String name) { - super(name); - } - + @Test public void testConfigContent() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { startSimpleConfiguratorManipulator(); 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 index 666606381..b7cbecbf9 100644 --- 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 @@ -13,7 +13,10 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; -import java.io.*; +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileOutputStream; import java.net.MalformedURLException; import java.net.URL; import org.eclipse.core.runtime.FileLocator; @@ -21,25 +24,25 @@ 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.*; +import org.junit.Test; 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); - } - + @Test public void testRelativePaths() throws Exception { File installFolder = Activator.getContext().getDataFile(RelativePathTest.class.getName()); - //First we copy some jars into a well + // 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); + 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(); @@ -53,33 +56,35 @@ public class RelativePathTest extends FwkAdminAndSimpleConfiguratorTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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); + 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"); - } + manipulator.save(false); - //":path.jar" is a poor man approach to test relative paths + // ":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()); + 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); + // 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()); + // 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(); @@ -88,49 +93,40 @@ public class RelativePathTest extends FwkAdminAndSimpleConfiguratorTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } } - public void testMakeRelative_NonWindows() { + @Test + public void testMakeRelative_NonWindows() throws MalformedURLException { if (WINDOWS) return; - URL base = null; - try { - base = new URL("file:/eclipse/"); - } catch (MalformedURLException e) { - e.printStackTrace(); - fail("0.98"); - } + URL base = new URL("file:/eclipse/"); // 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"}, // + 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() { + @Test + public void testMakeRelative_Windows() throws MalformedURLException { 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"); - } + URL base = new URL("file:/c:/a/eclipse/"); // 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"}, // + 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 index a58ccfffe..15315d17f 100644 --- 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 @@ -13,33 +13,40 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertTrue; + 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.junit.Before; +import org.junit.Test; import org.osgi.framework.BundleException; public class RemovingABundle extends FwkAdminAndSimpleConfiguratorTest { - public RemovingABundle(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @Before + public 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.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); + File fooINI = new File(getInstallFolder(), getLauncherName() + ".ini"); + assertTrue(fooINI.exists()); assertContent(getBundleTxt(), "bundle_1"); } - - public void testRemoveBundleWithoutURL() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { + + @Test + public void testRemoveBundleWithoutURL() + throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { Manipulator m2 = getEquinoxFrameworkAdmin().getManipulator(); LauncherData launcherData2 = m2.getLauncherData(); @@ -49,7 +56,7 @@ public class RemovingABundle extends FwkAdminAndSimpleConfiguratorTest { try { m2.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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); 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 index 2d933b977..e972393cb 100644 --- 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 @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -20,15 +23,14 @@ 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.junit.Test; 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 { + @Test + public void testConfigFiles() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, + BundleException, URISyntaxException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); @@ -43,11 +45,17 @@ public class RemovingAllBundles extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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); + 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); @@ -55,7 +63,7 @@ public class RemovingAllBundles extends AbstractFwkAdminTest { manipulator.save(false); File fooINI = new File(installFolder, "foo.ini"); - assertEquals(fooINI.exists(), true); + assertTrue(fooINI.exists()); Manipulator m2 = fwkAdmin.getManipulator(); @@ -66,7 +74,7 @@ public class RemovingAllBundles extends AbstractFwkAdminTest { try { m2.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } BundleInfo[] infos = m2.getConfigData().getBundles(); @@ -75,6 +83,6 @@ public class RemovingAllBundles extends AbstractFwkAdminTest { } m2.save(false); - assertEquals(new File(configurationFolder + "/org.eclipse.equinox.simpleconfigurator", "bundles.info").exists(), false); + assertFalse(new File(configurationFolder + "/org.eclipse.equinox.simpleconfigurator", "bundles.info").exists()); } } 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 index 36d664ea3..d676aee98 100644 --- 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 @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -20,14 +22,12 @@ 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.junit.Test; import org.osgi.framework.BundleException; public class RenamingLauncherIni extends AbstractFwkAdminTest { - public RenamingLauncherIni(String name) { - super(name); - } - + @Test public void testConfigFiles() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException, URISyntaxException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); @@ -55,7 +55,7 @@ public class RenamingLauncherIni extends AbstractFwkAdminTest { manipulator.save(false); File fooINI = new File(installFolder, "foo.ini"); - assertEquals(fooINI.exists(), true); + assertTrue(fooINI.exists()); Manipulator m2 = fwkAdmin.getManipulator(); @@ -71,6 +71,6 @@ public class RenamingLauncherIni extends AbstractFwkAdminTest { launcherData2.setLauncher(new File(installFolder, "foo")); m2.save(false); - assertEquals(new File(installFolder, "foo.ini").exists(), true); + assertTrue(new File(installFolder, "foo.ini").exists()); } } 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 index b873d4d72..011f8e82b 100644 --- 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 @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.*; + import java.io.*; import java.net.URISyntaxException; import java.util.Properties; @@ -24,26 +26,30 @@ import org.eclipse.equinox.internal.frameworkadmin.equinox.Log; import org.eclipse.equinox.internal.frameworkadmin.equinox.Messages; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; import org.eclipse.osgi.util.NLS; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; import org.osgi.framework.BundleException; import org.osgi.service.log.LogService; public class SharedConfigurationTest extends AbstractFwkAdminTest { private static final String BASE_CONFIG_INI_TIMESTAMP = ".baseConfigIniTimestamp"; + @Rule + public TestName name = new TestName(); - public SharedConfigurationTest(String name) { - super(name); - } - - public void testDefaultConfiguration() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { + @Test + public void testDefaultConfiguration() + throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); - File installFolder = Activator.getContext().getDataFile(getName()); + File installFolder = Activator.getContext().getDataFile(name.getMethodName()); File defaultConfigurationFolder = new File(installFolder, "configuration"); defaultConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini")); + copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), + new File(defaultConfigurationFolder, "config.ini")); String launcherName = "foo"; @@ -54,25 +60,29 @@ public class SharedConfigurationTest extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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 { + @Test + public void testSharedConfiguration() + throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); - File installFolder = Activator.getContext().getDataFile(getName()); + File installFolder = Activator.getContext().getDataFile(name.getMethodName()); File defaultConfigurationFolder = new File(installFolder, "configuration"); defaultConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini")); + 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")); + copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/user-config.ini"), + new File(userConfigurationFolder, "config.ini")); String launcherName = "foo"; @@ -83,25 +93,29 @@ public class SharedConfigurationTest extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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 { + @Test + public void testNotSharedConfiguration() + throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); - File installFolder = Activator.getContext().getDataFile(getName()); + File installFolder = Activator.getContext().getDataFile(name.getMethodName()); File defaultConfigurationFolder = new File(installFolder, "configuration"); defaultConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini")); + 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")); + copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/user-noshare-config.ini"), + new File(userConfigurationFolder, "config.ini")); String launcherName = "foo"; @@ -112,25 +126,29 @@ public class SharedConfigurationTest extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } assertEquals("false", manipulator.getConfigData().getProperty("config.shared")); assertEquals(null, manipulator.getConfigData().getProperty("from.parent")); } - public void testConfigIniTimestamp() throws BundleException, FrameworkAdminRuntimeException, IOException, URISyntaxException { + @Test + public void testConfigIniTimestamp() + throws BundleException, FrameworkAdminRuntimeException, IOException, URISyntaxException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); - File installFolder = Activator.getContext().getDataFile(getName()); + File installFolder = Activator.getContext().getDataFile(name.getMethodName()); File defaultConfigurationFolder = new File(installFolder, "configuration"); defaultConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini")); + 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")); + copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/user-config.ini"), + new File(userConfigurationFolder, "config.ini")); String launcherName = "foo"; @@ -142,38 +160,57 @@ public class SharedConfigurationTest extends AbstractFwkAdminTest { manipulator.load(); } catch (IllegalStateException e) { e.printStackTrace(); - //TODO We ignore the framework JAR location not set exception + // 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); + 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 baseTimestamp = new File(userConfigurationFolder, BASE_CONFIG_INI_TIMESTAMP); - assertIsFile(baseTimestamp); + assertTrue(baseTimestamp.exists()); + assertTrue(baseTimestamp.isFile()); assertContent(baseTimestamp, Long.toString(new File(defaultConfigurationFolder, "config.ini").lastModified())); } - public void testConfigurationIgnoredWhenChanged() throws BundleException, FrameworkAdminRuntimeException, IOException { + @Test + public void testConfigurationIgnoredWhenChanged() + throws BundleException, FrameworkAdminRuntimeException, IOException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); - //setup the files - File installFolder = Activator.getContext().getDataFile(getName()); + // setup the files + File installFolder = Activator.getContext().getDataFile(name.getMethodName()); File defaultConfigurationFolder = new File(installFolder, "configuration"); defaultConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/ignoreUserConfig/config.ini"), new File(defaultConfigurationFolder, "config.ini")); + copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/ignoreUserConfig/config.ini"), + new File(defaultConfigurationFolder, "config.ini")); File userConfigurationFolder = new File(installFolder, "user/configuration"); userConfigurationFolder.mkdirs(); - copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/ignoreUserConfig/user-config.ini"), new File(userConfigurationFolder, "config.ini")); - - //setup the timestamp + copy("creating shared config.ini", + getTestData("", "dataFile/sharedconfiguration/ignoreUserConfig/user-config.ini"), + new File(userConfigurationFolder, "config.ini")); + + // setup the timestamp Properties p = new Properties(); - p.setProperty("configIniTimestamp", Long.toString(new File(defaultConfigurationFolder, "config.ini").lastModified() - 10)); //Here we write an outdated timestamp to mimic the fact that the base has changed + p.setProperty("configIniTimestamp", + Long.toString(new File(defaultConfigurationFolder, "config.ini").lastModified() - 10)); // Here we write + // an outdated + // timestamp to + // mimic the + // fact that the + // base has + // changed saveProperties(new File(userConfigurationFolder, BASE_CONFIG_INI_TIMESTAMP), p); String launcherName = "foo"; @@ -185,7 +222,7 @@ public class SharedConfigurationTest extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // TODO We ignore the framework JAR location not set exception } assertNull(manipulator.getConfigData().getProperty("userKey")); 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 index 0b39fe925..dfcafa998 100644 --- 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 @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertFalse; + import java.io.File; import java.io.IOException; import java.net.URISyntaxException; @@ -20,23 +22,25 @@ 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.junit.Before; +import org.junit.Test; import org.osgi.framework.BundleException; public class SimpleConfiguratorComingAndGoing extends FwkAdminAndSimpleConfiguratorTest { Manipulator m = null; - public SimpleConfiguratorComingAndGoing(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); m = createMinimalConfiguration(SimpleConfiguratorComingAndGoing.class.getName()); } + @Test public void testWithMutipleBundles() throws IOException, BundleException, URISyntaxException { - BundleInfo bi = new BundleInfo(URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, false); + BundleInfo bi = new BundleInfo( + URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/bundle_1"))), 2, + false); m.getConfigData().addBundle(bi); m.save(false); @@ -48,7 +52,7 @@ public class SimpleConfiguratorComingAndGoing extends FwkAdminAndSimpleConfigura } m.save(false); - assertNothing(getBundleTxt()); + assertFalse(getBundleTxt().exists()); assertContent(getConfigIni(), "bundle_1"); assertContent(getConfigIni(), "org.eclipse.osgi"); @@ -61,10 +65,12 @@ public class SimpleConfiguratorComingAndGoing extends FwkAdminAndSimpleConfigura try { newManipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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.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"); 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 index f369f4e50..e2b8393a5 100644 --- 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 @@ -13,24 +13,25 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; -import java.net.URI; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.io.File; import java.io.IOException; +import java.net.URI; 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.junit.Test; 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 { + @Test + public void testConfigFiles() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, + BundleException, URISyntaxException { startSimpleConfiguratorManipulator(); FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin(); Manipulator manipulator = fwkAdmin.getManipulator(); @@ -45,11 +46,17 @@ public class SimpleConfiguratorTest extends AbstractFwkAdminTest { try { manipulator.load(); } catch (IllegalStateException e) { - //TODO We ignore the framework JAR location not set exception + // 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); + 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); @@ -64,20 +71,22 @@ public class SimpleConfiguratorTest extends AbstractFwkAdminTest { assertContent(configINI, "org.eclipse.equinox.simpleconfigurator"); } + @Test 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); - + 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 index e8ee45ab1..9025738c5 100644 --- 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 @@ -15,20 +15,20 @@ package org.eclipse.equinox.frameworkadmin.tests; import java.io.File; import java.io.IOException; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; +import org.junit.After; +import org.junit.Test; public class TestEclipseDataArea extends FwkAdminAndSimpleConfiguratorTest { Manipulator m = null; - public TestEclipseDataArea(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @After + public void setUp() throws Exception { super.setUp(); m = createMinimalConfiguration(TestEclipseDataArea.class.getName()); } + @Test public void testp2DataArea() throws IOException { m.getConfigData().setProperty("eclipse.p2.data.area", "@config.dir/../p2"); m.save(false); @@ -37,14 +37,16 @@ public class TestEclipseDataArea extends FwkAdminAndSimpleConfiguratorTest { m.save(false); assertContent(getConfigIni(), "@config.dir/../p2"); - m.getConfigData().setProperty("eclipse.p2.data.area", new File(getConfigurationFolder(), "p2").getAbsoluteFile().toURI().toString()); + 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.getConfigData().setProperty("eclipse.p2.data.area", + new File(getConfigurationFolder(), "../p2").getAbsoluteFile().toURI().toString()); m.save(false); assertContent(getConfigIni(), "@config.dir/../p2"); m.load(); 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 index c1cb1f42b..413856a63 100644 --- 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 @@ -13,28 +13,29 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + 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.junit.Test; import org.osgi.framework.*; public class TestRunningInstance extends AbstractFwkAdminTest { - public TestRunningInstance(String name) { - super(name); - } - + @Test public void testRunningInstance() throws BundleException { - //TODO Commented out due to NPE failure on Windows on test machines only + // 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 (Bundle bundle : bundles) { boolean found = false; @@ -46,7 +47,7 @@ public class TestRunningInstance extends AbstractFwkAdminTest { } } } - + private boolean same(BundleInfo info, Bundle bundle) { if (info.getSymbolicName().equals(bundle.getSymbolicName())) { if (new Version(bundle.getHeaders().get(Constants.BUNDLE_VERSION)).equals(new Version(info.getVersion()))) 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 index c7fb2d385..fb2e50d39 100644 --- 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 @@ -13,28 +13,30 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + 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; +import org.junit.Before; +import org.junit.Test; -public class TestVMArg extends FwkAdminAndSimpleConfiguratorTest { +public class TestVMArg extends FwkAdminAndSimpleConfiguratorTest { private Manipulator m; - public TestVMArg(String name) { - super(name); - } - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); m = createMinimalConfiguration(TestEclipseDataArea.class.getName()); } - + @Test public void testVMInsideInstall() throws FrameworkAdminRuntimeException, IOException { - //Test VM path in the install folder + // Test VM path in the install folder File jreLocation = new File(m.getLauncherData().getLauncher().getParentFile(), "jre"); m.getLauncherData().setJvm(jreLocation); m.save(false); @@ -51,7 +53,7 @@ public class TestVMArg extends FwkAdminAndSimpleConfiguratorTest { assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "-vm"); assertNotContent(m.getLauncherData().getLauncherConfigLocation(), "jre"); } - + // public void testVMInsideInstall_MacOS() throws Exception { // m = createMinimalConfiguration(TestEclipseDataArea.class.getName(), Constants.OS_MACOSX); // final String expectedRelativePath = "../../../jre"; @@ -78,26 +80,26 @@ public class TestVMArg extends FwkAdminAndSimpleConfiguratorTest { // assertNotContent("No absolute JRE path must be present in " + launcherConfigFile, launcherConfigFile, jreLocation.getAbsolutePath()); // assertContent("Relative JRE path must be present in " + launcherConfigFile, launcherConfigFile, expectedRelativePath); // } - + @Test public void testVMOutsideInstall() throws FrameworkAdminRuntimeException, IOException { - //Test VM path in the install folder + // 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(getLauncherConfigFile(), jreLocation.getAbsolutePath().replace('\\','/')); + assertContent(getLauncherConfigFile(), 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()); } - + @Test public void test269502() throws FrameworkAdminRuntimeException, IOException { - //Test VM path in the install folder + // 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); + String chosenPath = Platform.getOS().equals("win32") ? winPath : linuxPath; + File jreLocation = new File(chosenPath); m.getLauncherData().setJvm(jreLocation); m.save(false); assertContent(getLauncherConfigFile(), chosenPath); @@ -125,13 +127,13 @@ public class TestVMArg extends FwkAdminAndSimpleConfiguratorTest { // } /** - * But 282303: - * Have -vm ../jre as program arguments. - * See them vanish during the save operation of the manipulator + * But 282303: Have -vm ../jre as program arguments. See them vanish during the + * save operation of the manipulator * * @throws FrameworkAdminRuntimeException * @throws IOException */ + @Test public void test282303() throws FrameworkAdminRuntimeException, IOException { assertNotContent(getLauncherConfigFile(), "-vm"); assertNotContent(getLauncherConfigFile(), "../mylocation"); @@ -144,9 +146,9 @@ public class TestVMArg extends FwkAdminAndSimpleConfiguratorTest { 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])) { + 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; } 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 index d4bb5ed6b..22684786d 100644 --- 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 @@ -13,21 +13,18 @@ *******************************************************************************/ package org.eclipse.equinox.frameworkadmin.tests; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.net.URI; import org.eclipse.equinox.internal.frameworkadmin.equinox.utils.FileUtils; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; import org.eclipse.osgi.service.environment.Constants; +import org.junit.Test; public class UtilsTest extends AbstractFwkAdminTest { - /** - * @param name - */ - public UtilsTest(String name) { - super(name); - } - + @Test public void test_getEclipseRealLocation() throws Exception { File installFolder = Activator.getContext().getDataFile("212361"); @@ -41,21 +38,25 @@ public class UtilsTest extends AbstractFwkAdminTest { foo_64.mkdirs(); fooWithSpaces.mkdirs(); - Manipulator manipulator = getFrameworkManipulator(new File(installFolder, "configuration"), new File(installFolder, "eclipse")); + 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()); + + 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()); } - + + @Test public void testMacRealLocation() throws Exception { File installFolder = Activator.getContext().getDataFile("280007/Eclipse.app/Contents/Eclipse/"); @@ -63,7 +64,8 @@ public class UtilsTest extends AbstractFwkAdminTest { File foo = new File(plugins, "org.foo_1.2.3.abc"); foo.mkdirs(); - Manipulator manipulator = getFrameworkManipulator(new File(installFolder, "configuration"), new File(installFolder, "../MacOS/eclipse")); + Manipulator manipulator = getFrameworkManipulator(new File(installFolder, "configuration"), + new File(installFolder, "../MacOS/eclipse")); manipulator.getLauncherData().setOS(Constants.OS_MACOSX); URI res = FileUtils.getEclipseRealLocation(manipulator, "org.foo"); assertEquals(res, foo.toURI()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java index fb3932973..9e5893905 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java @@ -14,59 +14,45 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests; -import junit.framework.*; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; /** - * This is the master test suite for all automated provisioning tests. It runs every test - * that is suitable for running in an automated fashion as part of a build. Some - * tests may be excluded if they require special setup (such as generating metadata). - * + * This is the master test suite for all automated provisioning tests. It runs + * every test that is suitable for running in an automated fashion as part of a + * build. Some tests may be excluded if they require special setup (such as + * generating metadata). + * * PLEASE ADD SUITES IN THE PACKAGE NAME ORDER. */ -public class AutomatedTests extends TestCase { - public static Test suite() { - TestSuite suite = new TestSuite(AutomatedTests.class.getName()); - suite.addTest(org.eclipse.equinox.p2.tests.publisher.AllTests.suite()); - suite.addTest(org.eclipse.equinox.frameworkadmin.tests.AllTests.suite()); - - suite.addTest(org.eclipse.equinox.p2.tests.ant.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.artifact.processors.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.artifact.repository.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.artifact.repository.processing.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.core.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.director.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.directorywatcher.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.engine.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.extensionlocation.AllTests.suite()); - //org.eclipse.equinox.p2.tests.full - Off sequence - suite.addTest(org.eclipse.equinox.p2.tests.gc.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.generator.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.installer.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.jarprocessor.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.metadata.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.metadata.expression.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.metadata.repository.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.mirror.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.omniVersion.AllTests.suite()); - //org.eclipse.equinox.p2.tests.perf -- Executed as part of the - suite.addTest(org.eclipse.equinox.p2.tests.planner.AllTests.suite()); - //org.eclipse.equinox.p2.tests.publisher.actions -- The tests found in this package are invoked from the publisher package - suite.addTest(org.eclipse.equinox.p2.tests.ql.AllTests.suite()); - //org.eclipse.equinox.p2.tests.reconciler.dropins -- Off sequence - suite.addTest(org.eclipse.equinox.p2.tests.repository.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.sat4j.smoke.AllTests.suite()); - //org.eclipse.equinox.p2.tests.sharedinstall -- Off sequence - suite.addTest(org.eclipse.equinox.p2.tests.simpleconfigurator.SimpleConfiguratorTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.simpleconfigurator.manipulator.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.touchpoint.eclipse.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.touchpoint.natives.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.updatechecker.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.updatesite.AllTests.suite()); - - //Off sequence - suite.addTest(org.eclipse.equinox.p2.tests.reconciler.dropins.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.sharedinstall.AllTests.suite()); - suite.addTest(org.eclipse.equinox.p2.tests.full.AllTests.suite()); - return suite; - } +@RunWith(Suite.class) +@Suite.SuiteClasses({ org.eclipse.equinox.p2.tests.publisher.AllTests.class, + org.eclipse.equinox.frameworkadmin.tests.AllTests.class, + org.eclipse.equinox.p2.tests.ant.AllTests.class, + org.eclipse.equinox.p2.tests.artifact.processors.AllTests.class, + org.eclipse.equinox.p2.tests.artifact.repository.AllTests.class, + org.eclipse.equinox.p2.tests.artifact.repository.processing.AllTests.class, + org.eclipse.equinox.p2.tests.core.AllTests.class, org.eclipse.equinox.p2.tests.director.AllTests.class, + org.eclipse.equinox.p2.tests.directorywatcher.AllTests.class, + org.eclipse.equinox.p2.tests.engine.AllTests.class, + org.eclipse.equinox.p2.tests.extensionlocation.AllTests.class, org.eclipse.equinox.p2.tests.gc.AllTests.class, + org.eclipse.equinox.p2.tests.generator.AllTests.class, org.eclipse.equinox.p2.tests.installer.AllTests.class, + org.eclipse.equinox.p2.tests.jarprocessor.AllTests.class, + org.eclipse.equinox.p2.tests.metadata.AllTests.class, + org.eclipse.equinox.p2.tests.metadata.expression.AllTests.class, + org.eclipse.equinox.p2.tests.metadata.repository.AllTests.class, + org.eclipse.equinox.p2.tests.mirror.AllTests.class, org.eclipse.equinox.p2.tests.omniVersion.AllTests.class, + org.eclipse.equinox.p2.tests.planner.AllTests.class, org.eclipse.equinox.p2.tests.ql.AllTests.class, + org.eclipse.equinox.p2.tests.repository.AllTests.class, + org.eclipse.equinox.p2.tests.sat4j.smoke.AllTests.class, + org.eclipse.equinox.p2.tests.simpleconfigurator.SimpleConfiguratorTests.class, + org.eclipse.equinox.p2.tests.simpleconfigurator.manipulator.AllTests.class, + org.eclipse.equinox.p2.tests.touchpoint.eclipse.AllTests.class, + org.eclipse.equinox.p2.tests.touchpoint.natives.AllTests.class, + org.eclipse.equinox.p2.tests.updatechecker.AllTests.class, + org.eclipse.equinox.p2.tests.updatesite.AllTests.class, + org.eclipse.equinox.p2.tests.reconciler.dropins.AllTests.class, + org.eclipse.equinox.p2.tests.sharedinstall.AllTests.class, org.eclipse.equinox.p2.tests.full.AllTests.class }) +public class AutomatedTests { + // SuiteClasses } |