Skip to content

Commit

Permalink
Fixed bug in computing pathname of copied .yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbos authored and jsevellec committed May 1, 2018
1 parent 7346b9a commit bfb1345
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.*;
import java.net.ServerSocket;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -96,8 +97,7 @@ public static void startEmbeddedCassandra(String yamlFile, String tmpDir, long t
}

rmdir(tmpDir);
copy(yamlFile, tmpDir);
File file = new File(tmpDir + yamlFile);
File file = copy(yamlFile, tmpDir).toFile();
readAndAdaptYaml(file);
startEmbeddedCassandra(file, tmpDir, timeout);
}
Expand Down Expand Up @@ -286,11 +286,13 @@ private static void rmdir(String dir) {
* @param directory
* @throws IOException
*/
private static void copy(String resource, String directory) throws IOException {
private static Path copy(String resource, String directory) throws IOException {
mkdir(directory);
String fileName = resource.substring(resource.lastIndexOf("/") + 1);
InputStream from = EmbeddedCassandraServerHelper.class.getResourceAsStream(resource);
Files.copy(from, Paths.get(directory + System.getProperty("file.separator") + fileName));
Path copyName = Paths.get(directory, fileName);
Files.copy(from, copyName);
return copyName;
}

/**
Expand Down

0 comments on commit bfb1345

Please sign in to comment.