Skip to content

Commit cf64030

Browse files
author
marcpalmer
committed
Cleaned up all tests with tearDown nulling refs
git-svn-id: https://svn.codehaus.org/grails/trunk@3981 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent 483841a commit cf64030

30 files changed

+180
-215
lines changed

test/commons/org/codehaus/groovy/grails/commons/DynamicMethodsMetaClassTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public void set(Object object, Object newValue) {
5050
this.groovyObject = (GroovyObject)groovyClass.newInstance();
5151
}
5252

53+
protected void tearDown() {
54+
groovyObject = null;
55+
}
56+
5357
public void testInvokeExistingJavaMethod() {
5458
assertNotNull(groovyObject.invokeMethod("toString", new Object[0]));
5559
}

test/commons/org/codehaus/groovy/grails/commons/test/AbstractGrailsIntegrationTests.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ protected HttpServletRequest createMockRequest(String uri) {
163163
protected abstract void onSetUp();
164164

165165
protected final void tearDown() throws Exception {
166-
super.tearDown();
167166
if(TransactionSynchronizationManager.hasResource(this.sessionFactory)) {
168167
SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(this.sessionFactory);
169168
org.hibernate.Session s = holder.getSession();
@@ -172,7 +171,18 @@ protected final void tearDown() throws Exception {
172171
SessionFactoryUtils.releaseSession(s, this.sessionFactory);
173172
}
174173
onTearDown();
175-
}
174+
175+
gcl = null;
176+
ga = null;
177+
messageSource = null;
178+
parentContext = null;
179+
applicationContext = null;
180+
servletContext = null;
181+
sessionFactory = null;
182+
session = null;
183+
184+
super.tearDown();
185+
}
176186

177187
/**
178188
* Called directly before destruction of the TestCase in the junit.framework.TestCase#tearDown() method

test/commons/org/codehaus/groovy/grails/commons/test/AbstractGrailsMockTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ protected final void tearDown() throws Exception {
6565

6666
ga = null;
6767
ctx = null;
68+
gcl = null;
6869

6970
super.tearDown();
7071
}

test/commons/org/codehaus/groovy/grails/commons/test/AbstractGrailsResourceTests.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,20 @@ protected final void tearDown() throws Exception {
175175
SessionFactoryUtils.releaseSession(s, this.sessionFactory);
176176
}
177177
onTearDown();
178-
}
179178

179+
gcl = null;
180+
ga = null;
181+
messageSource = null;
182+
parentContext = null;
183+
applicationContext = null;
184+
servletContext = null;
185+
sessionFactory = null;
186+
session = null;
187+
resourcePattern = null;
188+
resolver = null;
189+
resources = null;
190+
}
191+
180192
/**
181193
* Called directly before destruction of the TestCase in the junit.framework.TestCase#tearDown() method
182194
*/

test/commons/org/codehaus/groovy/grails/injection/GrailsInjectionOperationTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ public void setOperation(GrailsInjectionOperation injectionOperation) {
3434
}
3535

3636

37-
protected void onSetUp() throws Exception {
37+
protected void onTearDown() throws Exception
38+
{
39+
resources = null;
40+
injectionOperation = null;
41+
ga = null;
42+
super.onTearDown();
43+
}
44+
45+
protected void onSetUp() throws Exception {
3846
super.onSetUp();
3947

4048
resources = new PathMatchingResourcePatternResolver().getResources("classpath:org/codehaus/groovy/grails/injection/grails-app/domain/*.groovy");

test/commons/org/codehaus/groovy/grails/plugins/DefaultGrailsPluginTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ public class DefaultGrailsPluginTests extends AbstractGrailsMockTests {
3636
private Class disabled;
3737
private Class observed;
3838

39+
protected void onTearDown()
40+
{
41+
versioned = null;
42+
notVersion = null;
43+
notPluginClass = null;
44+
disabled = null;
45+
observed = null;
46+
super.onTearDown();
47+
//To change body of overridden methods use File | Settings | File Templates.
48+
}
49+
3950
protected void onSetUp() {
4051
versioned = gcl.parseClass("class MyGrailsPlugin {\n" +
4152
"def version = 1.1;" +

test/groovy/org/codehaus/groovy/grails/cli/AbstractCliTests.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ abstract class AbstractCliTests extends GroovyTestCase {
1616

1717
void tearDown() {
1818
ant.delete(dir:appBase, failonerror:false)
19+
ant = null
1920
}
2021

2122
}

test/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsControllerClassTests.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class DefaultGrailsControllerClassTests extends GroovyTestCase {
1111
gcl = new GroovyClassLoader()
1212
}
1313

14+
void tearDown() {
15+
gcl = null
16+
}
17+
1418
void testInterceptorInheritance() {
1519
gcl.parseClass("""
1620
abstract class ParentController {

test/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsDomainClassTests.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ class DefaultGrailsDomainClassTests extends GroovyTestCase {
1010
void setUp() {
1111
gcl = new GroovyClassLoader()
1212
}
13-
13+
14+
void tearDown() {
15+
gcl = null
16+
}
17+
1418
void testFetchMode() {
1519
gcl.parseClass(
1620
"""

test/groovy/org/codehaus/groovy/grails/commons/metaclass/ExpandoMetaClassCreationHandleTests.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class ExpandoMetaClassCreationHandleTests extends GroovyTestCase {
3535

3636
void tearDown() {
3737
registry.metaClassCreationHandle = original
38+
original = null
39+
registry = null
3840
}
41+
3942
void testExpandoCreationHandle() {
4043
def metaClass = registry.getMetaClass(URL.class)
4144
if(!(metaClass instanceof ExpandoMetaClass)) {

0 commit comments

Comments
 (0)