11package com .microsoft .graph .functional ;
22
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
34import static org .junit .jupiter .api .Assertions .assertFalse ;
45import static org .junit .jupiter .api .Assertions .assertNotNull ;
56import static org .junit .jupiter .api .Assertions .assertTrue ;
67
78import java .io .ByteArrayInputStream ;
89import java .io .IOException ;
910import java .io .InputStream ;
11+ import java .net .URL ;
1012import java .nio .charset .StandardCharsets ;
1113
1214import org .junit .jupiter .api .BeforeEach ;
2426import com .microsoft .graph .models .UploadSession ;
2527import com .microsoft .graph .models .DriveItemCreateUploadSessionParameterSet ;
2628
27- @ Disabled
2829public class OneDriveTests {
2930 private TestBase testBase ;
3031
31- @ BeforeEach
3232 public void setUp () {
33- testBase = new TestBase ();
33+ if (testBase == null ) {
34+ testBase = new TestBase ();
35+ }
3436 }
3537
3638 final IProgressCallback callback = new IProgressCallback () {
@@ -39,6 +41,17 @@ public void progress(final long current, final long max) {
3941 //Check progress
4042 }
4143 };
44+ /**
45+ * Tests that paths are properly encoded acording to ODSP's expectations
46+ * - everything is encoded to the application/x-www-form-urlencoded MIME format
47+ * - spaces are encoded with %20
48+ */
49+ @ Test
50+ public void itemWithPathEncodesSpecialCharacters () {
51+ final URL requestURL = new TestBase (false ).graphClient .me ().drive ().root ().itemWithPath ("some folder/some name with a + and a #777.docx" ).buildRequest ().getRequestUrl ();
52+ assertEquals ("/me/drive/root:/some%20folder%2Fsome%20name%20with%20a%20%2B%20and%20a%20%23777.docx:" , requestURL .getPath ().replace ("/v1.0" , "" ).replace ("/beta" , "" ));
53+ // version replacement so the test is version agnostic
54+ }
4255 /**
4356 * Test large file upload.
4457 * https://github.com/OneDrive/onedrive-sdk-csharp/blob/master/docs/chunked-uploads.md
@@ -47,8 +60,10 @@ public void progress(final long current, final long max) {
4760 * @throws InterruptedException if the chunked upload fails
4861 */
4962 @ Test
63+ @ Disabled
5064 public void testLargeFileUpload () throws IOException , InterruptedException {
51- //Get resource file from file system
65+ setUp ();
66+ //Get resource file from file system
5267 InputStream uploadFile = OneDriveTests .class .getClassLoader ().getResourceAsStream ("largefile10M.blob" );
5368 long fileSize = (long ) uploadFile .available ();
5469
@@ -72,14 +87,18 @@ public void testLargeFileUpload() throws IOException, InterruptedException {
7287 assertNotNull (result );
7388 }
7489 @ Test
90+ @ Disabled
7591 public void testDownloadWithCustomRequest () throws IOException {
92+ setUp ();
7693 final String testDownloadFileId = "01RWFXFJG3UYRHE75RZVFYWKNUEBB53H7A" ;
7794 try (final InputStream stream = testBase .graphClient .customRequest ("/me/drive/items/" +testDownloadFileId +"/content" , InputStream .class ).buildRequest ().get ()) {
7895 assertFalse (stream .read () == -1 , "stream should not be empty" );
7996 }
8097 }
8198 @ Test
99+ @ Disabled
82100 public void downloadJsonFileFromOneDrive () throws Exception {
101+ setUp ();
83102 final DriveItemUploadableProperties item = new DriveItemUploadableProperties ();
84103 item .name = "test.json" ;
85104 item .additionalDataManager ().put ("@microsoft.graph.conflictBehavior" , new JsonPrimitive ("replace" ));
0 commit comments