Project

General

Profile

« Previous | Next » 

Revision 1587a2cd

Added by François ARMAND over 7 years ago

Fixes #10029: Test create directories in /tmp that are not cleaned nor unique

View differences:

utils/src/test/scala/com/normation/utils/TestZipUtils.scala
import scala.collection.JavaConversions._
import java.util.zip.ZipEntry
import java.io.FileOutputStream
import org.specs2.specification.Fragments
import org.specs2.specification.Step
import org.apache.commons.io.FileUtils
@RunWith(classOf[JUnitRunner])
class TestZipUtils extends Specification with Loggable {
// prepare data
val directory = new File(System.getProperty("java.io.tmpdir"), "test-zip/"+ DateTime.now.toString(ISODateTimeFormat.dateTime))
val directory = new File(System.getProperty("java.io.tmpdir"), "test-zip-" + DateTime.now.toString(ISODateTimeFormat.dateTime))
directory.mkdirs()
override def map(fs: =>Fragments) = fs ^ Step(clean)
/**
* Add a switch to be able to see tmp files (not clean themps) with
* -Dtests.clean.tmp=false
*/
def clean = {
if(System.getProperty("tests.clean.tmp") != "false") {
FileUtils.forceDelete(directory)
}
}
logger.debug("Unzipping test in directory: " + directory.getPath())
val zip = new ZipFile(new File("src/test/resources/test.zip"))
......
}
}
}
}

Also available in: Unified diff