use of org.springframework.beans.FatalBeanException in project spring-framework by spring-projects.
the class BeanFactoryTransactionTests method testNoTransactionAttributeSource.
/**
* Check that we fail gracefully if the user doesn't set any transaction attributes.
*/
@Test
public void testNoTransactionAttributeSource() {
try {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("noTransactionAttributeSource.xml", getClass()));
bf.getBean("noTransactionAttributeSource");
fail("Should require TransactionAttributeSource to be set");
} catch (FatalBeanException ex) {
// Ok
}
}
use of org.springframework.beans.FatalBeanException in project spring-framework by spring-projects.
the class RollbackRuleTests method alwaysTrueForThrowable.
@Test
public void alwaysTrueForThrowable() {
RollbackRuleAttribute rr = new RollbackRuleAttribute(java.lang.Throwable.class.getName());
assertTrue(rr.getDepth(new MyRuntimeException("")) > 0);
assertTrue(rr.getDepth(new IOException()) > 0);
assertTrue(rr.getDepth(new FatalBeanException(null, null)) > 0);
assertTrue(rr.getDepth(new RuntimeException()) > 0);
}
use of org.springframework.beans.FatalBeanException in project spring-boot by spring-projects.
the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForExcludedAutoConfigurationType.
@Test
public void failureAnalysisForExcludedAutoConfigurationType() {
FatalBeanException failure = createFailure(StringHandler.class);
addExclusions(this.analyzer, TestPropertyAutoConfiguration.class);
FailureAnalysis analysis = analyzeFailure(failure);
assertDescriptionConstructorMissingType(analysis, StringHandler.class, 0, String.class);
String configClass = ClassUtils.getShortName(TestPropertyAutoConfiguration.class.getName());
assertClassDisabled(analysis, String.format("auto-configuration '%s' was excluded", configClass), "string");
assertActionMissingType(analysis, String.class);
}
use of org.springframework.beans.FatalBeanException in project spring-boot by spring-projects.
the class NoSuchBeanDefinitionFailureAnalyzerTests method createFailure.
private FatalBeanException createFailure(Class<?> config, String... environment) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
this.analyzer.setBeanFactory(context.getBeanFactory());
EnvironmentTestUtils.addEnvironment(context, environment);
context.register(config);
try {
context.refresh();
return null;
} catch (FatalBeanException ex) {
return ex;
} finally {
context.close();
}
}
use of org.springframework.beans.FatalBeanException in project spring-framework by spring-projects.
the class ControllerAdviceTests method resolveExceptionWithAssertionErrorAsRootCause.
@Test
public void resolveExceptionWithAssertionErrorAsRootCause() throws Exception {
AssertionError cause = new AssertionError("argh");
FatalBeanException exception = new FatalBeanException("wrapped", cause);
testException(exception, cause.toString());
}
Aggregations