40
40
import org .apache .maven .settings .Settings ;
41
41
import org .codehaus .plexus .util .ReflectionUtils ;
42
42
import org .junit .Before ;
43
+ import org .junit .Rule ;
43
44
import org .junit .Test ;
45
+ import org .junit .rules .TemporaryFolder ;
44
46
import org .junit .runner .RunWith ;
45
47
import org .junit .runners .JUnit4 ;
46
48
51
53
@ RunWith (JUnit4 .class )
52
54
public abstract class AbstractSiteDeployWebDavTest extends AbstractMojoTestCase {
53
55
54
- File siteTargetPath = new File (getBasedir () + File .separator + "target" + File .separator + "siteTargetDeploy" );
56
+ // Can use @TempDir with JUnit 5
57
+ @ Rule
58
+ public TemporaryFolder directory = new TemporaryFolder ();
59
+
60
+ private File siteTargetPath ;
55
61
56
62
@ Override
57
63
@ Before
58
64
public void setUp () throws Exception {
59
65
super .setUp ();
66
+ siteTargetPath = new File (directory .newFolder (), "target" );
60
67
if (!siteTargetPath .exists ()) {
61
68
siteTargetPath .mkdirs ();
62
- FileUtils .cleanDirectory (siteTargetPath );
63
69
}
64
70
}
65
71
@@ -69,7 +75,6 @@ public void setUp() throws Exception {
69
75
70
76
@ Test
71
77
public void noAuthzDavDeploy () throws Exception {
72
- FileUtils .cleanDirectory (siteTargetPath );
73
78
SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler (siteTargetPath );
74
79
75
80
try {
@@ -104,8 +109,6 @@ public void noAuthzDavDeploy() throws Exception {
104
109
105
110
@ Test
106
111
public void davDeployThruProxyWithoutAuthzInProxy () throws Exception {
107
-
108
- FileUtils .cleanDirectory (siteTargetPath );
109
112
SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler (siteTargetPath );
110
113
try {
111
114
File pluginXmlFile = getTestFile ("src/test/resources/unit/deploy-dav/pom.xml" );
@@ -151,10 +154,6 @@ public void davDeployThruProxyWithoutAuthzInProxy() throws Exception {
151
154
152
155
@ Test
153
156
public void davDeployThruProxyWitAuthzInProxy () throws Exception {
154
-
155
- FileUtils .cleanDirectory (siteTargetPath );
156
- // SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );
157
-
158
157
Map <String , String > authentications = new HashMap <>();
159
158
authentications .put ("foo" , "titi" );
160
159
@@ -226,8 +225,8 @@ private void assertContentInFiles() throws Exception {
226
225
227
226
File cssFile = new File (siteTargetPath , "site" + File .separator + "css" + File .separator + "maven-base.css" );
228
227
assertTrue (cssFile .exists ());
229
- fileContent = FileUtils .readFileToString (cssFile , StandardCharsets .UTF_8 );
230
- assertTrue (fileContent .contains ("background-image: url(../images/collapsed.gif);" ));
228
+ String cssContent = FileUtils .readFileToString (cssFile , StandardCharsets .UTF_8 );
229
+ assertTrue (cssContent .contains ("background-image: url(../images/collapsed.gif);" ));
231
230
}
232
231
233
232
/**
0 commit comments