GroovyBeanDefinitionReader consistently throws BeanDefinitionParsingException for invalid files of any name
Issue: SPR-12435
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,16 +16,20 @@
|
||||
|
||||
package org.springframework.context.groovy;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.support.GenericGroovyApplicationContext;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Jeff Brown
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class GroovyApplicationContextTests extends TestCase {
|
||||
public class GroovyApplicationContextTests {
|
||||
|
||||
@Test
|
||||
public void testLoadingConfigFile() {
|
||||
GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext(
|
||||
"org/springframework/context/groovy/applicationContext.groovy");
|
||||
@@ -35,6 +39,7 @@ public class GroovyApplicationContextTests extends TestCase {
|
||||
assertEquals("Grails", framework);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadingMultipleConfigFiles() {
|
||||
GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext(
|
||||
"org/springframework/context/groovy/applicationContext2.groovy",
|
||||
@@ -49,6 +54,7 @@ public class GroovyApplicationContextTests extends TestCase {
|
||||
assertEquals("SpringSource", company);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadingMultipleConfigFilesWithRelativeClass() {
|
||||
GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext();
|
||||
ctx.load(GroovyApplicationContextTests.class, "applicationContext2.groovy", "applicationContext.groovy");
|
||||
@@ -63,4 +69,14 @@ public class GroovyApplicationContextTests extends TestCase {
|
||||
assertEquals("SpringSource", company);
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
public void testConfigFileParsingError() {
|
||||
new GenericGroovyApplicationContext("org/springframework/context/groovy/applicationContext-error.groovy");
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
public void testConfigFileParsingErrorWhenNamedBeans() {
|
||||
new GenericGroovyApplicationContext("org/springframework/context/groovy/beans.groovy");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.springframework.context.groovy
|
||||
|
||||
beans = {
|
||||
framework String, 'Grails'
|
||||
foo String, 'hello'
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.springframework.context.groovy
|
||||
|
||||
beans = {
|
||||
framework String, 'Grails'
|
||||
foo String, 'hello'
|
||||
}
|
||||
Reference in New Issue
Block a user