Changeset 12656 in josm for trunk/test/unit/org
- Timestamp:
- 2017-08-26T00:40:19+02:00 (7 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 1 added
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java
r11104 r12656 13 13 import org.openstreetmap.josm.TestUtils; 14 14 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 15 import org.openstreetmap.josm.actions.search.SearchCompiler;16 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;17 15 import org.openstreetmap.josm.command.SequenceCommand; 18 16 import org.openstreetmap.josm.data.osm.DataSet; … … 20 18 import org.openstreetmap.josm.data.osm.RelationMember; 21 19 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.data.osm.search.SearchParseError; 21 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 22 22 import org.openstreetmap.josm.io.OsmReader; 23 23 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 56 56 @SuppressWarnings("unchecked") 57 57 private static Pair<SequenceCommand, Relation> createMultipolygonCommand(Collection<Way> ways, String pattern, Relation r) 58 throws ParseError {58 throws SearchParseError { 59 59 return CreateMultipolygonAction.createMultipolygonCommand( 60 60 (Collection<Way>) (Collection<?>) SubclassFilteredCollection.filter(ways, SearchCompiler.compile(regexpSearch(pattern))), r); -
trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java
r12636 r12656 12 12 import org.openstreetmap.josm.TestUtils; 13 13 import org.openstreetmap.josm.actions.OrthogonalizeAction.Direction; 14 import org.openstreetmap.josm.actions.search.SearchCompiler;15 14 import org.openstreetmap.josm.data.coor.LatLon; 16 15 import org.openstreetmap.josm.data.osm.DataSet; 17 16 import org.openstreetmap.josm.data.osm.Node; 18 17 import org.openstreetmap.josm.data.osm.Way; 18 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 19 19 import org.openstreetmap.josm.gui.MainApplication; 20 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; -
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchActionTest.java
r11978 r12656 6 6 import org.openstreetmap.josm.TestUtils; 7 7 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 8 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 8 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 9 10 -
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r11973 r12656 17 17 import org.junit.Test; 18 18 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 19 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;20 19 import org.openstreetmap.josm.data.coor.LatLon; 21 20 import org.openstreetmap.josm.data.osm.Filter.FilterPreferenceEntry; 21 import org.openstreetmap.josm.data.osm.search.SearchParseError; 22 22 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 23 23 import org.openstreetmap.josm.io.OsmReader; … … 41 41 42 42 @Test 43 public void testBasic() throws ParseError {43 public void testBasic() throws SearchParseError { 44 44 DataSet ds = new DataSet(); 45 45 Node n1 = new Node(LatLon.ZERO); -
trunk/test/unit/org/openstreetmap/josm/data/osm/search/PushbackTokenizerTest.java
r12651 r12656 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm. actions.search;2 package org.openstreetmap.josm.data.osm.search; 3 3 4 4 import org.junit.Rule; 5 5 import org.junit.Test; 6 6 import org.openstreetmap.josm.TestUtils; 7 import org.openstreetmap.josm. actions.search.PushbackTokenizer.Token;7 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token; 8 8 import org.openstreetmap.josm.testutils.JOSMTestRules; 9 9 -
trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java
r12651 r12656 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm. actions.search;2 package org.openstreetmap.josm.data.osm.search; 3 3 4 4 import static org.junit.Assert.assertEquals; … … 20 20 import org.openstreetmap.josm.TestUtils; 21 21 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 22 import org.openstreetmap.josm.actions.search.SearchCompiler.ExactKeyValue;23 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;24 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;25 22 import org.openstreetmap.josm.data.coor.LatLon; 26 23 import org.openstreetmap.josm.data.osm.DataSet; … … 35 32 import org.openstreetmap.josm.data.osm.Way; 36 33 import org.openstreetmap.josm.data.osm.WayData; 34 import org.openstreetmap.josm.data.osm.search.SearchCompiler.ExactKeyValue; 35 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match; 37 36 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 38 37 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetMenu; … … 69 68 private final Match n; 70 69 71 private SearchContext(String state) throws ParseError {70 private SearchContext(String state) throws SearchParseError { 72 71 m = SearchCompiler.compile(state); 73 72 n = SearchCompiler.compile('-' + state); … … 107 106 /** 108 107 * Search anything. 109 * @throws ParseError if an error has been encountered while compiling110 */ 111 @Test 112 public void testAny() throws ParseError {108 * @throws SearchParseError if an error has been encountered while compiling 109 */ 110 @Test 111 public void testAny() throws SearchParseError { 113 112 final SearchCompiler.Match c = SearchCompiler.compile("foo"); 114 113 assertTrue(c.match(newPrimitive("foobar", "true"))); … … 120 119 /** 121 120 * Search by equality key=value. 122 * @throws ParseError if an error has been encountered while compiling123 */ 124 @Test 125 public void testEquals() throws ParseError {121 * @throws SearchParseError if an error has been encountered while compiling 122 */ 123 @Test 124 public void testEquals() throws SearchParseError { 126 125 final SearchCompiler.Match c = SearchCompiler.compile("foo=bar"); 127 126 assertFalse(c.match(newPrimitive("foobar", "true"))); … … 134 133 /** 135 134 * Search by comparison. 136 * @throws ParseError if an error has been encountered while compiling137 */ 138 @Test 139 public void testCompare() throws ParseError {135 * @throws SearchParseError if an error has been encountered while compiling 136 */ 137 @Test 138 public void testCompare() throws SearchParseError { 140 139 final SearchCompiler.Match c1 = SearchCompiler.compile("start_date>1950"); 141 140 assertTrue(c1.match(newPrimitive("start_date", "1950-01-01"))); … … 174 173 /** 175 174 * Search by nth. 176 * @throws ParseError if an error has been encountered while compiling177 */ 178 @Test 179 public void testNth() throws ParseError {175 * @throws SearchParseError if an error has been encountered while compiling 176 */ 177 @Test 178 public void testNth() throws SearchParseError { 180 179 final DataSet dataSet = new DataSet(); 181 180 final Way way = new Way(); … … 202 201 /** 203 202 * Search by negative nth. 204 * @throws ParseError if an error has been encountered while compiling205 */ 206 @Test 207 public void testNthParseNegative() throws ParseError {203 * @throws SearchParseError if an error has been encountered while compiling 204 */ 205 @Test 206 public void testNthParseNegative() throws SearchParseError { 208 207 assertEquals("Nth{nth=-1, modulo=false}", SearchCompiler.compile("nth:-1").toString()); 209 208 } … … 211 210 /** 212 211 * Search by modified status. 213 * @throws ParseError if an error has been encountered while compiling214 */ 215 @Test 216 public void testModified() throws ParseError {212 * @throws SearchParseError if an error has been encountered while compiling 213 */ 214 @Test 215 public void testModified() throws SearchParseError { 217 216 SearchContext sc = new SearchContext("modified"); 218 217 // Not modified but new … … 247 246 /** 248 247 * Search by selected status. 249 * @throws ParseError if an error has been encountered while compiling250 */ 251 @Test 252 public void testSelected() throws ParseError {248 * @throws SearchParseError if an error has been encountered while compiling 249 */ 250 @Test 251 public void testSelected() throws SearchParseError { 253 252 SearchContext sc = new SearchContext("selected"); 254 253 // Not selected … … 267 266 /** 268 267 * Search by incomplete status. 269 * @throws ParseError if an error has been encountered while compiling270 */ 271 @Test 272 public void testIncomplete() throws ParseError {268 * @throws SearchParseError if an error has been encountered while compiling 269 */ 270 @Test 271 public void testIncomplete() throws SearchParseError { 273 272 SearchContext sc = new SearchContext("incomplete"); 274 273 // Not incomplete … … 293 292 /** 294 293 * Search by untagged status. 295 * @throws ParseError if an error has been encountered while compiling296 */ 297 @Test 298 public void testUntagged() throws ParseError {294 * @throws SearchParseError if an error has been encountered while compiling 295 */ 296 @Test 297 public void testUntagged() throws SearchParseError { 299 298 SearchContext sc = new SearchContext("untagged"); 300 299 // Untagged … … 313 312 /** 314 313 * Search by closed status. 315 * @throws ParseError if an error has been encountered while compiling316 */ 317 @Test 318 public void testClosed() throws ParseError {314 * @throws SearchParseError if an error has been encountered while compiling 315 */ 316 @Test 317 public void testClosed() throws SearchParseError { 319 318 SearchContext sc = new SearchContext("closed"); 320 319 // Closed … … 332 331 /** 333 332 * Search by new status. 334 * @throws ParseError if an error has been encountered while compiling335 */ 336 @Test 337 public void testNew() throws ParseError {333 * @throws SearchParseError if an error has been encountered while compiling 334 */ 335 @Test 336 public void testNew() throws SearchParseError { 338 337 SearchContext sc = new SearchContext("new"); 339 338 // New … … 352 351 /** 353 352 * Search for node objects. 354 * @throws ParseError if an error has been encountered while compiling355 */ 356 @Test 357 public void testTypeNode() throws ParseError {353 * @throws SearchParseError if an error has been encountered while compiling 354 */ 355 @Test 356 public void testTypeNode() throws SearchParseError { 358 357 final SearchContext sc = new SearchContext("type:node"); 359 358 for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) { … … 364 363 /** 365 364 * Search for way objects. 366 * @throws ParseError if an error has been encountered while compiling367 */ 368 @Test 369 public void testTypeWay() throws ParseError {365 * @throws SearchParseError if an error has been encountered while compiling 366 */ 367 @Test 368 public void testTypeWay() throws SearchParseError { 370 369 final SearchContext sc = new SearchContext("type:way"); 371 370 for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) { … … 376 375 /** 377 376 * Search for relation objects. 378 * @throws ParseError if an error has been encountered while compiling379 */ 380 @Test 381 public void testTypeRelation() throws ParseError {377 * @throws SearchParseError if an error has been encountered while compiling 378 */ 379 @Test 380 public void testTypeRelation() throws SearchParseError { 382 381 final SearchContext sc = new SearchContext("type:relation"); 383 382 for (OsmPrimitive p : new OsmPrimitive[]{sc.n1, sc.n2, sc.w1, sc.w2, sc.r1, sc.r2}) { … … 388 387 /** 389 388 * Search for users. 390 * @throws ParseError if an error has been encountered while compiling391 */ 392 @Test 393 public void testUser() throws ParseError {389 * @throws SearchParseError if an error has been encountered while compiling 390 */ 391 @Test 392 public void testUser() throws SearchParseError { 394 393 final SearchContext foobar = new SearchContext("user:foobar"); 395 394 foobar.n1.setUser(User.createLocalUser("foobar")); … … 410 409 SearchCompiler.compile("foo type bar"); 411 410 fail(); 412 } catch ( ParseError parseError) {411 } catch (SearchParseError parseError) { 413 412 assertEquals("<html>Expecting <code>:</code> after <i>type</i>", parseError.getMessage()); 414 413 } … … 417 416 /** 418 417 * Search for primitive timestamps. 419 * @throws ParseError if an error has been encountered while compiling420 */ 421 @Test 422 public void testTimestamp() throws ParseError {418 * @throws SearchParseError if an error has been encountered while compiling 419 */ 420 @Test 421 public void testTimestamp() throws SearchParseError { 423 422 final Match search = SearchCompiler.compile("timestamp:2010/2011"); 424 423 final Node n1 = new Node(); … … 431 430 /** 432 431 * Tests the implementation of the Boolean logic. 433 * @throws ParseError if an error has been encountered while compiling434 */ 435 @Test 436 public void testBooleanLogic() throws ParseError {432 * @throws SearchParseError if an error has been encountered while compiling 433 */ 434 @Test 435 public void testBooleanLogic() throws SearchParseError { 437 436 final SearchCompiler.Match c1 = SearchCompiler.compile("foo AND bar AND baz"); 438 437 assertTrue(c1.match(newPrimitive("foobar", "baz"))); … … 454 453 /** 455 454 * Tests {@code buildSearchStringForTag}. 456 * @throws ParseError if an error has been encountered while compiling457 */ 458 @Test 459 public void testBuildSearchStringForTag() throws ParseError {455 * @throws SearchParseError if an error has been encountered while compiling 456 */ 457 @Test 458 public void testBuildSearchStringForTag() throws SearchParseError { 460 459 final Tag tag1 = new Tag("foo=", "bar\""); 461 460 final Tag tag2 = new Tag("foo=", "=bar"); … … 472 471 /** 473 472 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/13870">Bug #13870</a>. 474 * @throws ParseError always475 */ 476 @Test(expected = ParseError.class)477 public void testPattern13870() throws ParseError {473 * @throws SearchParseError always 474 */ 475 @Test(expected = SearchParseError.class) 476 public void testPattern13870() throws SearchParseError { 478 477 // https://bugs.openjdk.java.net/browse/JI-9044959 479 478 SearchSetting setting = new SearchSetting(); … … 503 502 /** 504 503 * Robustness test for preset searching. Ensures that the query 'preset:' is not accepted. 505 * @throws ParseError always504 * @throws SearchParseError always 506 505 * @since 12464 507 506 */ 508 @Test(expected = ParseError.class)509 public void testPresetSearchMissingValue() throws ParseError {507 @Test(expected = SearchParseError.class) 508 public void testPresetSearchMissingValue() throws SearchParseError { 510 509 SearchSetting settings = new SearchSetting(); 511 510 settings.text = "preset:"; … … 520 519 * Robustness test for preset searching. Validates that it is not possible to search for 521 520 * non existing presets. 522 * @throws ParseError always521 * @throws SearchParseError always 523 522 * @since 12464 524 523 */ 525 @Test(expected = ParseError.class)526 public void testPresetNotExist() throws ParseError {524 @Test(expected = SearchParseError.class) 525 public void testPresetNotExist() throws SearchParseError { 527 526 String testPresetName = "groupnamethatshouldnotexist/namethatshouldnotexist"; 528 527 SearchSetting settings = new SearchSetting(); … … 539 538 * Robustness tests for preset searching. Ensures that combined preset names (having more than 540 539 * 1 word) must be enclosed with " . 541 * @throws ParseError always540 * @throws SearchParseError always 542 541 * @since 12464 543 542 */ 544 @Test(expected = ParseError.class)545 public void testPresetMultipleWords() throws ParseError {543 @Test(expected = SearchParseError.class) 544 public void testPresetMultipleWords() throws SearchParseError { 546 545 TaggingPreset testPreset = new TaggingPreset(); 547 546 testPreset.name = "Test Combined Preset Name"; … … 562 561 563 562 /** 564 * Ensures that correct presets are stored in the {@link org.openstreetmap.josm. actions.search.SearchCompiler.Preset}563 * Ensures that correct presets are stored in the {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.Preset} 565 564 * class against which the osm primitives are tested. 566 * @throws ParseError if an error has been encountered while compiling565 * @throws SearchParseError if an error has been encountered while compiling 567 566 * @throws NoSuchFieldException if there is no field called 'presets' 568 567 * @throws IllegalAccessException if cannot access the field where all matching presets are stored … … 570 569 */ 571 570 @Test 572 public void testPresetLookup() throws ParseError, NoSuchFieldException, IllegalAccessException {571 public void testPresetLookup() throws SearchParseError, NoSuchFieldException, IllegalAccessException { 573 572 TaggingPreset testPreset = new TaggingPreset(); 574 573 testPreset.name = "Test Preset Name"; … … 601 600 /** 602 601 * Ensures that the wildcard search works and that correct presets are stored in 603 * the {@link org.openstreetmap.josm. actions.search.SearchCompiler.Preset} class against which602 * the {@link org.openstreetmap.josm.data.osm.search.SearchCompiler.Preset} class against which 604 603 * the osm primitives are tested. 605 * @throws ParseError if an error has been encountered while compiling604 * @throws SearchParseError if an error has been encountered while compiling 606 605 * @throws NoSuchFieldException if there is no field called 'presets' 607 606 * @throws IllegalAccessException if cannot access the field where all matching presets are stored … … 609 608 */ 610 609 @Test 611 public void testPresetLookupWildcard() throws ParseError, NoSuchFieldException, IllegalAccessException {610 public void testPresetLookupWildcard() throws SearchParseError, NoSuchFieldException, IllegalAccessException { 612 611 TaggingPresetMenu group = new TaggingPresetMenu(); 613 612 group.name = "TestPresetGroup"; … … 650 649 /** 651 650 * Ensures that correct primitives are matched against the specified preset. 652 * @throws ParseError if an error has been encountered while compiling651 * @throws SearchParseError if an error has been encountered while compiling 653 652 * @since 12464 654 653 */ 655 654 @Test 656 public void testPreset() throws ParseError {655 public void testPreset() throws SearchParseError { 657 656 final String presetName = "Test Preset Name"; 658 657 final String presetGroupName = "Test Preset Group"; … … 689 688 } 690 689 } 691 -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollectionTest.java
r10962 r12656 12 12 import org.junit.Test; 13 13 import org.openstreetmap.josm.actions.search.SearchAction; 14 import org.openstreetmap.josm.actions.search.SearchCompiler;15 14 import org.openstreetmap.josm.data.osm.Tag; 15 import org.openstreetmap.josm.data.osm.search.SearchParseError; 16 16 import org.openstreetmap.josm.data.preferences.CollectionProperty; 17 17 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 34 34 * Performs various tests on a {@link RecentTagCollection}. 35 35 * 36 * @throws Search Compiler.ParseError if an error has been encountered while compiling36 * @throws SearchParseError if an error has been encountered while compiling 37 37 */ 38 38 @Test 39 public void testVarious() throws Search Compiler.ParseError {39 public void testVarious() throws SearchParseError { 40 40 final RecentTagCollection recentTags = new RecentTagCollection(2); 41 41 assertTrue(recentTags.isEmpty()); -
trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
r10657 r12656 9 9 import org.junit.Test; 10 10 import org.openstreetmap.josm.TestUtils; 11 import org.openstreetmap.josm.actions.search.SearchCompiler;12 11 import org.openstreetmap.josm.data.coor.EastNorth; 13 12 import org.openstreetmap.josm.data.osm.DataSet; 14 13 import org.openstreetmap.josm.data.osm.Relation; 15 14 import org.openstreetmap.josm.data.osm.Way; 15 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 16 16 import org.openstreetmap.josm.io.OsmReader; 17 17 import org.openstreetmap.josm.testutils.JOSMTestRules; -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java
r12548 r12656 9 9 import org.junit.Test; 10 10 import org.openstreetmap.josm.JOSMFixture; 11 import org.openstreetmap.josm.actions.search.SearchCompiler;12 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;13 11 import org.openstreetmap.josm.data.osm.Node; 14 12 import org.openstreetmap.josm.data.osm.Relation; 15 13 import org.openstreetmap.josm.data.osm.RelationMember; 14 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 15 import org.openstreetmap.josm.data.osm.search.SearchCompiler.Match; 16 import org.openstreetmap.josm.data.osm.search.SearchParseError; 16 17 import org.openstreetmap.josm.testutils.DatasetFactory; 17 18 import org.unitils.reflectionassert.ReflectionAssert; … … 79 80 } 80 81 81 private static Match compile(String expression) throws Search Compiler.ParseError {82 private static Match compile(String expression) throws SearchParseError { 82 83 return SearchCompiler.compile(expression); 83 84 } … … 86 87 * Test to parse a search expression condition. 87 88 * @throws ParseError if the template cannot be parsed 88 * @throws Search Compiler.ParseError if an error has been encountered while compiling89 */ 90 @Test 91 public void testConditionSearchExpression() throws ParseError, Search Compiler.ParseError {89 * @throws SearchParseError if an error has been encountered while compiling 90 */ 91 @Test 92 public void testConditionSearchExpression() throws ParseError, SearchParseError { 92 93 TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' | '{admin_level}'}"); 93 94 Condition condition = new Condition();
Note:
See TracChangeset
for help on using the changeset viewer.