diff options
author | Tobias Oberlies | 2012-09-26 16:31:14 +0000 |
---|---|---|
committer | Tobias Oberlies | 2012-09-27 17:29:18 +0000 |
commit | ccc748ef552feebefc485081c30b400e280e762a (patch) | |
tree | 9997d9c8fc5b10a914ee2ae08b3d5a0d980a8acd | |
parent | 4dac510d291ca8d261367da3febf043d97ca2d1f (diff) | |
download | rt.equinox.p2-ccc748ef552feebefc485081c30b400e280e762a.tar.gz rt.equinox.p2-ccc748ef552feebefc485081c30b400e280e762a.tar.xz rt.equinox.p2-ccc748ef552feebefc485081c30b400e280e762a.zip |
390361 Refactor ProductAction related tests
- Check status of execution of ProductAction.
- Removed included content from products where there inclusions were
not relevant for the test.
- Simplified ProductActionTest by providing more defaults. Tests
which really required the capturing mocks were moved to
ProductActionCapturingTest.
Bug: 390361 Published products are broken if included fragments are not in context
15 files changed, 307 insertions, 264 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java index d18c92780..bc0aa7129 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java @@ -35,6 +35,7 @@ public class AllTests extends TestCase { suite.addTestSuite(LocalUpdateSiteActionTest.class); suite.addTestSuite(MD5GenerationTest.class); suite.addTestSuite(ProductActionTest.class); + suite.addTestSuite(ProductActionCapturingTest.class); suite.addTestSuite(ProductActionTestMac.class); suite.addTestSuite(ProductActionWithAdviceFileTest.class); suite.addTestSuite(ProductActionWithJRELocationTest.class); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java index 50aae31b9..716a4290f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2012 Code 9 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 @@ -194,4 +194,12 @@ public abstract class ActionTest extends AbstractProvisioningTest { if (DEBUG) debug(message); } + + protected final void addContextUnit(String unitId, String unitVersion) { + publisherResult.addIU(createIU(unitId, Version.create(unitVersion)), IPublisherResult.NON_ROOT); + } + + protected final void addContextUnit(String unitId, String unitVersion, String filter) { + publisherResult.addIU(createIU(unitId, Version.create(unitVersion), filter, NO_PROVIDES), IPublisherResult.NON_ROOT); + } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionCapturingTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionCapturingTest.java new file mode 100644 index 000000000..0a6add989 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionCapturingTest.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2008, 2012 Code 9 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: + * Code 9 - initial API and implementation + * IBM - ongoing development + * SAP AG - ongoing development + ******************************************************************************/ +package org.eclipse.equinox.p2.tests.publisher.actions; + +import static org.easymock.EasyMock.*; +import static org.eclipse.equinox.p2.tests.publisher.actions.StatusMatchers.okStatus; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.io.File; +import java.util.Collections; +import org.easymock.Capture; +import org.easymock.EasyMock; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.frameworkadmin.BundleInfo; +import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.publisher.IPublisherInfo; +import org.eclipse.equinox.p2.publisher.actions.RootIUAdvice; +import org.eclipse.equinox.p2.publisher.eclipse.*; +import org.eclipse.equinox.p2.tests.TestData; +import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; + +@SuppressWarnings({"unchecked"}) +public class ProductActionCapturingTest extends ActionTest { + + File executablesFeatureLocation = null; + String source = ""; + + private Capture<RootIUAdvice> rootIUAdviceCapture; + private Capture<ProductFileAdvice> productFileAdviceCapture; + protected TestArtifactRepository artifactRepository = new TestArtifactRepository(getAgent()); + + @Override + protected IPublisherInfo createPublisherInfoMock() { + //override to create a nice mock, because we don't care about other method calls. + return createNiceMock(IPublisherInfo.class); + } + + protected void insertPublisherInfoBehavior() { + // capture these calls for assertions + publisherInfo.addAdvice(EasyMock.and(EasyMock.isA(RootIUAdvice.class), EasyMock.capture(rootIUAdviceCapture))); + publisherInfo.addAdvice(EasyMock.and(EasyMock.isA(ProductFileAdvice.class), EasyMock.capture(productFileAdviceCapture))); + + expect(publisherInfo.getArtifactRepository()).andReturn(artifactRepository).anyTimes(); + expect(publisherInfo.getArtifactOptions()).andReturn(IPublisherInfo.A_PUBLISH).anyTimes(); + //Return an empty list every time getAdvice is called + expect(publisherInfo.getAdvice((String) anyObject(), anyBoolean(), (String) anyObject(), (Version) anyObject(), (Class) anyObject())).andReturn(Collections.emptyList()); + expectLastCall().anyTimes(); + } + + public void setUp() throws Exception { + rootIUAdviceCapture = new Capture<RootIUAdvice>(); + productFileAdviceCapture = new Capture<ProductFileAdvice>(); + setupPublisherInfo(); + setupPublisherResult(); + } + + /** + * Tests that a product file containing bundle configuration data produces appropriate + * IConfigAdvice (start levels, auto-start). + */ + public void testSetBundleConfigData() throws Exception { + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "startLevel.product").toString()); + testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); + + IStatus status = testAction.perform(publisherInfo, publisherResult, null); + assertThat(status, is(okStatus())); + + IConfigAdvice configAdvice = productFileAdviceCapture.getValue(); + BundleInfo[] bundles = configAdvice.getBundles(); + assertEquals("1.0", 2, bundles.length); + assertEquals("1.1", "org.eclipse.equinox.common", bundles[0].getSymbolicName()); + assertEquals("1.2", "1.0.0", bundles[0].getVersion()); + assertEquals("1.3", 13, bundles[0].getStartLevel()); + assertEquals("1.4", false, bundles[0].isMarkedAsStarted()); + + assertEquals("2.1", "org.eclipse.core.runtime", bundles[1].getSymbolicName()); + assertEquals("2.2", "2.0.0", bundles[1].getVersion()); + assertEquals("2.3", 6, bundles[1].getStartLevel()); + assertEquals("2.4", true, bundles[1].isMarkedAsStarted()); + } + + /** + * Tests that correct advice is created for the org.eclipse.platform product. + */ + public void testPlatformProduct() throws Exception { + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "platform.product").toString()); + + testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); + IStatus status = testAction.perform(publisherInfo, publisherResult, null); + assertThat(status, is(okStatus())); + + IExecutableAdvice launchAdvice = productFileAdviceCapture.getValue(); + assertEquals("1.0", "eclipse", launchAdvice.getExecutableName()); + + String[] programArgs = launchAdvice.getProgramArguments(); + assertEquals("2.0", 0, programArgs.length); + + String[] vmArgs = launchAdvice.getVMArguments(); + assertEquals("3.0", 0, vmArgs.length); + + } + +} 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 ebfde784e..7c02ee8d7 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Code 9 and others. All rights reserved. This + * Copyright (c) 2008, 2012 Code 9 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 @@ -11,23 +11,26 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import static org.easymock.EasyMock.*; +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.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.matchers.JUnitMatchers.containsString; +import static org.junit.matchers.JUnitMatchers.hasItem; import java.io.File; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; -import java.util.Collections; -import org.easymock.Capture; -import org.easymock.EasyMock; -import org.eclipse.core.runtime.*; -import org.eclipse.equinox.frameworkadmin.BundleInfo; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.metadata.RequiredCapability; import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; import org.eclipse.equinox.p2.metadata.*; -import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.p2.publisher.*; -import org.eclipse.equinox.p2.publisher.actions.RootIUAdvice; -import org.eclipse.equinox.p2.publisher.eclipse.*; +import org.eclipse.equinox.p2.publisher.eclipse.IConfigAdvice; +import org.eclipse.equinox.p2.publisher.eclipse.ProductAction; import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.equinox.p2.tests.TestData; @@ -36,13 +39,14 @@ import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; @SuppressWarnings({"unchecked"}) public class ProductActionTest extends ActionTest { - private String winFitler = "(& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))"; - private String linuxFilter = "(& (osgi.ws=gtk)(osgi.os=linux)(osgi.arch=x86))"; + private static final String WIN_FILTER = "(& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))"; + private static final String LINUX_FILTER = "(& (osgi.ws=gtk)(osgi.os=linux)(osgi.arch=x86))"; + + private static final String WIN_CONFIG_SPEC = AbstractPublisherAction.createConfigSpec("win32", "win32", "x86"); + private static final String LINUX_CONFIG_SPEC = AbstractPublisherAction.createConfigSpec("gtk", "linux", "x86"); File executablesFeatureLocation = null; String productLocation = ""; - private Capture<RootIUAdvice> rootIUAdviceCapture; - private Capture<ProductFileAdvice> productFileAdviceCapture; String source = ""; protected TestArtifactRepository artifactRepository = new TestArtifactRepository(getAgent()); @@ -52,31 +56,28 @@ public class ProductActionTest extends ActionTest { return createNiceMock(IPublisherInfo.class); } - protected void insertPublisherInfoBehavior() { - publisherInfo.addAdvice(EasyMock.and(EasyMock.isA(RootIUAdvice.class), EasyMock.capture(rootIUAdviceCapture))); - publisherInfo.addAdvice(EasyMock.and(EasyMock.isA(ProductFileAdvice.class), EasyMock.capture(productFileAdviceCapture))); - expect(publisherInfo.getArtifactRepository()).andReturn(artifactRepository).anyTimes(); - expect(publisherInfo.getArtifactOptions()).andReturn(IPublisherInfo.A_PUBLISH).anyTimes(); - //Return an empty list every time getAdvice is called - expect(publisherInfo.getAdvice((String) anyObject(), anyBoolean(), (String) anyObject(), (Version) anyObject(), (Class) anyObject())).andReturn(Collections.emptyList()); - expectLastCall().anyTimes(); - } - public void setUp() throws Exception { - rootIUAdviceCapture = new Capture<RootIUAdvice>(); - productFileAdviceCapture = new Capture<ProductFileAdvice>(); setupPublisherInfo(); setupPublisherResult(); } + public void setupPublisherInfo() { + PublisherInfo publisherInfoImpl = new PublisherInfo(); + publisherInfoImpl.setArtifactRepository(artifactRepository); + publisherInfoImpl.setArtifactOptions(IPublisherInfo.A_PUBLISH); + publisherInfoImpl.setConfigurations(new String[] {configSpec}); + + publisherInfo = publisherInfoImpl; + } + /** * Tests publishing a product containing a branded application with a custom * splash screen, icon, etc. */ public void testBrandedApplication() throws Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "brandedProduct/branded.product").toString()); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(publisherInfo, publisherResult, null); + + performProductAction(productFile); Collection ius = publisherResult.getIUs("branded.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); @@ -85,10 +86,7 @@ public class ProductActionTest extends ActionTest { public void testLicense() throws Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "productWithLicense.product").toString()); - PublisherInfo info = new PublisherInfo(); - info.setConfigurations(new String[] {"win32.win32.x86"}); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(info, publisherResult, null); + performProductAction(productFile); Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); @@ -98,10 +96,7 @@ public class ProductActionTest extends ActionTest { public void testLicenseNoURL() throws Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "licenseNoURL.product").toString()); - PublisherInfo info = new PublisherInfo(); - info.setConfigurations(new String[] {"win32.win32.x86"}); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(info, publisherResult, null); + performProductAction(productFile); Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); @@ -111,10 +106,7 @@ public class ProductActionTest extends ActionTest { public void testLicenseNoText() throws Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "licenseNoText.product").toString()); - PublisherInfo info = new PublisherInfo(); - info.setConfigurations(new String[] {"win32.win32.x86"}); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(info, publisherResult, null); + performProductAction(productFile); Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); @@ -124,186 +116,100 @@ public class ProductActionTest extends ActionTest { public void testMissingLicense() throws Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "productWithNoLicense.product").toString()); - PublisherInfo info = new PublisherInfo(); - info.setConfigurations(new String[] {"win32.win32.x86"}); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(info, publisherResult, null); + performProductAction(productFile); Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); assertEquals(0, iu.getLicenses().size()); } - /** - * Tests that a product file containing bundle configuration data produces appropriate - * IConfigAdvice (start levels, auto-start). - */ - public void testSetBundleConfigData() throws Exception { - ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "startLevel.product").toString()); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - - testAction.perform(publisherInfo, publisherResult, null); - IConfigAdvice configAdvice = productFileAdviceCapture.getValue(); - BundleInfo[] bundles = configAdvice.getBundles(); - assertEquals("1.0", 2, bundles.length); - assertEquals("1.1", "org.eclipse.equinox.common", bundles[0].getSymbolicName()); - assertEquals("1.2", "1.0.0", bundles[0].getVersion()); - assertEquals("1.3", 13, bundles[0].getStartLevel()); - assertEquals("1.4", false, bundles[0].isMarkedAsStarted()); - - assertEquals("2.1", "org.eclipse.core.runtime", bundles[1].getSymbolicName()); - assertEquals("2.2", "2.0.0", bundles[1].getVersion()); - assertEquals("2.3", 6, bundles[1].getStartLevel()); - assertEquals("2.4", true, bundles[1].isMarkedAsStarted()); - } - public void testMultiProductPublishing() throws Exception { ProductFile productFile1 = new ProductFile(TestData.getFile("ProductActionTest", "boundedVersionConfigurations.product").toString()); ProductFile productFile2 = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); - PublisherInfo info = new PublisherInfo(); - info.setConfigurations(getArrayFromString(configSpec, COMMA_SEPARATOR)); - PublisherResult results = new PublisherResult(); - - InstallableUnitDescription iuDescription = new InstallableUnitDescription(); - iuDescription.setId("org.eclipse.core.runtime"); - iuDescription.setVersion(Version.create("4.0.0")); - IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription); - results.addIU(iu, IPublisherResult.NON_ROOT); - ProductAction action1 = new ProductAction(null, productFile1, flavorArg, executablesFeatureLocation); - ProductAction action2 = new ProductAction(null, productFile2, flavorArg, executablesFeatureLocation); - action1.perform(info, results, new NullProgressMonitor()); - results = new PublisherResult(); + addContextUnit("org.eclipse.core.runtime", "4.0.0"); + performProductAction(productFile1); - results.addIU(iu, IPublisherResult.NON_ROOT); - - action2.perform(info, results, new NullProgressMonitor()); - IQueryResult queryResult = results.query(QueryUtil.createIUQuery(flavorArg + configSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + publisherResult = new PublisherResult(); + addContextUnit("org.eclipse.core.runtime", "4.0.0"); + performProductAction(productFile2); + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + configSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("1.0", 1, queryResultSize(queryResult)); } public void testMultiPlatformCUs_DifferentPlatforms() throws Exception { - ProductFile productFile2 = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); - PublisherInfo info = new PublisherInfo(); - String windowsConfigSpec = AbstractPublisherAction.createConfigSpec("win32", "win32", "x86"); - String linuxConfigSpec = AbstractPublisherAction.createConfigSpec("gtk", "linux", "x86"); - info.setConfigurations(getArrayFromString(linuxConfigSpec, COMMA_SEPARATOR)); - PublisherResult results = new PublisherResult(); + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); + setConfiguration(LINUX_CONFIG_SPEC); - InstallableUnitDescription iuDescription = new InstallableUnitDescription(); - iuDescription.setId("org.eclipse.core.runtime"); - iuDescription.setVersion(Version.create("0.0.0")); - iuDescription.setFilter(winFitler); - IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription); + addContextUnit("org.eclipse.core.runtime", "0.0.0", WIN_FILTER); - results.addIU(iu, IPublisherResult.NON_ROOT); - ProductAction action = new ProductAction(null, productFile2, flavorArg, executablesFeatureLocation); + performProductAction(productFile); - action.perform(info, results, new NullProgressMonitor()); - - IQueryResult queryResult = results.query(QueryUtil.createIUQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + LINUX_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("1.0", 0, queryResultSize(queryResult)); - queryResult = results.query(QueryUtil.createIUQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + WIN_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testMultiPlatformCUs_SamePlatforms() throws Exception { - ProductFile productFile2 = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); - PublisherInfo info = new PublisherInfo(); - String windowsConfigSpec = AbstractPublisherAction.createConfigSpec("win32", "win32", "x86"); - String linuxConfigSpec = AbstractPublisherAction.createConfigSpec("gtk", "linux", "x86"); - info.setConfigurations(getArrayFromString(linuxConfigSpec, COMMA_SEPARATOR)); - PublisherResult results = new PublisherResult(); + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); + setConfiguration(LINUX_CONFIG_SPEC); - InstallableUnitDescription iuDescription = new InstallableUnitDescription(); - iuDescription.setId("org.eclipse.core.runtime"); - iuDescription.setVersion(Version.create("0.0.0")); - iuDescription.setFilter(linuxFilter); - IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription); + addContextUnit("org.eclipse.core.runtime", "0.0.0", LINUX_FILTER); - results.addIU(iu, IPublisherResult.NON_ROOT); - ProductAction action = new ProductAction(null, productFile2, flavorArg, executablesFeatureLocation); + performProductAction(productFile); - action.perform(info, results, new NullProgressMonitor()); - - IQueryResult queryResult = results.query(QueryUtil.createIUQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + LINUX_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("1.0", 1, queryResultSize(queryResult)); - queryResult = results.query(QueryUtil.createIUQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + WIN_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testMultiPlatformCUs_SamePlatforms_NoVersion() throws Exception { - ProductFile productFile2 = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); - PublisherInfo info = new PublisherInfo(); - String windowsConfigSpec = AbstractPublisherAction.createConfigSpec("win32", "win32", "x86"); - String linuxConfigSpec = AbstractPublisherAction.createConfigSpec("gtk", "linux", "x86"); - info.setConfigurations(getArrayFromString(linuxConfigSpec, COMMA_SEPARATOR)); - PublisherResult results = new PublisherResult(); + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); + setConfiguration(LINUX_CONFIG_SPEC); - InstallableUnitDescription iuDescription = new InstallableUnitDescription(); - iuDescription.setId("org.eclipse.core.runtime"); - iuDescription.setFilter(linuxFilter); - IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription); + addContextUnit("org.eclipse.core.runtime", null, LINUX_FILTER); - results.addIU(iu, IPublisherResult.NON_ROOT); - ProductAction action = new ProductAction(null, productFile2, flavorArg, executablesFeatureLocation); + performProductAction(productFile); - action.perform(info, results, new NullProgressMonitor()); - - IQueryResult queryResult = results.query(QueryUtil.createIUQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + LINUX_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("1.0", 1, queryResultSize(queryResult)); - queryResult = results.query(QueryUtil.createIUQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + WIN_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testMultiPlatformCUs_SamePlatforms_BoundedVersions() throws Exception { - ProductFile productFile2 = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); - PublisherInfo info = new PublisherInfo(); - String windowsConfigSpec = AbstractPublisherAction.createConfigSpec("win32", "win32", "x86"); - String linuxConfigSpec = AbstractPublisherAction.createConfigSpec("gtk", "linux", "x86"); - info.setConfigurations(getArrayFromString(linuxConfigSpec, COMMA_SEPARATOR)); - PublisherResult results = new PublisherResult(); + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); + setConfiguration(LINUX_CONFIG_SPEC); - InstallableUnitDescription iuDescription = new InstallableUnitDescription(); - iuDescription.setId("org.eclipse.core.runtime"); - iuDescription.setVersion(Version.create("4.0.0")); // Set a specific version number, the one in the .product file uses 0.0.0. Let's see if it binds properly - iuDescription.setFilter("(osgi.os=linux)"); //filter is different from linuxConfigSpec, but will still match - IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription); + // Set a specific version number, the one in the .product file uses 0.0.0. Let's see if it binds properly + //filter is different from linuxConfigSpec, but will still match + addContextUnit("org.eclipse.core.runtime", "4.0.0", "(osgi.os=linux)"); - results.addIU(iu, IPublisherResult.NON_ROOT); - ProductAction action = new ProductAction(null, productFile2, flavorArg, executablesFeatureLocation); + performProductAction(productFile); - action.perform(info, results, new NullProgressMonitor()); - - IQueryResult queryResult = results.query(QueryUtil.createIUQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + LINUX_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("1.0", 1, queryResultSize(queryResult)); - queryResult = results.query(QueryUtil.createIUQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + WIN_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testCUsHost() throws Exception { - ProductFile productFile2 = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); - PublisherInfo info = new PublisherInfo(); - String linuxConfigSpec = AbstractPublisherAction.createConfigSpec("gtk", "linux", "x86"); - info.setConfigurations(getArrayFromString(linuxConfigSpec, COMMA_SEPARATOR)); - PublisherResult results = new PublisherResult(); - - InstallableUnitDescription iuDescription = new InstallableUnitDescription(); - iuDescription.setId("org.eclipse.core.runtime"); - iuDescription.setVersion(Version.create("4.0.0")); // Set a specific version number, the one in the .product file uses 0.0.0. Let's see if it binds properly - iuDescription.setFilter("(osgi.os=linux)"); //filter is different from linuxConfigSpec, but will still match - IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription); + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); + setConfiguration(LINUX_CONFIG_SPEC); - results.addIU(iu, IPublisherResult.NON_ROOT); - ProductAction action = new ProductAction(null, productFile2, flavorArg, executablesFeatureLocation); + // Set a specific version number, the one in the .product file uses 0.0.0. Let's see if it binds properly + //filter is different from linuxConfigSpec, but will still match + addContextUnit("org.eclipse.core.runtime", "4.0.0", "(osgi.os=linux)"); - action.perform(info, results, new NullProgressMonitor()); + performProductAction(productFile); - IQueryResult queryResult = results.query(QueryUtil.createIUQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + LINUX_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("1.0", 1, queryResultSize(queryResult)); IInstallableUnitFragment fragment = (IInstallableUnitFragment) queryResult.iterator().next(); assertEquals("1.1", "org.eclipse.core.runtime", RequiredCapability.extractName(fragment.getHost().iterator().next().getMatches())); @@ -313,89 +219,58 @@ public class ProductActionTest extends ActionTest { } public void testCUNoHost() throws Exception { - ProductFile productFile2 = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); - PublisherInfo info = new PublisherInfo(); - String windowsConfigSpec = AbstractPublisherAction.createConfigSpec("win32", "win32", "x86"); - String linuxConfigSpec = AbstractPublisherAction.createConfigSpec("gtk", "linux", "x86"); - info.setConfigurations(getArrayFromString(linuxConfigSpec, COMMA_SEPARATOR)); - PublisherResult results = new PublisherResult(); - - ProductAction action = new ProductAction(null, productFile2, flavorArg, executablesFeatureLocation); + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); + setConfiguration(LINUX_CONFIG_SPEC); - action.perform(info, results, new NullProgressMonitor()); + performProductAction(productFile); - IQueryResult queryResult = results.query(QueryUtil.createIUQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + LINUX_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("1.0", 0, queryResultSize(queryResult)); - queryResult = results.query(QueryUtil.createIUQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + WIN_CONFIG_SPEC + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testMultiConfigspecProductPublishing() throws IOException, Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "platform.product").toString()); - PublisherInfo info = new PublisherInfo(); - info.setConfigurations(new String[] {"carbon.macos.x86", "cocoa.macos.x86"}); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(info, publisherResult, null); + ((PublisherInfo) publisherInfo).setConfigurations(new String[] {"carbon.macos.x86", "cocoa.macos.x86"}); - Collection advice = info.getAdvice("carbon.macos.x86", false, null, null, IConfigAdvice.class); - assertEquals("1.0", 1, advice.size()); - } - - /** - * Tests that correct advice is created for the org.eclipse.platform product. - */ - public void testPlatformProduct() throws Exception { - ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "platform.product").toString()); - testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(publisherInfo, publisherResult, null); - - IExecutableAdvice launchAdvice = productFileAdviceCapture.getValue(); - assertEquals("1.0", "eclipse", launchAdvice.getExecutableName()); - - String[] programArgs = launchAdvice.getProgramArguments(); - assertEquals("2.0", 0, programArgs.length); - - String[] vmArgs = launchAdvice.getVMArguments(); - assertEquals("3.0", 0, vmArgs.length); + performProductAction(productFile); + Collection advice = publisherInfo.getAdvice("carbon.macos.x86", false, null, null, IConfigAdvice.class); + assertEquals("1.0", 1, advice.size()); } - public void testConfigSpecANYProductPublishing() throws Exception { - ProductFile productFile2 = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); - PublisherInfo info = new PublisherInfo(); + public void testANYConfigSpecPublishing_GeneralBundle() throws Exception { + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); String configSpecANY = AbstractPublisherAction.createConfigSpec("ANY", "ANY", "ANY"); // configuration spec to create CUs without filters - info.setConfigurations(getArrayFromString(configSpecANY, COMMA_SEPARATOR)); - PublisherResult results = new PublisherResult(); + setConfiguration(configSpecANY); - InstallableUnitDescription iuDescription1 = new InstallableUnitDescription(); - iuDescription1.setId("org.eclipse.core.runtime"); - iuDescription1.setVersion(Version.create("4.0.0")); // Set a specific version number, the one in the .product file uses 0.0.0. Let's see if it binds properly - IInstallableUnit iu1 = MetadataFactory.createInstallableUnit(iuDescription1); - results.addIU(iu1, IPublisherResult.NON_ROOT); + addContextUnit("org.eclipse.core.runtime", "4.0.0"); - InstallableUnitDescription iuDescription2 = new InstallableUnitDescription(); - iuDescription2.setId("org.eclipse.core.commands"); - iuDescription2.setVersion(Version.create("4.0.0")); // Set a specific version number, the one in the .product file uses 0.0.0. Let's see if it binds properly - iuDescription2.setFilter(winFitler); // any valid filter can be set here - IInstallableUnit iu2 = MetadataFactory.createInstallableUnit(iuDescription2); - results.addIU(iu2, IPublisherResult.NON_ROOT); + performProductAction(productFile); - ProductAction action = new ProductAction(null, productFile2, flavorArg, executablesFeatureLocation); - - action.perform(info, results, new NullProgressMonitor()); - - // there is a CU for the first IU because it has no filters - IQueryResult queryResult = results.query(QueryUtil.createIUQuery(flavorArg + configSpecANY + "org.eclipse.core.runtime"), new NullProgressMonitor()); + // there is a CU for the IU because it applies to all platforms + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + configSpecANY + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("1.0", 1, queryResultSize(queryResult)); IInstallableUnitFragment fragment = (IInstallableUnitFragment) queryResult.iterator().next(); assertEquals("1.1", "org.eclipse.core.runtime", RequiredCapability.extractName(fragment.getHost().iterator().next().getMatches())); assertEquals("1.2", Version.create("4.0.0"), RequiredCapability.extractRange(fragment.getHost().iterator().next().getMatches()).getMinimum()); assertEquals("1.3", Version.create("1.0.0"), fragment.getVersion()); assertNull("1.3", fragment.getFilter()); + } + + public void testANYConfigSpecPublishing_PlatformSpecificBundle() throws Exception { + ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "unboundedVersionConfigurations.product").toString()); + String configSpecANY = AbstractPublisherAction.createConfigSpec("ANY", "ANY", "ANY"); // configuration spec to create CUs without filters + setConfiguration(configSpecANY); + + addContextUnit("org.eclipse.core.runtime", "4.0.0", WIN_FILTER); // any valid filter can be set here + + performProductAction(productFile); - // there is no CU for the second IU because it has a filter - queryResult = results.query(QueryUtil.createIUQuery(flavorArg + configSpecANY + "org.eclipse.core.commands"), new NullProgressMonitor()); + // there is no CU for the IU because it is platform specific + IQueryResult queryResult = publisherResult.query(QueryUtil.createIUQuery(flavorArg + configSpecANY + "org.eclipse.core.runtime"), new NullProgressMonitor()); assertEquals("2.0", 0, queryResultSize(queryResult)); } @@ -404,15 +279,19 @@ public class ProductActionTest extends ActionTest { testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); IStatus status = testAction.perform(publisherInfo, publisherResult, null); - assertTrue(status instanceof MultiStatus); - IStatus[] children = ((MultiStatus) status).getChildren(); - boolean messageFound = false; - for (IStatus child : children) { - // TODO the message should have a code identifying it - if (child.getMessage().contains("are ignored")) - messageFound = true; - } - // requested in bug 325611 - assertTrue("Expected a warning about redundant ignored content in product file", messageFound); + // expect a warning about redundant, ignored content in product file -> requested in bug 325611 + assertThat(Arrays.asList(status.getChildren()), hasItem(statusWithMessageWhich(containsString("are ignored")))); + // TODO the message should have a code identifying it } + + private void performProductAction(ProductFile productFile) { + testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); + IStatus status = testAction.perform(publisherInfo, publisherResult, null); + assertThat(status, is(okStatus())); + } + + private void setConfiguration(String configSpec) { + ((PublisherInfo) publisherInfo).setConfigurations(new String[] {configSpec}); + } + } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java index 40cac01e9..460e65fc5 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2012 IBM Corporation 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 @@ -11,11 +11,15 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; +import static org.eclipse.equinox.p2.tests.publisher.actions.StatusMatchers.okStatus; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; import java.io.File; import java.util.Collections; import org.easymock.Capture; import org.easymock.EasyMock; +import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.equinox.p2.publisher.AbstractPublisherAction; @@ -27,7 +31,7 @@ import org.eclipse.equinox.p2.tests.TestData; /** * Tests for {@link ProductAction} specific to Mac. */ -@SuppressWarnings( {"unchecked"}) +@SuppressWarnings({"unchecked"}) public class ProductActionTestMac extends ActionTest { private File executablesFeatureLocation = null; @@ -63,7 +67,8 @@ public class ProductActionTestMac extends ActionTest { public void testPlatformProduct() throws Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest", "platform.product").toString()); testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(publisherInfo, publisherResult, null); + IStatus status = testAction.perform(publisherInfo, publisherResult, null); + assertThat(status, is(okStatus())); IExecutableAdvice launchAdvice = productFileAdviceCapture.getValue(); assertEquals("1.0", "eclipse", launchAdvice.getExecutableName()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java index 4b052c628..e58cc6054 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java @@ -10,9 +10,14 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; +import static org.eclipse.equinox.p2.tests.publisher.actions.StatusMatchers.okStatus; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + import java.io.File; import java.net.URI; import java.util.*; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; @@ -75,9 +80,12 @@ public class ProductActionWithAdviceFileTest extends ActionTest { testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); PublisherInfo info = new PublisherInfo(); info.setContextMetadataRepository(repository); + // TODO this line doesn't have any effect -> is this a bug in the implementation? info.addAdvice(new QueryableFilterAdvice(info.getContextMetadataRepository())); - testAction.perform(info, publisherResult, null); + IStatus status = testAction.perform(info, publisherResult, null); + assertThat(status, is(okStatus())); + IQueryResult results = publisherResult.query(new IUQuery("org.eclipse.platform.ide", Version.create("3.5.0.I20081118")), null); assertEquals("1.0", 1, queryResultSize(results)); IInstallableUnit unit = (IInstallableUnit) results.iterator().next(); @@ -86,7 +94,7 @@ public class ProductActionWithAdviceFileTest extends ActionTest { IRequiredCapability capability = null; for (Iterator iterator = requiredCapabilities.iterator(); iterator.hasNext();) { IRequiredCapability req = (IRequiredCapability) iterator.next(); - if (req.getName().equals("org.eclipse.equinox.p2.user.ui.feature.group")) { + if (req.getName().equals("org.eclipse.platform.feature.group")) { capability = req; break; } @@ -101,7 +109,8 @@ public class ProductActionWithAdviceFileTest extends ActionTest { public void testProductWithAdviceFile() throws Exception { ProductFile productFile = new ProductFile(TestData.getFile("ProductActionTest/productWithAdvice", "productWithAdvice.product").toString()); testAction = new ProductAction(source, productFile, flavorArg, executablesFeatureLocation); - testAction.perform(new PublisherInfo(), publisherResult, null); + IStatus status = testAction.perform(new PublisherInfo(), publisherResult, null); + assertThat(status, is(okStatus())); Collection productIUs = publisherResult.getIUs("productWithAdvice.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, productIUs.size()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithJRELocationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithJRELocationTest.java index a07c7376f..a5eed95f3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithJRELocationTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithJRELocationTest.java @@ -9,8 +9,13 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; +import static org.eclipse.equinox.p2.tests.publisher.actions.StatusMatchers.okStatus; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + import java.io.File; import java.util.*; +import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.publisher.*; @@ -51,7 +56,8 @@ public class ProductActionWithJRELocationTest extends AbstractProvisioningTest { ProductFile productFile = new ProductFile(productFileLocation.getCanonicalPath()); ProductAction testAction = new ProductAction(null, productFile, "tooling", null, jreLocation); IPublisherResult publisherResult = new PublisherResult(); - testAction.perform(new PublisherInfo(), publisherResult, null); + IStatus status = testAction.perform(new PublisherInfo(), publisherResult, null); + assertThat(status, is(okStatus())); Collection<IInstallableUnit> ius = publisherResult.getIUs(jreIuName, IPublisherResult.ROOT); assertEquals(1, ius.size()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductContentTypeTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductContentTypeTest.java index c096d32cc..a7f91b1cb 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductContentTypeTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductContentTypeTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 SAP AG and others. + * Copyright (c) 2011, 2012 SAP AG 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 @@ -10,13 +10,19 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; +import static org.eclipse.equinox.p2.tests.publisher.actions.StatusMatchers.errorStatus; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + import java.io.File; import java.util.*; +import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; import org.eclipse.equinox.p2.metadata.*; -import org.eclipse.equinox.p2.publisher.*; +import org.eclipse.equinox.p2.publisher.IPublisherResult; +import org.eclipse.equinox.p2.publisher.PublisherInfo; import org.eclipse.equinox.p2.publisher.eclipse.ProductAction; -import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestData; /** @@ -24,7 +30,7 @@ import org.eclipse.equinox.p2.tests.TestData; * and how its semantics replaces the <code>useFeatures</code> attribute. * Verify that all the installable units, expected to be included in the product, are published as its requirements. */ -public class ProductContentTypeTest extends AbstractProvisioningTest { +public class ProductContentTypeTest extends ActionTest { private static final String TEST_DATA_FOLDER = "ProductContentTypeTest"; private static final String flavor = "tooling"; @@ -34,6 +40,7 @@ public class ProductContentTypeTest extends AbstractProvisioningTest { private IInstallableUnit bundleIU = createIU("TestBundle"); public void setUp() throws Exception { + setupPublisherResult(); initCUsList(); } @@ -118,6 +125,9 @@ public class ProductContentTypeTest extends AbstractProvisioningTest { } private void testTemplate(String productFileName, String productVersion, int expectedRequirementsSize, IInstallableUnit... requiredInstallableUnits) throws Exception { + for (int i = 0; i < requiredInstallableUnits.length; i++) { + publisherResult.addIU(requiredInstallableUnits[i], IPublisherResult.NON_ROOT); + } File productFileLocation = TestData.getFile(TEST_DATA_FOLDER, productFileName); IInstallableUnit productIU = publishProduct(productFileLocation, productFileName); @@ -131,9 +141,9 @@ public class ProductContentTypeTest extends AbstractProvisioningTest { private IInstallableUnit publishProduct(final File productFileLocation, final String productIUName) throws Exception { ProductFile productFile = new ProductFile(productFileLocation.toString()); - ProductAction testAction = new ProductAction(null, productFile, flavor, null); - IPublisherResult publisherResult = new PublisherResult(); - testAction.perform(new PublisherInfo(), publisherResult, null); + testAction = new ProductAction(null, productFile, flavor, null); + IStatus status = testAction.perform(new PublisherInfo(), publisherResult, null); + assertThat(status, is(not(errorStatus()))); Collection<IInstallableUnit> ius = publisherResult.getIUs(productIUName, IPublisherResult.NON_ROOT); assertEquals(1, ius.size()); return ius.iterator().next(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/StatusMatchers.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/StatusMatchers.java index db2451f86..b0a30172f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/StatusMatchers.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/StatusMatchers.java @@ -31,6 +31,20 @@ public class StatusMatchers { }; } + public static Matcher<IStatus> okStatus() { + return new TypeSafeMatcher<IStatus>() { + + public void describeTo(Description description) { + description.appendText("a status with severity OK"); + } + + @Override + public boolean matchesSafely(IStatus item) { + return item.isOK(); + } + }; + } + public static Matcher<IStatus> statusWithMessageWhich(final Matcher<String> messageMatcher) { return new TypeSafeMatcher<IStatus>() { diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/boundedVersionConfigurations.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/boundedVersionConfigurations.product index 8aa1b4b15..ecdb47679 100644 --- a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/boundedVersionConfigurations.product +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/boundedVersionConfigurations.product @@ -23,7 +23,6 @@ </vm> <plugins> - <plugin id="org.eclipse.core.commands" version="5.0.0"/> <plugin id="org.eclipse.core.runtime" version="4.0.0"/> </plugins> diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/brandedProduct/branded.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/brandedProduct/branded.product index 57dd91fbb..ebead1de4 100644 --- a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/brandedProduct/branded.product +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/brandedProduct/branded.product @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <?pde version="3.5"?> -<product name="Branded Product" id="branded.product" application="org.eclipse.ui.ide.workbench" version="3.5.0.I20081118" useFeatures="true"> +<product name="Branded Product" id="branded.product" application="org.eclipse.ui.ide.workbench" version="3.5.0.I20081118" useFeatures="true" includeLaunchers="true"> <aboutInfo> <image path="/org.eclipse.equinox.p2.tests/testData/ProductActionTest/brandedProduct/about.gif"/> @@ -35,7 +35,6 @@ org.eclipse.platform</programArgsMac> </win> </launcher> - <vm> </vm> @@ -51,7 +50,6 @@ org.eclipse.platform</programArgsMac> <features> <feature id="org.eclipse.platform"/> - <feature id="org.eclipse.equinox.p2.user.ui" version="1.0.0.qualifier"/> </features> diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/contextRepos/content.xml b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/contextRepos/content.xml index b9c441562..ce74fc82e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/contextRepos/content.xml +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/contextRepos/content.xml @@ -7,7 +7,7 @@ <property name='site.checksum' value='2404093275'/> </properties> <units size='1'> - <unit id='org.eclipse.equinox.p2.user.ui.feature.group' version='1.0.0.qualifier'> + <unit id='org.eclipse.platform.feature.group' version='1.0.0.qualifier'> <provides size='3'> <provided namespace='org.eclipse.equinox.p2.iu' name='test.feature.feature.jar' version='1.0.0'/> <provided namespace='org.eclipse.equinox.p2.eclipse.type' name='feature' version='1.0.0'/> diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/platform.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/platform.product index 72fb126ab..6194a7adb 100644 --- a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/platform.product +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/platform.product @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<?pde version="3.4"?> +<?pde version="3.5"?> -<product name="Eclipse Platform" id="org.eclipse.platform.ide" application="org.eclipse.ui.ide.workbench" version="3.5.0.I20081118" useFeatures="true"> +<product name="Eclipse Platform" id="org.eclipse.platform.ide" application="org.eclipse.ui.ide.workbench" version="3.5.0.I20081118" useFeatures="true" includeLaunchers="true"> <configIni use="default"> </configIni> @@ -31,8 +31,8 @@ org.eclipse.platform</programArgsMac> </plugins> <features> - <feature id="org.eclipse.platform" version="0.0.0"/> - <feature id="org.eclipse.equinox.p2.user.ui" version="1.0.0.qualifier"/> + <feature id="org.eclipse.platform"/> </features> + </product> diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/productWithAdvice/productWithAdvice.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/productWithAdvice/productWithAdvice.product index 651369201..23fc5c31c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/productWithAdvice/productWithAdvice.product +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/productWithAdvice/productWithAdvice.product @@ -1,4 +1,7 @@ -<product name="aaTestProduct" id="productWithAdvice.product" application="test.app" version="1" useFeatures="true"> +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product name="aaTestProduct" id="productWithAdvice.product" application="test.app" version="1" useFeatures="true" includeLaunchers="true"> <configIni use="default"> </configIni> @@ -6,7 +9,5 @@ <plugins> </plugins> - <features> - <feature id="org.eclipse.rcp" version="3.5.0.v20081110-9C9tEvNEla71LZ2jFz-RFB-t"/> - </features> + </product> diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/unboundedVersionConfigurations.product b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/unboundedVersionConfigurations.product index d0ee899d5..51fa9bda6 100644 --- a/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/unboundedVersionConfigurations.product +++ b/bundles/org.eclipse.equinox.p2.tests/testData/ProductActionTest/unboundedVersionConfigurations.product @@ -23,7 +23,6 @@ </vm> <plugins> - <plugin id="org.eclipse.core.commands"/> <plugin id="org.eclipse.core.runtime"/> </plugins> |