diff options
author | Krzysztof Daniel | 2013-12-13 15:35:29 +0000 |
---|---|---|
committer | Krzysztof Daniel | 2013-12-17 12:03:36 +0000 |
commit | 39da65192fec835fafe75c0f863a63757b59f2dd (patch) | |
tree | de0b0b83fc920afcd0e77f1e0b6dcd8113ae6c29 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java | |
parent | efa5443d0d66120dfb2f8f80db365c02b6dbd6d8 (diff) | |
download | rt.equinox.p2-39da65192fec835fafe75c0f863a63757b59f2dd.tar.gz rt.equinox.p2-39da65192fec835fafe75c0f863a63757b59f2dd.tar.xz rt.equinox.p2-39da65192fec835fafe75c0f863a63757b59f2dd.zip |
bug 421935: Extend simpleconfigurator to read .info files from many
locations.
Locations should be passed to the simpleconfigurator via the
p2.fragments java property and separated using ",".
Each location may contain multiple fragments. A fragment consist of a
directory shaped as:
+ extension-parent-dir
+ extension.info
+ artifacts.xml
+ content.xml
+ plugins/*
+ features/*
Or a link file (f.e. extension.link) which contains a single java
property ("link") pointing to another location in the system.
The *.info file may contain relative or absolute paths to plugins.
Relative paths will be resolved against the extension root.
The simpleconfigurator, if configured with extensions, will attempt to
load them all at startup, duplicates will be removed.
It is the responsibility of the fragment provider to ensure that all
fragments will lead to a valid Eclipse installation, AS NO VALIDATION OR
INTEGRITY CHECK IS PERFORMED.
Bundles that can't be loaded due to unsatisfied constraints will result
in errors handled by OSGi (written to the .log in the configuration
area).
Change-Id: Ib2689c072f3149b29ed77797d7df7b209d9abde7
Signed-off-by: Krzysztof Daniel <kdaniel@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java new file mode 100644 index 000000000..5de86bea9 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2012,2013 Red Hat, Inc. and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + * Ericsson AB - ongoing development + ******************************************************************************/ +package org.eclipse.equinox.p2.tests.simpleconfigurator; + +import java.io.*; +import java.net.URISyntaxException; +import java.util.ArrayList; +import org.eclipse.equinox.internal.simpleconfigurator.Activator; +import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils; + +public class SimpleConfiguratorTestExtendedConfigured extends SimpleConfiguratorTestExtended { + + private File parentFolder; + private File ext1Info; + private File ext1Parent; + private File ext3Info; + private File ext3Parent; + + @Override + public void setUp() throws Exception { + super.setUp(); + parentFolder = new File(getTempFolder(), "extension"); + ext1Parent = new File(parentFolder, "ext1"); + ext1Parent.mkdirs(); + ext1Info = new File(ext1Parent, "ext1.info"); + ext1Info.createNewFile(); + ext3Parent = new File(parentFolder, "ext3"); + ext3Parent.mkdirs(); + ext3Info = new File(ext3Parent, "ext3.info"); + ext3Info.createNewFile(); + ext1Info.setLastModified(System.currentTimeMillis() + 1000); + ext1Parent.setWritable(false); + ext3Info.setLastModified(System.currentTimeMillis() + 1000); + } + + @Override + protected void tearDown() throws Exception { + Activator.EXTENSIONS = null; + ext1Parent.setWritable(true); + super.tearDown(); + } + + public void testWriteableExtension() throws FileNotFoundException, IOException, URISyntaxException { + Activator.EXTENSIONS = parentFolder.toString(); + ArrayList<File> infoFiles = SimpleConfiguratorUtils.getInfoFiles(); + assertEquals("only read-only info file should be considered", 1, infoFiles.size()); + // ext1 is expected because ext3 is writeable + assertEquals(ext1Info.getName(), infoFiles.get(0).getName()); + } + + public void testExtensionAdded() throws IOException { + + storeTimestamp(new File(masterConfguration, relativeURL.getFile()).lastModified()); + assertEquals(sharedConfiguration[0], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration)); + assertIsPropertySet(false); + + Activator.EXTENSIONS = parentFolder.toString(); + + assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration)); + assertIsPropertySet(true); + } + + public void testExtensionRemoved() throws IOException { + + Activator.EXTENSIONS = parentFolder.toString(); + storeTimestamp(ext1Info.lastModified()); + //on adding extension master must be selected in order to create new profile with extensions! + assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration)); + assertIsPropertySet(true); + + //disable extension + Activator.EXTENSIONS = null; + + assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration)); + assertIsPropertySet(true); + } + + public void testExtensionModified() throws IOException { + + Activator.EXTENSIONS = parentFolder.toString(); + storeTimestamp(ext1Info.lastModified()); + //on adding extension master must be selected in order to create new profile with extensions! + assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration)); + assertIsPropertySet(true); + + //add new extension + File ext2Dir = new File(parentFolder, "ext2"); + ext2Dir.mkdirs(); + File file = new File(ext2Dir, "ext2.info"); + file.createNewFile(); + file.setLastModified(parentFolder.lastModified() + 3000); + + assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration)); + assertIsPropertySet(true); + } +} |