@Test public void loadClassName() throws Exception { BeanDefinitionLoader loader = new BeanDefinitionLoader(this.registry, MyComponent.class.getName()); assertThat(loader.load()).isEqualTo(1); assertThat(this.registry.containsBean("myComponent")).isTrue(); }
@Test public void loadXmlResource() throws Exception { ClassPathResource resource = new ClassPathResource("sample-beans.xml", getClass()); BeanDefinitionLoader loader = new BeanDefinitionLoader(this.registry, resource); assertThat(loader.load()).isEqualTo(1); assertThat(this.registry.containsBean("myXmlComponent")).isTrue(); }
@Test public void loadGroovyResourceWithNamespace() throws Exception { ClassPathResource resource = new ClassPathResource("sample-namespace.groovy", getClass()); BeanDefinitionLoader loader = new BeanDefinitionLoader(this.registry, resource); assertThat(loader.load()).isEqualTo(1); assertThat(this.registry.containsBean("myGroovyComponent")).isTrue(); }
@Test public void loadPackageAndClassDoesNotDoubleAdd() throws Exception { BeanDefinitionLoader loader = new BeanDefinitionLoader(this.registry, MyComponent.class.getPackage(), MyComponent.class); assertThat(loader.load()).isEqualTo(1); assertThat(this.registry.containsBean("myComponent")).isTrue(); }
@Test public void loadResourceName() throws Exception { BeanDefinitionLoader loader = new BeanDefinitionLoader( this.registry, "classpath:org/springframework/boot/sample-beans.xml"); assertThat(loader.load()).isEqualTo(1); assertThat(this.registry.containsBean("myXmlComponent")).isTrue(); }