List of usage examples for org.springframework.beans FatalBeanException getMessage
@Override
@Nullable
public String getMessage()
From source file:org.jasig.cas.util.annotation.AnnotationBeanPostProcessorTests.java
public void testFailed() { for (final AbstractAnnotationBeanPostProcessor processor : this.processors) { try {/*from w ww.j a v a2 s.c o m*/ processor.postProcessBeforeInitialization(new BadTestClass(), "test"); fail("processor: " + processor.getClass().getName() + "did not fail."); } catch (final FatalBeanException e) { System.out.println(e.getMessage()); } } try { this.processors[2].postProcessBeforeInitialization(new BadNotEmptyCollection(), "test"); fail("processor: " + this.processors[2].getClass().getName() + " did not fail."); } catch (final FatalBeanException e) { System.out.println(e.getMessage()); } try { this.processors[2].postProcessBeforeInitialization(new BadNotEmptyArray(), "test"); fail("processor: " + this.processors[2].getClass().getName() + " did not fail."); } catch (final FatalBeanException e) { System.out.println(e.getMessage()); } try { this.processors[2].postProcessBeforeInitialization(new BadNotEmptyArray2(), "test"); fail("processor: " + this.processors[2].getClass().getName() + " did not fail."); } catch (final FatalBeanException e) { System.out.println(e.getMessage()); } }
From source file:org.jasig.cas.util.annotation.AnnotationBeanPostProcessorTests.java
public void testPassed() { for (final AbstractAnnotationBeanPostProcessor processor : this.processors) { try {//from ww w .java 2s. co m processor.postProcessBeforeInitialization(new GoodTestClass(), "test"); } catch (final FatalBeanException e) { fail("processor: " + processor.getClass().getName() + "did fail:" + e.getMessage()); } } }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestPluginConfigurationServiceDefault.java
@Test public void testInitialize02() throws IOException { File xsd = new File(TestPluginConfigurationServiceDefault.workingDirectory, PluginConfigurationService.CONFIG_XSD_FILE_NAME); File xml = new File(TestPluginConfigurationServiceDefault.workingDirectory, PluginConfigurationService.CONFIG_XML_FILE_NAME); assertFalse("The XSD file [" + xsd.getCanonicalPath() + "] should not exist yet.", xsd.exists()); assertFalse("The XML file [" + xml.getCanonicalPath() + "] should not exist yet.", xml.exists()); replay(this.service); try {//from ww w. ja v a 2 s . c o m this.service.initialize(); assertTrue("The XSD file should exist now.", xsd.exists()); assertTrue("The XML file should exist now.", xml.exists()); ConfigurationEntity configuration = this.getExistingConfiguration(); assertNotNull("The configuration should not be null.", configuration); FileUtils.forceDelete(xml); try { this.service.changeOccured(""); fail("Expected exception org.springframework.beans.FatalBeanException, got no exception."); } catch (FatalBeanException e) { assertTrue("The error message [" + e.getMessage() + "] is not correct.", e.getMessage().startsWith("Could not read plugin configuration XML file;")); } this.service.destroy(); verify(this.service); } finally { if (xsd.exists()) FileUtils.forceDelete(xsd); if (xml.exists()) FileUtils.forceDelete(xml); } }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestPluginConfigurationServiceDefault.java
@Test public void testInitialize03() throws IOException { File xsd = new File(TestPluginConfigurationServiceDefault.workingDirectory, PluginConfigurationService.CONFIG_XSD_FILE_NAME); File xml = new File(TestPluginConfigurationServiceDefault.workingDirectory, PluginConfigurationService.CONFIG_XML_FILE_NAME); assertFalse("The XSD file [" + xsd.getCanonicalPath() + "] should not exist yet.", xsd.exists()); assertFalse("The XML file [" + xml.getCanonicalPath() + "] should not exist yet.", xml.exists()); replay(this.service); try {//from ww w. ja v a 2s .c o m this.service.initialize(); assertTrue("The XSD file should exist now.", xsd.exists()); assertTrue("The XML file should exist now.", xml.exists()); ConfigurationEntity configuration = this.getExistingConfiguration(); assertNotNull("The configuration should not be null.", configuration); PluginFileUtils.copyResource(this.getClass(), "testInvalidLastUpdateDate.xml", xml); try { this.service.changeOccured(""); fail("Expected exception org.springframework.beans.FatalBeanException, got no exception."); } catch (FatalBeanException e) { assertTrue("The error message [" + e.getMessage() + "] is not correct.", e.getMessage().startsWith("Could not parse plugin configuration XML;")); } this.service.destroy(); verify(this.service); } finally { if (xsd.exists()) FileUtils.forceDelete(xsd); if (xml.exists()) FileUtils.forceDelete(xml); } }
From source file:org.springframework.beans.factory.xml.XmlBeanFactoryTests.java
@Test public void testNoSuchInitMethod() throws Exception { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(INITIALIZERS_CONTEXT); try {// w w w . j ava 2s. c om xbf.getBean("init-method3"); fail(); } catch (FatalBeanException ex) { // check message is helpful assertTrue(ex.getMessage().indexOf("initializers.xml") != -1); assertTrue(ex.getMessage().indexOf("init-method3") != -1); assertTrue(ex.getMessage().indexOf("init") != -1); } }