diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.search.engine.test')
14 files changed, 1006 insertions, 1006 deletions
diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/.classpath b/plugins/org.eclipse.osee.framework.search.engine.test/.classpath index 8a8f1668cdc..ad32c83a788 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/.classpath +++ b/plugins/org.eclipse.osee.framework.search.engine.test/.classpath @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/.project b/plugins/org.eclipse.osee.framework.search.engine.test/.project index 0abdb5d263e..40717cbb75a 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/.project +++ b/plugins/org.eclipse.osee.framework.search.engine.test/.project @@ -1,28 +1,28 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.osee.framework.search.engine.test</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.framework.search.engine.test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/build.properties b/plugins/org.eclipse.osee.framework.search.engine.test/build.properties index 41eb6ade2b4..34d2e4d2dad 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/build.properties +++ b/plugins/org.eclipse.osee.framework.search.engine.test/build.properties @@ -1,4 +1,4 @@ -source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/data/test1.tags.txt b/plugins/org.eclipse.osee.framework.search.engine.test/data/test1.tags.txt index f74c2bc6655..4fc21e04f82 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/data/test1.tags.txt +++ b/plugins/org.eclipse.osee.framework.search.engine.test/data/test1.tags.txt @@ -1,4 +1,4 @@ -this 103194
-is 402
-a 10
+this 103194 +is 402 +a 10 test 113146
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/data/test2.tags.txt b/plugins/org.eclipse.osee.framework.search.engine.test/data/test2.tags.txt index 2843136d53c..f811f09752f 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/data/test2.tags.txt +++ b/plugins/org.eclipse.osee.framework.search.engine.test/data/test2.tags.txt @@ -1,6 +1,6 @@ -inside 15546706
-element 459231038
-outside 248748982
-element 459231038
-no 373
+inside 15546706 +element 459231038 +outside 248748982 +element 459231038 +no 373 nesting 290699765
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/data/test3.tags.txt b/plugins/org.eclipse.osee.framework.search.engine.test/data/test3.tags.txt index 3275c576a7c..f949807d9c5 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/data/test3.tags.txt +++ b/plugins/org.eclipse.osee.framework.search.engine.test/data/test3.tags.txt @@ -1,8 +1,8 @@ -i 18
-am 330
-going 1135472
-to 378
-test 113146
-appendix -220858502
-this 103194
+i 18 +am 330 +going 1135472 +to 378 +test 113146 +appendix -220858502 +this 103194 time 62778
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/data/test4.tags.txt b/plugins/org.eclipse.osee.framework.search.engine.test/data/test4.tags.txt index 9741207e1e1..53cf5d19946 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/data/test4.tags.txt +++ b/plugins/org.eclipse.osee.framework.search.engine.test/data/test4.tags.txt @@ -1,280 +1,280 @@ -test 113146
-objective -743637058
-the 3866
-objective -743637058
-of 246
-this 103194
-test 113146
-is 402
-to 378
-verify 32454908
-that 109338
-the 3866
-system 22002169
-power 1637751
-and 3418
-external 995687422
-store 1021881
-subsystem -73425987
-satisfy 519649977
-the 3866
-physical 986947351
-and 3418
-functional 1463473599
-requirement 1335083006
-specification -755499013
-success 429837753
-criterion 1938797469
-successful -107033157
-completion 989033854
-of 246
-the 3866
-item 85938
-external 995687422
-store 1021881
-ground 14006160
-test 113146
-procedure -1679894625
-doc 3437
-tbd 3514
-which 1168157
-satisfy 519649977
-test 113146
-verification -1389395970
-requirement 1335083006
-as 410
-specified -218968195
-in 338
-the 3866
-xiv 7487
-test 113146
-approach 481793914
-condition 1941099901
-the 3866
-test 113146
-sequence -312492039
-will 78653
-be 235
-conducted -86256275
-in 338
-the 3866
-lab 2995
-using 1135515
-external 995687422
-power 1637751
-note 64373
-that 109338
-requirement 1335083006
-associated -1423083042
-with 72509
-rate 64184
-timing 18167098
-and 3418
-power 1637751
-up 379
-will 78653
-be 235
-verified -550553348
-in 338
-the 3866
-lab 2995
-likewise -113377485
-performance -1248395529
-and 3418
-safety 33222585
-inhibit 455815506
-associated -1423083042
-with 72509
-the 3866
-power 1637751
-system 22002169
-as 410
-well 78845
-as 410
-other 1634742
-system 22002169
-will 78653
-be 235
-verified -550553348
-in 338
-the 3866
-lab 2995
-finally 523482415
-testing 290699770
-will 78653
-be 235
-constrained 731618813
-to 378
-functional 1463473599
-assurance -709248610
-only 127830
-as 410
-fault 1784751
-insertion 1941502295
-testing 290699770
-will 78653
-be 235
-performed -174655233
-in 338
-the 3866
-lab 2995
-the 3866
-power 1637751
-external 995687422
-store 1021881
-and 3418
-other 1634742
-testing 290699770
-will 78653
-encompass -1686803105
-the 3866
-following 1406612351
-functional 1463473599
-area 44938
-power 1637751
-subsystem -73425987
-control 326743404
-and 3418
-display 515078445
-to 378
-include 249249106
-symbology 389461503
-power 1637751
-type 63482
-and 3418
-inventory -1749680802
-management -185551435
-power 1637751
-mode 60788
-control 326743404
-power 1637751
-start 1805241
-up 379
-power 1637751
-using 1135515
-box 16235
-power 1637751
-subsystem -73425987
-initialization 871873535
-power 1637751
-training 355806106
-mode 60788
-operation 1940623223
-fuel 81855
-present 459251607
-and 3418
-empty 2078542
-status 26979257
-detection 1940716285
-from 87951
-each 72878
-power 1637751
-station 359902137
-selective -743640065
-and 3418
-emergency -705589410
-power 1637751
-from 87951
-each 72878
-station 359902137
-and 3418
-other 1634742
-station 359902137
-test 113146
-data 47789
-required -543965192
-one 3926
-and 3418
-two 6106
-recording 1389980920
-channel 334846748
-a1 26
-a5 90
-and 3418
-a9 154
-at 426
-minimum 364197172
-item 85938
-under 1633627
-test 113146
-the 3866
-component 1599567230
-under 1633627
-test 113146
-include 249249106
-power 1637751
-assembly -206243430
-include 249249106
-system 22002169
-1 1
-maintenance -1241817355
-panel 1308087
-power 1637751
-panel 1308087
-software -121786503
-special 330485625
-or 406
-major 1671092
-test 113146
-support 462911417
-equipment 1599552510
-the 3866
-following 1406612351
-test 113146
-support 462911417
-equipment 1599552510
-will 78653
-be 235
-required -543965192
-to 378
-facilitate -1154274049
-execution 1941688319
-of 246
-the 3866
-test 113146
-event 1793998
-power 1637751
-item 85938
-installed -214189729
-on 342
-each 72878
-station 359902137
-10 1
-total 1293178
-box 16235
-16 97
-total 1293178
-power 1637751
-simulator 2058597689
-11 17
-total 1293178
-fuel 81855
-tank 259514
-simulator 2058597689
-test 113146
-set 6905
-123456789 -2023406807
-portable -205801097
-workstation -1413743233
-monitor 427505012
-special 330485625
-consideration -1898448914
-remark 66630904
-test 113146
-system 22002169
-must 113076
-be 235
-fitted 14662447
-with 72509
-a 10
-functional 1463473599
-system 22002169
-1 1
-system 22002169
-2 2
-and 3418
-system 22002169
-3 3
-to 378
-include 249249106
+test 113146 +objective -743637058 +the 3866 +objective -743637058 +of 246 +this 103194 +test 113146 +is 402 +to 378 +verify 32454908 +that 109338 +the 3866 +system 22002169 +power 1637751 +and 3418 +external 995687422 +store 1021881 +subsystem -73425987 +satisfy 519649977 +the 3866 +physical 986947351 +and 3418 +functional 1463473599 +requirement 1335083006 +specification -755499013 +success 429837753 +criterion 1938797469 +successful -107033157 +completion 989033854 +of 246 +the 3866 +item 85938 +external 995687422 +store 1021881 +ground 14006160 +test 113146 +procedure -1679894625 +doc 3437 +tbd 3514 +which 1168157 +satisfy 519649977 +test 113146 +verification -1389395970 +requirement 1335083006 +as 410 +specified -218968195 +in 338 +the 3866 +xiv 7487 +test 113146 +approach 481793914 +condition 1941099901 +the 3866 +test 113146 +sequence -312492039 +will 78653 +be 235 +conducted -86256275 +in 338 +the 3866 +lab 2995 +using 1135515 +external 995687422 +power 1637751 +note 64373 +that 109338 +requirement 1335083006 +associated -1423083042 +with 72509 +rate 64184 +timing 18167098 +and 3418 +power 1637751 +up 379 +will 78653 +be 235 +verified -550553348 +in 338 +the 3866 +lab 2995 +likewise -113377485 +performance -1248395529 +and 3418 +safety 33222585 +inhibit 455815506 +associated -1423083042 +with 72509 +the 3866 +power 1637751 +system 22002169 +as 410 +well 78845 +as 410 +other 1634742 +system 22002169 +will 78653 +be 235 +verified -550553348 +in 338 +the 3866 +lab 2995 +finally 523482415 +testing 290699770 +will 78653 +be 235 +constrained 731618813 +to 378 +functional 1463473599 +assurance -709248610 +only 127830 +as 410 +fault 1784751 +insertion 1941502295 +testing 290699770 +will 78653 +be 235 +performed -174655233 +in 338 +the 3866 +lab 2995 +the 3866 +power 1637751 +external 995687422 +store 1021881 +and 3418 +other 1634742 +testing 290699770 +will 78653 +encompass -1686803105 +the 3866 +following 1406612351 +functional 1463473599 +area 44938 +power 1637751 +subsystem -73425987 +control 326743404 +and 3418 +display 515078445 +to 378 +include 249249106 +symbology 389461503 +power 1637751 +type 63482 +and 3418 +inventory -1749680802 +management -185551435 +power 1637751 +mode 60788 +control 326743404 +power 1637751 +start 1805241 +up 379 +power 1637751 +using 1135515 +box 16235 +power 1637751 +subsystem -73425987 +initialization 871873535 +power 1637751 +training 355806106 +mode 60788 +operation 1940623223 +fuel 81855 +present 459251607 +and 3418 +empty 2078542 +status 26979257 +detection 1940716285 +from 87951 +each 72878 +power 1637751 +station 359902137 +selective -743640065 +and 3418 +emergency -705589410 +power 1637751 +from 87951 +each 72878 +station 359902137 +and 3418 +other 1634742 +station 359902137 +test 113146 +data 47789 +required -543965192 +one 3926 +and 3418 +two 6106 +recording 1389980920 +channel 334846748 +a1 26 +a5 90 +and 3418 +a9 154 +at 426 +minimum 364197172 +item 85938 +under 1633627 +test 113146 +the 3866 +component 1599567230 +under 1633627 +test 113146 +include 249249106 +power 1637751 +assembly -206243430 +include 249249106 +system 22002169 +1 1 +maintenance -1241817355 +panel 1308087 +power 1637751 +panel 1308087 +software -121786503 +special 330485625 +or 406 +major 1671092 +test 113146 +support 462911417 +equipment 1599552510 +the 3866 +following 1406612351 +test 113146 +support 462911417 +equipment 1599552510 +will 78653 +be 235 +required -543965192 +to 378 +facilitate -1154274049 +execution 1941688319 +of 246 +the 3866 +test 113146 +event 1793998 +power 1637751 +item 85938 +installed -214189729 +on 342 +each 72878 +station 359902137 +10 1 +total 1293178 +box 16235 +16 97 +total 1293178 +power 1637751 +simulator 2058597689 +11 17 +total 1293178 +fuel 81855 +tank 259514 +simulator 2058597689 +test 113146 +set 6905 +123456789 -2023406807 +portable -205801097 +workstation -1413743233 +monitor 427505012 +special 330485625 +consideration -1898448914 +remark 66630904 +test 113146 +system 22002169 +must 113076 +be 235 +fitted 14662447 +with 72509 +a 10 +functional 1463473599 +system 22002169 +1 1 +system 22002169 +2 2 +and 3418 +system 22002169 +3 3 +to 378 +include 249249106 wheel 1306397
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/data/test5.tags.txt b/plugins/org.eclipse.osee.framework.search.engine.test/data/test5.tags.txt index f6f6687ba6b..cfb1e891880 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/data/test5.tags.txt +++ b/plugins/org.eclipse.osee.framework.search.engine.test/data/test5.tags.txt @@ -1,12 +1,12 @@ -battery 529513131
-shall 1260313
-be 235
-the 3866
-alternate -1420231874
-backup 24902827
-power 1637751
-source 15571833
-test1 113146
-test2 244218
-test3 244218
+battery 529513131 +shall 1260313 +be 235 +the 3866 +alternate -1420231874 +backup 24902827 +power 1637751 +source 15571833 +test1 113146 +test2 244218 +test3 244218 test4 375290
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/data/test6.tags.txt b/plugins/org.eclipse.osee.framework.search.engine.test/data/test6.tags.txt index 7f91fc5ad2f..54b8d53dc8b 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/data/test6.tags.txt +++ b/plugins/org.eclipse.osee.framework.search.engine.test/data/test6.tags.txt @@ -1,26 +1,26 @@ -during 18168253
-autorotation -1149665350
-the 3866
-engine 16068958
-not 7029
-supplying 1408464825
-torque 16513402
-shall 1260313
-be 235
-automatically 985627582
-decoupled -210014995
-from 87951
-the 3866
-drive 1037197
-system 22002169
-by 491
-overrunning 1438228438
-clutch 18725692
-to 378
-permit 28530935
-continued -78400147
-operation 1940623223
-of 246
-the 3866
-main 86708
+during 18168253 +autorotation -1149665350 +the 3866 +engine 16068958 +not 7029 +supplying 1408464825 +torque 16513402 +shall 1260313 +be 235 +automatically 985627582 +decoupled -210014995 +from 87951 +the 3866 +drive 1037197 +system 22002169 +by 491 +overrunning 1438228438 +clutch 18725692 +to 378 +permit 28530935 +continued -78400147 +operation 1940623223 +of 246 +the 3866 +main 86708 motor 1670004
\ No newline at end of file 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 34052e3e3c6..d36b74da2dd 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 @@ -1,26 +1,26 @@ -/*******************************************************************************
- * 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;
-
-import org.eclipse.osee.framework.search.engine.test.utility.UtilityTestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author Roberto E. Escobar
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses( { //
-UtilityTestSuite.class, //
-})
-public class AllSearchEngineTestSuite {
-
-}
+/******************************************************************************* + * 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; + +import org.eclipse.osee.framework.search.engine.test.utility.UtilityTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Roberto E. Escobar + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( { // +UtilityTestSuite.class, // +}) +public class AllSearchEngineTestSuite { + +} diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/SearchTagDataStoreTest.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/SearchTagDataStoreTest.java index e5f68d48e46..ace5995d38b 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/SearchTagDataStoreTest.java +++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/SearchTagDataStoreTest.java @@ -1,129 +1,129 @@ -/*******************************************************************************
- * 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.utility;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.database.core.DbTransaction;
-import org.eclipse.osee.framework.database.core.JoinUtility;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.database.core.JoinUtility.TransactionJoinQuery;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.framework.search.engine.data.IAttributeLocator;
-import org.eclipse.osee.framework.search.engine.data.SearchTag;
-import org.eclipse.osee.framework.search.engine.utility.SearchTagDataStore;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Test Case for {@link SearchTagDataStore}
- *
- * @author Roberto E. Escobar
- */
-public class SearchTagDataStoreTest {
-
- private List<SearchTag> getTestSearchTagDataStoreData() {
- List<SearchTag> tags = new ArrayList<SearchTag>();
-
- SearchTag tag = new SearchTag(2345);
- tag.addTag(-99999999999L);
- tag.addTag(-99999999998L);
- tags.add(tag);
-
- tag = new SearchTag(91011);
- tag.addTag(-99999999997L);
- tag.addTag(-99999999996L);
- tags.add(tag);
-
- tag = new SearchTag(15161718);
- tag.addTag(-99999999995L);
- tag.addTag(-99999999994L);
- tags.add(tag);
-
- return tags;
- }
-
- @Ignore
- // Decouple from database
- @Test
- public void testSearchTagDataStore() throws OseeCoreException {
- new DbTransaction() {
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- List<SearchTag> testData = getTestSearchTagDataStoreData();
- int totalTags = 0;
- for (SearchTag searchTag : testData) {
- totalTags += searchTag.cacheSize();
- }
- int updated = SearchTagDataStore.storeTags(connection, testData);
- Assert.assertEquals(totalTags, updated);
-
- for (SearchTag tag : testData) {
- for (Long codedTag : tag.getTags()) {
- Set<IAttributeLocator> locators = SearchTagDataStore.fetchTagEntries(connection, codedTag);
- Assert.assertEquals(locators.size(), 1);
- IAttributeLocator locator = locators.iterator().next();
- Assert.assertEquals(locator.getGammaId(), tag.getGammaId());
- }
- }
-
- List<IAttributeLocator> locators = Collections.castAll(testData);
- updated = SearchTagDataStore.deleteTags(connection, locators);
- Assert.assertEquals(totalTags, updated);
- }
- }.execute();
- }
-
- @Ignore
- // Decouple from database
- @Test
- public void testSearchTagDataStoreDeleteByQuery() throws Exception {
- new DbTransaction() {
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- List<SearchTag> testData = getTestSearchTagDataStoreData();
- TransactionJoinQuery joinQuery = null;
- int totalTags = 0;
- for (SearchTag searchTag : testData) {
- totalTags += searchTag.cacheSize();
- }
-
- int updated = SearchTagDataStore.storeTags(connection, testData);
- Assert.assertEquals(totalTags, updated);
-
- for (SearchTag tag : testData) {
- for (Long codedTag : tag.getTags()) {
- Set<IAttributeLocator> locators = SearchTagDataStore.fetchTagEntries(connection, codedTag);
- Assert.assertEquals(locators.size(), 1);
- IAttributeLocator locator = locators.iterator().next();
- Assert.assertEquals(locator.getGammaId(), tag.getGammaId());
- }
- }
- try {
- joinQuery = JoinUtility.createTransactionJoinQuery();
- for (SearchTag tag : testData) {
- joinQuery.add(tag.getGammaId(), -1);
- }
- joinQuery.store(connection);
- updated = SearchTagDataStore.deleteTags(connection, joinQuery.getQueryId());
- Assert.assertEquals(totalTags, updated);
- } finally {
- if (joinQuery != null) {
- joinQuery.delete(connection);
- }
- }
- }
- }.execute();
- }
-}
+/******************************************************************************* + * 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.utility; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.database.core.DbTransaction; +import org.eclipse.osee.framework.database.core.JoinUtility; +import org.eclipse.osee.framework.database.core.OseeConnection; +import org.eclipse.osee.framework.database.core.JoinUtility.TransactionJoinQuery; +import org.eclipse.osee.framework.jdk.core.util.Collections; +import org.eclipse.osee.framework.search.engine.data.IAttributeLocator; +import org.eclipse.osee.framework.search.engine.data.SearchTag; +import org.eclipse.osee.framework.search.engine.utility.SearchTagDataStore; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Test Case for {@link SearchTagDataStore} + * + * @author Roberto E. Escobar + */ +public class SearchTagDataStoreTest { + + private List<SearchTag> getTestSearchTagDataStoreData() { + List<SearchTag> tags = new ArrayList<SearchTag>(); + + SearchTag tag = new SearchTag(2345); + tag.addTag(-99999999999L); + tag.addTag(-99999999998L); + tags.add(tag); + + tag = new SearchTag(91011); + tag.addTag(-99999999997L); + tag.addTag(-99999999996L); + tags.add(tag); + + tag = new SearchTag(15161718); + tag.addTag(-99999999995L); + tag.addTag(-99999999994L); + tags.add(tag); + + return tags; + } + + @Ignore + // Decouple from database + @Test + public void testSearchTagDataStore() throws OseeCoreException { + new DbTransaction() { + @Override + protected void handleTxWork(OseeConnection connection) throws OseeCoreException { + List<SearchTag> testData = getTestSearchTagDataStoreData(); + int totalTags = 0; + for (SearchTag searchTag : testData) { + totalTags += searchTag.cacheSize(); + } + int updated = SearchTagDataStore.storeTags(connection, testData); + Assert.assertEquals(totalTags, updated); + + for (SearchTag tag : testData) { + for (Long codedTag : tag.getTags()) { + Set<IAttributeLocator> locators = SearchTagDataStore.fetchTagEntries(connection, codedTag); + Assert.assertEquals(locators.size(), 1); + IAttributeLocator locator = locators.iterator().next(); + Assert.assertEquals(locator.getGammaId(), tag.getGammaId()); + } + } + + List<IAttributeLocator> locators = Collections.castAll(testData); + updated = SearchTagDataStore.deleteTags(connection, locators); + Assert.assertEquals(totalTags, updated); + } + }.execute(); + } + + @Ignore + // Decouple from database + @Test + public void testSearchTagDataStoreDeleteByQuery() throws Exception { + new DbTransaction() { + @Override + protected void handleTxWork(OseeConnection connection) throws OseeCoreException { + List<SearchTag> testData = getTestSearchTagDataStoreData(); + TransactionJoinQuery joinQuery = null; + int totalTags = 0; + for (SearchTag searchTag : testData) { + totalTags += searchTag.cacheSize(); + } + + int updated = SearchTagDataStore.storeTags(connection, testData); + Assert.assertEquals(totalTags, updated); + + for (SearchTag tag : testData) { + for (Long codedTag : tag.getTags()) { + Set<IAttributeLocator> locators = SearchTagDataStore.fetchTagEntries(connection, codedTag); + Assert.assertEquals(locators.size(), 1); + IAttributeLocator locator = locators.iterator().next(); + Assert.assertEquals(locator.getGammaId(), tag.getGammaId()); + } + } + try { + joinQuery = JoinUtility.createTransactionJoinQuery(); + for (SearchTag tag : testData) { + joinQuery.add(tag.getGammaId(), -1); + } + joinQuery.store(connection); + updated = SearchTagDataStore.deleteTags(connection, joinQuery.getQueryId()); + Assert.assertEquals(totalTags, updated); + } finally { + if (joinQuery != null) { + joinQuery.delete(connection); + } + } + } + }.execute(); + } +} diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/TagProcessorTest.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/TagProcessorTest.java index 45ed283a0ee..e3ad0cb49ad 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/TagProcessorTest.java +++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/TagProcessorTest.java @@ -1,163 +1,163 @@ -/*******************************************************************************
- * 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.utility;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Scanner;
-import org.eclipse.osee.framework.jdk.core.type.MutableInteger;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream;
-import org.eclipse.osee.framework.search.engine.utility.ITagCollector;
-import org.eclipse.osee.framework.search.engine.utility.TagProcessor;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Test Case for {@link TagProcessor}
- *
- * @author Roberto E. Escobar
- */
-public class TagProcessorTest {
-
- private Map<String, TestData<URL, URL>> getTestTagData() {
- Map<String, TestData<URL, URL>> toReturn = new LinkedHashMap<String, TestData<URL, URL>>();
- // Bundle bundle = Activator.getInstance().getBundleContext().getBundle();
- // Enumeration<?> urls = bundle.findEntries("data", "*.*", true);
- // while (urls.hasMoreElements()) {
- // URL url = (URL) urls.nextElement();
- // String name = getFileName(url.getPath());
- // if (Strings.isValid(name) && (url.getPath().endsWith(".data.xml") || url.getPath().endsWith(".tags.txt"))) {
- // TestData<URL, URL> pair = toReturn.get(name);
- // if (pair == null) {
- // pair = new TestData<URL, URL>();
- // toReturn.put(name, pair);
- // }
- // if (isDataFile(url.getPath())) {
- // pair.data = url;
- // } else if (isExpectedFile(url.getPath())) {
- // pair.expected = url;
- // } else if (pair.data == null || pair.expected == null) {
- // toReturn.remove(pair);
- // }
- // }
- // }
- return toReturn;
- }
-
- private void checkValue(int currentCount, Scanner expectedTags, String test, String word, Long codedTag) {
- try {
- if (expectedTags.hasNext()) {
- Assert.assertEquals(String.format("Line: [%d] Test: [%s] word: [%s]", currentCount, test, word),
- expectedTags.next(), word);
- Assert.assertEquals(String.format("Line: [%d] Test: [%s] word: [%s]", currentCount, test, word),
- expectedTags.nextLong(), codedTag.longValue());
- } else {
- Assert.assertTrue(String.format("Line: [%d] Test: [%s] word: [%s] tag: [%d] -- Extra Tag Found",
- currentCount, test, word, codedTag), false);
- }
- } catch (Exception ex) {
- Assert.fail(String.format("%s %s", word, codedTag));
- }
- }
-
- @Ignore
- // Decouple from file system
- @Test
- public void testTagFromInputStream() throws IOException {
- Map<String, TestData<URL, URL>> testMap = getTestTagData();
- for (final String key : testMap.keySet()) {
- TestData<URL, URL> testData = testMap.get(key);
-
- InputStream dataStream = null;
- InputStream expectedStream = null;
- try {
- dataStream = new BufferedInputStream(testData.data.openStream());
- expectedStream = new BufferedInputStream(testData.expected.openStream());
- final Scanner expectedTags = new Scanner(expectedStream, "UTF-8");
-
- Scanner sourceScanner = new Scanner(new XmlTextInputStream(dataStream));
- final MutableInteger count = new MutableInteger(0);
- TagProcessor.collectFromScanner(sourceScanner, new ITagCollector() {
- @Override
- public void addTag(String word, Long codedTag) {
- checkValue(count.getValueAndInc(), expectedTags, key, word, codedTag);
- }
- });
- } finally {
- if (dataStream != null) {
- try {
- dataStream.close();
- } catch (IOException ex) {
- }
- }
- if (expectedStream != null) {
- try {
- expectedStream.close();
- } catch (IOException ex) {
- }
- }
- }
- }
- }
-
- // private String getFileName(String name) {
- // int index = name.lastIndexOf("/");
- // if (index > -1) {
- // name = name.substring(index + 1, name.length());
- // }
- // if (name.endsWith(".data.xml")) {
- // name = name.substring(0, name.length() - 9);
- // }
- // if (name.endsWith(".tags.txt")) {
- // name = name.substring(0, name.length() - 9);
- // }
- // return name;
- // }
-
- // private boolean isDataFile(String name) {
- // return name != null && name.endsWith(".data.xml");
- // }
- //
- // private boolean isExpectedFile(String name) {
- // return name != null && name.endsWith(".tags.txt");
- // }
-
- private class TestData<K, V> {
- private K data;
- private V expected;
- }
-
- @Ignore
- // Decouple from file system
- @Test
- public void testTagWordFile() throws IOException {
- // This is here to be able to look at tags generated from xml file source
- // Bundle bundle = Activator.getInstance().getBundleContext().getBundle();
- // URL url = bundle.getEntry("data/test5.data.xml");
- // InputStream dataStream = null;
- // try {
- // dataStream = new XmlTextInputStream(new BufferedInputStream(url.openStream()));
- // TagProcessor.collectFromInputStream(dataStream, new ITagCollector() {
- // @Override
- // public void addTag(String word, Long codedTag) {
- // System.out.println("Word: [" + word + "] Tag: [" + codedTag + "]");
- // }
- // });
- // } finally {
- // dataStream.close();
- // }
- }
-}
+/******************************************************************************* + * 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.utility; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Scanner; +import org.eclipse.osee.framework.jdk.core.type.MutableInteger; +import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream; +import org.eclipse.osee.framework.search.engine.utility.ITagCollector; +import org.eclipse.osee.framework.search.engine.utility.TagProcessor; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Test Case for {@link TagProcessor} + * + * @author Roberto E. Escobar + */ +public class TagProcessorTest { + + private Map<String, TestData<URL, URL>> getTestTagData() { + Map<String, TestData<URL, URL>> toReturn = new LinkedHashMap<String, TestData<URL, URL>>(); + // Bundle bundle = Activator.getInstance().getBundleContext().getBundle(); + // Enumeration<?> urls = bundle.findEntries("data", "*.*", true); + // while (urls.hasMoreElements()) { + // URL url = (URL) urls.nextElement(); + // String name = getFileName(url.getPath()); + // if (Strings.isValid(name) && (url.getPath().endsWith(".data.xml") || url.getPath().endsWith(".tags.txt"))) { + // TestData<URL, URL> pair = toReturn.get(name); + // if (pair == null) { + // pair = new TestData<URL, URL>(); + // toReturn.put(name, pair); + // } + // if (isDataFile(url.getPath())) { + // pair.data = url; + // } else if (isExpectedFile(url.getPath())) { + // pair.expected = url; + // } else if (pair.data == null || pair.expected == null) { + // toReturn.remove(pair); + // } + // } + // } + return toReturn; + } + + private void checkValue(int currentCount, Scanner expectedTags, String test, String word, Long codedTag) { + try { + if (expectedTags.hasNext()) { + Assert.assertEquals(String.format("Line: [%d] Test: [%s] word: [%s]", currentCount, test, word), + expectedTags.next(), word); + Assert.assertEquals(String.format("Line: [%d] Test: [%s] word: [%s]", currentCount, test, word), + expectedTags.nextLong(), codedTag.longValue()); + } else { + Assert.assertTrue(String.format("Line: [%d] Test: [%s] word: [%s] tag: [%d] -- Extra Tag Found", + currentCount, test, word, codedTag), false); + } + } catch (Exception ex) { + Assert.fail(String.format("%s %s", word, codedTag)); + } + } + + @Ignore + // Decouple from file system + @Test + public void testTagFromInputStream() throws IOException { + Map<String, TestData<URL, URL>> testMap = getTestTagData(); + for (final String key : testMap.keySet()) { + TestData<URL, URL> testData = testMap.get(key); + + InputStream dataStream = null; + InputStream expectedStream = null; + try { + dataStream = new BufferedInputStream(testData.data.openStream()); + expectedStream = new BufferedInputStream(testData.expected.openStream()); + final Scanner expectedTags = new Scanner(expectedStream, "UTF-8"); + + Scanner sourceScanner = new Scanner(new XmlTextInputStream(dataStream)); + final MutableInteger count = new MutableInteger(0); + TagProcessor.collectFromScanner(sourceScanner, new ITagCollector() { + @Override + public void addTag(String word, Long codedTag) { + checkValue(count.getValueAndInc(), expectedTags, key, word, codedTag); + } + }); + } finally { + if (dataStream != null) { + try { + dataStream.close(); + } catch (IOException ex) { + } + } + if (expectedStream != null) { + try { + expectedStream.close(); + } catch (IOException ex) { + } + } + } + } + } + + // private String getFileName(String name) { + // int index = name.lastIndexOf("/"); + // if (index > -1) { + // name = name.substring(index + 1, name.length()); + // } + // if (name.endsWith(".data.xml")) { + // name = name.substring(0, name.length() - 9); + // } + // if (name.endsWith(".tags.txt")) { + // name = name.substring(0, name.length() - 9); + // } + // return name; + // } + + // private boolean isDataFile(String name) { + // return name != null && name.endsWith(".data.xml"); + // } + // + // private boolean isExpectedFile(String name) { + // return name != null && name.endsWith(".tags.txt"); + // } + + private class TestData<K, V> { + private K data; + private V expected; + } + + @Ignore + // Decouple from file system + @Test + public void testTagWordFile() throws IOException { + // This is here to be able to look at tags generated from xml file source + // Bundle bundle = Activator.getInstance().getBundleContext().getBundle(); + // URL url = bundle.getEntry("data/test5.data.xml"); + // InputStream dataStream = null; + // try { + // dataStream = new XmlTextInputStream(new BufferedInputStream(url.openStream())); + // TagProcessor.collectFromInputStream(dataStream, new ITagCollector() { + // @Override + // public void addTag(String word, Long codedTag) { + // System.out.println("Word: [" + word + "] Tag: [" + codedTag + "]"); + // } + // }); + // } finally { + // dataStream.close(); + // } + } +} diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/UtilityTestSuite.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/UtilityTestSuite.java index a40dffc4de9..25962f09688 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/UtilityTestSuite.java +++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/UtilityTestSuite.java @@ -1,27 +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.utility;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author Roberto E. Escobar
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses( { //
-SearchTagDataStoreTest.class,//
- TagProcessorTest.class, //
- WordsUtilTest.class, //
-})
-public class UtilityTestSuite {
-
-}
+/******************************************************************************* + * 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.utility; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Roberto E. Escobar + */ +@RunWith(Suite.class) +@Suite.SuiteClasses( { // +SearchTagDataStoreTest.class,// + TagProcessorTest.class, // + WordsUtilTest.class, // +}) +public class UtilityTestSuite { + +} diff --git a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordsUtilTest.java b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordsUtilTest.java index 498bc71a70d..01dfa223468 100644 --- a/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordsUtilTest.java +++ b/plugins/org.eclipse.osee.framework.search.engine.test/src/org/eclipse/osee/framework/search/engine/test/utility/WordsUtilTest.java @@ -1,292 +1,292 @@ -/*******************************************************************************
- * 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.utility;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Scanner;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream;
-import org.eclipse.osee.framework.search.engine.utility.WordsUtil;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Test Case for {@link WordsUtil}
- *
- * @author Roberto E. Escobar
- */
-public class WordsUtilTest {
-
- private Map<String, String> getSingularToPluralData() {
- Map<String, String> testMap = new LinkedHashMap<String, String>();
- testMap.put("tries", "try");
- testMap.put("volcanoes", "volcano");
- testMap.put("geese", "goose");
- testMap.put("windows", "window");
- testMap.put("glasses", "glass");
- testMap.put("fishes", "fish");
- testMap.put("houses", "house");
- testMap.put("judges", "judge");
- testMap.put("dishes", "dish");
- testMap.put("phases", "phase");
- testMap.put("witches", "witch");
- testMap.put("baths", "bath");
- testMap.put("calves", "calf");
- testMap.put("lives", "life");
- testMap.put("proofs", "proof");
- testMap.put("boys", "boy");
- testMap.put("dwarfs", "dwarf");
- testMap.put("dwarves", "dwarf");
- testMap.put("hooves", "hoof");
- testMap.put("chairs", "chair");
- testMap.put("heroes", "hero");
- testMap.put("cantos", "canto");
- testMap.put("porticos", "portico");
- testMap.put("indices", "index");
- testMap.put("leaves", "leaf");
- testMap.put("hello", "hello");
- testMap.put("axes", "axis");
- testMap.put("boxes", "box");
- testMap.put("foxes", "fox");
- testMap.put("species", "species");
- testMap.put("series", "series");
- testMap.put("status", "status");
- testMap.put("as", "as");
- testMap.put("appendeces", "appendix");
- return testMap;
- }
-
- @Ignore
- // Decouple from file system
- @Test
- public void testSingularToPlural() {
- Map<String, String> testMap = getSingularToPluralData();
- for (String key : testMap.keySet()) {
- String expected = testMap.get(key);
- String actual = WordsUtil.toSingular(key);
- Assert.assertEquals(String.format("Original: [%s] ", key), expected, actual);
- }
- }
-
- private Map<String, String> getStripPossessiveData() {
- Map<String, String> toReturn = new LinkedHashMap<String, String>();
- toReturn.put("don't", "don't");
- toReturn.put("yours", "yours");
- toReturn.put("Larry's", "Larry");
- toReturn.put("Joe's bag of tricks", "Joe bag of tricks");
- toReturn.put("What's that?", "What that?");
- toReturn.put("Company's books", "Company books");
- toReturn.put("Charles's cars.", "Charles cars.");
- toReturn.put("witches' brooms", "witches brooms");
- toReturn.put("babies' beds.", "babies beds.");
- toReturn.put("children's books", "children books");
- return toReturn;
- }
-
- @Ignore
- // Decouple from file system
- @Test
- public void testStripPossessive() throws UnsupportedEncodingException {
- Map<String, String> testMap = getStripPossessiveData();
- for (String key : testMap.keySet()) {
- StringBuilder builder = new StringBuilder();
- Scanner scanner = new Scanner(key);
- while (scanner.hasNext()) {
- if (builder.length() > 0) {
- builder.append(" ");
- }
- builder.append(WordsUtil.stripPossesive(scanner.next()));
- }
- Assert.assertEquals(String.format("Original: [%s] ", key), testMap.get(key), builder.toString());
- }
- }
-
- private Map<String, String[]> getSplitOnPuntucationData() {
- Map<String, String[]> toReturn = new LinkedHashMap<String, String[]>();
- toReturn.put("test.db.preset", new String[] {"test", "db", "preset"});
- toReturn.put("{what is this}", new String[] {"what", "is", "this"});
- toReturn.put("What is your name?", new String[] {"What", "is", "your", "name"});
- toReturn.put("Run!!", new String[] {"Run"});
- toReturn.put("don't", new String[] {"don't"});
- toReturn.put("hello", new String[] {"hello"});
- return toReturn;
- }
-
- @Ignore
- // Decouple from file system
- @Test
- public void testSplitOnPunctuation() {
- Map<String, String[]> testMap = getSplitOnPuntucationData();
- for (String key : testMap.keySet()) {
- String[] results = WordsUtil.splitOnPunctuation(key);
- Assert.assertEquals(String.format("Original: [%s] ", key), Arrays.deepToString(testMap.get(key)),
- Arrays.deepToString(results));
- }
- }
-
- // private String getFileName(String name) {
- // int index = name.lastIndexOf("/");
- // if (index > -1) {
- // name = name.substring(index + 1, name.length());
- // }
- // if (name.endsWith(".data.xml")) {
- // name = name.substring(0, name.length() - 9);
- // }
- // if (name.endsWith(".expected.txt")) {
- // name = name.substring(0, name.length() - 13);
- // }
- // return name;
- // }
- //
- // private boolean isDataFile(String name) {
- // return name != null && name.endsWith(".data.xml");
- // }
- //
- // private boolean isExpectedFile(String name) {
- // return name != null && name.endsWith(".expected.txt");
- // }
-
- private Map<String, TestData<URL, URL>> getXmlMarkupRemovalData() {
- Map<String, TestData<URL, URL>> toReturn = new LinkedHashMap<String, TestData<URL, URL>>();
-
- // Bundle bundle = Activator.getInstance().getBundleContext().getBundle();
- // Enumeration<?> urls = bundle.findEntries("data", "*.*", true);
- // while (urls.hasMoreElements()) {
- // URL url = (URL) urls.nextElement();
- // String name = getFileName(url.getPath());
- // if (Strings.isValid(name) && (url.getPath().endsWith(".data.xml") || url.getPath().endsWith(".expected.txt"))) {
- // TestData<URL, URL> pair = toReturn.get(name);
- // if (pair == null) {
- // pair = new TestData<URL, URL>();
- // toReturn.put(name, pair);
- // }
- // if (isDataFile(url.getPath())) {
- // pair.data = url;
- // } else if (isExpectedFile(url.getPath())) {
- // pair.expected = url;
- // } else if (pair.data == null || pair.expected == null) {
- // toReturn.remove(pair);
- // }
- // }
- // }
-
- return toReturn;
- }
-
- // public void testXmlMarkupRemovalScanner() throws IOException {
- // Map<String, TestData<URL, URL>> testMap = getXmlMarkupRemovalData();
- // for (String key : testMap.keySet()) {
- // TestData<URL, URL> testData = testMap.get(key);
- //
- // InputStream dataStream = null;
- // InputStream expectedStream = null;
- // Scanner scanner = null;
- // try {
- // dataStream = new BufferedInputStream(testData.data.openStream());
- // expectedStream = new BufferedInputStream(testData.expected.openStream());
- //
- // StringBuilder builder = new StringBuilder();
- // scanner = WordsUtil.inputStreamToXmlTextScanner(dataStream);
- // while (scanner.hasNext()) {
- // String value = scanner.next();
- // if (value.length() > 0) {
- // builder.append(value);
- // if (scanner.hasNext()) {
- // builder.append(" ");
- // }
- // }
- // }
- //
- // String actual = builder.toString();
- // String expected = Lib.inputStreamToString(expectedStream);
- // assertEquals(String.format("Original: [%s] ", key), expected, actual);
- // } finally {
- // if (scanner != null) {
- // scanner.close();
- // }
- // if (dataStream != null) {
- // try {
- // dataStream.close();
- // } catch (IOException ex) {
- // }
- // }
- // if (expectedStream != null) {
- // try {
- // expectedStream.close();
- // } catch (IOException ex) {
- // }
- // }
- // }
- // }
- // }
- @Ignore
- // Decouple from file system
- @Test
- public void testXmlMarkupRemovalStream() throws IOException {
- Map<String, TestData<URL, URL>> testMap = getXmlMarkupRemovalData();
- for (String key : testMap.keySet()) {
- TestData<URL, URL> testData = testMap.get(key);
-
- InputStream dataStream = null;
- InputStream expectedStream = null;
- Scanner scanner = null;
- try {
- dataStream = new XmlTextInputStream(new BufferedInputStream(testData.data.openStream()));
- expectedStream = new BufferedInputStream(testData.expected.openStream());
-
- StringBuilder builder = new StringBuilder();
- scanner = new Scanner(dataStream, "UTF-8");
- while (scanner.hasNext()) {
- String value = scanner.next();
- if (value.length() > 0) {
- builder.append(value);
- if (scanner.hasNext()) {
- builder.append(" ");
- }
- }
- }
-
- String actual = builder.toString();
- String expected = Lib.inputStreamToString(expectedStream);
- Assert.assertEquals(String.format("Original: [%s] ", key), expected, actual);
- } finally {
- if (scanner != null) {
- scanner.close();
- }
- if (dataStream != null) {
- try {
- dataStream.close();
- } catch (IOException ex) {
- }
- }
- if (expectedStream != null) {
- try {
- expectedStream.close();
- } catch (IOException ex) {
- }
- }
- }
- }
- }
-
- private class TestData<K, V> {
- private K data;
- private V expected;
- }
-}
+/******************************************************************************* + * 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.utility; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Scanner; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream; +import org.eclipse.osee.framework.search.engine.utility.WordsUtil; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Test Case for {@link WordsUtil} + * + * @author Roberto E. Escobar + */ +public class WordsUtilTest { + + private Map<String, String> getSingularToPluralData() { + Map<String, String> testMap = new LinkedHashMap<String, String>(); + testMap.put("tries", "try"); + testMap.put("volcanoes", "volcano"); + testMap.put("geese", "goose"); + testMap.put("windows", "window"); + testMap.put("glasses", "glass"); + testMap.put("fishes", "fish"); + testMap.put("houses", "house"); + testMap.put("judges", "judge"); + testMap.put("dishes", "dish"); + testMap.put("phases", "phase"); + testMap.put("witches", "witch"); + testMap.put("baths", "bath"); + testMap.put("calves", "calf"); + testMap.put("lives", "life"); + testMap.put("proofs", "proof"); + testMap.put("boys", "boy"); + testMap.put("dwarfs", "dwarf"); + testMap.put("dwarves", "dwarf"); + testMap.put("hooves", "hoof"); + testMap.put("chairs", "chair"); + testMap.put("heroes", "hero"); + testMap.put("cantos", "canto"); + testMap.put("porticos", "portico"); + testMap.put("indices", "index"); + testMap.put("leaves", "leaf"); + testMap.put("hello", "hello"); + testMap.put("axes", "axis"); + testMap.put("boxes", "box"); + testMap.put("foxes", "fox"); + testMap.put("species", "species"); + testMap.put("series", "series"); + testMap.put("status", "status"); + testMap.put("as", "as"); + testMap.put("appendeces", "appendix"); + return testMap; + } + + @Ignore + // Decouple from file system + @Test + public void testSingularToPlural() { + Map<String, String> testMap = getSingularToPluralData(); + for (String key : testMap.keySet()) { + String expected = testMap.get(key); + String actual = WordsUtil.toSingular(key); + Assert.assertEquals(String.format("Original: [%s] ", key), expected, actual); + } + } + + private Map<String, String> getStripPossessiveData() { + Map<String, String> toReturn = new LinkedHashMap<String, String>(); + toReturn.put("don't", "don't"); + toReturn.put("yours", "yours"); + toReturn.put("Larry's", "Larry"); + toReturn.put("Joe's bag of tricks", "Joe bag of tricks"); + toReturn.put("What's that?", "What that?"); + toReturn.put("Company's books", "Company books"); + toReturn.put("Charles's cars.", "Charles cars."); + toReturn.put("witches' brooms", "witches brooms"); + toReturn.put("babies' beds.", "babies beds."); + toReturn.put("children's books", "children books"); + return toReturn; + } + + @Ignore + // Decouple from file system + @Test + public void testStripPossessive() throws UnsupportedEncodingException { + Map<String, String> testMap = getStripPossessiveData(); + for (String key : testMap.keySet()) { + StringBuilder builder = new StringBuilder(); + Scanner scanner = new Scanner(key); + while (scanner.hasNext()) { + if (builder.length() > 0) { + builder.append(" "); + } + builder.append(WordsUtil.stripPossesive(scanner.next())); + } + Assert.assertEquals(String.format("Original: [%s] ", key), testMap.get(key), builder.toString()); + } + } + + private Map<String, String[]> getSplitOnPuntucationData() { + Map<String, String[]> toReturn = new LinkedHashMap<String, String[]>(); + toReturn.put("test.db.preset", new String[] {"test", "db", "preset"}); + toReturn.put("{what is this}", new String[] {"what", "is", "this"}); + toReturn.put("What is your name?", new String[] {"What", "is", "your", "name"}); + toReturn.put("Run!!", new String[] {"Run"}); + toReturn.put("don't", new String[] {"don't"}); + toReturn.put("hello", new String[] {"hello"}); + return toReturn; + } + + @Ignore + // Decouple from file system + @Test + public void testSplitOnPunctuation() { + Map<String, String[]> testMap = getSplitOnPuntucationData(); + for (String key : testMap.keySet()) { + String[] results = WordsUtil.splitOnPunctuation(key); + Assert.assertEquals(String.format("Original: [%s] ", key), Arrays.deepToString(testMap.get(key)), + Arrays.deepToString(results)); + } + } + + // private String getFileName(String name) { + // int index = name.lastIndexOf("/"); + // if (index > -1) { + // name = name.substring(index + 1, name.length()); + // } + // if (name.endsWith(".data.xml")) { + // name = name.substring(0, name.length() - 9); + // } + // if (name.endsWith(".expected.txt")) { + // name = name.substring(0, name.length() - 13); + // } + // return name; + // } + // + // private boolean isDataFile(String name) { + // return name != null && name.endsWith(".data.xml"); + // } + // + // private boolean isExpectedFile(String name) { + // return name != null && name.endsWith(".expected.txt"); + // } + + private Map<String, TestData<URL, URL>> getXmlMarkupRemovalData() { + Map<String, TestData<URL, URL>> toReturn = new LinkedHashMap<String, TestData<URL, URL>>(); + + // Bundle bundle = Activator.getInstance().getBundleContext().getBundle(); + // Enumeration<?> urls = bundle.findEntries("data", "*.*", true); + // while (urls.hasMoreElements()) { + // URL url = (URL) urls.nextElement(); + // String name = getFileName(url.getPath()); + // if (Strings.isValid(name) && (url.getPath().endsWith(".data.xml") || url.getPath().endsWith(".expected.txt"))) { + // TestData<URL, URL> pair = toReturn.get(name); + // if (pair == null) { + // pair = new TestData<URL, URL>(); + // toReturn.put(name, pair); + // } + // if (isDataFile(url.getPath())) { + // pair.data = url; + // } else if (isExpectedFile(url.getPath())) { + // pair.expected = url; + // } else if (pair.data == null || pair.expected == null) { + // toReturn.remove(pair); + // } + // } + // } + + return toReturn; + } + + // public void testXmlMarkupRemovalScanner() throws IOException { + // Map<String, TestData<URL, URL>> testMap = getXmlMarkupRemovalData(); + // for (String key : testMap.keySet()) { + // TestData<URL, URL> testData = testMap.get(key); + // + // InputStream dataStream = null; + // InputStream expectedStream = null; + // Scanner scanner = null; + // try { + // dataStream = new BufferedInputStream(testData.data.openStream()); + // expectedStream = new BufferedInputStream(testData.expected.openStream()); + // + // StringBuilder builder = new StringBuilder(); + // scanner = WordsUtil.inputStreamToXmlTextScanner(dataStream); + // while (scanner.hasNext()) { + // String value = scanner.next(); + // if (value.length() > 0) { + // builder.append(value); + // if (scanner.hasNext()) { + // builder.append(" "); + // } + // } + // } + // + // String actual = builder.toString(); + // String expected = Lib.inputStreamToString(expectedStream); + // assertEquals(String.format("Original: [%s] ", key), expected, actual); + // } finally { + // if (scanner != null) { + // scanner.close(); + // } + // if (dataStream != null) { + // try { + // dataStream.close(); + // } catch (IOException ex) { + // } + // } + // if (expectedStream != null) { + // try { + // expectedStream.close(); + // } catch (IOException ex) { + // } + // } + // } + // } + // } + @Ignore + // Decouple from file system + @Test + public void testXmlMarkupRemovalStream() throws IOException { + Map<String, TestData<URL, URL>> testMap = getXmlMarkupRemovalData(); + for (String key : testMap.keySet()) { + TestData<URL, URL> testData = testMap.get(key); + + InputStream dataStream = null; + InputStream expectedStream = null; + Scanner scanner = null; + try { + dataStream = new XmlTextInputStream(new BufferedInputStream(testData.data.openStream())); + expectedStream = new BufferedInputStream(testData.expected.openStream()); + + StringBuilder builder = new StringBuilder(); + scanner = new Scanner(dataStream, "UTF-8"); + while (scanner.hasNext()) { + String value = scanner.next(); + if (value.length() > 0) { + builder.append(value); + if (scanner.hasNext()) { + builder.append(" "); + } + } + } + + String actual = builder.toString(); + String expected = Lib.inputStreamToString(expectedStream); + Assert.assertEquals(String.format("Original: [%s] ", key), expected, actual); + } finally { + if (scanner != null) { + scanner.close(); + } + if (dataStream != null) { + try { + dataStream.close(); + } catch (IOException ex) { + } + } + if (expectedStream != null) { + try { + expectedStream.close(); + } catch (IOException ex) { + } + } + } + } + } + + private class TestData<K, V> { + private K data; + private V expected; + } +} |