|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 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.
|
@@ -168,39 +168,35 @@ public void testRelOperatorsInstanceof06() {
|
168 | 168 | }
|
169 | 169 |
|
170 | 170 | @Test
|
171 |
| - public void testRelOperatorsMatches01() { |
172 |
| - evaluate("'5.0067' matches '^-?\\d+(\\.\\d{2})?$'", "false", Boolean.class); |
| 171 | + void matchesTrue() { |
| 172 | + evaluate("'5.00' matches '^-?\\d+(\\.\\d{2})?$'", "true", Boolean.class); |
173 | 173 | }
|
174 | 174 |
|
175 | 175 | @Test
|
176 |
| - public void testRelOperatorsMatches02() { |
177 |
| - evaluate("'5.00' matches '^-?\\d+(\\.\\d{2})?$'", "true", Boolean.class); |
| 176 | + void matchesFalse() { |
| 177 | + evaluate("'5.0067' matches '^-?\\d+(\\.\\d{2})?$'", "false", Boolean.class); |
178 | 178 | }
|
179 | 179 |
|
180 | 180 | @Test
|
181 |
| - public void testRelOperatorsMatches03() { |
182 |
| - evaluateAndCheckError("null matches '^.*$'", SpelMessage.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, 0, null); |
| 181 | + void matchesWithInputConversion() { |
| 182 | + evaluate("27 matches '^.*2.*$'", true, Boolean.class); // conversion int --> string |
183 | 183 | }
|
184 | 184 |
|
185 | 185 | @Test
|
186 |
| - public void testRelOperatorsMatches04() { |
187 |
| - evaluateAndCheckError("'abc' matches null", SpelMessage.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, 14, null); |
| 186 | + void matchesWithNullInput() { |
| 187 | + evaluateAndCheckError("null matches '^.*$'", SpelMessage.INVALID_FIRST_OPERAND_FOR_MATCHES_OPERATOR, 0, null); |
188 | 188 | }
|
189 | 189 |
|
190 | 190 | @Test
|
191 |
| - public void testRelOperatorsMatches05() { |
192 |
| - evaluate("27 matches '^.*2.*$'", true, Boolean.class); // conversion int>string |
| 191 | + void matchesWithNullPattern() { |
| 192 | + evaluateAndCheckError("'abc' matches null", SpelMessage.INVALID_SECOND_OPERAND_FOR_MATCHES_OPERATOR, 14, null); |
193 | 193 | }
|
194 | 194 |
|
195 | 195 | @Test // SPR-16731
|
196 |
| - public void testMatchesWithPatternAccessThreshold() { |
| 196 | + void matchesWithPatternAccessThreshold() { |
197 | 197 | String pattern = "^(?=[a-z0-9-]{1,47})([a-z0-9]+[-]{0,1}){1,47}[a-z0-9]{1}$";
|
198 |
| - String expression = "'abcde-fghijklmn-o42pasdfasdfasdf.qrstuvwxyz10x.xx.yyy.zasdfasfd' matches \'" + pattern + "\'"; |
199 |
| - Expression expr = parser.parseExpression(expression); |
200 |
| - assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy( |
201 |
| - expr::getValue) |
202 |
| - .withCauseInstanceOf(IllegalStateException.class) |
203 |
| - .satisfies(ex -> assertThat(ex.getMessageCode()).isEqualTo(SpelMessage.FLAWED_PATTERN)); |
| 198 | + String expression = "'abcde-fghijklmn-o42pasdfasdfasdf.qrstuvwxyz10x.xx.yyy.zasdfasfd' matches '" + pattern + "'"; |
| 199 | + evaluateAndCheckError(expression, SpelMessage.FLAWED_PATTERN); |
204 | 200 | }
|
205 | 201 |
|
206 | 202 | // mixing operators
|
|
0 commit comments