org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry Java Examples

The following examples show how to use org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void generateBeanNameWithNamedComponent() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentWithName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertNotNull("The generated beanName must *never* be null.", beanName);
	assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
	assertEquals("walden", beanName);
}
 
Example #2
Source File: AnnotationBeanNameGeneratorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * @since 4.0.1
 * @see https://jira.spring.io/browse/SPR-11360
 */
@Test
public void generateBeanNameFromComposedControllerAnnotationWithoutName() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithoutName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #3
Source File: AnnotationBeanNameGeneratorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * @since 4.0.1
 * @see https://jira.spring.io/browse/SPR-11360
 */
@Test
public void generateBeanNameFromComposedControllerAnnotationWithBlankName() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithBlankName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #4
Source File: AnnotationBeanNameGeneratorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * @since 4.0.1
 * @see https://jira.spring.io/browse/SPR-11360
 */
@Test
public void generateBeanNameFromComposedControllerAnnotationWithStringValue() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(
		ComposedControllerAnnotationWithStringValue.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertEquals("restController", beanName);
}
 
Example #5
Source File: XmlBeanDefinitionReaderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void withWildcardImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("importPattern.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #6
Source File: XmlBeanDefinitionReaderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void withOpenInputStreamAndExplicitValidationMode() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
	XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
	reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_DTD);
	reader.loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #7
Source File: XmlBeanDefinitionReaderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void withImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("import.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #8
Source File: XmlBeanDefinitionReaderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void withWildcardImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("importPattern.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #9
Source File: XmlBeanDefinitionReaderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void withImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("import.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #10
Source File: XmlBeanDefinitionReaderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void withInputSourceAndExplicitValidationMode() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	InputSource resource = new InputSource(getClass().getResourceAsStream("test.xml"));
	XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
	reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_DTD);
	reader.loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #11
Source File: XmlBeanDefinitionReaderTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void withFreshInputStream() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("test.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #12
Source File: AnnotationBeanNameGeneratorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void generateBeanNameFromMetaComponentWithNonStringValue() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentFromNonStringMeta.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertEquals("annotationBeanNameGeneratorTests.ComponentFromNonStringMeta", beanName);
}
 
Example #13
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void generateBeanNameWithDefaultNamedComponent() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(DefaultNamedComponent.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertNotNull("The generated beanName must *never* be null.", beanName);
	assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
	assertEquals("thoreau", beanName);
}
 
Example #14
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void generateBeanNameWithNamedComponentWhereTheNameIsBlank() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentWithBlankName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertNotNull("The generated beanName must *never* be null.", beanName);
	assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #15
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void generateBeanNameWithAnonymousComponentYieldsGeneratedBeanName() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnonymousComponent.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertNotNull("The generated beanName must *never* be null.", beanName);
	assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #16
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void generateBeanNameFromMetaComponentWithStringValue() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentFromStringMeta.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertEquals("henry", beanName);
}
 
Example #17
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void generateBeanNameFromMetaComponentWithNonStringValue() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentFromNonStringMeta.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertEquals("annotationBeanNameGeneratorTests.ComponentFromNonStringMeta", beanName);
}
 
Example #18
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * @since 4.0.1
 * @see https://jira.spring.io/browse/SPR-11360
 */
@Test
public void generateBeanNameFromComposedControllerAnnotationWithoutName() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithoutName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #19
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * @since 4.0.1
 * @see https://jira.spring.io/browse/SPR-11360
 */
@Test
public void generateBeanNameFromComposedControllerAnnotationWithBlankName() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithBlankName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #20
Source File: AnnotationBeanNameGeneratorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * @since 4.0.1
 * @see https://jira.spring.io/browse/SPR-11360
 */
@Test
public void generateBeanNameFromComposedControllerAnnotationWithStringValue() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(
		ComposedControllerAnnotationWithStringValue.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertEquals("restController", beanName);
}
 
Example #21
Source File: XmlBeanDefinitionReaderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void withOpenInputStreamAndExplicitValidationMode() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
	XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
	reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_DTD);
	reader.loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #22
Source File: XmlBeanDefinitionReaderTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test(expected = BeanDefinitionStoreException.class)
public void withOpenInputStream() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new InputStreamResource(getClass().getResourceAsStream(
			"test.xml"));
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
}
 
Example #23
Source File: XmlBeanDefinitionReaderTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void withImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("import.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example #24
Source File: AnnotationBeanNameGeneratorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void generateBeanNameWithDefaultNamedComponent() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(DefaultNamedComponent.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertNotNull("The generated beanName must *never* be null.", beanName);
	assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
	assertEquals("thoreau", beanName);
}
 
Example #25
Source File: AnnotationBeanNameGeneratorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void generateBeanNameWithNamedComponentWhereTheNameIsBlank() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentWithBlankName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertNotNull("The generated beanName must *never* be null.", beanName);
	assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #26
Source File: AnnotationBeanNameGeneratorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void generateBeanNameWithAnonymousComponentYieldsGeneratedBeanName() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnonymousComponent.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertNotNull("The generated beanName must *never* be null.", beanName);
	assertTrue("The generated beanName must *never* be blank.", StringUtils.hasText(beanName));
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #27
Source File: AnnotationBeanNameGeneratorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void generateBeanNameFromMetaComponentWithStringValue() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentFromStringMeta.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertEquals("henry", beanName);
}
 
Example #28
Source File: AnnotationBeanNameGeneratorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void generateBeanNameFromMetaComponentWithNonStringValue() {
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComponentFromNonStringMeta.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertEquals("annotationBeanNameGeneratorTests.ComponentFromNonStringMeta", beanName);
}
 
Example #29
Source File: AnnotationBeanNameGeneratorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void generateBeanNameFromComposedControllerAnnotationWithoutName() {
	// SPR-11360
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithoutName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}
 
Example #30
Source File: AnnotationBeanNameGeneratorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void generateBeanNameFromComposedControllerAnnotationWithBlankName() {
	// SPR-11360
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithBlankName.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	String expectedGeneratedBeanName = this.beanNameGenerator.buildDefaultBeanName(bd);
	assertEquals(expectedGeneratedBeanName, beanName);
}