Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oberlies2012-10-01 12:44:02 +0000
committerTobias Oberlies2012-10-01 12:52:39 +0000
commit5ff2bd944bf00db8f06f8a33ae7cc16eecee930c (patch)
treec7c9bb0c3edeef445dd4bfec776bd2dd75d8693e
parentaa6e786cd25e59f8f36e22099f3239a553b0bc2f (diff)
downloadrt.equinox.p2-5ff2bd944bf00db8f06f8a33ae7cc16eecee930c.tar.gz
rt.equinox.p2-5ff2bd944bf00db8f06f8a33ae7cc16eecee930c.tar.xz
rt.equinox.p2-5ff2bd944bf00db8f06f8a33ae7cc16eecee930c.zip
388566 Fix corner case when publishing a single osgi.ee capability
- Fix case where a profile only specifies a single version for an osgi.ee capability and hence uses the version:Version attribute instead of the more common version:List<Version> attribute. - Also: Fail if both version:Version and version:List<Version> is specified in a single system capability entry. Bug: 388566 JREAction: Publish osgi.ee capabilities in 'a.jre' IUs
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/messages.properties5
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/invalidOsgiEE/ee-capability-syntax-test.profile3
5 files changed, 47 insertions, 13 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Messages.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Messages.java
index 9a938b8cc..0b8f76634 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Messages.java
@@ -43,6 +43,7 @@ public class Messages extends NLS {
public static String message_eeInvalidVersionAttribute;
public static String message_eeMissingNameAttribute;
public static String message_eeMissingVersionAttribute;
+ public static String message_eeDuplicateVersionAttribute;
public static String exception_artifactRepoNoAppendDestroysInput;
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/messages.properties b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/messages.properties
index dd655204b..6d1f30db8 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/messages.properties
@@ -23,10 +23,11 @@ exception_invalidSiteReferenceInFeature=Invalid site reference {0} in feature {1
exception_repoMustBeURL=Repository location ({0}) must be a URL.
exception_sourcePath=Source location ({0}) must be a valid file-system path.
exception_nonExistingJreLocationFile=Provided location to JRE \"{0}\" does not exist on the file system.
+message_eeDuplicateVersionAttribute=Cannot specify both ''version:Version'' and ''version:List<Version>'' in one entry: {0}
message_eeIgnoringNamespace=Ignoring unknown capability namespace ''{0}''
message_eeInvalidVersionAttribute=Syntax error in version ''{0}''
-message_eeMissingNameAttribute=Attribute ''osgi.ee'' is missing for entry {0}
-message_eeMissingVersionAttribute=Attribute ''version:List<Version>'' is missing for execution environment ''{0}''
+message_eeMissingNameAttribute=Attribute ''osgi.ee'' is missing in entry {0}
+message_eeMissingVersionAttribute=Either ''version:Version'' or ''version:List<Version>'' must be specified in entry {0}
message_generatingMetadata = Generating metadata for {0}.
message_generationCompleted = Generation completed with success [{0} seconds].
message_noSimpleconfigurator = Could not find simpleconfigurator bundle.
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
index ae10c179e..9186fb0bc 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
@@ -208,9 +208,9 @@ public class JREAction extends AbstractPublisherAction {
return;
}
- String[] eeVersions = ManifestElement.getArrayFromList(eeCapability.getAttribute("version:List<Version>")); //$NON-NLS-1$
+ String[] eeVersions = parseEECapabilityVersion(eeCapability, parsingStatus);
if (eeVersions == null) {
- parsingStatus.add(newErrorStatus(NLS.bind(Messages.message_eeMissingVersionAttribute, eeName), null));
+ // status was already updated by parse method
return;
}
@@ -228,6 +228,26 @@ public class JREAction extends AbstractPublisherAction {
}
}
+ private static String[] parseEECapabilityVersion(ManifestElement eeCapability, MultiStatus parsingStatus) {
+ String singleVersion = eeCapability.getAttribute("version:Version"); //$NON-NLS-1$
+ String[] multipleVersions = ManifestElement.getArrayFromList(eeCapability.getAttribute("version:List<Version>")); //$NON-NLS-1$
+
+ if (singleVersion == null && multipleVersions == null) {
+ parsingStatus.add(newErrorStatus(NLS.bind(Messages.message_eeMissingVersionAttribute, eeCapability), null));
+ return null;
+
+ } else if (singleVersion == null) {
+ return multipleVersions;
+
+ } else if (multipleVersions == null) {
+ return new String[] {singleVersion};
+
+ } else {
+ parsingStatus.add(newErrorStatus(NLS.bind(Messages.message_eeDuplicateVersionAttribute, eeCapability), null));
+ return null;
+ }
+ }
+
private void generateJREIUData(InstallableUnitDescription iu) {
if (profileProperties == null || profileProperties.size() == 0)
return; //got nothing
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java
index af32ef859..032cce2ef 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java
@@ -130,15 +130,25 @@ public class JREActionTest extends ActionTest {
public void testOsgiEECapabilities() {
// added for bug 388566
- performAction(new JREAction("JavaSE-1.7"));
+ performAction(new JREAction("J2SE-1.5"));
- Collection<IProvidedCapability> capabilities = getPublishedCapabilitiesOf("a.jre.javase");
- assertThat(capabilities, hasItem((IProvidedCapability) new ProvidedCapability("osgi.ee", "JavaSE", Version.parseVersion("1.7"))));
+ Collection<IProvidedCapability> capabilities = getPublishedCapabilitiesOf("a.jre.j2se");
+ assertThat(capabilities, not(hasItem((IProvidedCapability) new ProvidedCapability("osgi.ee", "JavaSE", Version.parseVersion("1.6")))));
assertThat(capabilities, hasItem((IProvidedCapability) new ProvidedCapability("osgi.ee", "JavaSE", Version.parseVersion("1.5"))));
assertThat(capabilities, hasItem((IProvidedCapability) new ProvidedCapability("osgi.ee", "OSGi/Minimum", Version.parseVersion("1.0"))));
+
assertThat(capabilities, not(hasItem((IProvidedCapability) new ProvidedCapability("osgi.ee", "J2SE", Version.parseVersion("1.5")))));
}
+ public void testSingleOsgiEECapability() {
+ // contains a single version:Version attribute instead of the common version:List<Version>
+ performAction(new JREAction("OSGi/Minimum-1.0"));
+
+ Collection<IProvidedCapability> capabilities = getPublishedCapabilitiesOf("a.jre.osgi.minimum");
+ assertThat(capabilities, not(hasItem((IProvidedCapability) new ProvidedCapability("osgi.ee", "JavaSE", Version.parseVersion("1.5")))));
+ assertThat(capabilities, hasItem((IProvidedCapability) new ProvidedCapability("osgi.ee", "OSGi/Minimum", Version.parseVersion("1.0"))));
+ }
+
public void testInvalidOsgiEECapabilitySpec() {
testAction = new JREAction(new File(TestActivator.getTestDataFolder(), "JREActionTest/invalidOsgiEE/ee-capability-syntax-test.profile"));
IStatus status = testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor());
@@ -146,11 +156,12 @@ public class JREActionTest extends ActionTest {
IStatus eeStatus = status.getChildren()[0];
assertThat(eeStatus.getMessage(), containsString("org.osgi.framework.system.capabilities"));
- assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("'osgi.ee' is missing"))));
- assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("'version:List<Version>' is missing"))));
- assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("error in version '1.a.invalidversion'"))));
- assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("unknown capability namespace 'other.namespace'"))));
- assertThat(eeStatus.getChildren().length, is(4));
+ assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("Attribute 'osgi.ee' is missing"))));
+ assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("Either 'version:Version' or 'version:List<Version>' must be specified"))));
+ assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("Syntax error in version '1.a.invalidversion'"))));
+ assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("Ignoring unknown capability namespace 'other.namespace'"))));
+ assertThat(Arrays.asList(eeStatus.getChildren()), hasItem(statusWithMessageWhich(containsString("Cannot specify both 'version:Version' and 'version:List<Version>'"))));
+ assertThat(eeStatus.getChildren().length, is(5));
}
private void performAction(JREAction jreAction) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/invalidOsgiEE/ee-capability-syntax-test.profile b/bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/invalidOsgiEE/ee-capability-syntax-test.profile
index 9662e3a65..4998bd8a3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/invalidOsgiEE/ee-capability-syntax-test.profile
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/invalidOsgiEE/ee-capability-syntax-test.profile
@@ -14,5 +14,6 @@ org.osgi.framework.system.capabilities = \
osgi.ee; other.namespace; version:List<Version>="1.0"; osgi.ee="JavaSE",\
osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.a.invalidversion",\
osgi.ee; osgi.ee="OSGi/Minimum",\
- osgi.ee; version:List<Version>="2.0,2.1"
+ osgi.ee; version:List<Version>="2.0,2.1",\
+ osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.0, 1.1"; version:Version="1.1"
osgi.java.profile.name = EECapabilitySyntaxTest

Back to the top