From aa6e6c13491af1c259fbd754f498b9b48e397aa2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 11 Dec 2013 22:58:23 +0100 Subject: [PATCH] Polishing --- .../AbstractCircularImportDetectionTests.java | 22 +++++++++---------- .../AsmCircularImportDetectionTests.java | 11 +++++----- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java index 8f7026a9560..10aa8ee950e 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java @@ -13,21 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.context.annotation; -import static org.junit.Assert.*; +package org.springframework.context.annotation; import org.junit.Test; -import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConfigurationClassParser; -import org.springframework.context.annotation.Import; +import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.tests.sample.beans.TestBean; +import static org.junit.Assert.*; + /** - * TCK-style unit tests for handling circular use of the {@link Import} annotation. Explore - * subclass hierarchy for specific concrete implementations. + * TCK-style unit tests for handling circular use of the {@link Import} annotation. + * Explore the subclass hierarchy for specific concrete implementations. * * @author Chris Beams */ @@ -37,23 +35,23 @@ public abstract class AbstractCircularImportDetectionTests { protected abstract String loadAsConfigurationSource(Class clazz) throws Exception; + @Test public void simpleCircularImportIsDetected() throws Exception { boolean threw = false; try { newParser().parse(loadAsConfigurationSource(A.class), "A"); - } catch (BeanDefinitionParsingException ex) { + } + catch (BeanDefinitionParsingException ex) { assertTrue("Wrong message. Got: " + ex.getMessage(), ex.getMessage().contains( "Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.B' " + "to import class 'AbstractCircularImportDetectionTests.A'")); threw = true; } - assertTrue(threw); } - @Test public void complexCircularImportIsDetected() throws Exception { boolean threw = false; @@ -67,10 +65,10 @@ public abstract class AbstractCircularImportDetectionTests { "to import class 'AbstractCircularImportDetectionTests.Z'")); threw = true; } - assertTrue(threw); } + @Configuration @Import(B.class) static class A { diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java index 8bcbbf711eb..8cb5152ea06 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.context.annotation; import org.springframework.beans.factory.parsing.FailFastProblemReporter; @@ -22,12 +23,12 @@ import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.type.classreading.CachingMetadataReaderFactory; /** - * Unit test proving that ASM-based {@link ConfigurationClassParser} correctly detects circular use of - * the {@link Import @Import} annotation. + * Unit test proving that ASM-based {@link ConfigurationClassParser} correctly detects circular + * use of the {@link Import @Import} annotation. * - *

While this test is the only subclass of {@link AbstractCircularImportDetectionTests}, the - * hierarchy remains in place in case a JDT-based ConfigurationParser implementation needs to be - * developed. + *

While this test is the only subclass of {@link AbstractCircularImportDetectionTests}, + * the hierarchy remains in place in case a JDT-based ConfigurationParser implementation + * needs to be developed. * * @author Chris Beams */