diff options
author | Chris Goldthorpe | 2011-10-13 17:10:03 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2011-10-13 17:10:03 +0000 |
commit | 673b49e2a9561cd1c82717523e29da497c91c804 (patch) | |
tree | ab8a41ca4d1fc6bd33d7c44e4da1e09801c65f9c /org.eclipse.ua.tests/help/org | |
parent | 33cfd4bc66bb10c3ac10931113170dc5779e0ed6 (diff) | |
download | eclipse.platform.ua-673b49e2a9561cd1c82717523e29da497c91c804.tar.gz eclipse.platform.ua-673b49e2a9561cd1c82717523e29da497c91c804.tar.xz eclipse.platform.ua-673b49e2a9561cd1c82717523e29da497c91c804.zip |
Fix tests for Search index locking to work on SUN JREs
Diffstat (limited to 'org.eclipse.ua.tests/help/org')
-rw-r--r-- | org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java index b5a69408c..55ffa0f20 100644 --- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java +++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java @@ -11,6 +11,8 @@ package org.eclipse.ua.tests.help.search; +import java.nio.channels.OverlappingFileLockException; + import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -28,18 +30,30 @@ public class LockTest extends TestCase { public void testSingleLock() { SearchIndex index1 = new SearchIndex(null, null, null); - boolean try1 = index1.tryLock(); - assertTrue(try1); + try { + boolean try1 = index1.tryLock(); + assertTrue(try1); + } catch (OverlappingFileLockException e1) { + fail("Exception thrown"); + } index1.releaseLock(); } public void testCompetingLocks() { SearchIndex index1 = new SearchIndex(null, null, null); - boolean try1 = index1.tryLock(); - assertTrue(try1); + try { + boolean try1 = index1.tryLock(); + assertTrue(try1); + } catch (OverlappingFileLockException e1) { + fail("Exception thrown"); + } SearchIndex index2 = new SearchIndex(null, null, null); - boolean try2 = index2.tryLock(); - assertFalse(try2); + try { + boolean try2 = index2.tryLock(); + assertFalse(try2); + } catch (OverlappingFileLockException e) { + // Throwing this exception or returning false is the expected result + } index1.releaseLock(); index2.releaseLock(); } @@ -47,12 +61,20 @@ public class LockTest extends TestCase { public void testNonCompetingLocks() { SearchIndex index1 = new SearchIndex(null, null, null); - boolean try1 = index1.tryLock(); - assertTrue(try1); + try { + boolean try1 = index1.tryLock(); + assertTrue(try1); + } catch (OverlappingFileLockException e1) { + fail("Exception thrown"); + } index1.releaseLock(); SearchIndex index2 = new SearchIndex(null, null, null); - boolean try2 = index2.tryLock(); - assertTrue(try2); + try { + boolean try2 = index2.tryLock(); + assertTrue(try2); + } catch (OverlappingFileLockException e) { + fail("Exception thrown"); + } index2.releaseLock(); } |