当前位置: 首页>>代码示例>>Scala>>正文


Scala TrueFileFilter类代码示例

本文整理汇总了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
  }
} 
开发者ID:TouK,项目名称:nussknacker,代码行数:58,代码来源:InitializationItSpec.scala


注:本文中的org.apache.commons.io.filefilter.TrueFileFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。