|
Spring Framework example source code file (AnnotationScopeMetadataResolverTests.java)
The Spring Framework AnnotationScopeMetadataResolverTests.java source codepackage org.springframework.context.annotation; import junit.framework.TestCase; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.test.AssertThrows; /** * Unit tests for the {@link AnnotationScopeMetadataResolver} class. * * @author Rick Evans */ public final class AnnotationScopeMetadataResolverTests extends TestCase { private AnnotationScopeMetadataResolver scopeMetadataResolver; @Override protected void setUp() throws Exception { this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(); } public void testThatResolveScopeMetadataDoesNotApplyScopedProxyModeToASingleton() { AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithSingletonScope.class); ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd); assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata); assertEquals(BeanDefinition.SCOPE_SINGLETON, scopeMetadata.getScopeName()); assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode()); } public void testThatResolveScopeMetadataDoesApplyScopedProxyModeToAPrototype() { this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(ScopedProxyMode.INTERFACES); AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithPrototypeScope.class); ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd); assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata); assertEquals(BeanDefinition.SCOPE_PROTOTYPE, scopeMetadata.getScopeName()); assertEquals(ScopedProxyMode.INTERFACES, scopeMetadata.getScopedProxyMode()); } public void testCtorWithNullScopedProxyMode() { new AssertThrows(IllegalArgumentException.class) { public void test() throws Exception { new AnnotationScopeMetadataResolver(null); } }.runTest(); } public void testSetScopeAnnotationTypeWithNullType() { new AssertThrows(IllegalArgumentException.class) { public void test() throws Exception { scopeMetadataResolver.setScopeAnnotationType(null); } }.runTest(); } @Scope("singleton") private static final class AnnotatedWithSingletonScope { } @Scope("prototype") private static final class AnnotatedWithPrototypeScope { } } Other Spring Framework examples (source code examples)Here is a short list of links related to this Spring Framework AnnotationScopeMetadataResolverTests.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.