Skip to content

Commit fb39812

Browse files
committed
Cleanup test projects after tests
1 parent ed2c571 commit fb39812

File tree

6 files changed

+41
-48
lines changed

6 files changed

+41
-48
lines changed

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmdTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.eclipse.core.resources.IFile;
1010
import org.eclipse.core.resources.IFolder;
1111
import org.eclipse.core.resources.IProject;
12+
import org.eclipse.core.resources.IResource;
1213
import org.eclipse.core.runtime.CoreException;
1314
import org.junit.After;
1415
import org.junit.Assert;
@@ -45,19 +46,16 @@ public void setUp() throws Exception {
4546
is.close();
4647
}
4748

48-
/**
49-
* @see junit.framework.TestCase#tearDown()
50-
*/
5149
@After
5250
public void tearDown() throws Exception {
5351
if (this.testProject != null) {
5452
if (this.testProject.exists() && this.testProject.isAccessible()) {
5553
EclipseUtils.removePMDNature(this.testProject);
56-
// this.testProject.refreshLocal(IResource.DEPTH_INFINITE,
57-
// null);
58-
// Thread.sleep(500);
59-
// this.testProject.delete(true, true, null);
60-
// this.testProject = null;
54+
this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
55+
this.testProject.delete(true, true, null);
56+
this.testProject = null;
57+
} else {
58+
System.out.println("WARNING: Test Project has not been deleted!");
6159
}
6260
}
6361
}

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/MultipleRulesetsTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,15 @@ public void setUp() throws Exception {
8787

8888
@After
8989
public void tearDown() throws Exception {
90-
try {
91-
if (this.testProject != null) {
92-
if (this.testProject.exists() && this.testProject.isAccessible()) {
93-
EclipseUtils.removePMDNature(this.testProject);
94-
this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
95-
this.testProject.delete(true, true, null);
96-
this.testProject = null;
97-
}
90+
if (this.testProject != null) {
91+
if (this.testProject.exists() && this.testProject.isAccessible()) {
92+
EclipseUtils.removePMDNature(this.testProject);
93+
this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
94+
this.testProject.delete(true, true, null);
95+
this.testProject = null;
96+
} else {
97+
System.out.println("WARNING: Test Project has not been deleted!");
9898
}
99-
} catch (final Exception e) {
100-
System.out.println("Exception " + e.getClass().getName() + " when tearing down. Ignored.");
10199
}
102100
}
103101

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportCmdTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,16 @@ public void setUp() throws Exception {
4848

4949
}
5050

51-
/**
52-
* @see junit.framework.TestCase#tearDown()
53-
*/
5451
@After
5552
public void tearDown() throws Exception {
5653
if (this.testProject != null) {
5754
if (this.testProject.exists() && this.testProject.isAccessible()) {
5855
EclipseUtils.removePMDNature(this.testProject);
59-
// this.testProject.refreshLocal(IResource.DEPTH_INFINITE,
60-
// null);
61-
// Thread.sleep(500);
62-
// this.testProject.delete(true, true, null);
63-
// this.testProject = null;
56+
this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
57+
this.testProject.delete(true, true, null);
58+
this.testProject = null;
59+
} else {
60+
System.out.println("WARNING: Test Project has not been deleted!");
6461
}
6562
}
6663
}

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCmdTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,15 @@ public void setUp() throws Exception {
6767

6868
@After
6969
public void tearDown() throws Exception {
70-
try {
71-
if (this.testProject != null) {
72-
if (this.testProject.exists() && this.testProject.isAccessible()) {
73-
EclipseUtils.removePMDNature(this.testProject);
74-
this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
75-
this.testProject.delete(true, true, null);
76-
this.testProject = null;
77-
}
70+
if (this.testProject != null) {
71+
if (this.testProject.exists() && this.testProject.isAccessible()) {
72+
EclipseUtils.removePMDNature(this.testProject);
73+
this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
74+
this.testProject.delete(true, true, null);
75+
this.testProject = null;
76+
} else {
77+
System.out.println("WARNING: Test Project has not been deleted!");
7878
}
79-
} catch (final Exception e) {
80-
System.out.println("Exception " + e.getClass().getName() + " when tearing down. Ignored.");
8179
}
8280
}
8381

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/ProjectPropertiesModelTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.eclipse.core.resources.IFolder;
2727
import org.eclipse.core.resources.IProject;
2828
import org.eclipse.core.resources.IProjectDescription;
29+
import org.eclipse.core.resources.IResource;
2930
import org.eclipse.core.resources.IncrementalProjectBuilder;
3031
import org.eclipse.core.resources.ResourcesPlugin;
3132
import org.eclipse.core.runtime.CoreException;
@@ -89,16 +90,17 @@ public void setUp() throws Exception {
8990

9091
}
9192

92-
/**
93-
* @see junit.framework.TestCase#tearDown()
94-
*/
9593
@After
9694
public void tearDown() throws Exception {
9795
// 1. Delete the test project
9896
if (this.testProject != null) {
9997
if (this.testProject.exists() && this.testProject.isAccessible()) {
98+
EclipseUtils.removePMDNature(this.testProject);
99+
this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
100100
this.testProject.delete(true, true, null);
101101
this.testProject = null;
102+
} else {
103+
System.out.println("WARNING: Test Project has not been deleted!");
102104
}
103105
}
104106

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/ui/properties/UpdateProjectPropertiesCmdTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package net.sourceforge.pmd.eclipse.ui.properties;
66

77
import org.eclipse.core.resources.IProject;
8+
import org.eclipse.core.resources.IResource;
89
import org.junit.After;
910
import org.junit.Assert;
1011
import org.junit.Before;
@@ -32,16 +33,15 @@ public void setUp() throws Exception {
3233

3334
@After
3435
public void tearDown() throws Exception {
35-
try {
36-
// 1. Delete the test project
37-
if (this.testProject != null) {
38-
if (this.testProject.exists() && this.testProject.isAccessible()) {
39-
this.testProject.delete(true, true, null);
40-
this.testProject = null;
41-
}
36+
if (this.testProject != null) {
37+
if (this.testProject.exists() && this.testProject.isAccessible()) {
38+
EclipseUtils.removePMDNature(this.testProject);
39+
this.testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
40+
this.testProject.delete(true, true, null);
41+
this.testProject = null;
42+
} else {
43+
System.out.println("WARNING: Test Project has not been deleted!");
4244
}
43-
} catch (final Exception e) {
44-
System.out.println("Exception " + e.getClass().getName() + " when tearing down. Ignored.");
4545
}
4646
}
4747

0 commit comments

Comments
 (0)