Skip to content

Commit 96e1fbc

Browse files
committed
Polish @conditional Javadoc and tests
1 parent 239ce14 commit 96e1fbc

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

spring-context/src/main/java/org/springframework/context/annotation/Conditional.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.lang.annotation.Target;
2323

2424
/**
25-
* Indicates that a component is is only eligible for registration when all
25+
* Indicates that a component is only eligible for registration when all
2626
* {@linkplain #value() specified conditions} match.
2727
*
2828
* <p>A <em>condition</em> is any state that can be determined programmatically

spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.lang.annotation.RetentionPolicy;
2828
import java.lang.annotation.Target;
2929

30+
import org.junit.After;
3031
import org.junit.Rule;
3132
import org.junit.Test;
3233
import org.junit.rules.ExpectedException;
@@ -36,18 +37,24 @@
3637
import org.springframework.stereotype.Component;
3738

3839
/**
39-
* Test for {@link Conditional} beans.
40-
*
40+
* Tests for {@link Conditional} beans.
41+
*
4142
* @author Phillip Webb
4243
*/
4344
public class ConfigurationClassWithConditionTests {
4445

46+
private final AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
47+
4548
@Rule
4649
public ExpectedException thrown = ExpectedException.none();
4750

51+
@After
52+
public void closeContext() {
53+
ctx.close();
54+
}
55+
4856
@Test
4957
public void conditionalOnMissingBeanMatch() throws Exception {
50-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
5158
ctx.register(BeanOneConfiguration.class, BeanTwoConfiguration.class);
5259
ctx.refresh();
5360
assertTrue(ctx.containsBean("bean1"));
@@ -57,7 +64,6 @@ public void conditionalOnMissingBeanMatch() throws Exception {
5764

5865
@Test
5966
public void conditionalOnMissingBeanNoMatch() throws Exception {
60-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
6167
ctx.register(BeanTwoConfiguration.class);
6268
ctx.refresh();
6369
assertFalse(ctx.containsBean("bean1"));
@@ -67,7 +73,6 @@ public void conditionalOnMissingBeanNoMatch() throws Exception {
6773

6874
@Test
6975
public void conditionalOnBeanMatch() throws Exception {
70-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
7176
ctx.register(BeanOneConfiguration.class, BeanThreeConfiguration.class);
7277
ctx.refresh();
7378
assertTrue(ctx.containsBean("bean1"));
@@ -76,7 +81,6 @@ public void conditionalOnBeanMatch() throws Exception {
7681

7782
@Test
7883
public void conditionalOnBeanNoMatch() throws Exception {
79-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
8084
ctx.register(BeanThreeConfiguration.class);
8185
ctx.refresh();
8286
assertFalse(ctx.containsBean("bean1"));
@@ -85,15 +89,13 @@ public void conditionalOnBeanNoMatch() throws Exception {
8589

8690
@Test
8791
public void metaConditional() throws Exception {
88-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
8992
ctx.register(ConfigurationWithMetaCondition.class);
9093
ctx.refresh();
9194
assertTrue(ctx.containsBean("bean"));
9295
}
9396

9497
@Test
9598
public void nonConfigurationClass() throws Exception {
96-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
9799
ctx.register(NonConfigurationClass.class);
98100
ctx.refresh();
99101
thrown.expect(NoSuchBeanDefinitionException.class);
@@ -102,7 +104,6 @@ public void nonConfigurationClass() throws Exception {
102104

103105
@Test
104106
public void methodConditional() throws Exception {
105-
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
106107
ctx.register(ConditionOnMethodConfiguration.class);
107108
ctx.refresh();
108109
thrown.expect(NoSuchBeanDefinitionException.class);

0 commit comments

Comments
 (0)