|
|
@ -4,6 +4,8 @@ import org.airsonic.player.controller.JAXBWriter; |
|
|
|
import org.airsonic.player.dao.DaoHelper; |
|
|
|
import org.airsonic.player.dao.DaoHelper; |
|
|
|
import org.airsonic.player.service.MediaScannerService; |
|
|
|
import org.airsonic.player.service.MediaScannerService; |
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
import org.springframework.context.support.ClassPathXmlApplicationContext; |
|
|
|
import org.springframework.context.support.ClassPathXmlApplicationContext; |
|
|
|
|
|
|
|
|
|
|
@ -16,6 +18,8 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
public class TestCaseUtils { |
|
|
|
public class TestCaseUtils { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(TestCaseUtils.class); |
|
|
|
|
|
|
|
|
|
|
|
private static File airsonicHomeDirForTest = null; |
|
|
|
private static File airsonicHomeDirForTest = null; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -33,7 +37,7 @@ public class TestCaseUtils { |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException("Error while creating temporary AIRSONIC_HOME directory for tests"); |
|
|
|
throw new RuntimeException("Error while creating temporary AIRSONIC_HOME directory for tests"); |
|
|
|
} |
|
|
|
} |
|
|
|
System.out.println("AIRSONIC_HOME directory will be "+airsonicHomeDirForTest.getAbsolutePath()); |
|
|
|
LOG.info("AIRSONIC_HOME directory will be {}", airsonicHomeDirForTest.getAbsolutePath()); |
|
|
|
} |
|
|
|
} |
|
|
|
return airsonicHomeDirForTest.getAbsolutePath(); |
|
|
|
return airsonicHomeDirForTest.getAbsolutePath(); |
|
|
|
} |
|
|
|
} |
|
|
@ -53,11 +57,11 @@ public class TestCaseUtils { |
|
|
|
|
|
|
|
|
|
|
|
File airsonicHomeDir = new File(airsonicHomePathForTest()); |
|
|
|
File airsonicHomeDir = new File(airsonicHomePathForTest()); |
|
|
|
if (airsonicHomeDir.exists() && airsonicHomeDir.isDirectory()) { |
|
|
|
if (airsonicHomeDir.exists() && airsonicHomeDir.isDirectory()) { |
|
|
|
System.out.println("Delete airsonic home (ie. "+airsonicHomeDir.getAbsolutePath()+")."); |
|
|
|
LOG.debug("Delete airsonic home (ie. {}).", airsonicHomeDir.getAbsolutePath()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
FileUtils.deleteDirectory(airsonicHomeDir); |
|
|
|
FileUtils.deleteDirectory(airsonicHomeDir); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
System.out.println("Error while deleting airsonic home."); |
|
|
|
LOG.warn("Error while deleting airsonic home."); |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
throw e; |
|
|
|
throw e; |
|
|
|
} |
|
|
|
} |
|
|
|