Search in sources :

Example 11 with ScopeMetadata

use of cn.taketoday.context.loader.ScopeMetadata in project today-framework by TAKETODAY.

the class AnnotationScopeMetadataResolverTests method resolveScopeMetadataShouldNotApplyScopedProxyModeToSingleton.

@Test
public void resolveScopeMetadataShouldNotApplyScopedProxyModeToSingleton() {
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithSingletonScope.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    Assertions.assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull();
    Assertions.assertThat(scopeMetadata.getScopeName()).isEqualTo(BeanDefinition.SCOPE_SINGLETON);
    Assertions.assertThat(scopeMetadata.getScopedProxyMode()).isEqualTo(NO);
}
Also used : AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) ScopeMetadata(cn.taketoday.context.loader.ScopeMetadata) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 12 with ScopeMetadata

use of cn.taketoday.context.loader.ScopeMetadata in project today-framework by TAKETODAY.

the class AnnotationScopeMetadataResolverTests method customRequestScopeWithAttributeViaAsm.

@Test
public void customRequestScopeWithAttributeViaAsm() throws IOException {
    MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
    MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScopeWithAttributeOverride.class.getName());
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata());
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    Assertions.assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull();
    Assertions.assertThat(scopeMetadata.getScopeName()).isEqualTo("request");
    Assertions.assertThat(scopeMetadata.getScopedProxyMode()).isEqualTo(TARGET_CLASS);
}
Also used : SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReaderFactory(cn.taketoday.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) ScopeMetadata(cn.taketoday.context.loader.ScopeMetadata) MetadataReader(cn.taketoday.core.type.classreading.MetadataReader) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 13 with ScopeMetadata

use of cn.taketoday.context.loader.ScopeMetadata in project today-framework by TAKETODAY.

the class AnnotationScopeMetadataResolverTests method customRequestScopeViaAsm.

@Test
public void customRequestScopeViaAsm() throws IOException {
    MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
    MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScope.class.getName());
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata());
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    Assertions.assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull();
    Assertions.assertThat(scopeMetadata.getScopeName()).isEqualTo("request");
    Assertions.assertThat(scopeMetadata.getScopedProxyMode()).isEqualTo(NO);
}
Also used : SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) MetadataReaderFactory(cn.taketoday.core.type.classreading.MetadataReaderFactory) SimpleMetadataReaderFactory(cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory) AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) ScopeMetadata(cn.taketoday.context.loader.ScopeMetadata) MetadataReader(cn.taketoday.core.type.classreading.MetadataReader) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 14 with ScopeMetadata

use of cn.taketoday.context.loader.ScopeMetadata in project today-framework by TAKETODAY.

the class AnnotationScopeMetadataResolverTests method resolveScopeMetadataShouldReadScopedProxyModeFromAnnotation.

@Test
public void resolveScopeMetadataShouldReadScopedProxyModeFromAnnotation() {
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithScopedProxy.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    Assertions.assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull();
    Assertions.assertThat(scopeMetadata.getScopeName()).isEqualTo("request");
    Assertions.assertThat(scopeMetadata.getScopedProxyMode()).isEqualTo(TARGET_CLASS);
}
Also used : AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) ScopeMetadata(cn.taketoday.context.loader.ScopeMetadata) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Example 15 with ScopeMetadata

use of cn.taketoday.context.loader.ScopeMetadata in project today-framework by TAKETODAY.

the class AnnotationScopeMetadataResolverTests method resolveScopeMetadataShouldApplyScopedProxyModeToPrototype.

@Test
public void resolveScopeMetadataShouldApplyScopedProxyModeToPrototype() {
    this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(INTERFACES);
    AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithPrototypeScope.class);
    ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
    Assertions.assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull();
    Assertions.assertThat(scopeMetadata.getScopeName()).isEqualTo(BeanDefinition.SCOPE_PROTOTYPE);
    Assertions.assertThat(scopeMetadata.getScopedProxyMode()).isEqualTo(INTERFACES);
}
Also used : AnnotatedBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition) ScopeMetadata(cn.taketoday.context.loader.ScopeMetadata) AnnotatedGenericBeanDefinition(cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

ScopeMetadata (cn.taketoday.context.loader.ScopeMetadata)22 AnnotatedGenericBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedGenericBeanDefinition)16 AnnotatedBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition)14 Test (org.junit.jupiter.api.Test)14 BeanDefinitionHolder (cn.taketoday.beans.factory.config.BeanDefinitionHolder)5 BeanDefinitionStoreException (cn.taketoday.beans.factory.BeanDefinitionStoreException)4 MetadataReader (cn.taketoday.core.type.classreading.MetadataReader)4 MetadataReaderFactory (cn.taketoday.core.type.classreading.MetadataReaderFactory)4 SimpleMetadataReaderFactory (cn.taketoday.core.type.classreading.SimpleMetadataReaderFactory)4 IOException (java.io.IOException)4 AutowireCandidateQualifier (cn.taketoday.beans.factory.support.AutowireCandidateQualifier)2 Resource (cn.taketoday.core.io.Resource)2 BeanDefinition (cn.taketoday.beans.factory.config.BeanDefinition)1 AbstractBeanDefinition (cn.taketoday.beans.factory.support.AbstractBeanDefinition)1 LinkedHashSet (java.util.LinkedHashSet)1