org.springframework.beans.factory.parsing.BeanDefinitionParsingException Java Examples

The following examples show how to use org.springframework.beans.factory.parsing.BeanDefinitionParsingException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyBeanDefinitionReader.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Define a Spring XML namespace definition to use.
 * @param definition the namespace definition
 */
public void xmlns(Map<String, String> definition) {
	if (!definition.isEmpty()) {
		for (Map.Entry<String,String> entry : definition.entrySet()) {
			String namespace = entry.getKey();
			String uri = entry.getValue();
			if (uri == null) {
				throw new IllegalArgumentException("Namespace definition must supply a non-null URI");
			}
			NamespaceHandler namespaceHandler = this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(
				uri);
			if (namespaceHandler == null) {
				throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri,
						new Location(new DescriptiveResource(("Groovy")))));
			}
			this.namespaces.put(namespace, uri);
		}
	}
}
 
Example #2
Source File: GroovyBeanDefinitionReader.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Define a Spring XML namespace definition to use.
 * @param definition the namespace definition
 */
public void xmlns(Map<String, String> definition) {
	if (!definition.isEmpty()) {
		for (Map.Entry<String,String> entry : definition.entrySet()) {
			String namespace = entry.getKey();
			String uri = entry.getValue();
			if (uri == null) {
				throw new IllegalArgumentException("Namespace definition must supply a non-null URI");
			}
			NamespaceHandler namespaceHandler =
					this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri);
			if (namespaceHandler == null) {
				throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri,
						new Location(new DescriptiveResource(("Groovy")))));
			}
			this.namespaces.put(namespace, uri);
		}
	}
}
 
Example #3
Source File: GroovyBeanDefinitionReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Define a Spring XML namespace definition to use.
 * @param definition the namespace definition
 */
public void xmlns(Map<String, String> definition) {
	if (!definition.isEmpty()) {
		for (Map.Entry<String,String> entry : definition.entrySet()) {
			String namespace = entry.getKey();
			String uri = entry.getValue();
			if (uri == null) {
				throw new IllegalArgumentException("Namespace definition must supply a non-null URI");
			}
			NamespaceHandler namespaceHandler =
					this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri);
			if (namespaceHandler == null) {
				throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri,
						new Location(new DescriptiveResource(("Groovy")))));
			}
			this.namespaces.put(namespace, uri);
		}
	}
}
 
Example #4
Source File: InvalidConfigurationClassDefinitionTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void configurationClassesMayNotBeFinal() {
	@Configuration
	final class Config { }

	BeanDefinition configBeanDef = rootBeanDefinition(Config.class).getBeanDefinition();
	DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
	beanFactory.registerBeanDefinition("config", configBeanDef);

	try {
		ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
		pp.postProcessBeanFactory(beanFactory);
		fail("expected exception");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue(ex.getMessage(), ex.getMessage().contains("Remove the final modifier"));
	}
}
 
Example #5
Source File: GroovyBeanDefinitionReader.java    From blog_demos with Apache License 2.0 6 votes vote down vote up
/**
 * Define a Spring namespace definition to use.
 * @param definition the namespace definition
 */
public void xmlns(Map<String, String> definition) {
	if (!definition.isEmpty()) {
		for (Map.Entry<String,String> entry : definition.entrySet()) {
			String namespace = entry.getKey();
			String uri = entry.getValue();
			if (uri == null) {
				throw new IllegalArgumentException("Namespace definition must supply a non-null URI");
			}
			NamespaceHandler namespaceHandler = this.xmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri);
			if (namespaceHandler == null) {
				throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri,
						new Location(new DescriptiveResource(("Groovy")))));
			}
			this.namespaces.put(namespace, uri);
		}
	}
}
 
Example #6
Source File: GroovyBeanDefinitionReader.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Define a Spring XML namespace definition to use.
 * @param definition the namespace definition
 */
public void xmlns(Map<String, String> definition) {
	if (!definition.isEmpty()) {
		for (Map.Entry<String,String> entry : definition.entrySet()) {
			String namespace = entry.getKey();
			String uri = entry.getValue();
			if (uri == null) {
				throw new IllegalArgumentException("Namespace definition must supply a non-null URI");
			}
			NamespaceHandler namespaceHandler =
					this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri);
			if (namespaceHandler == null) {
				throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri,
						new Location(new DescriptiveResource(("Groovy")))));
			}
			this.namespaces.put(namespace, uri);
		}
	}
}
 
Example #7
Source File: InvalidConfigurationClassDefinitionTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void configurationClassesMayNotBeFinal() {
	@Configuration
	final class Config { }

	BeanDefinition configBeanDef = rootBeanDefinition(Config.class).getBeanDefinition();
	DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
	beanFactory.registerBeanDefinition("config", configBeanDef);

	try {
		ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
		pp.postProcessBeanFactory(beanFactory);
		fail("expected exception");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue(ex.getMessage(), ex.getMessage().contains("Remove the final modifier"));
	}
}
 
Example #8
Source File: InvalidConfigurationClassDefinitionTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void configurationClassesMayNotBeFinal() {
	@Configuration
	final class Config { }

	BeanDefinition configBeanDef = rootBeanDefinition(Config.class).getBeanDefinition();
	DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
	beanFactory.registerBeanDefinition("config", configBeanDef);

	try {
		ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
		pp.postProcessBeanFactory(beanFactory);
		fail("expected exception");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue(ex.getMessage(), ex.getMessage().contains("Remove the final modifier"));
	}
}
 
Example #9
Source File: AbstractCircularImportDetectionTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void simpleCircularImportIsDetected() throws Exception {
	boolean threw = false;
	try {
		newParser().parse(loadAsConfigurationSource(A.class), "A");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue("Wrong message. Got: " + ex.getMessage(),
				ex.getMessage().contains(
					"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.B' " +
					"to import class 'AbstractCircularImportDetectionTests.A'"));
		threw = true;
	}
	assertTrue(threw);
}
 
Example #10
Source File: AopNamespaceHandlerPointcutErrorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testMissingPointcutConfig() {
	try {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
				qualifiedResource(getClass(), "pointcutMissing.xml"));
		fail("parsing should have caused a BeanDefinitionStoreException");
	}
	catch (BeanDefinitionStoreException ex) {
		assertTrue(ex.contains(BeanDefinitionParsingException.class));
	}
}
 
Example #11
Source File: AbstractCircularImportDetectionTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void complexCircularImportIsDetected() throws Exception {
	boolean threw = false;
	try {
		newParser().parse(loadAsConfigurationSource(X.class), "X");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue("Wrong message. Got: " + ex.getMessage(),
				ex.getMessage().contains(
					"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.Z2' " +
					"to import class 'AbstractCircularImportDetectionTests.Z'"));
		threw = true;
	}
	assertTrue(threw);
}
 
Example #12
Source File: AopNamespaceHandlerPointcutErrorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testDuplicatePointcutConfig() {
	try {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
				qualifiedResource(getClass(), "pointcutDuplication.xml"));
		fail("parsing should have caused a BeanDefinitionStoreException");
	}
	catch (BeanDefinitionStoreException ex) {
		assertTrue(ex.contains(BeanDefinitionParsingException.class));
	}
}
 
Example #13
Source File: ComponentScanParserScopedProxyTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("resource")
public void testInvalidConfigScopedProxy() throws Exception {
	exception.expect(BeanDefinitionParsingException.class);
	exception.expectMessage(containsString("Cannot define both 'scope-resolver' and 'scoped-proxy' on <component-scan> tag"));
	exception.expectMessage(containsString("Offending resource: class path resource [org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml]"));
	new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml");
}
 
Example #14
Source File: GroovyBeanDefinitionReader.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Load bean definitions from the specified Groovy script or XML file.
 * <p>Note that {@code ".xml"} files will be parsed as XML content; all other kinds
 * of resources will be parsed as Groovy scripts.
 * @param encodedResource the resource descriptor for the Groovy script or XML file,
 * allowing specification of an encoding to use for parsing the file
 * @return the number of bean definitions found
 * @throws BeanDefinitionStoreException in case of loading or parsing errors
 */
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
	// Check for XML files and redirect them to the "standard" XmlBeanDefinitionReader
	String filename = encodedResource.getResource().getFilename();
	if (StringUtils.endsWithIgnoreCase(filename, ".xml")) {
		return this.standardXmlBeanDefinitionReader.loadBeanDefinitions(encodedResource);
	}

	Closure beans = new Closure(this) {
		public Object call(Object[] args) {
			invokeBeanDefiningClosure((Closure) args[0]);
			return null;
		}
	};
	Binding binding = new Binding() {
		@Override
		public void setVariable(String name, Object value) {
			if (currentBeanDefinition != null) {
				applyPropertyToBeanDefinition(name, value);
			}
			else {
				super.setVariable(name, value);
			}
		}
	};
	binding.setVariable("beans", beans);

	int countBefore = getRegistry().getBeanDefinitionCount();
	try {
		GroovyShell shell = new GroovyShell(getResourceLoader().getClassLoader(), binding);
		shell.evaluate(encodedResource.getReader(), "beans");
	}
	catch (Throwable ex) {
		throw new BeanDefinitionParsingException(new Problem("Error evaluating Groovy script: " + ex.getMessage(),
				new Location(encodedResource.getResource()), null, ex));
	}
	return getRegistry().getBeanDefinitionCount() - countBefore;
}
 
Example #15
Source File: GroovyBeanDefinitionReader.java    From blog_demos with Apache License 2.0 5 votes vote down vote up
/**
 * Load bean definitions from the specified Groovy script.
 * @param encodedResource the resource descriptor for the Groovy script,
 * allowing to specify an encoding to use for parsing the file
 * @return the number of bean definitions found
 * @throws BeanDefinitionStoreException in case of loading or parsing errors
 */
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
	Closure beans = new Closure(this){
		public Object call(Object[] args) {
			invokeBeanDefiningClosure((Closure) args[0]);
			return null;
		}
	};
	Binding binding = new Binding() {
		@Override
		public void setVariable(String name, Object value) {
			if (currentBeanDefinition !=null) {
				applyPropertyToBeanDefinition(name, value);
			}
			else {
				super.setVariable(name, value);
			}
		}
	};
	binding.setVariable("beans", beans);

	int countBefore = getRegistry().getBeanDefinitionCount();
	try {
		GroovyShell shell = new GroovyShell(getResourceLoader().getClassLoader(), binding);
		shell.evaluate(encodedResource.getReader(), encodedResource.getResource().getFilename());
	}
	catch (Throwable ex) {
		throw new BeanDefinitionParsingException(new Problem("Error evaluating Groovy script: " + ex.getMessage(),
				new Location(encodedResource.getResource()), null, ex));
	}
	return getRegistry().getBeanDefinitionCount() - countBefore;
}
 
Example #16
Source File: GroovyBeanDefinitionReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load bean definitions from the specified Groovy script or XML file.
 * <p>Note that {@code ".xml"} files will be parsed as XML content; all other kinds
 * of resources will be parsed as Groovy scripts.
 * @param encodedResource the resource descriptor for the Groovy script or XML file,
 * allowing specification of an encoding to use for parsing the file
 * @return the number of bean definitions found
 * @throws BeanDefinitionStoreException in case of loading or parsing errors
 */
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
	// Check for XML files and redirect them to the "standard" XmlBeanDefinitionReader
	String filename = encodedResource.getResource().getFilename();
	if (StringUtils.endsWithIgnoreCase(filename, ".xml")) {
		return this.standardXmlBeanDefinitionReader.loadBeanDefinitions(encodedResource);
	}

	Closure beans = new Closure(this) {
		public Object call(Object[] args) {
			invokeBeanDefiningClosure((Closure) args[0]);
			return null;
		}
	};
	Binding binding = new Binding() {
		@Override
		public void setVariable(String name, Object value) {
			if (currentBeanDefinition != null) {
				applyPropertyToBeanDefinition(name, value);
			}
			else {
				super.setVariable(name, value);
			}
		}
	};
	binding.setVariable("beans", beans);

	int countBefore = getRegistry().getBeanDefinitionCount();
	try {
		GroovyShell shell = new GroovyShell(getResourceLoader().getClassLoader(), binding);
		shell.evaluate(encodedResource.getReader(), "beans");
	}
	catch (Throwable ex) {
		throw new BeanDefinitionParsingException(new Problem("Error evaluating Groovy script: " + ex.getMessage(),
				new Location(encodedResource.getResource()), null, ex));
	}
	return getRegistry().getBeanDefinitionCount() - countBefore;
}
 
Example #17
Source File: AopNamespaceHandlerPointcutErrorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testMissingPointcutConfig() {
	try {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
				qualifiedResource(getClass(), "pointcutMissing.xml"));
		fail("parsing should have caused a BeanDefinitionStoreException");
	}
	catch (BeanDefinitionStoreException ex) {
		assertTrue(ex.contains(BeanDefinitionParsingException.class));
	}
}
 
Example #18
Source File: AopNamespaceHandlerPointcutErrorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testDuplicatePointcutConfig() {
	try {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
				qualifiedResource(getClass(), "pointcutDuplication.xml"));
		fail("parsing should have caused a BeanDefinitionStoreException");
	}
	catch (BeanDefinitionStoreException ex) {
		assertTrue(ex.contains(BeanDefinitionParsingException.class));
	}
}
 
Example #19
Source File: ComponentScanParserScopedProxyTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("resource")
public void testInvalidConfigScopedProxy() throws Exception {
	exception.expect(BeanDefinitionParsingException.class);
	exception.expectMessage(containsString("Cannot define both 'scope-resolver' and 'scoped-proxy' on <component-scan> tag"));
	exception.expectMessage(containsString("Offending resource: class path resource [org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml]"));

	new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml");
}
 
Example #20
Source File: AbstractCircularImportDetectionTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void complexCircularImportIsDetected() throws Exception {
	boolean threw = false;
	try {
		newParser().parse(loadAsConfigurationSource(X.class), "X");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue("Wrong message. Got: " + ex.getMessage(),
				ex.getMessage().contains(
					"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.Z2' " +
					"to import class 'AbstractCircularImportDetectionTests.Z'"));
		threw = true;
	}
	assertTrue(threw);
}
 
Example #21
Source File: AbstractCircularImportDetectionTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void simpleCircularImportIsDetected() throws Exception {
	boolean threw = false;
	try {
		newParser().parse(loadAsConfigurationSource(A.class), "A");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue("Wrong message. Got: " + ex.getMessage(),
				ex.getMessage().contains(
					"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.B' " +
					"to import class 'AbstractCircularImportDetectionTests.A'"));
		threw = true;
	}
	assertTrue(threw);
}
 
Example #22
Source File: AopNamespaceHandlerPointcutErrorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testMissingPointcutConfig() {
	try {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
				qualifiedResource(getClass(), "pointcutMissing.xml"));
		fail("parsing should have caused a BeanDefinitionStoreException");
	}
	catch (BeanDefinitionStoreException ex) {
		assertTrue(ex.contains(BeanDefinitionParsingException.class));
	}
}
 
Example #23
Source File: AopNamespaceHandlerPointcutErrorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testDuplicatePointcutConfig() {
	try {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
				qualifiedResource(getClass(), "pointcutDuplication.xml"));
		fail("parsing should have caused a BeanDefinitionStoreException");
	}
	catch (BeanDefinitionStoreException ex) {
		assertTrue(ex.contains(BeanDefinitionParsingException.class));
	}
}
 
Example #24
Source File: AbstractCircularImportDetectionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void simpleCircularImportIsDetected() throws Exception {
	boolean threw = false;
	try {
		newParser().parse(loadAsConfigurationSource(A.class), "A");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue("Wrong message. Got: " + ex.getMessage(),
				ex.getMessage().contains(
					"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.B' " +
					"to import class 'AbstractCircularImportDetectionTests.A'"));
		threw = true;
	}
	assertTrue(threw);
}
 
Example #25
Source File: AbstractCircularImportDetectionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void complexCircularImportIsDetected() throws Exception {
	boolean threw = false;
	try {
		newParser().parse(loadAsConfigurationSource(X.class), "X");
	}
	catch (BeanDefinitionParsingException ex) {
		assertTrue("Wrong message. Got: " + ex.getMessage(),
				ex.getMessage().contains(
					"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.Z2' " +
					"to import class 'AbstractCircularImportDetectionTests.Z'"));
		threw = true;
	}
	assertTrue(threw);
}
 
Example #26
Source File: ComponentScanParserScopedProxyTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("resource")
public void testInvalidConfigScopedProxy() throws Exception {
	assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() ->
			new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml"))
		.withMessageContaining("Cannot define both 'scope-resolver' and 'scoped-proxy' on <component-scan> tag")
		.withMessageContaining("Offending resource: class path resource [org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml]");
}
 
Example #27
Source File: GroovyBeanDefinitionReader.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Load bean definitions from the specified Groovy script or XML file.
 * <p>Note that {@code ".xml"} files will be parsed as XML content; all other kinds
 * of resources will be parsed as Groovy scripts.
 * @param encodedResource the resource descriptor for the Groovy script or XML file,
 * allowing specification of an encoding to use for parsing the file
 * @return the number of bean definitions found
 * @throws BeanDefinitionStoreException in case of loading or parsing errors
 */
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
	// Check for XML files and redirect them to the "standard" XmlBeanDefinitionReader
	String filename = encodedResource.getResource().getFilename();
	if (StringUtils.endsWithIgnoreCase(filename, ".xml")) {
		return this.standardXmlBeanDefinitionReader.loadBeanDefinitions(encodedResource);
	}

	if (logger.isTraceEnabled()) {
		logger.trace("Loading Groovy bean definitions from " + encodedResource);
	}

	Closure beans = new Closure(this) {
		@Override
		public Object call(Object[] args) {
			invokeBeanDefiningClosure((Closure) args[0]);
			return null;
		}
	};
	Binding binding = new Binding() {
		@Override
		public void setVariable(String name, Object value) {
			if (currentBeanDefinition != null) {
				applyPropertyToBeanDefinition(name, value);
			}
			else {
				super.setVariable(name, value);
			}
		}
	};
	binding.setVariable("beans", beans);

	int countBefore = getRegistry().getBeanDefinitionCount();
	try {
		GroovyShell shell = new GroovyShell(getBeanClassLoader(), binding);
		shell.evaluate(encodedResource.getReader(), "beans");
	}
	catch (Throwable ex) {
		throw new BeanDefinitionParsingException(new Problem("Error evaluating Groovy script: " + ex.getMessage(),
				new Location(encodedResource.getResource()), null, ex));
	}

	int count = getRegistry().getBeanDefinitionCount() - countBefore;
	if (logger.isDebugEnabled()) {
		logger.debug("Loaded " + count + " bean definitions from " + encodedResource);
	}
	return count;
}
 
Example #28
Source File: ConfigurationClassProcessingTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testFinalBeanMethod() {
	assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() ->
			initBeanFactory(ConfigWithFinalBean.class));
}
 
Example #29
Source File: GroovyApplicationContextTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test(expected = BeanDefinitionParsingException.class)
public void testConfigFileParsingError() {
	new GenericGroovyApplicationContext("org/springframework/context/groovy/applicationContext-error.groovy");
}
 
Example #30
Source File: ConfigurationClassProcessingTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test(expected=BeanDefinitionParsingException.class)
public void testFinalBeanMethod() {
	initBeanFactory(ConfigWithFinalBean.class);
}