Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-09-16 22:20:15 -0400
committerRyan D. Brooks2010-09-16 22:20:15 -0400
commit916c579b09ac251268d67ae10fcabccfc19be7a7 (patch)
tree66bf0c42b72b3837ccfe8118fbbf24908334b9cb /plugins
parentc443fd722b994f018e0ff763b198616dea1bb1c0 (diff)
downloadorg.eclipse.osee-916c579b09ac251268d67ae10fcabccfc19be7a7.tar.gz
org.eclipse.osee-916c579b09ac251268d67ae10fcabccfc19be7a7.tar.xz
org.eclipse.osee-916c579b09ac251268d67ae10fcabccfc19be7a7.zip
bug[ats_UNJKK]: Add SearchStatisticsTest to search engine test suite0.9.6.v201009170005_RC
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/AllSearchEngineTestSuite.java3
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/InternalTestSuite.java28
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/search/InternalSearchTestSuite.java27
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/search/SearchStatisticsTest.java109
4 files changed, 166 insertions, 1 deletions
diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/AllSearchEngineTestSuite.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/AllSearchEngineTestSuite.java
index a52aab336d..55f21a5155 100644
--- a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/AllSearchEngineTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/AllSearchEngineTestSuite.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.search.engine.test;
import org.eclipse.osee.framework.search.engine.test.attribute.AttributeTestSuite;
+import org.eclipse.osee.framework.search.engine.test.internal.InternalTestSuite;
import org.eclipse.osee.framework.search.engine.test.language.LanguageTestSuite;
import org.eclipse.osee.framework.search.engine.test.utility.UtilityTestSuite;
import org.junit.runner.RunWith;
@@ -23,9 +24,9 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({
//@formatter:off
AttributeTestSuite.class,
+ InternalTestSuite.class,
LanguageTestSuite.class,
UtilityTestSuite.class,
- SearchResultToXmlOperationTest.class,
//@formatter:on
})
public class AllSearchEngineTestSuite {
diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/InternalTestSuite.java
new file mode 100644
index 0000000000..86cdffa26a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/InternalTestSuite.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.search.engine.test.internal;
+
+import org.eclipse.osee.framework.search.engine.test.internal.search.InternalSearchTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+//@formatter:off
+ InternalSearchTestSuite.class,
+//@formatter:on
+})
+public class InternalTestSuite {
+ // Test Suite Class
+}
diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/search/InternalSearchTestSuite.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/search/InternalSearchTestSuite.java
new file mode 100644
index 0000000000..562006f0c1
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/search/InternalSearchTestSuite.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.search.engine.test.internal.search;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+//@formatter:off
+ SearchStatisticsTest.class,
+//@formatter:on
+})
+public class InternalSearchTestSuite {
+ // Test Suite Class
+}
diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/search/SearchStatisticsTest.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/search/SearchStatisticsTest.java
new file mode 100644
index 0000000000..4be6405d01
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/internal/search/SearchStatisticsTest.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.search.engine.test.internal.search;
+
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.message.SearchRequest;
+import org.eclipse.osee.framework.search.engine.internal.search.SearchStatistics;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Case for {@link SearchStatistics}
+ *
+ * @author Roberto E. Escobar
+ */
+public class SearchStatisticsTest {
+
+ private static SearchRequest searchRequest1;
+ private static SearchRequest searchRequest2;
+ private static SearchRequest searchRequest3;
+
+ @BeforeClass
+ public static void setup() {
+ searchRequest1 = new SearchRequest(CoreBranches.COMMON, "[hello]");
+ searchRequest2 = new SearchRequest(CoreBranches.SYSTEM_ROOT, "short search");
+ searchRequest3 = new SearchRequest(CoreBranches.SYSTEM_ROOT, "long search");
+ }
+
+ @Test
+ public void testEmptyStats() {
+ checkStat(SearchStatistics.EMPTY_STATS, 0, 0, 0, "");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testEmptyStatsAdd() throws OseeCoreException {
+ SearchStatistics.EMPTY_STATS.addEntry(null, -1, -1);
+ }
+
+ @Test(expected = OseeArgumentException.class)
+ public void testAddNullSearchRequest() throws OseeCoreException {
+ SearchStatistics actual = new SearchStatistics();
+ actual.addEntry(null, 0, 0);
+ }
+
+ @Test
+ public void testStatistics() throws OseeCoreException {
+ SearchStatistics actual = new SearchStatistics();
+ checkStat(actual, 0, 0, 0, "");
+
+ actual.addEntry(searchRequest1, 3, 500);
+ checkStat(actual, 500, 500, 1, searchRequest1.toString() + " - [3 in 500 ms]");
+
+ actual.addEntry(searchRequest2, 10, 499);
+ long expectedAverage = (500 + 499) / 2;
+ checkStat(actual, expectedAverage, 500, 2, searchRequest1.toString() + " - [3 in 500 ms]");
+
+ actual.addEntry(searchRequest3, 20000, 501);
+ expectedAverage = (500 + 499 + 501) / 3;
+ checkStat(actual, expectedAverage, 501, 3, searchRequest3.toString() + " - [20000 in 501 ms]");
+
+ actual.clear();
+ checkStat(actual, 0, 0, 0, "");
+ }
+
+ @Test
+ public void testClear() throws OseeCoreException {
+ SearchStatistics actual = new SearchStatistics();
+ checkStat(actual, 0, 0, 0, "");
+ actual.addEntry(searchRequest1, 7, 111111);
+
+ checkStat(actual, 111111, 111111, 1, searchRequest1.toString() + " - [7 in 111111 ms]");
+ actual.clear();
+ checkStat(actual, 0, 0, 0, "");
+ }
+
+ @Test
+ public void testClone() throws OseeCoreException, CloneNotSupportedException {
+ SearchStatistics actual = new SearchStatistics();
+ checkStat(actual, 0, 0, 0, "");
+ actual.addEntry(searchRequest1, 7, 111111);
+ checkStat(actual, 111111, 111111, 1, searchRequest1.toString() + " - [7 in 111111 ms]");
+
+ SearchStatistics copy = actual.clone();
+ Assert.assertTrue(!actual.equals(copy));
+
+ actual.clear();
+ checkStat(actual, 0, 0, 0, "");
+ checkStat(copy, 111111, 111111, 1, searchRequest1.toString() + " - [7 in 111111 ms]");
+
+ }
+
+ private static void checkStat(SearchStatistics actual, long average, long longest, int total, String longestData) {
+ Assert.assertEquals(average, actual.getAverageSearchTime());
+ Assert.assertEquals(longest, actual.getLongestSearchTime());
+ Assert.assertEquals(total, actual.getTotalSearches());
+ Assert.assertEquals(longestData, actual.getLongestSearch());
+ }
+}

Back to the top