本文整理汇总了Scala中org.apache.commons.io.filefilter.TrueFileFilter类的典型用法代码示例。如果您正苦于以下问题:Scala TrueFileFilter类的具体用法?Scala TrueFileFilter怎么用?Scala TrueFileFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TrueFileFilter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: InitializationItSpec
//设置package包名称以及导入依赖的类
package pl.touk.nussknacker.ui.initialization
import java.io.File
import java.nio.file.{Files, Paths}
import java.util.concurrent.TimeUnit
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.apache.commons.io.FileUtils
import org.apache.commons.io.filefilter.TrueFileFilter
import org.scalatest.concurrent.{Eventually, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, FlatSpec, Matchers}
import pl.touk.nussknacker.ui.api.helpers.{EspItTest, TestFactory}
import pl.touk.nussknacker.ui.process.repository.ProcessRepository.ProcessDetails
import pl.touk.nussknacker.ui.security.{LoggedUser, Permission}
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
class InitializationItSpec extends FlatSpec with ScalatestRouteTest with Matchers with ScalaFutures with BeforeAndAfterEach with EspItTest with Eventually {
val toukuser = LoggedUser("TouK", "", List(Permission.Write, Permission.Admin), List())
var processesDir: File = _
override protected def beforeEach(): Unit = {
super.beforeEach()
processesDir = Files.createTempDirectory("processesJsons").toFile
val sampleProcessesDir = new File(getClass.getResource("/jsons").getFile)
FileUtils.copyDirectory(sampleProcessesDir, processesDir)
Files.deleteIfExists(Paths.get(processesDir.getAbsolutePath + "/standaloneProcesses/StandaloneCategory1/RequestResponseTest1.json")) //fixme make standalone mode testing easier
}
override protected def afterEach(): Unit = {
super.afterEach()
processesDir.delete()
}
it should "save json processes and delete files afterwards" in {
val processesFromFilesCount = listFilesFromDir(processesDir).size
processesFromFilesCount should be > 1
Await.result(getAllProcesses, Duration.apply(1, TimeUnit.SECONDS)) should have size 0
Initialization.init(processRepository, db, "test", isDevelopmentMode = false, initialProcessDirectory = processesDir, standaloneModeEnabled = true)
eventually {
listFilesFromDir(processesDir) should have size 0
Await.result(getAllProcesses, Duration.apply(1, TimeUnit.SECONDS)) should have size processesFromFilesCount
}
}
private def getAllProcesses: Future[List[ProcessDetails]] = {
processRepository.fetchProcessesDetails()(toukuser)
}
private def listFilesFromDir(dir: File) = {
FileUtils.listFiles(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE).toArray.toList
}
}