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

The following examples show how to use org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry. These examples are extracted from open source projects. 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
@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
@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 3
@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 4
@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 5
@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 6
@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 7
@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 8
@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);
}
 
Example 9
@Test
public void generateBeanNameFromComposedControllerAnnotationWithStringValue() {
	// SPR-11360
	BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(
		ComposedControllerAnnotationWithStringValue.class);
	String beanName = this.beanNameGenerator.generateBeanName(bd, registry);
	assertEquals("restController", beanName);
}
 
Example 10
@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 11
@Test
public void withImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("import.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example 12
@Test
public void withWildcardImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("importPattern.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example 13
@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 14
@Test
public void withFreshInputStream() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("test.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example 15
@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 16
@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 17
@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 18
@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 19
@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 20
@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 21
/**
 * @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 22
/**
 * @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 23
/**
 * @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 24
@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 25
@Test
public void withImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("import.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example 26
@Test
public void withWildcardImport() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("importPattern.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example 27
@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 28
@Test
public void withFreshInputStream() {
	SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
	Resource resource = new ClassPathResource("test.xml", getClass());
	new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
	testBeanDefinitions(registry);
}
 
Example 29
@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 30
@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);
}