View | Details | Raw Unified | Return to bug 248045 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (+1 lines)
Lines 51-56 Link Here
51
 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",
51
 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",
52
 org.eclipse.equinox.internal.provisional.p2.core;
52
 org.eclipse.equinox.internal.provisional.p2.core;
53
  x-friends:="org.eclipse.equinox.p2.artifact.repository,
53
  x-friends:="org.eclipse.equinox.p2.artifact.repository,
54
   org.eclipse.equinox.p2.director.app,
54
   org.eclipse.equinox.p2.extensionlocation,
55
   org.eclipse.equinox.p2.extensionlocation,
55
   org.eclipse.equinox.p2.metadata.repository,
56
   org.eclipse.equinox.p2.metadata.repository,
56
   org.eclipse.equinox.p2.ui,
57
   org.eclipse.equinox.p2.ui,
(-)src/org/eclipse/equinox/p2/tests/director/AllTests.java (+1 lines)
Lines 32-37 Link Here
32
		suite.addTestSuite(SingletonTest.class);
32
		suite.addTestSuite(SingletonTest.class);
33
		suite.addTestSuite(UninstallTest.class);
33
		suite.addTestSuite(UninstallTest.class);
34
		suite.addTestSuite(UpdateTest.class);
34
		suite.addTestSuite(UpdateTest.class);
35
		suite.addTestSuite(DirectorAppTest.class);
35
		return suite;
36
		return suite;
36
	}
37
	}
37
38
(-)src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java (+162 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: IBM Corporation - initial API and implementation
8
 ******************************************************************************/
9
package org.eclipse.equinox.p2.tests.director;
10
11
import java.io.File;
12
import java.net.MalformedURLException;
13
import java.net.URL;
14
import java.util.HashMap;
15
import java.util.Map;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.equinox.app.IApplicationContext;
18
import org.eclipse.equinox.internal.p2.director.app.Application;
19
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
20
import org.osgi.framework.Bundle;
21
22
/**
23
 * Various automated tests of the {@link IDirector} API.
24
 */
25
public class DirectorAppTest extends AbstractProvisioningTest {
26
27
	/**
28
	 * runs default director app.
29
	 */
30
	private void runDirectorApp(final String message, final URL metadata, final URL artifact, final URL destination, final String installIU) throws Exception {
31
		Application application = new Application();
32
		application.start(new IApplicationContext() {
33
34
			public void applicationRunning() {
35
			}
36
37
			public Map getArguments() {
38
				Map arguments = new HashMap();
39
40
				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"});
41
42
				return arguments;
43
			}
44
45
			public String getBrandingApplication() {
46
				return null;
47
			}
48
49
			public Bundle getBrandingBundle() {
50
				return null;
51
			}
52
53
			public String getBrandingDescription() {
54
				return null;
55
			}
56
57
			public String getBrandingId() {
58
				return null;
59
			}
60
61
			public String getBrandingName() {
62
				return null;
63
			}
64
65
			public String getBrandingProperty(String key) {
66
				return null;
67
			}
68
		});
69
	}
70
71
	public void testRepoCreationBothInvalid() {
72
		//Setup: Create the folders
73
		File metadataRepo = new File(getTempFolder(), "DirectorApp Metadata");
74
		File artifactRepo = new File(getTempFolder(), "DirectorApp Artifact");
75
		File destinationRepo = new File(getTempFolder(), "DirectorApp Destination");
76
		String installIU = "invalidIU";
77
78
		//Setup: ensure folders do not exist
79
		delete(metadataRepo);
80
		delete(artifactRepo);
81
		delete(destinationRepo);
82
83
		try {
84
			runDirectorApp("1.0", metadataRepo.toURL(), artifactRepo.toURL(), destinationRepo.toURL(), installIU);
85
		} catch (MalformedURLException e) {
86
			fail("1.1", e);
87
		} catch (CoreException e) {
88
			//fall through
89
		} catch (Exception e) {
90
			fail("1.2", e);
91
		}
92
93
		//ensures that repositories have not been mistakenly created
94
		assertTrue("1.3", !metadataRepo.exists());
95
		assertTrue("1.4", !artifactRepo.exists());
96
97
		//Cleanup: delete the folders
98
		delete(metadataRepo);
99
		delete(artifactRepo);
100
		delete(destinationRepo);
101
	}
102
103
	public void testRepoCreationMetadataInvalid() {
104
		//Setup: create repos
105
		File metadataRepo = new File(getTempFolder(), "DirectorApp Metadata");
106
		File artifactRepo = getTestData("2.0", "/testData/mirror/mirrorSourceRepo1");
107
		File destinationRepo = new File(getTempFolder(), "DirectorApp Destination");
108
		String installIU = "invalidIU";
109
110
		//Setup: ensure folders do not exist
111
		delete(metadataRepo);
112
		delete(destinationRepo);
113
114
		try {
115
			runDirectorApp("2.1", metadataRepo.toURL(), artifactRepo.toURL(), destinationRepo.toURL(), installIU);
116
		} catch (MalformedURLException e) {
117
			fail("2.2", e);
118
		} catch (CoreException e) {
119
			//fall through
120
		} catch (Exception e) {
121
			fail("2.3", e);
122
		}
123
124
		//ensures that repository has not been mistakenly created
125
		assertTrue("2.4", !metadataRepo.exists());
126
		assertTrue("2.5", artifactRepo.exists());
127
128
		//Cleanup: delete the folders
129
		delete(metadataRepo);
130
		delete(destinationRepo);
131
	}
132
133
	public void testRepoCreationArtifactInvalid() {
134
		//Setup: create repos
135
		File metadataRepo = getTestData("3.0", "/testData/mirror/mirrorSourceRepo1");
136
		File artifactRepo = new File(getTempFolder(), "DirectorApp Artifact");
137
		File destinationRepo = new File(getTempFolder(), "DirectorApp Destination");
138
		String installIU = "invalidIU";
139
140
		//Setup: ensure folders do not exist
141
		delete(artifactRepo);
142
		delete(destinationRepo);
143
144
		try {
145
			runDirectorApp("3.1", metadataRepo.toURL(), artifactRepo.toURL(), destinationRepo.toURL(), installIU);
146
		} catch (MalformedURLException e) {
147
			fail("3.2", e);
148
		} catch (CoreException e) {
149
			//fall through
150
		} catch (Exception e) {
151
			fail("3.3", e);
152
		}
153
154
		//ensures that repository has not been mistakenly created
155
		assertTrue("3.4", !artifactRepo.exists());
156
		assertTrue("3.5", metadataRepo.exists());
157
158
		//Cleanup: delete the folders
159
		delete(artifactRepo);
160
		delete(destinationRepo);
161
	}
162
}
(-)src/org/eclipse/equinox/internal/p2/director/app/Application.java (-2 / +13 lines)
Lines 21-30 Link Here
21
import org.eclipse.equinox.internal.p2.console.ProvisioningHelper;
21
import org.eclipse.equinox.internal.p2.console.ProvisioningHelper;
22
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
22
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
23
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
23
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
24
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
25
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
24
import org.eclipse.equinox.internal.provisional.p2.director.*;
26
import org.eclipse.equinox.internal.provisional.p2.director.*;
25
import org.eclipse.equinox.internal.provisional.p2.engine.*;
27
import org.eclipse.equinox.internal.provisional.p2.engine.*;
26
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
28
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
27
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
29
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
30
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
28
import org.eclipse.equinox.internal.provisional.p2.query.Collector;
31
import org.eclipse.equinox.internal.provisional.p2.query.Collector;
29
import org.eclipse.osgi.service.resolver.VersionRange;
32
import org.eclipse.osgi.service.resolver.VersionRange;
30
import org.eclipse.osgi.util.NLS;
33
import org.eclipse.osgi.util.NLS;
Lines 166-181 Link Here
166
			if (throwException)
169
			if (throwException)
167
				missingArgument("artifactRepository"); //$NON-NLS-1$
170
				missingArgument("artifactRepository"); //$NON-NLS-1$
168
		} else {
171
		} else {
172
			IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
173
			if (manager == null)
174
				throw new ProvisionException(Messages.Application_NoManager);
169
			for (int i = 0; i < artifactRepositoryLocations.length; i++)
175
			for (int i = 0; i < artifactRepositoryLocations.length; i++)
170
				ProvisioningHelper.addArtifactRepository(artifactRepositoryLocations[i]);
176
				//Try and load each repository. Throws exception if one cannot be loaded (such as if it is invalid)
177
				manager.loadRepository(artifactRepositoryLocations[i], null);
171
		}
178
		}
172
179
173
		if (metadataRepositoryLocations == null) {
180
		if (metadataRepositoryLocations == null) {
174
			if (throwException)
181
			if (throwException)
175
				missingArgument("metadataRepository"); //$NON-NLS-1$
182
				missingArgument("metadataRepository"); //$NON-NLS-1$
176
		} else {
183
		} else {
184
			IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
185
			if (manager == null)
186
				throw new ProvisionException(Messages.Application_NoManager);
177
			for (int i = 0; i < metadataRepositoryLocations.length; i++)
187
			for (int i = 0; i < metadataRepositoryLocations.length; i++)
178
				ProvisioningHelper.addMetadataRepository(metadataRepositoryLocations[i]);
188
				//Try and load each repository. Throws exception if one cannot be loaded (such as if it is invalid)
189
				manager.loadRepository(metadataRepositoryLocations[i], null);
179
		}
190
		}
180
	}
191
	}
181
192
(-)src/org/eclipse/equinox/internal/p2/director/app/Messages.java (+1 lines)
Lines 29-34 Link Here
29
29
30
	public static String Listing;
30
	public static String Listing;
31
	public static String Ambigous_Command;
31
	public static String Ambigous_Command;
32
	public static String Application_NoManager;
32
	public static String Missing_Required_Argument;
33
	public static String Missing_Required_Argument;
33
34
34
	public static String Installing;
35
	public static String Installing;
(-)src/org/eclipse/equinox/internal/p2/director/app/messages.properties (+1 lines)
Lines 24-29 Link Here
24
Missing_IU=The installable unit {0} has not been found.
24
Missing_IU=The installable unit {0} has not been found.
25
Missing_Required_Argument=Missing required argument -{0}.
25
Missing_Required_Argument=Missing required argument -{0}.
26
Ambigous_Command=Cannot execute both {0} and {1} in one invocation
26
Ambigous_Command=Cannot execute both {0} and {1} in one invocation
27
Application_NoManager=Error occured while aquiring manager
27
Listing=Listing Installable Units from {0}
28
Listing=Listing Installable Units from {0}
28
Installing=Installing {0} {1}.
29
Installing=Installing {0} {1}.
29
Uninstalling=Uninstalling {0} {1}.
30
Uninstalling=Uninstalling {0} {1}.
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 10-15 Link Here
10
 org.eclipse.equinox.internal.p2.core.helpers,
10
 org.eclipse.equinox.internal.p2.core.helpers,
11
 org.eclipse.equinox.internal.p2.engine,
11
 org.eclipse.equinox.internal.p2.engine,
12
 org.eclipse.equinox.internal.provisional.p2.artifact.repository,
12
 org.eclipse.equinox.internal.provisional.p2.artifact.repository,
13
 org.eclipse.equinox.internal.provisional.p2.core,
13
 org.eclipse.equinox.internal.provisional.p2.core.location,
14
 org.eclipse.equinox.internal.provisional.p2.core.location,
14
 org.eclipse.equinox.internal.provisional.p2.director,
15
 org.eclipse.equinox.internal.provisional.p2.director,
15
 org.eclipse.equinox.internal.provisional.p2.engine,
16
 org.eclipse.equinox.internal.provisional.p2.engine,
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 20-25 Link Here
20
   org.eclipse.equinox.p2.updatechecker,
20
   org.eclipse.equinox.p2.updatechecker,
21
   org.eclipse.equinox.p2.console,
21
   org.eclipse.equinox.p2.console,
22
   org.eclipse.equinox.p2.director,
22
   org.eclipse.equinox.p2.director,
23
   org.eclipse.equinox.p2.director.app,
23
   org.eclipse.equinox.p2.directorywatcher,
24
   org.eclipse.equinox.p2.directorywatcher,
24
   org.eclipse.equinox.p2.engine,
25
   org.eclipse.equinox.p2.engine,
25
   org.eclipse.equinox.p2.metadata.generator,
26
   org.eclipse.equinox.p2.metadata.generator,
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 13-18 Link Here
13
 org.eclipse.equinox.internal.provisional.p2.artifact.repository;
13
 org.eclipse.equinox.internal.provisional.p2.artifact.repository;
14
  x-friends:="org.eclipse.equinox.p2.artifact.optimizers,
14
  x-friends:="org.eclipse.equinox.p2.artifact.optimizers,
15
   org.eclipse.equinox.p2.artifact.processors,
15
   org.eclipse.equinox.p2.artifact.processors,
16
   org.eclipse.equinox.p2.director.app,
16
   org.eclipse.equinox.p2.directorywatcher,
17
   org.eclipse.equinox.p2.directorywatcher,
17
   org.eclipse.equinox.p2.metadata.generator,
18
   org.eclipse.equinox.p2.metadata.generator,
18
   org.eclipse.equinox.p2.updatesite,
19
   org.eclipse.equinox.p2.updatesite,

Return to bug 248045