### Eclipse Workspace Patch 1.0 #P org.eclipse.equinox.p2.core Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF,v retrieving revision 1.24 diff -u -r1.24 MANIFEST.MF --- META-INF/MANIFEST.MF 26 Sep 2008 19:55:59 -0000 1.24 +++ META-INF/MANIFEST.MF 1 Oct 2008 18:28:43 -0000 @@ -51,6 +51,7 @@ org.eclipse.equinox.internal.p2.persistence;x-friends:="org.eclipse.equinox.p2.artifact.repository,org.eclipse.equinox.p2.engine,org.eclipse.equinox.p2.metadata.repository", org.eclipse.equinox.internal.provisional.p2.core; x-friends:="org.eclipse.equinox.p2.artifact.repository, + org.eclipse.equinox.p2.director.app, org.eclipse.equinox.p2.extensionlocation, org.eclipse.equinox.p2.metadata.repository, org.eclipse.equinox.p2.ui, #P org.eclipse.equinox.p2.tests Index: src/org/eclipse/equinox/p2/tests/director/AllTests.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AllTests.java,v retrieving revision 1.5 diff -u -r1.5 AllTests.java --- src/org/eclipse/equinox/p2/tests/director/AllTests.java 21 Nov 2007 20:14:48 -0000 1.5 +++ src/org/eclipse/equinox/p2/tests/director/AllTests.java 1 Oct 2008 18:28:44 -0000 @@ -32,6 +32,7 @@ suite.addTestSuite(SingletonTest.class); suite.addTestSuite(UninstallTest.class); suite.addTestSuite(UpdateTest.class); + suite.addTestSuite(DirectorAppTest.class); return suite; } Index: src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java =================================================================== RCS file: src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java diff -N src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2008 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 + ******************************************************************************/ +package org.eclipse.equinox.p2.tests.director; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.equinox.internal.p2.director.app.Application; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.osgi.framework.Bundle; + +/** + * Various automated tests of the {@link IDirector} API. + */ +public class DirectorAppTest extends AbstractProvisioningTest { + + /** + * runs default director app. + */ + private void runDirectorApp(final String message, final URL metadata, final URL artifact, final URL destination, final String installIU) throws Exception { + Application application = new Application(); + application.start(new IApplicationContext() { + + public void applicationRunning() { + } + + public Map getArguments() { + Map arguments = new HashMap(); + + arguments.put(IApplicationContext.APPLICATION_ARGS, new String[] {"-metadataRepository", metadata.toExternalForm(), "-artifactRepository", artifact.toExternalForm(), "-installIU", installIU, "-destination", destination.toExternalForm(), "-profile", "PlatformSDKProfile", "-profileProperties", "org.eclipse.update.install.features=true", "-bundlepool", destination.toExternalForm(), "-roaming", "-vmargs", "-Declipse.p2.data.area=c:/install_dest/p2"}); + + return arguments; + } + + public String getBrandingApplication() { + return null; + } + + public Bundle getBrandingBundle() { + return null; + } + + public String getBrandingDescription() { + return null; + } + + public String getBrandingId() { + return null; + } + + public String getBrandingName() { + return null; + } + + public String getBrandingProperty(String key) { + return null; + } + }); + } + + public void testRepoCreationBothInvalid() { + //Setup: Create the folders + File metadataRepo = new File(getTempFolder(), "DirectorApp Metadata"); + File artifactRepo = new File(getTempFolder(), "DirectorApp Artifact"); + File destinationRepo = new File(getTempFolder(), "DirectorApp Destination"); + String installIU = "invalidIU"; + + //Setup: ensure folders do not exist + delete(metadataRepo); + delete(artifactRepo); + delete(destinationRepo); + + try { + runDirectorApp("1.0", metadataRepo.toURL(), artifactRepo.toURL(), destinationRepo.toURL(), installIU); + } catch (MalformedURLException e) { + fail("1.1", e); + } catch (CoreException e) { + //fall through + } catch (Exception e) { + fail("1.2", e); + } + + //ensures that repositories have not been mistakenly created + assertTrue("1.3", !metadataRepo.exists()); + assertTrue("1.4", !artifactRepo.exists()); + + //Cleanup: delete the folders + delete(metadataRepo); + delete(artifactRepo); + delete(destinationRepo); + } + + public void testRepoCreationMetadataInvalid() { + //Setup: create repos + File metadataRepo = new File(getTempFolder(), "DirectorApp Metadata"); + File artifactRepo = getTestData("2.0", "/testData/mirror/mirrorSourceRepo1"); + File destinationRepo = new File(getTempFolder(), "DirectorApp Destination"); + String installIU = "invalidIU"; + + //Setup: ensure folders do not exist + delete(metadataRepo); + delete(destinationRepo); + + try { + runDirectorApp("2.1", metadataRepo.toURL(), artifactRepo.toURL(), destinationRepo.toURL(), installIU); + } catch (MalformedURLException e) { + fail("2.2", e); + } catch (CoreException e) { + //fall through + } catch (Exception e) { + fail("2.3", e); + } + + //ensures that repository has not been mistakenly created + assertTrue("2.4", !metadataRepo.exists()); + assertTrue("2.5", artifactRepo.exists()); + + //Cleanup: delete the folders + delete(metadataRepo); + delete(destinationRepo); + } + + public void testRepoCreationArtifactInvalid() { + //Setup: create repos + File metadataRepo = getTestData("3.0", "/testData/mirror/mirrorSourceRepo1"); + File artifactRepo = new File(getTempFolder(), "DirectorApp Artifact"); + File destinationRepo = new File(getTempFolder(), "DirectorApp Destination"); + String installIU = "invalidIU"; + + //Setup: ensure folders do not exist + delete(artifactRepo); + delete(destinationRepo); + + try { + runDirectorApp("3.1", metadataRepo.toURL(), artifactRepo.toURL(), destinationRepo.toURL(), installIU); + } catch (MalformedURLException e) { + fail("3.2", e); + } catch (CoreException e) { + //fall through + } catch (Exception e) { + fail("3.3", e); + } + + //ensures that repository has not been mistakenly created + assertTrue("3.4", !artifactRepo.exists()); + assertTrue("3.5", metadataRepo.exists()); + + //Cleanup: delete the folders + delete(artifactRepo); + delete(destinationRepo); + } +} #P org.eclipse.equinox.p2.director.app Index: src/org/eclipse/equinox/internal/p2/director/app/Application.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java,v retrieving revision 1.35 diff -u -r1.35 Application.java --- src/org/eclipse/equinox/internal/p2/director/app/Application.java 14 Aug 2008 20:54:31 -0000 1.35 +++ src/org/eclipse/equinox/internal/p2/director/app/Application.java 1 Oct 2008 18:28:45 -0000 @@ -21,10 +21,13 @@ import org.eclipse.equinox.internal.p2.console.ProvisioningHelper; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.director.*; import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; import org.eclipse.equinox.internal.provisional.p2.query.Collector; import org.eclipse.osgi.service.resolver.VersionRange; import org.eclipse.osgi.util.NLS; @@ -166,16 +169,24 @@ if (throwException) missingArgument("artifactRepository"); //$NON-NLS-1$ } else { + IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); + if (manager == null) + throw new ProvisionException(Messages.Application_NoManager); for (int i = 0; i < artifactRepositoryLocations.length; i++) - ProvisioningHelper.addArtifactRepository(artifactRepositoryLocations[i]); + //Try and load each repository. Throws exception if one cannot be loaded (such as if it is invalid) + manager.loadRepository(artifactRepositoryLocations[i], null); } if (metadataRepositoryLocations == null) { if (throwException) missingArgument("metadataRepository"); //$NON-NLS-1$ } else { + IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); + if (manager == null) + throw new ProvisionException(Messages.Application_NoManager); for (int i = 0; i < metadataRepositoryLocations.length; i++) - ProvisioningHelper.addMetadataRepository(metadataRepositoryLocations[i]); + //Try and load each repository. Throws exception if one cannot be loaded (such as if it is invalid) + manager.loadRepository(metadataRepositoryLocations[i], null); } } Index: src/org/eclipse/equinox/internal/p2/director/app/Messages.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Messages.java,v retrieving revision 1.5 diff -u -r1.5 Messages.java --- src/org/eclipse/equinox/internal/p2/director/app/Messages.java 14 May 2008 21:34:22 -0000 1.5 +++ src/org/eclipse/equinox/internal/p2/director/app/Messages.java 1 Oct 2008 18:28:45 -0000 @@ -29,6 +29,7 @@ public static String Listing; public static String Ambigous_Command; + public static String Application_NoManager; public static String Missing_Required_Argument; public static String Installing; Index: src/org/eclipse/equinox/internal/p2/director/app/messages.properties =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/messages.properties,v retrieving revision 1.7 diff -u -r1.7 messages.properties --- src/org/eclipse/equinox/internal/p2/director/app/messages.properties 15 May 2008 14:44:24 -0000 1.7 +++ src/org/eclipse/equinox/internal/p2/director/app/messages.properties 1 Oct 2008 18:28:45 -0000 @@ -24,6 +24,7 @@ Missing_IU=The installable unit {0} has not been found. Missing_Required_Argument=Missing required argument -{0}. Ambigous_Command=Cannot execute both {0} and {1} in one invocation +Application_NoManager=Error occured while aquiring manager Listing=Listing Installable Units from {0} Installing=Installing {0} {1}. Uninstalling=Uninstalling {0} {1}. Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF,v retrieving revision 1.12 diff -u -r1.12 MANIFEST.MF --- META-INF/MANIFEST.MF 10 Jul 2008 17:16:55 -0000 1.12 +++ META-INF/MANIFEST.MF 1 Oct 2008 18:28:45 -0000 @@ -10,6 +10,7 @@ org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.engine, org.eclipse.equinox.internal.provisional.p2.artifact.repository, + org.eclipse.equinox.internal.provisional.p2.core, org.eclipse.equinox.internal.provisional.p2.core.location, org.eclipse.equinox.internal.provisional.p2.director, org.eclipse.equinox.internal.provisional.p2.engine, #P org.eclipse.equinox.p2.metadata.repository Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF,v retrieving revision 1.25 diff -u -r1.25 MANIFEST.MF --- META-INF/MANIFEST.MF 30 Sep 2008 14:20:21 -0000 1.25 +++ META-INF/MANIFEST.MF 1 Oct 2008 18:28:45 -0000 @@ -20,6 +20,7 @@ org.eclipse.equinox.p2.updatechecker, org.eclipse.equinox.p2.console, org.eclipse.equinox.p2.director, + org.eclipse.equinox.p2.director.app, org.eclipse.equinox.p2.directorywatcher, org.eclipse.equinox.p2.engine, org.eclipse.equinox.p2.metadata.generator, #P org.eclipse.equinox.p2.artifact.repository Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF,v retrieving revision 1.27 diff -u -r1.27 MANIFEST.MF --- META-INF/MANIFEST.MF 26 Sep 2008 19:57:45 -0000 1.27 +++ META-INF/MANIFEST.MF 1 Oct 2008 18:28:46 -0000 @@ -13,6 +13,7 @@ org.eclipse.equinox.internal.provisional.p2.artifact.repository; x-friends:="org.eclipse.equinox.p2.artifact.optimizers, org.eclipse.equinox.p2.artifact.processors, + org.eclipse.equinox.p2.director.app, org.eclipse.equinox.p2.directorywatcher, org.eclipse.equinox.p2.metadata.generator, org.eclipse.equinox.p2.updatesite,