1313import org .junit .jupiter .api .Assertions ;
1414import org .junit .jupiter .api .DisplayName ;
1515import org .junit .jupiter .api .Test ;
16- import org .junit .jupiter .params .ParameterizedTest ;
17- import org .junit .jupiter .params .provider .ValueSource ;
1816
1917import java .io .BufferedReader ;
2018import java .io .IOException ;
@@ -153,19 +151,17 @@ public void testRandomAccessRead() throws InterruptedException {
153151 Assertions .assertEquals ("/cloud/remote.php/webdav/Documents/About.txt" , rq .getPath ());
154152 }
155153
156-
154+ @ Test
157155 @ DisplayName ("write to /foo.txt (non-existing)" )
158- @ ParameterizedTest (name = "replace = {0}" )
159- @ ValueSource (booleans = {true , false })
160- public void testWriteToNewFile (boolean replace ) throws InterruptedException {
161- server .enqueue (getInterceptedResponse (201 , "" ));
156+ public void testWriteToNewFile () throws InterruptedException {
157+ server .enqueue (getInterceptedResponse (404 , "" ));
162158 server .enqueue (getInterceptedResponse (201 , "" ));
163159 server .enqueue (getInterceptedResponse ("item-write-response.xml" ));
164160
165161 final var writtenItemMetadata = new CloudItemMetadata ("foo.txt" , Path .of ("/cloud/remote.php/webdav/foo.txt" ), CloudItemType .FILE , Optional .of (TestUtil .toInstant ("Thu, 07 Jul 2020 16:55:50 GMT" )), Optional .of (8193L ));
166162
167163 final var inputStream = getClass ().getResourceAsStream ("/progress-request-text.txt" );
168- final var cloudItemMetadata = provider .write (Path .of ("/foo.txt" ), replace , inputStream , ProgressListener .NO_PROGRESS_AWARE ).toCompletableFuture ().join ();
164+ final var cloudItemMetadata = provider .write (Path .of ("/foo.txt" ), false , inputStream , ProgressListener .NO_PROGRESS_AWARE ).toCompletableFuture ().join ();
169165
170166 Assertions .assertEquals (writtenItemMetadata , cloudItemMetadata );
171167 RecordedRequest rq = server .takeRequest ();
@@ -185,6 +181,30 @@ public void testWriteToNewFile(boolean replace) throws InterruptedException {
185181 Assertions .assertEquals (webDavRequestBody , rq .getBody ().readUtf8 ());
186182 }
187183
184+ @ Test
185+ @ DisplayName ("write to /foo.txt (non-existing, replace)" )
186+ public void testWriteToAndReplaceNewFile () throws InterruptedException {
187+ server .enqueue (getInterceptedResponse (201 , "" ));
188+ server .enqueue (getInterceptedResponse ("item-write-response.xml" ));
189+
190+ final var writtenItemMetadata = new CloudItemMetadata ("foo.txt" , Path .of ("/cloud/remote.php/webdav/foo.txt" ), CloudItemType .FILE , Optional .of (TestUtil .toInstant ("Thu, 07 Jul 2020 16:55:50 GMT" )), Optional .of (8193L ));
191+
192+ final var inputStream = getClass ().getResourceAsStream ("/progress-request-text.txt" );
193+ final var cloudItemMetadata = provider .write (Path .of ("/foo.txt" ), true , inputStream , ProgressListener .NO_PROGRESS_AWARE ).toCompletableFuture ().join ();
194+
195+ Assertions .assertEquals (writtenItemMetadata , cloudItemMetadata );
196+
197+ RecordedRequest rq = server .takeRequest ();
198+ Assertions .assertEquals ("PUT" , rq .getMethod ());
199+ Assertions .assertEquals ("/cloud/remote.php/webdav/foo.txt" , rq .getPath ());
200+
201+ rq = server .takeRequest ();
202+ Assertions .assertEquals ("PROPFIND" , rq .getMethod ());
203+ Assertions .assertEquals ("0" , rq .getHeader ("DEPTH" ));
204+ Assertions .assertEquals ("/cloud/remote.php/webdav/foo.txt" , rq .getPath ());
205+ Assertions .assertEquals (webDavRequestBody , rq .getBody ().readUtf8 ());
206+ }
207+
188208 @ Test
189209 @ DisplayName ("write to /file (already existing)" )
190210 public void testWriteToExistingFile () throws InterruptedException {
@@ -209,7 +229,6 @@ public void testWriteToExistingFile() throws InterruptedException {
209229 @ DisplayName ("write to /foo.txt (replace existing)" )
210230 public void testWriteToAndReplaceExistingFile () throws InterruptedException {
211231 server .enqueue (getInterceptedResponse ("item-write-response.xml" ));
212- server .enqueue (getInterceptedResponse (200 , "" ));
213232 server .enqueue (getInterceptedResponse ("item-write-response.xml" ));
214233
215234 final var writtenItemMetadata = new CloudItemMetadata ("foo.txt" , Path .of ("/cloud/remote.php/webdav/foo.txt" ), CloudItemType .FILE , Optional .of (TestUtil .toInstant ("Thu, 07 Jul 2020 16:55:50 GMT" )), Optional .of (8193L ));
@@ -220,12 +239,6 @@ public void testWriteToAndReplaceExistingFile() throws InterruptedException {
220239 Assertions .assertEquals (writtenItemMetadata , cloudItemMetadata );
221240
222241 RecordedRequest rq = server .takeRequest ();
223- Assertions .assertEquals ("PROPFIND" , rq .getMethod ());
224- Assertions .assertEquals ("0" , rq .getHeader ("DEPTH" ));
225- Assertions .assertEquals ("/cloud/remote.php/webdav/foo.txt" , rq .getPath ());
226- Assertions .assertEquals (webDavRequestBody , rq .getBody ().readUtf8 ());
227-
228- rq = server .takeRequest ();
229242 Assertions .assertEquals ("PUT" , rq .getMethod ());
230243 Assertions .assertEquals ("/cloud/remote.php/webdav/foo.txt" , rq .getPath ());
231244
0 commit comments