Skip to content

Commit 139adba

Browse files
committed
Removed TestGroup.LONG_RUNNING marker from Groovy and JRuby tests
1 parent 7502ecd commit 139adba

File tree

2 files changed

+42
-41
lines changed

2 files changed

+42
-41
lines changed

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

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
package org.springframework.scripting.groovy;
1818

19-
import groovy.lang.DelegatingMetaClass;
20-
import groovy.lang.GroovyObject;
21-
2219
import java.io.FileNotFoundException;
2320
import java.util.Arrays;
2421
import java.util.Map;
2522

23+
import groovy.lang.DelegatingMetaClass;
24+
import groovy.lang.GroovyObject;
25+
2626
import org.junit.Before;
2727
import org.junit.Ignore;
2828
import org.junit.Test;
@@ -61,13 +61,9 @@
6161
* @author Mark Fisher
6262
* @author Chris Beams
6363
*/
64+
@SuppressWarnings("resource")
6465
public class GroovyScriptFactoryTests {
6566

66-
@Before
67-
public void setUp() {
68-
Assume.group(TestGroup.LONG_RUNNING);
69-
}
70-
7167
@Test
7268
public void testStaticScript() throws Exception {
7369
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
@@ -191,7 +187,8 @@ public void testScriptCompilationException() throws Exception {
191187
try {
192188
new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml");
193189
fail("Should throw exception for broken script file");
194-
} catch (NestedRuntimeException ex) {
190+
}
191+
catch (NestedRuntimeException ex) {
195192
assertTrue("Wrong root cause: " + ex, ex.contains(ScriptCompilationException.class));
196193
}
197194
}
@@ -205,9 +202,10 @@ public void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception {
205202
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
206203
+ badScript);
207204
try {
208-
factory.getScriptedObject(script, new Class<?>[] {});
205+
factory.getScriptedObject(script);
209206
fail("Must have thrown a ScriptCompilationException (no public no-arg ctor in scripted class).");
210-
} catch (ScriptCompilationException expected) {
207+
}
208+
catch (ScriptCompilationException expected) {
211209
assertTrue(expected.contains(InstantiationException.class));
212210
}
213211
}
@@ -221,9 +219,10 @@ public void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception {
221219
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
222220
+ badScript);
223221
try {
224-
factory.getScriptedObject(script, new Class<?>[] {});
222+
factory.getScriptedObject(script);
225223
fail("Must have thrown a ScriptCompilationException (no oublic no-arg ctor in scripted class).");
226-
} catch (ScriptCompilationException expected) {
224+
}
225+
catch (ScriptCompilationException expected) {
227226
assertTrue(expected.contains(IllegalAccessException.class));
228227
}
229228
}
@@ -257,7 +256,8 @@ public void testCtorWithNullScriptSourceLocator() throws Exception {
257256
try {
258257
new GroovyScriptFactory(null);
259258
fail("Must have thrown exception by this point.");
260-
} catch (IllegalArgumentException expected) {
259+
}
260+
catch (IllegalArgumentException expected) {
261261
}
262262
}
263263

@@ -266,7 +266,8 @@ public void testCtorWithEmptyScriptSourceLocator() throws Exception {
266266
try {
267267
new GroovyScriptFactory("");
268268
fail("Must have thrown exception by this point.");
269-
} catch (IllegalArgumentException expected) {
269+
}
270+
catch (IllegalArgumentException expected) {
270271
}
271272
}
272273

@@ -275,7 +276,8 @@ public void testCtorWithWhitespacedScriptSourceLocator() throws Exception {
275276
try {
276277
new GroovyScriptFactory("\n ");
277278
fail("Must have thrown exception by this point.");
278-
} catch (IllegalArgumentException expected) {
279+
}
280+
catch (IllegalArgumentException expected) {
279281
}
280282
}
281283

@@ -284,7 +286,8 @@ public void testWithInlineScriptWithLeadingWhitespace() throws Exception {
284286
try {
285287
new ClassPathXmlApplicationContext("lwspBadGroovyContext.xml", getClass());
286288
fail("Must have thrown a BeanCreationException ('inline:' prefix was preceded by whitespace");
287-
} catch (BeanCreationException expected) {
289+
}
290+
catch (BeanCreationException expected) {
288291
assertTrue(expected.contains(FileNotFoundException.class));
289292
}
290293
}
@@ -296,17 +299,18 @@ public void testGetScriptedObjectDoesNotChokeOnNullInterfacesBeingPassedIn() thr
296299
given(script.suggestedClassName()).willReturn("someName");
297300

298301
GroovyScriptFactory factory = new GroovyScriptFactory("a script source locator (doesn't matter here)");
299-
Object scriptedObject = factory.getScriptedObject(script, null);
302+
Object scriptedObject = factory.getScriptedObject(script);
300303
assertNotNull(scriptedObject);
301304
}
302305

303306
@Test
304307
public void testGetScriptedObjectDoesChokeOnNullScriptSourceBeingPassedIn() throws Exception {
305308
GroovyScriptFactory factory = new GroovyScriptFactory("a script source locator (doesn't matter here)");
306309
try {
307-
factory.getScriptedObject(null, null);
310+
factory.getScriptedObject(null);
308311
fail("Must have thrown a NullPointerException as per contract ('null' ScriptSource supplied");
309-
} catch (NullPointerException expected) {
312+
}
313+
catch (NullPointerException expected) {
310314
}
311315
}
312316

@@ -395,15 +399,14 @@ public void testRefreshableFromTagProxyTargetClass() throws Exception {
395399
public void testProxyTargetClassNotAllowedIfNotGroovy() throws Exception {
396400
try {
397401
new ClassPathXmlApplicationContext("jruby-with-xsd-proxy-target-class.xml", getClass());
398-
} catch (BeanCreationException e) {
399-
assertTrue(e.getMessage().contains("Cannot use proxyTargetClass=true"));
402+
}
403+
catch (BeanCreationException ex) {
404+
assertTrue(ex.getMessage().contains("Cannot use proxyTargetClass=true"));
400405
}
401406
}
402407

403408
@Test
404409
public void testAnonymousScriptDetected() throws Exception {
405-
Assume.group(TestGroup.LONG_RUNNING);
406-
407410
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
408411
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.class);
409412
assertEquals(4, beans.size());
@@ -431,7 +434,8 @@ public void testCanPassInMoreThanOneProperty() {
431434
try {
432435
ctx.getBean("bean3");
433436
fail("Should have thrown BeanCreationException");
434-
} catch (BeanCreationException ex) {
437+
}
438+
catch (BeanCreationException ex) {
435439
// expected
436440
assertTrue(ex.contains(UnsatisfiedDependencyException.class));
437441
}
@@ -454,7 +458,8 @@ private void testMetaClass(final String xmlFile) {
454458
Calculator calc = (Calculator) ctx.getBean("delegatingCalculator");
455459
calc.add(1, 2);
456460
fail("expected IllegalStateException");
457-
} catch (IllegalStateException ex) {
461+
}
462+
catch (IllegalStateException ex) {
458463
assertEquals("Gotcha", ex.getMessage());
459464
}
460465
}
@@ -479,16 +484,18 @@ public void testRefreshableFactoryBean() {
479484
assertEquals("test", result);
480485
}
481486

487+
482488
public static class TestCustomizer implements GroovyObjectCustomizer {
483489

484490
@Override
485491
public void customize(GroovyObject goo) {
486492
DelegatingMetaClass dmc = new DelegatingMetaClass(goo.getMetaClass()) {
487493
@Override
488494
public Object invokeMethod(Object arg0, String mName, Object[] arg2) {
489-
if (mName.indexOf("Missing") != -1) {
495+
if (mName.contains("Missing")) {
490496
throw new IllegalStateException("Gotcha");
491-
} else {
497+
}
498+
else {
492499
return super.invokeMethod(arg0, mName, arg2);
493500
}
494501
}

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818

1919
import java.util.Map;
2020

21-
import org.junit.Before;
2221
import org.junit.Test;
22+
2323
import org.springframework.aop.support.AopUtils;
2424
import org.springframework.aop.target.dynamic.Refreshable;
25-
import org.springframework.tests.sample.beans.TestBean;
2625
import org.springframework.beans.factory.BeanCreationException;
2726
import org.springframework.context.ApplicationContext;
2827
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -31,8 +30,7 @@
3130
import org.springframework.scripting.Messenger;
3231
import org.springframework.scripting.ScriptCompilationException;
3332
import org.springframework.scripting.TestBeanAwareMessenger;
34-
import org.springframework.tests.Assume;
35-
import org.springframework.tests.TestGroup;
33+
import org.springframework.tests.sample.beans.TestBean;
3634

3735
import static org.junit.Assert.*;
3836

@@ -50,10 +48,6 @@ public class JRubyScriptFactoryTests {
5048
"end\n" +
5149
"RubyBar.new";
5250

53-
@Before
54-
public void setUp() {
55-
Assume.group(TestGroup.LONG_RUNNING);
56-
}
5751

5852
@Test
5953
public void testStaticScript() throws Exception {
@@ -106,7 +100,7 @@ public void testScriptCompilationException() throws Exception {
106100
@Test
107101
public void testCtorWithNullScriptSourceLocator() throws Exception {
108102
try {
109-
new JRubyScriptFactory(null, new Class<?>[]{Messenger.class});
103+
new JRubyScriptFactory(null, Messenger.class);
110104
fail("Must have thrown exception by this point.");
111105
}
112106
catch (IllegalArgumentException expected) {
@@ -116,7 +110,7 @@ public void testCtorWithNullScriptSourceLocator() throws Exception {
116110
@Test
117111
public void testCtorWithEmptyScriptSourceLocator() throws Exception {
118112
try {
119-
new JRubyScriptFactory("", new Class<?>[]{Messenger.class});
113+
new JRubyScriptFactory("", Messenger.class);
120114
fail("Must have thrown exception by this point.");
121115
}
122116
catch (IllegalArgumentException expected) {
@@ -126,7 +120,7 @@ public void testCtorWithEmptyScriptSourceLocator() throws Exception {
126120
@Test
127121
public void testCtorWithWhitespacedScriptSourceLocator() throws Exception {
128122
try {
129-
new JRubyScriptFactory("\n ", new Class<?>[]{Messenger.class});
123+
new JRubyScriptFactory("\n ", Messenger.class);
130124
fail("Must have thrown exception by this point.");
131125
}
132126
catch (IllegalArgumentException expected) {
@@ -136,7 +130,7 @@ public void testCtorWithWhitespacedScriptSourceLocator() throws Exception {
136130
@Test
137131
public void testCtorWithNullScriptInterfacesArray() throws Exception {
138132
try {
139-
new JRubyScriptFactory(RUBY_SCRIPT_SOURCE_LOCATOR, null);
133+
new JRubyScriptFactory(RUBY_SCRIPT_SOURCE_LOCATOR);
140134
fail("Must have thrown exception by this point.");
141135
}
142136
catch (IllegalArgumentException expected) {
@@ -291,7 +285,7 @@ public void testWithWrapperArgsInReturnTypeAndParameters() throws Exception {
291285
}
292286

293287
@Test
294-
public void testAOP() throws Exception {
288+
public void testAop() throws Exception {
295289
ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-aop.xml", getClass());
296290
Messenger messenger = (Messenger) ctx.getBean("messenger");
297291
assertEquals(new StringBuffer("Hello World!").reverse().toString(), messenger.getMessage());

0 commit comments

Comments
 (0)