diff options
author | Tobias Oberlies | 2012-09-28 16:29:50 +0000 |
---|---|---|
committer | Tobias Oberlies | 2012-09-28 16:37:00 +0000 |
commit | d3f8376c143849bf553164fe053febd5cd602fbf (patch) | |
tree | f9639af2730e378963ff29cd08b83a4cf082f4e7 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions | |
parent | 7cd8464a2a1bec3a24092d8274109f461ad19181 (diff) | |
download | rt.equinox.p2-d3f8376c143849bf553164fe053febd5cd602fbf.tar.gz rt.equinox.p2-d3f8376c143849bf553164fe053febd5cd602fbf.tar.xz rt.equinox.p2-d3f8376c143849bf553164fe053febd5cd602fbf.zip |
390361 Test that ProductAction fails if the result may be brokenv20120928-163700
- Added test for fail fast behaviour of ProductAction in case of unknown
inclusion filters.
- Also: For callers that don't check the returned status, the behavior
remains as before -> the missing filter issue may then be detected
later when the product is installed.
- Also: Improved messages.
Bug: 390361 Published products are broken if included fragments are not in context
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java index 49eb38bc6..55fec1996 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java @@ -12,8 +12,7 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.createNiceMock; -import static org.eclipse.equinox.p2.tests.publisher.actions.StatusMatchers.okStatus; -import static org.eclipse.equinox.p2.tests.publisher.actions.StatusMatchers.statusWithMessageWhich; +import static org.eclipse.equinox.p2.tests.publisher.actions.StatusMatchers.*; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertThat; @@ -313,10 +312,29 @@ public class ProductActionTest extends ActionTest { assertFalse("2.6", update.isUpdateOf(createIU("com.other", Version.createOSGi(4, 1, 0)))); } + public void testFiltersOfInclusions() throws Exception { + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "productIncludingFragments.product").toString()); + addContextIU("generalbundle", "1.0.1"); + addContextIU("fragment.win", "1.0.2", WIN_FILTER); + // no fragment.linux in the context + + IStatus status = performProductActionAndReturnStatus(productFile); + + IInstallableUnit productIU = getUniquePublishedIU("productIncludingFragments.uid"); + assertThat(productIU.getRequirements(), hasItem(createIURequirement("generalbundle", createStrictVersionRange("1.0.1")))); + assertThat(productIU.getRequirements(), hasItem(createIURequirement("fragment.win", createStrictVersionRange("1.0.2"), WIN_FILTER))); + + // this is bug 390361: the Linux fragment is required without filter, so the product cannot be installed for Windows ... + assertThat(productIU.getRequirements(), hasItem(createIURequirement("fragment.linux", ANY_VERSION))); + + // ... therefore the action shall report an error + assertThat(status, is(errorStatus())); + assertThat(Arrays.asList(status.getChildren()), hasItem(statusWithMessageWhich(containsString("Included element fragment.linux 0.0.0 is missing")))); + } + public void testMessageForProductWithIgnoredContent() throws Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "mixedContentIgnored.product").toString()); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - IStatus status = testAction.perform(publisherInfo, publisherResult, null); + IStatus status = performProductActionAndReturnStatus(productFile); // expect a warning about redundant, ignored content in product file -> requested in bug 325611 assertThat(Arrays.asList(status.getChildren()), hasItem(statusWithMessageWhich(containsString("are ignored")))); @@ -324,11 +342,15 @@ public class ProductActionTest extends ActionTest { } private void performProductAction(ProductFile productFile) { - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - IStatus status = testAction.perform(publisherInfo, publisherResult, null); + IStatus status = performProductActionAndReturnStatus(productFile); assertThat(status, is(okStatus())); } + private IStatus performProductActionAndReturnStatus(ProductFile productFile) { + testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); + return testAction.perform(publisherInfo, publisherResult, null); + } + private void setConfiguration(String configSpec) { ((PublisherInfo) publisherInfo).setConfigurations(new String[] {configSpec}); } |