GroovyBeanDefinitionReader consistently throws BeanDefinitionParsingException for invalid files of any name

Issue: SPR-12435
This commit is contained in:
Juergen Hoeller
2014-11-22 16:08:28 +01:00
parent 4bd75e4146
commit b4167be52d
4 changed files with 34 additions and 6 deletions

View File

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

View File

@@ -0,0 +1,6 @@
package org.springframework.context.groovy
beans = {
framework String, 'Grails'
foo String, 'hello'
}

View File

@@ -0,0 +1,6 @@
package org.springframework.context.groovy
beans = {
framework String, 'Grails'
foo String, 'hello'
}