From 3ad938e16227692213f76b5b58571cc8549eb171 Mon Sep 17 00:00:00 2001 From: Ian Bull Date: Tue, 30 Mar 2010 22:26:28 +0000 Subject: bug 305237: [repository] Handle operation cancelled exception in execute batch https://bugs.eclipse.org/bugs/show_bug.cgi?id=305237 --- .../BatchExecuteArtifactRepositoryTest.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact') diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java index ba65a7ba9..ca1065c99 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java @@ -299,6 +299,31 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest } } + /* + * This tests that exceptions are properly propagated for a CompositeRepository + */ + public void testBatchProcessingCancelled() { + try { + Map properties = new HashMap(); + repositoryFile = getTempFolder(); + repositoryURI = repositoryFile.toURI(); + SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); + IProgressMonitor monitor = new NullProgressMonitor(); + monitor.setCanceled(true); + + IStatus status = repo.executeBatch(new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) { + if (monitor.isCanceled()) + throw new OperationCanceledException(); + } + }, monitor); + + assertTrue(status.getSeverity() == IStatus.CANCEL); + } catch (Exception e) { + fail("Test failed", e); + } + } + /* * This tests that exceptions are properly propagated for a CompositeRepository */ -- cgit v1.2.3