|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -127,17 +127,6 @@ void safeNavigation() {
|
127 | 127 | evaluate("null?.null?.null", null, null);
|
128 | 128 | }
|
129 | 129 |
|
130 |
| - @Test // SPR-16731 |
131 |
| - void matchesWithPatternAccessThreshold() { |
132 |
| - String pattern = "^(?=[a-z0-9-]{1,47})([a-z0-9]+[-]{0,1}){1,47}[a-z0-9]{1}$"; |
133 |
| - String expression = "'abcde-fghijklmn-o42pasdfasdfasdf.qrstuvwxyz10x.xx.yyy.zasdfasfd' matches \'" + pattern + "\'"; |
134 |
| - Expression expr = parser.parseExpression(expression); |
135 |
| - assertThatExceptionOfType(SpelEvaluationException.class) |
136 |
| - .isThrownBy(expr::getValue) |
137 |
| - .withCauseInstanceOf(IllegalStateException.class) |
138 |
| - .satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.FLAWED_PATTERN)); |
139 |
| - } |
140 |
| - |
141 | 130 | // mixing operators
|
142 | 131 | @Test
|
143 | 132 | void mixingOperators() {
|
@@ -462,28 +451,35 @@ void relOperatorsInstanceof06() {
|
462 | 451 | }
|
463 | 452 |
|
464 | 453 | @Test
|
465 |
| - void relOperatorsMatches01() { |
| 454 | + void matchesTrue() { |
| 455 | + evaluate("'5.00' matches '^-?\\d+(\\.\\d{2})?$'", "true", Boolean.class); |
| 456 | + } |
| 457 | + |
| 458 | + @Test |
| 459 | + void matchesFalse() { |
466 | 460 | evaluate("'5.0067' matches '^-?\\d+(\\.\\d{2})?$'", "false", Boolean.class);
|
467 | 461 | }
|
468 | 462 |
|
469 | 463 | @Test
|
470 |
| - void relOperatorsMatches02() { |
471 |
| - evaluate("'5.00' matches '^-?\\d+(\\.\\d{2})?$'", "true", Boolean.class); |
| 464 | + void matchesWithInputConversion() { |
| 465 | + evaluate("27 matches '^.*2.*$'", true, Boolean.class); // conversion int --> string |
472 | 466 | }
|
473 | 467 |
|
474 | 468 | @Test
|
475 |
| - void relOperatorsMatches03() { |
| 469 | + void matchesWithNullInput() { |
476 | 470 | evaluateAndCheckError("null matches '^.*$'", SpelMessage.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, 0, null);
|
477 | 471 | }
|
478 | 472 |
|
479 | 473 | @Test
|
480 |
| - void relOperatorsMatches04() { |
| 474 | + void matchesWithNullPattern() { |
481 | 475 | evaluateAndCheckError("'abc' matches null", SpelMessage.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, 14, null);
|
482 | 476 | }
|
483 | 477 |
|
484 |
| - @Test |
485 |
| - void relOperatorsMatches05() { |
486 |
| - evaluate("27 matches '^.*2.*$'", true, Boolean.class); // conversion int>string |
| 478 | + @Test // SPR-16731 |
| 479 | + void matchesWithPatternAccessThreshold() { |
| 480 | + String pattern = "^(?=[a-z0-9-]{1,47})([a-z0-9]+[-]{0,1}){1,47}[a-z0-9]{1}$"; |
| 481 | + String expression = "'abcde-fghijklmn-o42pasdfasdfasdf.qrstuvwxyz10x.xx.yyy.zasdfasfd' matches '" + pattern + "'"; |
| 482 | + evaluateAndCheckError(expression, SpelMessage.FLAWED_PATTERN); |
487 | 483 | }
|
488 | 484 |
|
489 | 485 | }
|
|
0 commit comments