Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShenol Yousouf2012-01-07 12:56:42 +0000
committerTobias Oberlies2012-02-20 18:24:24 +0000
commitb6e303672b8fdafc5035df293837c4b266d9c789 (patch)
tree481e99eaa4b3bc6ffc2919ae30fd5890b18da20d
parentbb00e45ec27dedb09d69ac0c7735b0a1048642ba (diff)
downloadrt.equinox.p2-b6e303672b8fdafc5035df293837c4b266d9c789.tar.gz
rt.equinox.p2-b6e303672b8fdafc5035df293837c4b266d9c789.tar.xz
rt.equinox.p2-b6e303672b8fdafc5035df293837c4b266d9c789.zip
334519 Added parameter for selecting JRE profile in product publisher applicationv20120220-1824
Introducing a new parameter for the product publisher application to read the java profile from an external file. The value of the specified location can be either a single file or a JRE folder with a .profile file. In the latter case, the whole JRE folder is zipped and uploaded as binary artifact to p2 repository. Also, fixed reading the versions of the packages, described in the java profile. Bug 334519 - [publisher] Erroneous behavior in product publisher when handling the java profile
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/ProductPublisherTask.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/Messages.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/messages.properties4
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java61
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithJRELocationTest.java75
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/packageVersions/test-1.0.0.profile31
10 files changed, 225 insertions, 23 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java
index 8c5bec5cf..d0f3fa92d 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java
@@ -32,18 +32,24 @@ public class ProductAction extends AbstractPublisherAction {
//protected String productLocation;
protected File executablesFeatureLocation;
protected IProductDescriptor product;
+ protected File jreLocation;
protected IPublisherResult publisherResults;
protected MultiStatus finalStatus;
- public ProductAction(String source, IProductDescriptor product, String flavor, File executablesFeatureLocation) {
+ public ProductAction(String source, IProductDescriptor product, String flavor, File executablesFeatureLocation, File jreLocation) {
super();
this.source = source;
this.flavor = flavor;
this.executablesFeatureLocation = executablesFeatureLocation;
this.product = product;
+ this.jreLocation = jreLocation;
//this.productLocation = productLocation;
}
+ public ProductAction(String source, IProductDescriptor product, String flavor, File executablesFeatureLocation) {
+ this(source, product, flavor, executablesFeatureLocation, null);
+ }
+
protected IPublisherAction[] createActions(IPublisherResult results) {
// generate the advice we can up front.
createAdvice();
@@ -78,8 +84,7 @@ public class ProductAction extends AbstractPublisherAction {
}
protected IPublisherAction createJREAction() {
- //TODO set a proper execution environment
- return new JREAction((String) null);
+ return new JREAction(jreLocation);
}
@Override
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java
index 1b8f33900..44f39b0d2 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductPublisherApplication.java
@@ -7,6 +7,7 @@
* Contributors:
* Code 9 - initial API and implementation
* IBM - ongoing development
+ * SAP AG - ongoing development
******************************************************************************/
package org.eclipse.equinox.p2.publisher.eclipse;
@@ -26,6 +27,7 @@ public class ProductPublisherApplication extends AbstractPublisherApplication {
private String product;
private String executables;
private String flavor;
+ private String jreLocation;
public ProductPublisherApplication() {
//hidden
@@ -45,7 +47,8 @@ public class ProductPublisherApplication extends AbstractPublisherApplication {
throw new IllegalArgumentException(NLS.bind(Messages.exception_errorLoadingProductFile, product, e.toString()));
}
File executablesFeature = executables == null ? null : new File(executables);
- return new ProductAction(source, productDescriptor, flavor, executablesFeature);
+ File jreLocationFile = jreLocation == null ? null : new File(jreLocation);
+ return new ProductAction(source, productDescriptor, flavor, executablesFeature, jreLocationFile);
}
protected void processParameter(String arg, String parameter, PublisherInfo publisherInfo) throws URISyntaxException {
@@ -57,6 +60,8 @@ public class ProductPublisherApplication extends AbstractPublisherApplication {
executables = parameter;
if (arg.equalsIgnoreCase("-flavor")) //$NON-NLS-1$
flavor = parameter;
+ if (arg.equalsIgnoreCase("-jreLocation")) //$NON-NLS-1$
+ jreLocation = parameter;
if (arg.equalsIgnoreCase("-pluginVersionsAdvice")) { //$NON-NLS-1$
VersionAdvice versionAdvice = new VersionAdvice();
versionAdvice.load(IInstallableUnit.NAMESPACE_IU_ID, parameter, null);
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/ProductPublisherTask.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/ProductPublisherTask.java
index 541fe4cf3..49b79f82d 100644
--- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/ProductPublisherTask.java
+++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/ProductPublisherTask.java
@@ -61,8 +61,9 @@ public class ProductPublisherTask extends AbstractPublishTask {
private String flavor;
private String productFile;
private String executables;
- private List<ConfigElement> configurations = new ArrayList<ConfigElement>(3);
- private List<AdviceElement> advice = new ArrayList<AdviceElement>(3);
+ private String jreLocation;
+ private final List<ConfigElement> configurations = new ArrayList<ConfigElement>(3);
+ private final List<AdviceElement> advice = new ArrayList<AdviceElement>(3);
public void execute() throws BuildException {
try {
@@ -82,7 +83,7 @@ public class ProductPublisherTask extends AbstractPublishTask {
if (flavor == null || flavor.startsWith(ANT_PROPERTY_PREFIX))
flavor = "tooling"; //$NON-NLS-1$
- IPublisherAction action = new ProductAction(source, productDescriptor, flavor, executables != null ? new File(executables) : null);
+ IPublisherAction action = new ProductAction(source, productDescriptor, flavor, executables != null ? new File(executables) : null, jreLocation != null ? new File(jreLocation) : null);
new Publisher(getInfo()).publish(new IPublisherAction[] {action}, new NullProgressMonitor());
}
@@ -123,6 +124,10 @@ public class ProductPublisherTask extends AbstractPublishTask {
this.executables = executables;
}
+ public void setJreLocation(String jreLocation) {
+ this.jreLocation = jreLocation;
+ }
+
public void setSource(String source) {
super.source = source;
}
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 af8eeb7b3..45342b967 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
@@ -1,10 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2007, 2011 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 http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * SAP AG - ongoing development
******************************************************************************/
package org.eclipse.equinox.internal.p2.publisher;
@@ -27,6 +29,7 @@ public class Messages extends NLS {
public static String exception_invalidSiteReferenceInFeature;
public static String exception_repoMustBeURL;
public static String exception_sourcePath;
+ public static String exception_nonExistingJreLocationFile;
public static String message_generatingMetadata;
public static String message_generationCompleted;
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 0b7a16934..2cc00ea2d 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
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007, 2010 IBM Corporation and others.
+# Copyright (c) 2007, 2011 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
@@ -7,6 +7,7 @@
#
# Contributors:
# IBM Corporation - initial API and implementation
+# SAP AG - ongoing development
###############################################################################
exception_errorConverting = An error occurred while generating manifest for {0}.
exception_stateAddition = An error has occurred while adding the bundle {0}.
@@ -21,6 +22,7 @@ exception_invalidSiteReference=Invalid site reference: {0}
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_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 44e08cf27..b0436475c 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
@@ -7,6 +7,7 @@
* Contributors:
* Code 9 - initial API and implementation
* IBM - ongoing development
+ * SAP AG - ongoing development
******************************************************************************/
package org.eclipse.equinox.p2.publisher.actions;
@@ -18,6 +19,7 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.publisher.Activator;
+import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
@@ -25,6 +27,7 @@ import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.util.ManifestElement;
+import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleException;
public class JREAction extends AbstractPublisherAction {
@@ -82,7 +85,7 @@ public class JREAction extends AbstractPublisherAction {
cu.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
Map<String, String> touchpointData = new HashMap<String, String>();
- if (jreLocation == null || !jreLocation.exists()) {
+ if (jreLocation == null || !jreLocation.isDirectory()) {
touchpointData.put("install", ""); //$NON-NLS-1$ //$NON-NLS-2$
cu.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
results.addIU(MetadataFactory.createInstallableUnit(iu), IPublisherResult.ROOT);
@@ -120,7 +123,9 @@ public class JREAction extends AbstractPublisherAction {
IProvidedCapability[] exportedPackageAsCapabilities = new IProvidedCapability[jrePackages.length + 1];
exportedPackageAsCapabilities[0] = PublisherHelper.createSelfCapability(id, version);
for (int i = 1; i <= jrePackages.length; i++) {
- exportedPackageAsCapabilities[i] = MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, jrePackages[i - 1].getValue(), null);
+ String packageName = jrePackages[i - 1].getValue();
+ Version packageVersion = Version.create(jrePackages[i - 1].getAttribute("version")); //$NON-NLS-1$
+ exportedPackageAsCapabilities[i] = MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, packageName, packageVersion);
}
return exportedPackageAsCapabilities;
} catch (BundleException e) {
@@ -176,15 +181,26 @@ public class JREAction extends AbstractPublisherAction {
this.info = publisherInfo;
if (jreLocation != null) {
- //Look for a JRE profile file to set version and capabilities
- File[] profiles = jreLocation.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- return pathname.getAbsolutePath().endsWith(".profile"); //$NON-NLS-1$
+
+ File javaProfile = null;
+
+ if (jreLocation.isDirectory()) {
+ //Look for a JRE profile file to set version and capabilities
+ File[] profiles = jreLocation.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.getAbsolutePath().endsWith(".profile"); //$NON-NLS-1$
+ }
+ });
+ if (profiles != null && profiles.length > 0) {
+ javaProfile = profiles[0];
}
- });
- if (profiles != null && profiles.length > 0) {
- profileProperties = loadProfile(profiles[0]);
- }
+ } else if (jreLocation.isFile())
+ javaProfile = jreLocation;
+ else
+ // jreLocation file does not exist
+ throw new IllegalArgumentException(NLS.bind(Messages.exception_nonExistingJreLocationFile, jreLocation.getAbsolutePath()));
+
+ profileProperties = loadProfile(javaProfile);
}
if (profileProperties == null) {
String entry = environment != null ? "/profiles/" + environment.replace('/', '_') + ".profile" : DEFAULT_PROFILE; //$NON-NLS-1$ //$NON-NLS-2$
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 d8dd352b2..d18c92780 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This
+ * Copyright (c) 2008, 2011 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
@@ -7,7 +7,7 @@
* Contributors:
* Code 9 - initial API and implementation
* IBM - ongoing development
- * SAP - ongoing development
+ * SAP AG - ongoing development
******************************************************************************/
package org.eclipse.equinox.p2.tests.publisher;
@@ -37,6 +37,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(ProductActionTest.class);
suite.addTestSuite(ProductActionTestMac.class);
suite.addTestSuite(ProductActionWithAdviceFileTest.class);
+ suite.addTestSuite(ProductActionWithJRELocationTest.class);
suite.addTestSuite(ProductContentTypeTest.class);
suite.addTestSuite(ProductFileAdviceTest.class);
suite.addTestSuite(ProductFileTest.class);
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 6bf0892ff..645f19d39 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Code 9 and others. All rights reserved. This
+ * Copyright (c) 2008, 2011 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
@@ -7,10 +7,13 @@
* 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.expect;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItem;
import java.io.*;
import java.util.*;
@@ -24,6 +27,7 @@ import org.eclipse.equinox.p2.publisher.IPublisherResult;
import org.eclipse.equinox.p2.publisher.actions.JREAction;
import org.eclipse.equinox.p2.tests.*;
import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository;
+import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
@SuppressWarnings({"unchecked"})
public class JREActionTest extends ActionTest {
@@ -31,6 +35,8 @@ public class JREActionTest extends ActionTest {
private File J14 = new File(TestActivator.getTestDataFolder(), "JREActionTest/1.4/"); //$NON-NLS-1$
private File J15 = new File(TestActivator.getTestDataFolder(), "JREActionTest/1.5/"); //$NON-NLS-1$
private File J16 = new File(TestActivator.getTestDataFolder(), "JREActionTest/1.6/"); //$NON-NLS-1$
+ private File jreWithPackageVersionsFolder = new File(TestActivator.getTestDataFolder(), "JREActionTest/packageVersions/"); //$NON-NLS-1$
+ private File jreWithPackageVersionsProfile = new File(TestActivator.getTestDataFolder(), "JREActionTest/packageVersions/test-1.0.0.profile"); //$NON-NLS-1$
protected TestArtifactRepository artifactRepository = new TestArtifactRepository(getAgent());
protected TestMetadataRepository metadataRepository;
@@ -67,6 +73,52 @@ public class JREActionTest extends ActionTest {
verifyResults("a.jre.osgi.minimum", 2, Version.create("1.2.0"), false); //$NON-NLS-1$
}
+ public void testPackageVersionsFromJreFolder() throws Exception {
+ testAction = new JREAction(jreWithPackageVersionsFolder);
+ testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor());
+
+ Collection<IProvidedCapability> providedCapabilities = getPublishedCapabilitiesOf("a.jre.test");
+ assertThat(providedCapabilities, hasItem(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, "my.package", null)));
+ assertThat(providedCapabilities, hasItem(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, "my.package", Version.create("1.0.0"))));
+
+ verifyArtifactRepository(ArtifactKey.parse("binary,a.jre.test,1.0.0"), jreWithPackageVersionsFolder, "test-1.0.0.profile"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ public void testPackageVersionsFromJavaProfile() throws Exception {
+ // introduced for bug 334519: directly point to a profile file
+ testAction = new JREAction(jreWithPackageVersionsProfile);
+ testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor());
+
+ Collection<IProvidedCapability> providedCapabilities = getPublishedCapabilitiesOf("a.jre.test");
+ assertThat(providedCapabilities, hasItem(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, "my.package", null)));
+ assertThat(providedCapabilities, hasItem(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, "my.package", Version.create("1.0.0"))));
+ }
+
+ public void testDefaultJavaProfile() throws Exception {
+ // take note that these constants should be changed each time the default java profile, hardcoded in o.e.e.p2.publisher.actions.JREAction, is changed;
+ // this could be avoided by making the respective static properties of JREAction class public but doing so for test purposes only is questionable
+ final String DEFAULT_JRE_NAME = "a.jre.javase"; //$NON-NLS-1$
+ final Version DEFAULT_JRE_VERSION = Version.parseVersion("1.6"); //$NON-NLS-1$
+ final int DEFAULT_NUM_PROVIDED_CAPABILITIES = 159;
+
+ testAction = new JREAction((File) null);
+ testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor());
+ verifyResults(DEFAULT_JRE_NAME, DEFAULT_NUM_PROVIDED_CAPABILITIES, DEFAULT_JRE_VERSION, false);
+ }
+
+ public void testNonExistingJreLocation() {
+ File nonExistingProfile = new File(jreWithPackageVersionsFolder, "no.profile");
+ testAction = new JREAction(nonExistingProfile);
+ try {
+ testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor());
+ fail("Expected failure when the JRE location does not exists.");
+ } catch (IllegalArgumentException e) {
+ // test is successful
+ } catch (Exception e) {
+ fail("Expected IllegalArgumentException when the JRE location does not exists, caught " + e.getClass().getName());
+ }
+ }
+
private void verifyResults(String id, int numProvidedCapabilities, Version JREVersion, boolean testInstructions) {
ArrayList fooIUs = new ArrayList(publisherResult.getIUs(id, IPublisherResult.ROOT)); //$NON-NLS-1$
assertTrue(fooIUs.size() == 1);
@@ -122,6 +174,13 @@ public class JREActionTest extends ActionTest {
TestData.assertContains(fileMap, zipInputStream, true);
}
+ private Collection<IProvidedCapability> getPublishedCapabilitiesOf(String id) {
+ Collection<IInstallableUnit> ius = publisherResult.getIUs(id, IPublisherResult.ROOT);
+ assertTrue(ius.size() == 1);
+ IInstallableUnit iu = ius.iterator().next();
+ return iu.getProvidedCapabilities();
+ }
+
protected void insertPublisherInfoBehavior() {
expect(publisherInfo.getArtifactRepository()).andReturn(artifactRepository).anyTimes();
expect(publisherInfo.getArtifactOptions()).andReturn(IPublisherInfo.A_PUBLISH).anyTimes();
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
new file mode 100644
index 000000000..a07c7376f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithJRELocationTest.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.p2.tests.publisher.actions;
+
+import java.io.File;
+import java.util.*;
+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.eclipse.ProductAction;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.TestData;
+import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
+
+/**
+ * Tests the new ProductAction constructor which accepts a file path to an external JRE location or an external java profile.
+ * The goal is to verify that the new constructors leads to the creation of a JRE unit, based on the external profile.
+ * For that purpose, the checks are overall quite basic, limited mainly to verifying the existence of the JRE unit and
+ * the provided java packages in the result p2 metadata. The in-depth analysis of the JRE unit properties is delegated to
+ * the corresponding new tests in o.e.e.p2.test.publisher.actions.JREActionTest.
+ */
+public class ProductActionWithJRELocationTest extends AbstractProvisioningTest {
+
+ public void testWithJRELocationFolder() throws Exception {
+ File productFileLocation = TestData.getFile("ProductActionTest", "productWithLicense.product");
+ File jreLocation = TestData.getFile("JREActionTest", "packageVersions");
+ List<IProvidedCapability> expectedProvidedCapabilities = new ArrayList<IProvidedCapability>();
+ expectedProvidedCapabilities.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, "my.package", null));
+ expectedProvidedCapabilities.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, "my.package", Version.create("1.0.0")));
+ testTemplate(productFileLocation, jreLocation, "a.jre.test", Version.create("1.0.0"), expectedProvidedCapabilities);
+ }
+
+ public void testWithJREProfile() throws Exception {
+ File productFileLocation = TestData.getFile("ProductActionTest", "productWithLicense.product");
+ File jreLocation = TestData.getFile("JREActionTest", "packageVersions/test-1.0.0.profile");
+ List<IProvidedCapability> expectedProvidedCapabilities = new ArrayList<IProvidedCapability>();
+ expectedProvidedCapabilities.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, "my.package", null));
+ expectedProvidedCapabilities.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, "my.package", Version.create("1.0.0")));
+ testTemplate(productFileLocation, jreLocation, "a.jre.test", Version.create("1.0.0"), expectedProvidedCapabilities);
+ }
+
+ private void testTemplate(File productFileLocation, File jreLocation, String jreIuName, Version jreIuVersion, Collection<IProvidedCapability> expectedProvidedCapabilities) throws Exception {
+
+ 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);
+
+ Collection<IInstallableUnit> ius = publisherResult.getIUs(jreIuName, IPublisherResult.ROOT);
+ assertEquals(1, ius.size());
+
+ IInstallableUnit jreIU = ius.iterator().next();
+ assertEquals(jreIuVersion, jreIU.getVersion());
+
+ Collection<IProvidedCapability> providedCapabilities = jreIU.getProvidedCapabilities();
+ for (IProvidedCapability expectedProvidedCapability : expectedProvidedCapabilities) {
+ assertTrue("Expected capability " + expectedProvidedCapability + " was not found in published JRE", verifyProvidedCapabilities(providedCapabilities, expectedProvidedCapability));
+ }
+ }
+
+ private boolean verifyProvidedCapabilities(Collection<IProvidedCapability> providedCapabilities, IProvidedCapability expectedProvidedCapability) {
+ for (IProvidedCapability iProvidedCapability : providedCapabilities) {
+ if (iProvidedCapability.equals(expectedProvidedCapability))
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/packageVersions/test-1.0.0.profile b/bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/packageVersions/test-1.0.0.profile
new file mode 100644
index 000000000..213443d14
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/JREActionTest/packageVersions/test-1.0.0.profile
@@ -0,0 +1,31 @@
+###############################################################################
+# Copyright (c) 2011 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
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# SAP AG - initial API and implementation
+###############################################################################
+org.osgi.framework.system.packages = \
+ my.package,\
+ my.package;version="1.0.0"
+org.osgi.framework.bootdelegation = \
+ javax.*,\
+ org.ietf.jgss,\
+ org.omg.*,\
+ org.w3c.*,\
+ org.xml.*,\
+ sun.*,\
+ com.sun.*
+org.osgi.framework.executionenvironment = \
+ OSGi/Minimum-1.0,\
+ OSGi/Minimum-1.1,\
+ JRE-1.1,\
+ J2SE-1.2,\
+ J2SE-1.3,\
+ J2SE-1.4,\
+ J2SE-1.5,\
+ JavaSE-1.6
+osgi.java.profile.name = JavaSE-1.6

Back to the top