Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-01-20 17:15:52 +0000
committerPascal Rapicault2009-01-20 17:15:52 +0000
commit22852606526eef91db1a78cd867b825ab37a9cc7 (patch)
treefd8187518ecd1c75400472a9574a31655d5063e1 /bundles/org.eclipse.equinox.p2.tests.ui
parenta433d49c8635490ea790c46166734069d14c0836 (diff)
downloadrt.equinox.p2-22852606526eef91db1a78cd867b825ab37a9cc7.tar.gz
rt.equinox.p2-22852606526eef91db1a78cd867b825ab37a9cc7.tar.xz
rt.equinox.p2-22852606526eef91db1a78cd867b825ab37a9cc7.zip
Bug 261278 - IUPropertyUtils should not short circuit the collector
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java
index 47041b4bf..144083476 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/IUPropertyUtilsTest.java
@@ -7,14 +7,25 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * EclipseSource - bug fixing
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
import java.io.File;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Locale;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.engine.Profile;
+import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
+import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
@@ -54,6 +65,72 @@ public class IUPropertyUtilsTest extends AbstractQueryTest {
assertEquals("1.6", "Test Provider Name", provider);
}
+ public void testLocalizedLicense() throws URISyntaxException {
+ SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(ProvUIActivator.getContext(), IProfileRegistry.class.getName());
+ Profile profile = (Profile) profileRegistry.getProfile(IProfileRegistry.SELF);
+ profileRegistry.lockProfile(profile);
+ String germanLicense = "German License";
+ String canadianFRLicense = "Canadian French License";
+
+ // Create a IU that has a license, but the license body is simply %license. This will be filled in by
+ // a fragment
+ InstallableUnitDescription iuDescription = new InstallableUnitDescription();
+ iuDescription.setId("some IU");
+ iuDescription.setVersion(new Version(1, 0, 0));
+ iuDescription.setLicense(new License(new URI("http://example.com"), "%license"));
+ IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription);
+
+ // Create a bunch of fragments which spec our IU as their host
+ // These fragments don't contribute language information
+ for (int i = 0; i < 10; i++) {
+ InstallableUnitFragmentDescription installableUnitFragmentDescription = new InstallableUnitFragmentDescription();
+ installableUnitFragmentDescription.setId("fragment number: " + i);
+ installableUnitFragmentDescription.setVersion(new Version(1, 0, 0));
+ installableUnitFragmentDescription.setHost(new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "some IU", ANY_VERSION, null, false, false)});
+ installableUnitFragmentDescription.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, "true");
+ IInstallableUnitFragment iuFragment = MetadataFactory.createInstallableUnitFragment(installableUnitFragmentDescription);
+ profile.addInstallableUnit(iuFragment);
+ }
+
+ // Create fragment with a German license
+ InstallableUnitFragmentDescription installableUnitFragmentDescription = new InstallableUnitFragmentDescription();
+ IProvidedCapability providedCapability = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.localization", "de", new Version(1, 0, 0));
+ ArrayList list = new ArrayList();
+ list.add(providedCapability);
+ installableUnitFragmentDescription.addProvidedCapabilities(list);
+ installableUnitFragmentDescription.setId("german fragment");
+ installableUnitFragmentDescription.setVersion(new Version(1, 0, 0));
+ installableUnitFragmentDescription.setHost(new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "some IU", ANY_VERSION, null, false, false)});
+ installableUnitFragmentDescription.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, "true");
+ installableUnitFragmentDescription.setProperty("de.license", germanLicense);
+ IInstallableUnitFragment iuFragment = MetadataFactory.createInstallableUnitFragment(installableUnitFragmentDescription);
+ profile.addInstallableUnit(iuFragment);
+
+ // Create a French fragment with an fr_CA license
+ installableUnitFragmentDescription = new InstallableUnitFragmentDescription();
+ providedCapability = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.localization", "fr", new Version(1, 0, 0));
+ list = new ArrayList();
+ list.add(providedCapability);
+ installableUnitFragmentDescription.addProvidedCapabilities(list);
+ installableUnitFragmentDescription.setId("cnd french fragment");
+ installableUnitFragmentDescription.setVersion(new Version(1, 0, 0));
+ installableUnitFragmentDescription.setHost(new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "some IU", ANY_VERSION, null, false, false)});
+ installableUnitFragmentDescription.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, "true");
+ installableUnitFragmentDescription.setProperty("fr_CA.license", canadianFRLicense);
+ iuFragment = MetadataFactory.createInstallableUnitFragment(installableUnitFragmentDescription);
+
+ profile.addInstallableUnit(iuFragment);
+ profile.addInstallableUnit(iu);
+
+ profileRegistry.updateProfile(profile);
+ profileRegistry.unlockProfile(profile);
+
+ ILicense license = IUPropertyUtils.getLicense(iu, Locale.GERMAN);
+ assertEquals("1.0", germanLicense, license.getBody());
+ license = IUPropertyUtils.getLicense(iu, Locale.CANADA_FRENCH);
+ assertEquals("1.1", canadianFRLicense, license.getBody());
+ }
+
public void testBasicIU() {
IInstallableUnit unit = createIU("f1");

Back to the top