diff options
author | John Arthorne | 2009-05-14 18:51:58 +0000 |
---|---|---|
committer | John Arthorne | 2009-05-14 18:51:58 +0000 |
commit | a79adfbeb3c3a579cd211411f0fff34cbc66c8cf (patch) | |
tree | 50dce951ce35cfe0762f507993c113adcf4ec7ee | |
parent | 86446769d518abb6a83aa98584c9064fe7e9324e (diff) | |
download | rt.equinox.p2-a79adfbeb3c3a579cd211411f0fff34cbc66c8cf.tar.gz rt.equinox.p2-a79adfbeb3c3a579cd211411f0fff34cbc66c8cf.tar.xz rt.equinox.p2-a79adfbeb3c3a579cd211411f0fff34cbc66c8cf.zip |
Tests for bug 275975 [transport] cancelling the "timeout" test server took at least 2 min
4 files changed, 17 insertions, 11 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java index ad6eca7e8..da7df13f3 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java @@ -251,7 +251,7 @@ public abstract class AbstractRepositoryManager implements IRepositoryManager, P Assert.isNotNull(type); IRepository result = null; try { - enterLoad(location); + enterLoad(location, new NullProgressMonitor()); boolean loaded = false; try { //repository should not already exist @@ -313,15 +313,17 @@ public abstract class AbstractRepositoryManager implements IRepositoryManager, P * * @param location The location to lock */ - private void enterLoad(URI location) { + private void enterLoad(URI location, IProgressMonitor monitor) { Thread current = Thread.currentThread(); synchronized (loadLocks) { while (true) { Thread owner = (Thread) loadLocks.get(location); if (owner == null || current.equals(owner)) break; + if (monitor.isCanceled()) + throw new OperationCanceledException(); try { - loadLocks.wait(); + loadLocks.wait(1000); } catch (InterruptedException e) { //keep trying } @@ -594,7 +596,7 @@ public abstract class AbstractRepositoryManager implements IRepositoryManager, P IRepository result = null; try { - enterLoad(location); + enterLoad(location, monitor); result = basicGetRepository(location); if (result != null) return result; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java index 11a636d6d..9a1399e06 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java @@ -115,7 +115,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { // The download succeeded assertTrue(request.getResult().toString(), request.getResult().isOK()); // All available mirrors used - assertTrue("All mirrors utilized", selector.index == selector.mirrors.length); + assertEquals("All mirrors utilized", selector.mirrors.length, selector.index); } /* @@ -338,16 +338,19 @@ public class MirrorRequestTest extends AbstractProvisioningTest { } // Overridden to prevent mirror sorting + @Override public synchronized void reportResult(String toDownload, IStatus result) { return; } // We want to test each mirror once. + @Override public synchronized boolean hasValidMirror() { return mirrors != null && index < mirrors.length; } - public synchronized URI getMirrorLocation(URI inputLocation) { + @Override + public synchronized URI getMirrorLocation(URI inputLocation, IProgressMonitor monitor) { return URIUtil.append(nextMirror(), repoLocation.relativize(inputLocation).getPath()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java index 9b1b9585c..e6c525e03 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java @@ -63,8 +63,7 @@ public class TimeoutTest extends AbstractTestServerClientCase { transport.getLastModified(toDownload, null); break; case STREAM : - transport.stream(toDownload); - // transport.stream(toDownload, null); // + transport.stream(toDownload, null); break; } } catch (OperationCanceledException e) { @@ -155,8 +154,7 @@ public class TimeoutTest extends AbstractTestServerClientCase { transport.getLastModified(toDownload, monitor); break; case STREAM : - transport.stream(toDownload); - // transport.stream(toDownload, null); // + transport.stream(toDownload, monitor); break; } } catch (OperationCanceledException e) { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java index dfa4d35a5..728e3e137 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java @@ -851,16 +851,19 @@ public class UpdateSiteTest extends AbstractProvisioningTest { } // Overridden to prevent mirror sorting + @Override public synchronized void reportResult(String toDownload, IStatus result) { return; } // We want to test each mirror once. + @Override public synchronized boolean hasValidMirror() { return mirrors != null && index < mirrors.length; } - public synchronized URI getMirrorLocation(URI inputLocation) { + @Override + public synchronized URI getMirrorLocation(URI inputLocation, IProgressMonitor monitor) { return URIUtil.append(nextMirror(), repoLocation.relativize(inputLocation).getPath()); } |