1919package cn .vika .client .api ;
2020
2121import java .io .File ;
22+ import java .net .URL ;
2223
2324import cn .vika .client .api .model .Attachment ;
2425import cn .vika .core .http .ClassPathResourceLoader ;
@@ -70,7 +71,11 @@ public void testUploadWithUrlResource() throws JsonProcessingException {
7071 @ Test
7172 @ Order (3 )
7273 public void testUploadWithFileResource () throws JsonProcessingException {
73- File file = new File ("/Users/shawndeng/Documents/Project/vika.java/client/src/test/resources/test.docx" );
74+ ClassLoader classLoader = getClass ().getClassLoader ();
75+ URL url = classLoader .getResource ("test.txt" );
76+ assertThat (url ).isNotNull ();
77+ File file = new File (url .getFile ());
78+ assertThat (file ).isNotNull ();
7479 Attachment attachment = vikaApiClient .getAttachmentApi ().upload (TEST_DATASHEET_ID .get (), new FileResourceLoader (file ));
7580 assertThat (attachment ).isNotNull ();
7681 System .out .println (JacksonJsonUtil .toJson (attachment , true ));
@@ -79,7 +84,11 @@ public void testUploadWithFileResource() throws JsonProcessingException {
7984 @ Test
8085 @ Order (4 )
8186 public void testUploadWithFile () throws JsonProcessingException {
82- File file = new File ("/Users/shawndeng/Documents/Project/vika.java/client/src/test/resources/test.docx" );
87+ ClassLoader classLoader = getClass ().getClassLoader ();
88+ URL url = classLoader .getResource ("test.txt" );
89+ assertThat (url ).isNotNull ();
90+ File file = new File (url .getFile ());
91+ assertThat (file ).isNotNull ();
8392 Attachment attachment = vikaApiClient .getAttachmentApi ().upload (TEST_DATASHEET_ID .get (), file );
8493 assertThat (attachment ).isNotNull ();
8594 System .out .println (JacksonJsonUtil .toJson (attachment , true ));
0 commit comments