当前位置: 首页 > news >正文

嘉兴公司制作网站的perl网站建设

嘉兴公司制作网站的,perl网站建设,建设网站制,北京网站建设公司服务哪家好对于将在Synology RS815 NAS上检查备份文件的Spring Boot应用程序#xff0c;我们希望能够轻松测试此NAS上存储的文件#xff0c;而不必复制存储在其上的7TB。 理想情况下#xff0c;我们希望创建相同的文件结构以在Spring开发配置文件中使用Web应用程序#xff0c;并在J… 对于将在Synology RS815 NAS上检查备份文件的Spring Boot应用程序我们希望能够轻松测试此NAS上存储的文件而不必复制存储在其上的7TB。 理想情况下我们希望创建相同的文件结构以在Spring开发配置文件中使用Web应用程序并在JUnit测试中使用这些文件结构。 介绍FileStructureCreator 我们首先创建一个新的类FileStructureCreator 如下所示 Getter Setter public class FileStructureCreator implements Closeable {public static final Path baseTestPath Paths.get(testFiles);private Path fileStructureBasePath;public static FileStructureCreator create(Path file) {return createStructure(file, false);}public static FileStructureCreator createTempDirectory(Path file) {return createStructure(file, true);}SneakyThrowsprivate static FileStructureCreator createStructure(Path file, boolean createTempDirectory) {FileStructureCreator fileStructureCreator new FileStructureCreator();if (!Files.exists(baseTestPath)) {Files.createDirectory(baseTestPath);}String path baseTestPath.toString() (createTempDirectory ? / UUID.randomUUID().toString() : ) /;Path basePath Paths.get(path);fileStructureCreator.setFileStructureBasePath(basePath);FileUtils.forceMkdir(basePath.toFile());try (StreamString stream Files.lines(file)) {stream.forEach(line - {Metadata fileMetaData Metadata.from(line);Path fileEntry Paths.get(path fileMetaData.getWindowsSafeFilename());try {FileUtils.forceMkdir(fileEntry.getParent().toFile());if (!Files.exists(fileEntry)) {Files.write(fileEntry, line.getBytes());Files.setLastModifiedTime(fileEntry, FileTime.from(fileMetaData.getModificationTime()));}} catch (IOException ignore) {throw new RuntimeException(Exception creating directory: fileEntry.getParent());}});}return fileStructureCreator;}OverrideSneakyThrowspublic void close() {if (fileStructureBasePath ! null) {FileUtils.deleteDirectory(fileStructureBasePath.toFile());}} } 基本上这将创建整个目录结构和必要的文件。 我们只需要传递一个包含文件结构元数据的基本文件即可。 元数据保存时间戳文件大小和该文件的路径。 看起来像这样 2016-04-05T10:30:15.012345678   5120backupftp/eaDir/sharesnap_share_configuration/SYNO.quota2018-02-26T00:00:09.012345678  169backupftp/eaDir/sharesnap_share_configuration/share_configuration 然后在Synology NAS上我们可以通过执行以下命令轻松生成具有特定目录的整个树结构的文件 find backupftp -type f -printf %TY-%Tm-%TdT%TH:%TM:%.12TS\t%s\t%p\ntest/backupftp.files.txt 将生成的文件从您的Synology NAS复制到您的项目。 在JUnit测试中我们使用FileStructureCreator类如下面的示例所示。 请注意 FileStructureCreator实现了AutoCloseable 因此我们可以在测试完成后使用try / catch块来清理文件。 Value(classpath:/TestDiskConsistencyPolicy-notEnoughFileSets.txt) private Path notEnoughFileSets;Test(expected RuntimeException.class) public void backupSetWithNoFileSetsThrowException() {try( FileStructureCreator creator FileStructureCreator.createTempDirectory(notEnoughFileSets) ) {BackupSet backupSet BackupSet.builder().uri(creator.getFileStructureBasePath().toString()).build();new DiskConsistencyPolicy(backupSet).execute();assertTrue( Expecting a RuntimeException here, false);} } 对于Spring Boot应用程序我们只定义一个Configuration类该类将为Synology NAS上定义的文件共享创建数据结构。 Configuration Profile(dev) public class TestFilesInstaller {Beanpublic FileStructureCreator ftpFiles(Value(classpath:/backupftp.files.txt) Path file) {return FileStructureCreator.create(file);}Beanpublic FileStructureCreator nfsFiles(Value(classpath:/backupnfs.files.txt) Path file) {return FileStructureCreator.create(file);} } 因为它们被定义为Bean 所以在应用程序关闭时将自动调用close()方法并在Spring Boot应用程序停止时从磁盘上删除所有文件。 只是……不要在生产环境中运行开发人员资料 我让你知道会发生什么。 ;-) 将来我们将向您展示如何构建备份检查器以监视和验证NAS上的备份。 翻译自: https://www.javacodegeeks.com/2018/04/mocking-files-for-junit-testing-a-spring-boot-web-application-on-synology-nas.html
http://www.zqtcl.cn/news/813885/

相关文章:

  • 月熊志网站福州建网站 做网页
  • 不同的网站有不同的风格宁波设计网站公司
  • 学校网站制作平台电子政务门户网站建设代码
  • 产品推广的网站怎么做网站标题与关键词
  • 青蛙网站建设wordpress修改logo
  • 网站套餐方案引擎搜索对人类记忆的影响
  • 滨州市滨城区建设局网站扎金花网站怎么做
  • 网站开发中视屏怎样编辑到网页上常州建站公司模板
  • 视频涉台互联网网站怎么做1cpu0.5g服务器用来做网站
  • 营销型网站设计官网怎么做网站优化 sit
  • 怎样获得做网站的客户免费企业网站程序上传
  • 新闻排版设计用什么软件网站seo诊断分析
  • 手机网站端域名怎样做解析一诺摄影设计
  • 网站开发行业竞争大吗郑州百度推广代运营公司
  • mvc4做网站五设计一个公司网站多少钱
  • 在什么网站可以做外贸出口劳保鞋北京 代理前置审批 网站备案
  • 邢台建设企业网站房地产宣传推广方案
  • 建设机械网站案例分析餐饮vi设计开题报告范文
  • 做本地生活网站深圳建设工程信息网站
  • C2C电商网站做博客的网站有哪些
  • 住房和城乡建设部网站 事故安微省建设厅田网站
  • 百度一下你就知道官页淘宝seo搜索引擎优化
  • 网站平台维护phpwind做的网站
  • 网站怎么做移动适配怎么样才算是一个网站页面
  • 做pc端网站策划百度网站建立
  • 高级网站开发技术青岛网站建设方案服务
  • 深圳公司网站建设设房地产网址大全
  • 怎么里ip做网站女生学广告学后悔死了
  • 做西餐网站wordpress 作者栏
  • 创建了网站安卓做视频网站