example for reproducing various exceptions

This commit is contained in:
eugenp 2013-08-11 15:41:26 +03:00
parent 873d76b254
commit 3433af9223
15 changed files with 202 additions and 0 deletions

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
package org.baeldung.ex.beancreationexception.cause1;
public class BeanB {
//
}

View File

@ -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;
}

View File

@ -0,0 +1,8 @@
package org.baeldung.ex.beancreationexception.cause2;
import org.springframework.stereotype.Component;
@Component
public class BeanB1 implements IBeanB {
//
}

View File

@ -0,0 +1,8 @@
package org.baeldung.ex.beancreationexception.cause2;
import org.springframework.stereotype.Component;
@Component
public class BeanB2 implements IBeanB {
//
}

View File

@ -0,0 +1,5 @@
package org.baeldung.ex.beancreationexception.cause2;
public interface IBeanB {
//
}

View File

@ -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();
}
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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() {
//
}
}

View File

@ -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() {
//
}
}

View File

@ -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() {
//
}
}

View File

@ -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() {
//
}
}