example for reproducing various exceptions
This commit is contained in:
parent
873d76b254
commit
3433af9223
|
@ -0,0 +1,12 @@
|
|||
package org.baeldung.ex.beancreationexception.cause1;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanA {
|
||||
|
||||
@Autowired
|
||||
private BeanB dependency;
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.baeldung.ex.beancreationexception.cause1;
|
||||
|
||||
public class BeanB {
|
||||
//
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package org.baeldung.ex.beancreationexception.cause2;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanA {
|
||||
|
||||
@Autowired
|
||||
private IBeanB dependency;
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.baeldung.ex.beancreationexception.cause2;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanB1 implements IBeanB {
|
||||
//
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.baeldung.ex.beancreationexception.cause2;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanB2 implements IBeanB {
|
||||
//
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.baeldung.ex.beancreationexception.cause2;
|
||||
|
||||
public interface IBeanB {
|
||||
//
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package org.baeldung.ex.beancreationexception.cause3;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanA {
|
||||
|
||||
public BeanA() {
|
||||
super();
|
||||
throw new NullPointerException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.baeldung.ex.beancreationexception.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.ex.beancreationexception.cause1")
|
||||
public class Cause1ContextWithJavaConfig {
|
||||
|
||||
public Cause1ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.baeldung.ex.beancreationexception.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.ex.beancreationexception.cause2")
|
||||
public class Cause2ContextWithJavaConfig {
|
||||
|
||||
public Cause2ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.baeldung.ex.beancreationexception.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.ex.beancreationexception.cause3")
|
||||
public class Cause3ContextWithJavaConfig {
|
||||
|
||||
public Cause3ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.baeldung.ex.beancreationexception.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.ex.beancreationexception.cause4")
|
||||
public class Cause4ContextWithJavaConfig {
|
||||
|
||||
public Cause4ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.baeldung.ex.beancreationexception;
|
||||
|
||||
import org.baeldung.ex.beancreationexception.spring.Cause1ContextWithJavaConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Cause1ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class Cause1BeanCreationExceptionIntegrationTest {
|
||||
|
||||
@Test
|
||||
public final void givenContextIsInitialized_thenNoException() {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.baeldung.ex.beancreationexception;
|
||||
|
||||
import org.baeldung.ex.beancreationexception.spring.Cause2ContextWithJavaConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Cause2ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class Cause2BeanCreationExceptionIntegrationTest {
|
||||
|
||||
@Test
|
||||
public final void givenContextIsInitialized_thenNoException() {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.baeldung.ex.beancreationexception;
|
||||
|
||||
import org.baeldung.ex.beancreationexception.spring.Cause3ContextWithJavaConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Cause3ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class Cause3BeanCreationExceptionIntegrationTest {
|
||||
|
||||
@Test
|
||||
public final void givenContextIsInitialized_thenNoException() {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.baeldung.ex.beancreationexception;
|
||||
|
||||
import org.baeldung.ex.beancreationexception.spring.Cause4ContextWithJavaConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { Cause4ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class Cause4BeanCreationExceptionIntegrationTest {
|
||||
|
||||
@Test
|
||||
public final void givenContextIsInitialized_thenNoException() {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue