@@ -169,6 +169,41 @@ public void testResumeOrCreateUpload() throws IOException, ProtocolException {
169169 assertEquals (uploader .getUploadURL (), new URL (mockServerURL + "/foo" ));
170170 }
171171
172+ @ Test
173+ public void testResumeOrCreateUploadNotFound () throws IOException , ProtocolException {
174+ mockServer .when (new HttpRequest ()
175+ .withMethod ("HEAD" )
176+ .withPath ("/files/not_found" )
177+ .withHeader ("Tus-Resumable" , TusClient .TUS_VERSION ))
178+ .respond (new HttpResponse ()
179+ .withStatusCode (404 ));
180+
181+ mockServer .when (new HttpRequest ()
182+ .withMethod ("POST" )
183+ .withPath ("/files" )
184+ .withHeader ("Tus-Resumable" , TusClient .TUS_VERSION )
185+ .withHeader ("Upload-Length" , "10" ))
186+ .respond (new HttpResponse ()
187+ .withStatusCode (201 )
188+ .withHeader ("Tus-Resumable" , TusClient .TUS_VERSION )
189+ .withHeader ("Location" , mockServerURL + "/foo" ));
190+
191+ TusClient client = new TusClient ();
192+ client .setUploadCreationURL (mockServerURL );
193+
194+ TusURLStore store = new TusURLMemoryStore ();
195+ store .set ("fingerprint" , new URL (mockServerURL + "/not_found" ));
196+ client .enableResuming (store );
197+
198+ TusUpload upload = new TusUpload ();
199+ upload .setSize (10 );
200+ upload .setInputStream (new ByteArrayInputStream (new byte [10 ]));
201+ upload .setFingerprint ("fingerprint" );
202+ TusUploader uploader = client .resumeOrCreateUpload (upload );
203+
204+ assertEquals (uploader .getUploadURL (), new URL (mockServerURL + "/foo" ));
205+ }
206+
172207 @ Test
173208 public void testPrepareConnection () throws IOException {
174209 HttpURLConnection connection = (HttpURLConnection ) mockServerURL .openConnection ();
0 commit comments