Browse Source

Removed TestGroup.LONG_RUNNING marker from Groovy and JRuby tests

pull/439/head
Juergen Hoeller 12 years ago
parent
commit
139adba96a
  1. 63
      spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java
  2. 20
      spring-context/src/test/java/org/springframework/scripting/jruby/JRubyScriptFactoryTests.java

63
spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java

@ -16,13 +16,13 @@ @@ -16,13 +16,13 @@
package org.springframework.scripting.groovy;
import groovy.lang.DelegatingMetaClass;
import groovy.lang.GroovyObject;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Map;
import groovy.lang.DelegatingMetaClass;
import groovy.lang.GroovyObject;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@ -61,13 +61,9 @@ import static org.mockito.BDDMockito.*; @@ -61,13 +61,9 @@ import static org.mockito.BDDMockito.*;
* @author Mark Fisher
* @author Chris Beams
*/
@SuppressWarnings("resource")
public class GroovyScriptFactoryTests {
@Before
public void setUp() {
Assume.group(TestGroup.LONG_RUNNING);
}
@Test
public void testStaticScript() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
@ -191,7 +187,8 @@ public class GroovyScriptFactoryTests { @@ -191,7 +187,8 @@ public class GroovyScriptFactoryTests {
try {
new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml");
fail("Should throw exception for broken script file");
} catch (NestedRuntimeException ex) {
}
catch (NestedRuntimeException ex) {
assertTrue("Wrong root cause: " + ex, ex.contains(ScriptCompilationException.class));
}
}
@ -205,9 +202,10 @@ public class GroovyScriptFactoryTests { @@ -205,9 +202,10 @@ public class GroovyScriptFactoryTests {
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
+ badScript);
try {
factory.getScriptedObject(script, new Class<?>[] {});
factory.getScriptedObject(script);
fail("Must have thrown a ScriptCompilationException (no public no-arg ctor in scripted class).");
} catch (ScriptCompilationException expected) {
}
catch (ScriptCompilationException expected) {
assertTrue(expected.contains(InstantiationException.class));
}
}
@ -221,9 +219,10 @@ public class GroovyScriptFactoryTests { @@ -221,9 +219,10 @@ public class GroovyScriptFactoryTests {
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
+ badScript);
try {
factory.getScriptedObject(script, new Class<?>[] {});
factory.getScriptedObject(script);
fail("Must have thrown a ScriptCompilationException (no oublic no-arg ctor in scripted class).");
} catch (ScriptCompilationException expected) {
}
catch (ScriptCompilationException expected) {
assertTrue(expected.contains(IllegalAccessException.class));
}
}
@ -257,7 +256,8 @@ public class GroovyScriptFactoryTests { @@ -257,7 +256,8 @@ public class GroovyScriptFactoryTests {
try {
new GroovyScriptFactory(null);
fail("Must have thrown exception by this point.");
} catch (IllegalArgumentException expected) {
}
catch (IllegalArgumentException expected) {
}
}
@ -266,7 +266,8 @@ public class GroovyScriptFactoryTests { @@ -266,7 +266,8 @@ public class GroovyScriptFactoryTests {
try {
new GroovyScriptFactory("");
fail("Must have thrown exception by this point.");
} catch (IllegalArgumentException expected) {
}
catch (IllegalArgumentException expected) {
}
}
@ -275,7 +276,8 @@ public class GroovyScriptFactoryTests { @@ -275,7 +276,8 @@ public class GroovyScriptFactoryTests {
try {
new GroovyScriptFactory("\n ");
fail("Must have thrown exception by this point.");
} catch (IllegalArgumentException expected) {
}
catch (IllegalArgumentException expected) {
}
}
@ -284,7 +286,8 @@ public class GroovyScriptFactoryTests { @@ -284,7 +286,8 @@ public class GroovyScriptFactoryTests {
try {
new ClassPathXmlApplicationContext("lwspBadGroovyContext.xml", getClass());
fail("Must have thrown a BeanCreationException ('inline:' prefix was preceded by whitespace");
} catch (BeanCreationException expected) {
}
catch (BeanCreationException expected) {
assertTrue(expected.contains(FileNotFoundException.class));
}
}
@ -296,7 +299,7 @@ public class GroovyScriptFactoryTests { @@ -296,7 +299,7 @@ public class GroovyScriptFactoryTests {
given(script.suggestedClassName()).willReturn("someName");
GroovyScriptFactory factory = new GroovyScriptFactory("a script source locator (doesn't matter here)");
Object scriptedObject = factory.getScriptedObject(script, null);
Object scriptedObject = factory.getScriptedObject(script);
assertNotNull(scriptedObject);
}
@ -304,9 +307,10 @@ public class GroovyScriptFactoryTests { @@ -304,9 +307,10 @@ public class GroovyScriptFactoryTests {
public void testGetScriptedObjectDoesChokeOnNullScriptSourceBeingPassedIn() throws Exception {
GroovyScriptFactory factory = new GroovyScriptFactory("a script source locator (doesn't matter here)");
try {
factory.getScriptedObject(null, null);
factory.getScriptedObject(null);
fail("Must have thrown a NullPointerException as per contract ('null' ScriptSource supplied");
} catch (NullPointerException expected) {
}
catch (NullPointerException expected) {
}
}
@ -395,15 +399,14 @@ public class GroovyScriptFactoryTests { @@ -395,15 +399,14 @@ public class GroovyScriptFactoryTests {
public void testProxyTargetClassNotAllowedIfNotGroovy() throws Exception {
try {
new ClassPathXmlApplicationContext("jruby-with-xsd-proxy-target-class.xml", getClass());
} catch (BeanCreationException e) {
assertTrue(e.getMessage().contains("Cannot use proxyTargetClass=true"));
}
catch (BeanCreationException ex) {
assertTrue(ex.getMessage().contains("Cannot use proxyTargetClass=true"));
}
}
@Test
public void testAnonymousScriptDetected() throws Exception {
Assume.group(TestGroup.LONG_RUNNING);
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.class);
assertEquals(4, beans.size());
@ -431,7 +434,8 @@ public class GroovyScriptFactoryTests { @@ -431,7 +434,8 @@ public class GroovyScriptFactoryTests {
try {
ctx.getBean("bean3");
fail("Should have thrown BeanCreationException");
} catch (BeanCreationException ex) {
}
catch (BeanCreationException ex) {
// expected
assertTrue(ex.contains(UnsatisfiedDependencyException.class));
}
@ -454,7 +458,8 @@ public class GroovyScriptFactoryTests { @@ -454,7 +458,8 @@ public class GroovyScriptFactoryTests {
Calculator calc = (Calculator) ctx.getBean("delegatingCalculator");
calc.add(1, 2);
fail("expected IllegalStateException");
} catch (IllegalStateException ex) {
}
catch (IllegalStateException ex) {
assertEquals("Gotcha", ex.getMessage());
}
}
@ -479,6 +484,7 @@ public class GroovyScriptFactoryTests { @@ -479,6 +484,7 @@ public class GroovyScriptFactoryTests {
assertEquals("test", result);
}
public static class TestCustomizer implements GroovyObjectCustomizer {
@Override
@ -486,9 +492,10 @@ public class GroovyScriptFactoryTests { @@ -486,9 +492,10 @@ public class GroovyScriptFactoryTests {
DelegatingMetaClass dmc = new DelegatingMetaClass(goo.getMetaClass()) {
@Override
public Object invokeMethod(Object arg0, String mName, Object[] arg2) {
if (mName.indexOf("Missing") != -1) {
if (mName.contains("Missing")) {
throw new IllegalStateException("Gotcha");
} else {
}
else {
return super.invokeMethod(arg0, mName, arg2);
}
}

20
spring-context/src/test/java/org/springframework/scripting/jruby/JRubyScriptFactoryTests.java

@ -18,11 +18,10 @@ package org.springframework.scripting.jruby; @@ -18,11 +18,10 @@ package org.springframework.scripting.jruby;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.aop.target.dynamic.Refreshable;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@ -31,8 +30,7 @@ import org.springframework.scripting.ConfigurableMessenger; @@ -31,8 +30,7 @@ import org.springframework.scripting.ConfigurableMessenger;
import org.springframework.scripting.Messenger;
import org.springframework.scripting.ScriptCompilationException;
import org.springframework.scripting.TestBeanAwareMessenger;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.TestBean;
import static org.junit.Assert.*;
@ -50,10 +48,6 @@ public class JRubyScriptFactoryTests { @@ -50,10 +48,6 @@ public class JRubyScriptFactoryTests {
"end\n" +
"RubyBar.new";
@Before
public void setUp() {
Assume.group(TestGroup.LONG_RUNNING);
}
@Test
public void testStaticScript() throws Exception {
@ -106,7 +100,7 @@ public class JRubyScriptFactoryTests { @@ -106,7 +100,7 @@ public class JRubyScriptFactoryTests {
@Test
public void testCtorWithNullScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory(null, new Class<?>[]{Messenger.class});
new JRubyScriptFactory(null, Messenger.class);
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
@ -116,7 +110,7 @@ public class JRubyScriptFactoryTests { @@ -116,7 +110,7 @@ public class JRubyScriptFactoryTests {
@Test
public void testCtorWithEmptyScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory("", new Class<?>[]{Messenger.class});
new JRubyScriptFactory("", Messenger.class);
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
@ -126,7 +120,7 @@ public class JRubyScriptFactoryTests { @@ -126,7 +120,7 @@ public class JRubyScriptFactoryTests {
@Test
public void testCtorWithWhitespacedScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory("\n ", new Class<?>[]{Messenger.class});
new JRubyScriptFactory("\n ", Messenger.class);
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
@ -136,7 +130,7 @@ public class JRubyScriptFactoryTests { @@ -136,7 +130,7 @@ public class JRubyScriptFactoryTests {
@Test
public void testCtorWithNullScriptInterfacesArray() throws Exception {
try {
new JRubyScriptFactory(RUBY_SCRIPT_SOURCE_LOCATOR, null);
new JRubyScriptFactory(RUBY_SCRIPT_SOURCE_LOCATOR);
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
@ -291,7 +285,7 @@ public class JRubyScriptFactoryTests { @@ -291,7 +285,7 @@ public class JRubyScriptFactoryTests {
}
@Test
public void testAOP() throws Exception {
public void testAop() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-aop.xml", getClass());
Messenger messenger = (Messenger) ctx.getBean("messenger");
assertEquals(new StringBuffer("Hello World!").reverse().toString(), messenger.getMessage());

Loading…
Cancel
Save