/*
 * Copyright 2014-2021 Web Firm Framework
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.webfirmframework.wffweb.util;

import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.junit.Test;

public class FileUtilTest {

	@Test
	public void testRemoveDirRecursively() throws IOException {

		Path path = Paths.get(Files.createTempDirectory("testpath").toString(), "dir1", "dir2");
		Files.createDirectories(path);

		boolean removed = FileUtil.removeDirRecursively(path.toString());
		
		assertTrue(removed);
	}

}

@@ -684,124 +684,345 @@
 sert
-True;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths
+Equals;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.junit.Assert.fail;%0A%0Aimport java.io.IOException;%0Aimport java.nio.charset.StandardCharsets;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.NoSuchFileException;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.util.List;%0Aimport java.util.stream.Stream
 ;%0A%0Ai
@@ -1148,14 +1148,20 @@
 %0A%0A%09%09
-Path p
+String baseP
 ath 
@@ -1227,152 +1227,959 @@
 ), %22
-dir1%22, %22dir2%22);%0A%09%09Files.createDirectories(path);%0A%0A%09%09boolean removed = FileUtil.removeDirRecursively(path.toString());%0A%09%09%0A%09%09assertTrue(remov
+basePath%22).toString();%0A        Path path = Paths.get(basePath, %22dir1%22, %22dir2%22);%0A%09%09Files.createDirectories(path);%0A%09%09%0A%09%09Path textFilePath = Paths.get(path.toString() + %22/somefile.txt%22);%0A        Files.write(textFilePath, %22somevalue%22.getBytes(StandardCharsets.UTF_8));%0A%09%09%0A%09%09assertEquals(%22somevalue%22, new String(Files.readAllBytes(textFilePath), StandardCharsets.UTF_8));%0A%09%09%0A%09%09String baseDir = basePath.substring(0, basePath.length() - %22basePath%22.length());%0A%0A%09%09boolean removed = FileUtil.removeDirRecursively(baseDir, %22basePath%22);%0A%09%09%0A%09%09assertTrue(removed);%0A%09%09%0A%09%09assertTrue(textFilePath.toString().endsWith(%22/dir1/dir2/somefile.txt%22));%0A%09%09%0A%09%09try (Stream%3CPath%3E list = Files.list(Path.of(baseDir));) %7B%0A%09%09    List%3CPath%3E filesUnderBaseDir = list.toList();%0A%09%09    assertEquals(0, filesUnderBaseDir.size());%0A%09%09%7D%0A%09%09%0A%09%09try %7B%0A%09%09    Files.readAllBytes(textFilePath);%0A%09%09    fail(%22File is not delet
 ed
+%22
 );%0A
+%09%09%7D catch (NoSuchFileException e) %7B%0A            //NOP%0A        %7D%0A%09%09%0A
 %09%7D%0A%0A

Test case improvements