|
22 | 22 | import java.util.Properties; |
23 | 23 | import java.util.function.BiPredicate; |
24 | 24 |
|
25 | | -import org.junit.Test; |
26 | | -import org.junit.runner.RunWith; |
| 25 | +import org.junit.jupiter.api.Test; |
27 | 26 |
|
28 | 27 | import org.springframework.beans.factory.annotation.Autowired; |
29 | 28 | import org.springframework.beans.factory.annotation.Qualifier; |
|
43 | 42 | import org.springframework.integration.selector.MetadataStoreSelector; |
44 | 43 | import org.springframework.messaging.MessageChannel; |
45 | 44 | import org.springframework.test.annotation.DirtiesContext; |
46 | | -import org.springframework.test.context.ContextConfiguration; |
47 | | -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| 45 | +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; |
48 | 46 |
|
49 | 47 | import static org.assertj.core.api.Assertions.assertThat; |
| 48 | +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
50 | 49 | import static org.assertj.core.api.Assertions.fail; |
51 | 50 | import static org.springframework.integration.test.util.TestUtils.getPropertyValue; |
52 | 51 |
|
53 | 52 | /** |
54 | 53 | * @author Artem Bilan |
| 54 | + * |
55 | 55 | * @since 4.1 |
56 | 56 | */ |
57 | | -@ContextConfiguration |
58 | | -@RunWith(SpringJUnit4ClassRunner.class) |
| 57 | +@SpringJUnitConfig |
59 | 58 | @DirtiesContext |
60 | 59 | public class IdempotentReceiverParserTests { |
61 | 60 |
|
@@ -158,111 +157,72 @@ public void testEmpty() throws Exception { |
158 | 157 | } |
159 | 158 |
|
160 | 159 | @Test |
161 | | - public void testWithoutEndpoint() throws Exception { |
162 | | - try { |
163 | | - bootStrap("without-endpoint"); |
164 | | - fail("BeanDefinitionParsingException expected"); |
165 | | - } |
166 | | - catch (BeanDefinitionParsingException e) { |
167 | | - assertThat(e.getMessage()).contains("he 'endpoint' attribute is required"); |
168 | | - } |
| 160 | + public void testWithoutEndpoint() { |
| 161 | + assertThatExceptionOfType(BeanDefinitionParsingException.class) |
| 162 | + .isThrownBy(() -> bootStrap("without-endpoint")) |
| 163 | + .withMessageContaining("The 'endpoint' attribute is required"); |
169 | 164 | } |
170 | 165 |
|
171 | 166 | @Test |
172 | | - public void testSelectorAndStore() throws Exception { |
173 | | - try { |
174 | | - bootStrap("selector-and-store"); |
175 | | - fail("BeanDefinitionParsingException expected"); |
176 | | - } |
177 | | - catch (BeanDefinitionParsingException e) { |
178 | | - assertThat(e.getMessage()) |
179 | | - .contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
180 | | - "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
181 | | - + "'compare-values'"); |
182 | | - } |
| 167 | + public void testSelectorAndStore() { |
| 168 | + assertThatExceptionOfType(BeanDefinitionParsingException.class) |
| 169 | + .isThrownBy(() -> bootStrap("selector-and-store")) |
| 170 | + .withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
| 171 | + "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
| 172 | + + "'compare-values'"); |
183 | 173 | } |
184 | 174 |
|
185 | 175 | @Test |
186 | | - public void testSelectorAndKeyStrategy() throws Exception { |
187 | | - try { |
188 | | - bootStrap("selector-and-key-strategy"); |
189 | | - fail("BeanDefinitionParsingException expected"); |
190 | | - } |
191 | | - catch (BeanDefinitionParsingException e) { |
192 | | - assertThat(e.getMessage()) |
193 | | - .contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
194 | | - "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
195 | | - + "'compare-values'"); |
196 | | - } |
| 176 | + public void testSelectorAndKeyStrategy() { |
| 177 | + assertThatExceptionOfType(BeanDefinitionParsingException.class) |
| 178 | + .isThrownBy(() -> bootStrap("selector-and-key-strategy")) |
| 179 | + .withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
| 180 | + "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
| 181 | + + "'compare-values'"); |
197 | 182 | } |
198 | 183 |
|
199 | 184 | @Test |
200 | | - public void testSelectorAndKeyExpression() throws Exception { |
201 | | - try { |
202 | | - bootStrap("selector-and-key-expression"); |
203 | | - fail("BeanDefinitionParsingException expected"); |
204 | | - } |
205 | | - catch (BeanDefinitionParsingException e) { |
206 | | - assertThat(e.getMessage()) |
207 | | - .contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
208 | | - "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
209 | | - + "'compare-values'"); |
210 | | - } |
| 185 | + public void testSelectorAndKeyExpression() { |
| 186 | + assertThatExceptionOfType(BeanDefinitionParsingException.class) |
| 187 | + .isThrownBy(() -> bootStrap("selector-and-key-expression")) |
| 188 | + .withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
| 189 | + "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
| 190 | + + "'compare-values'"); |
211 | 191 | } |
212 | 192 |
|
213 | 193 | @Test |
214 | | - public void testSelectorAndValueStrategy() throws Exception { |
215 | | - try { |
216 | | - bootStrap("selector-and-value-strategy"); |
217 | | - fail("BeanDefinitionParsingException expected"); |
218 | | - } |
219 | | - catch (BeanDefinitionParsingException e) { |
220 | | - assertThat(e.getMessage()) |
221 | | - .contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
222 | | - "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
223 | | - + "'compare-values'"); |
224 | | - } |
| 194 | + public void testSelectorAndValueStrategy() { |
| 195 | + assertThatExceptionOfType(BeanDefinitionParsingException.class) |
| 196 | + .isThrownBy(() -> bootStrap("selector-and-value-strategy")) |
| 197 | + .withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
| 198 | + "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
| 199 | + + "'compare-values'"); |
225 | 200 | } |
226 | 201 |
|
227 | 202 | @Test |
228 | | - public void testSelectorAndValueExpression() throws Exception { |
229 | | - try { |
230 | | - bootStrap("selector-and-value-expression"); |
231 | | - fail("BeanDefinitionParsingException expected"); |
232 | | - } |
233 | | - catch (BeanDefinitionParsingException e) { |
234 | | - assertThat(e.getMessage()) |
235 | | - .contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
236 | | - "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
237 | | - + "'compare-values'"); |
238 | | - } |
| 203 | + public void testSelectorAndValueExpression() { |
| 204 | + assertThatExceptionOfType(BeanDefinitionParsingException.class) |
| 205 | + .isThrownBy(() -> bootStrap("selector-and-value-expression")) |
| 206 | + .withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " + |
| 207 | + "'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and " |
| 208 | + + "'compare-values'"); |
239 | 209 | } |
240 | 210 |
|
241 | 211 | @Test |
242 | | - public void testKeyStrategyAndKeyExpression() throws Exception { |
243 | | - try { |
244 | | - bootStrap("key-strategy-and-key-expression"); |
245 | | - fail("BeanDefinitionParsingException expected"); |
246 | | - } |
247 | | - catch (BeanDefinitionParsingException e) { |
248 | | - assertThat(e.getMessage()) |
249 | | - .contains("The 'key-strategy' and 'key-expression' attributes are mutually exclusive"); |
250 | | - } |
| 212 | + public void testKeyStrategyAndKeyExpression() { |
| 213 | + assertThatExceptionOfType(BeanDefinitionParsingException.class) |
| 214 | + .isThrownBy(() -> bootStrap("key-strategy-and-key-expression")) |
| 215 | + .withMessageContaining("The 'key-strategy' and 'key-expression' attributes are mutually exclusive"); |
251 | 216 | } |
252 | 217 |
|
253 | 218 | @Test |
254 | | - public void testValueStrategyAndValueExpression() throws Exception { |
255 | | - try { |
256 | | - bootStrap("value-strategy-and-value-expression"); |
257 | | - fail("BeanDefinitionParsingException expected"); |
258 | | - } |
259 | | - catch (BeanDefinitionParsingException e) { |
260 | | - assertThat(e.getMessage()) |
261 | | - .contains("The 'value-strategy' and 'value-expression' attributes are mutually exclusive"); |
262 | | - } |
| 219 | + public void testValueStrategyAndValueExpression() { |
| 220 | + assertThatExceptionOfType(BeanDefinitionParsingException.class) |
| 221 | + .isThrownBy(() -> bootStrap("value-strategy-and-value-expression")) |
| 222 | + .withMessageContaining("The 'value-strategy' and 'value-expression' attributes are mutually exclusive"); |
263 | 223 | } |
264 | 224 |
|
265 | | - private ApplicationContext bootStrap(String configProperty) throws Exception { |
| 225 | + private static ApplicationContext bootStrap(String configProperty) throws Exception { |
266 | 226 | PropertiesFactoryBean pfb = new PropertiesFactoryBean(); |
267 | 227 | pfb.setLocation(new ClassPathResource( |
268 | 228 | "org/springframework/integration/config/xml/idempotent-receiver-configs.properties")); |
|
0 commit comments