22
22
import java .io .Writer ;
23
23
import java .net .InetSocketAddress ;
24
24
import java .net .URI ;
25
+ import java .net .URISyntaxException ;
25
26
import java .net .URL ;
26
27
import java .nio .charset .Charset ;
28
+ import java .nio .file .Files ;
29
+ import java .nio .file .Path ;
27
30
import java .util .concurrent .BlockingQueue ;
28
31
import java .util .concurrent .ExecutionException ;
29
32
import java .util .concurrent .Executors ;
@@ -47,16 +50,21 @@ public void stopWebbit() throws ExecutionException, InterruptedException {
47
50
}
48
51
49
52
@ Test
50
- public void can_write_to_file () throws IOException {
51
- File tmp = File .createTempFile ("cucumber-jvm" , "tmp" );
52
- Writer w = new UTF8OutputStreamWriter (new URLOutputStream (tmp .toURI ().toURL ()));
53
+ public void write_to_file_without_existing_parent_directory () throws IOException , URISyntaxException {
54
+ Path filesWithoutParent = Files .createTempDirectory ("filesWithoutParent" );
55
+ String baseURL = filesWithoutParent .toUri ().toURL ().toString ();
56
+ URL urlWithoutParentDirectory = new URL (baseURL + "/non/existing/directory" );
57
+
58
+ Writer w = new UTF8OutputStreamWriter (new URLOutputStream (urlWithoutParentDirectory ));
53
59
w .write ("Hellesøy" );
54
60
w .close ();
55
- assertEquals ("Hellesøy" , FixJava .readReader (openUTF8FileReader (tmp )));
61
+
62
+ File testFile = new File (urlWithoutParentDirectory .toURI ());
63
+ assertEquals ("Hellesøy" , FixJava .readReader (openUTF8FileReader (testFile )));
56
64
}
57
65
58
66
@ Test
59
- public void can_write_to_file_using_path () throws IOException {
67
+ public void can_write_to_file () throws IOException {
60
68
File tmp = File .createTempFile ("cucumber-jvm" , "tmp" );
61
69
Writer w = new UTF8OutputStreamWriter (new URLOutputStream (tmp .toURI ().toURL ()));
62
70
w .write ("Hellesøy" );
0 commit comments