Skip to content

Commit 5493ab7

Browse files
committed
GH-148: Test for @Retryable with an XML config
Fixes: #148 Issue link: #148
1 parent 74b7ae2 commit 5493ab7

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2024-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.retry.annotation;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
23+
24+
import static org.assertj.core.api.Assertions.assertThat;
25+
26+
/**
27+
* @author Artem Bilan
28+
* @since 2.0.9
29+
*/
30+
@SpringJUnitConfig
31+
public class RetryableXmlConfigTests {
32+
33+
@Autowired
34+
Service service;
35+
36+
@Test
37+
void serviceCallIsRetied() {
38+
this.service.service();
39+
assertThat(service.getCount()).isEqualTo(3);
40+
}
41+
42+
public static class Service {
43+
44+
private int count = 0;
45+
46+
@Retryable
47+
public void service() {
48+
if (this.count++ < 2) {
49+
throw new RuntimeException("Planned");
50+
}
51+
}
52+
53+
public int getCount() {
54+
return this.count;
55+
}
56+
57+
}
58+
59+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:aop="http://www.springframework.org/schema/aop"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
6+
http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">
7+
8+
<aop:aspectj-autoproxy/>
9+
10+
<bean class="org.springframework.retry.annotation.RetryConfiguration"/>
11+
12+
<bean class="org.springframework.retry.annotation.RetryableXmlConfigTests.Service"/>
13+
14+
</beans>

0 commit comments

Comments
 (0)