Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2011-10-12 21:51:09 +0000
committerChris Goldthorpe2011-10-12 21:51:09 +0000
commit33cfd4bc66bb10c3ac10931113170dc5779e0ed6 (patch)
treed8e857ea656e9a78edaa1b1b1d7a1bf4dece8dc4 /org.eclipse.ua.tests/help
parenta060838fb5b749bf2632e890047e823ade6e9760 (diff)
downloadeclipse.platform.ua-33cfd4bc66bb10c3ac10931113170dc5779e0ed6.tar.gz
eclipse.platform.ua-33cfd4bc66bb10c3ac10931113170dc5779e0ed6.tar.xz
eclipse.platform.ua-33cfd4bc66bb10c3ac10931113170dc5779e0ed6.zip
Add tests for Search index locking
Diffstat (limited to 'org.eclipse.ua.tests/help')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java1
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java59
2 files changed, 60 insertions, 0 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
index 7e0fd10aa..4216e92ee 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
@@ -46,5 +46,6 @@ public class AllSearchTests extends TestSuite {
addTestSuite(WorkingSetManagerTest.class);
addTestSuite(InfocenterWorkingSetManagerTest.class);
addTestSuite(PrebuiltIndexCompatibility.class);
+ addTestSuite(LockTest.class);
}
}
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
new file mode 100644
index 000000000..b5a69408c
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/LockTest.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ua.tests.help.search;
+
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.help.internal.search.SearchIndex;
+
+/**
+ * Test locking of search index
+ */
+public class LockTest extends TestCase {
+
+ public static Test suite() {
+ return new TestSuite(LockTest.class);
+ }
+
+ public void testSingleLock() {
+ SearchIndex index1 = new SearchIndex(null, null, null);
+ boolean try1 = index1.tryLock();
+ assertTrue(try1);
+ index1.releaseLock();
+ }
+
+ public void testCompetingLocks() {
+ SearchIndex index1 = new SearchIndex(null, null, null);
+ boolean try1 = index1.tryLock();
+ assertTrue(try1);
+ SearchIndex index2 = new SearchIndex(null, null, null);
+ boolean try2 = index2.tryLock();
+ assertFalse(try2);
+ index1.releaseLock();
+ index2.releaseLock();
+ }
+
+
+ public void testNonCompetingLocks() {
+ SearchIndex index1 = new SearchIndex(null, null, null);
+ boolean try1 = index1.tryLock();
+ assertTrue(try1);
+ index1.releaseLock();
+ SearchIndex index2 = new SearchIndex(null, null, null);
+ boolean try2 = index2.tryLock();
+ assertTrue(try2);
+ index2.releaseLock();
+ }
+
+}

Back to the top