Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 276562
Collapse All | Expand All

(-)src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java (-2 / +41 lines)
Lines 17-24 Link Here
17
import java.util.*;
17
import java.util.*;
18
import junit.framework.Test;
18
import junit.framework.Test;
19
import junit.framework.TestSuite;
19
import junit.framework.TestSuite;
20
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.*;
21
import org.eclipse.core.runtime.NullProgressMonitor;
21
import org.eclipse.core.runtime.jobs.Job;
22
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
22
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
23
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
23
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
24
import org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager;
24
import org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager;
Lines 212-217 Link Here
212
	}
212
	}
213
213
214
	/**
214
	/**
215
	 * Tests contention for the repository load lock
216
	 */
217
	public void testLoadContention() {
218
		File site = getTestData("Repositoy", "/testData/metadataRepo/good/");
219
		final URI location = site.toURI();
220
		final List<Exception> failures = new ArrayList<Exception>();
221
		final IMetadataRepositoryManager repoManager = getMetadataRepositoryManager();
222
		class LoadJob extends Job {
223
			LoadJob() {
224
				super("");
225
			}
226
227
			@Override
228
			protected IStatus run(IProgressMonitor monitor) {
229
				for (int i = 0; i < 100; i++) {
230
					try {
231
						repoManager.loadRepository(location, null);
232
					} catch (Exception e) {
233
						failures.add(e);
234
					}
235
				}
236
				return Status.OK_STATUS;
237
			}
238
		}
239
		Job job1 = new LoadJob();
240
		Job job2 = new LoadJob();
241
		job1.schedule();
242
		job2.schedule();
243
		try {
244
			job1.join();
245
			job2.join();
246
		} catch (InterruptedException e) {
247
			fail("4.99", e);
248
		}
249
		if (!failures.isEmpty())
250
			fail("1.0", failures.iterator().next());
251
	}
252
253
	/**
215
	 * Tests loading a repository that does not exist throws an appropriate exception.
254
	 * Tests loading a repository that does not exist throws an appropriate exception.
216
	 */
255
	 */
217
	public void testLoadMissingRepository() throws IOException {
256
	public void testLoadMissingRepository() throws IOException {
(-)src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java (+2 lines)
Lines 592-597 Link Here
592
592
593
	protected IRepository loadRepository(URI location, IProgressMonitor monitor, String type, int flags) throws ProvisionException {
593
	protected IRepository loadRepository(URI location, IProgressMonitor monitor, String type, int flags) throws ProvisionException {
594
		checkValidLocation(location);
594
		checkValidLocation(location);
595
		if (monitor == null)
596
			monitor = new NullProgressMonitor();
595
		boolean added = false;
597
		boolean added = false;
596
		IRepository result = null;
598
		IRepository result = null;
597
599

Return to bug 276562