@BeforeInjecting
 public void copyTestFiles() throws IOException {
   dataFolder = temporaryFolder.newFolder();
   File playerFolder =
       new File(dataFolder, FileUtils.makePath("playerdata", SAMPLE_UUID.toString()));
   if (!playerFolder.mkdirs()) {
     throw new IllegalStateException("Cannot create '" + playerFolder.getAbsolutePath() + "'");
   }
   Files.copy(
       TestHelper.getJarPath(FileUtils.makePath(SOURCE_FOLDER, "sample-folder", "data.json")),
       new File(playerFolder, "data.json").toPath());
 }
Ejemplo n.º 2
0
  @Test
  public void shouldCopyFileFromJar() throws IOException {
    // given
    File folder = temporaryFolder.newFolder();
    File file = new File(folder, "some/folders/config.yml");

    // when
    boolean result = FileUtils.copyFileFromResource(file, "config.yml");

    // then
    assertThat(result, equalTo(true));
    assertThat(file.exists(), equalTo(true));
    File configJarFile = TestHelper.getJarFile("/config.yml");
    assertThat(file.length(), equalTo(configJarFile.length()));
  }
Ejemplo n.º 3
0
  @Test
  public void shouldNotCopyFile() throws IOException {
    // given
    File folder = temporaryFolder.newFolder();
    File file = new File(folder, "config.yml");
    // purposely don't copy config.yml to verify that config.yml isn't copied by the method
    File emailJarFile = TestHelper.getJarFile("/email.html");
    Files.copy(emailJarFile, file);

    // when
    boolean result = FileUtils.copyFileFromResource(file, "config.yml");

    // then
    assertThat(result, equalTo(true));
    assertThat(file.length(), equalTo(emailJarFile.length()));
  }
Ejemplo n.º 4
0
 @BeforeClass
 public static void initializeLogger() {
   TestHelper.setupLogger();
 }