Skip to content

Commit 7da1bc0

Browse files
author
eugenp
committed
further exceptions work
1 parent 075dd7b commit 7da1bc0

File tree

6 files changed

+78
-0
lines changed

6 files changed

+78
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.baeldung.ex.beancreationexception.cause9;
2+
3+
public abstract class BeanA implements IBeanA {
4+
//
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.baeldung.ex.beancreationexception.cause9;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
@Component
6+
public class BeanB {
7+
//
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.baeldung.ex.beancreationexception.cause9;
2+
3+
public interface IBeanA {
4+
//
5+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.baeldung.ex.beancreationexception.spring;
2+
3+
import org.baeldung.ex.beancreationexception.cause9.BeanB;
4+
import org.springframework.beans.factory.BeanFactory;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.ComponentScan;
8+
import org.springframework.context.annotation.Configuration;
9+
import org.springframework.context.annotation.ImportResource;
10+
11+
@Configuration
12+
@ComponentScan("org.baeldung.ex.beancreationexception.cause9")
13+
@ImportResource("classpath:beancreationexception_cause9.xml")
14+
public class Cause9ContextWithJavaConfig {
15+
@Autowired
16+
BeanFactory beanFactory;
17+
18+
public Cause9ContextWithJavaConfig() {
19+
super();
20+
}
21+
22+
// beans
23+
24+
@Bean
25+
public BeanB beanB() {
26+
beanFactory.getBean("beanA");
27+
return new BeanB();
28+
}
29+
30+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
3+
xmlns:util="http://www.springframework.org/schema/util"
4+
xsi:schemaLocation="
5+
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
6+
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
7+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
8+
9+
<bean id="beanA" abstract="true" class="org.baeldung.ex.beancreationexception.cause9.BeanA" />
10+
11+
</beans>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.baeldung.ex.beancreationexception;
2+
3+
import org.baeldung.ex.beancreationexception.spring.Cause9ContextWithJavaConfig;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.springframework.test.context.ContextConfiguration;
7+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8+
import org.springframework.test.context.support.AnnotationConfigContextLoader;
9+
10+
@RunWith(SpringJUnit4ClassRunner.class)
11+
@ContextConfiguration(classes = { Cause9ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
12+
public class Cause9BeanCreationExceptionIntegrationTest {
13+
14+
@Test
15+
public final void givenContextIsInitialized_thenNoException() {
16+
//
17+
}
18+
19+
}

0 commit comments

Comments
 (0)