4040import org .apache .maven .settings .Settings ;
4141import org .codehaus .plexus .util .ReflectionUtils ;
4242import org .junit .Before ;
43+ import org .junit .Rule ;
4344import org .junit .Test ;
45+ import org .junit .rules .TemporaryFolder ;
4446import org .junit .runner .RunWith ;
4547import org .junit .runners .JUnit4 ;
4648
5153@ RunWith (JUnit4 .class )
5254public abstract class AbstractSiteDeployWebDavTest extends AbstractMojoTestCase {
5355
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 ;
5561
5662 @ Override
5763 @ Before
5864 public void setUp () throws Exception {
5965 super .setUp ();
66+ siteTargetPath = new File (directory .newFolder (), "target" );
6067 if (!siteTargetPath .exists ()) {
6168 siteTargetPath .mkdirs ();
62- FileUtils .cleanDirectory (siteTargetPath );
6369 }
6470 }
6571
@@ -69,7 +75,6 @@ public void setUp() throws Exception {
6975
7076 @ Test
7177 public void noAuthzDavDeploy () throws Exception {
72- FileUtils .cleanDirectory (siteTargetPath );
7378 SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler (siteTargetPath );
7479
7580 try {
@@ -104,8 +109,6 @@ public void noAuthzDavDeploy() throws Exception {
104109
105110 @ Test
106111 public void davDeployThruProxyWithoutAuthzInProxy () throws Exception {
107-
108- FileUtils .cleanDirectory (siteTargetPath );
109112 SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler (siteTargetPath );
110113 try {
111114 File pluginXmlFile = getTestFile ("src/test/resources/unit/deploy-dav/pom.xml" );
@@ -151,10 +154,6 @@ public void davDeployThruProxyWithoutAuthzInProxy() throws Exception {
151154
152155 @ Test
153156 public void davDeployThruProxyWitAuthzInProxy () throws Exception {
154-
155- FileUtils .cleanDirectory (siteTargetPath );
156- // SimpleDavServerHandler simpleDavServerHandler = new SimpleDavServerHandler( siteTargetPath );
157-
158157 Map <String , String > authentications = new HashMap <>();
159158 authentications .put ("foo" , "titi" );
160159
@@ -226,8 +225,8 @@ private void assertContentInFiles() throws Exception {
226225
227226 File cssFile = new File (siteTargetPath , "site" + File .separator + "css" + File .separator + "maven-base.css" );
228227 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);" ));
231230 }
232231
233232 /**
0 commit comments