3333import static io .restassured .module .jsv .JsonSchemaValidator .matchesJsonSchemaInClasspath ;
3434import static java .nio .charset .StandardCharsets .UTF_8 ;
3535import static org .apache .http .HttpStatus .*;
36+ import static org .hamcrest .core .IsEqual .equalTo ;
3637import static org .junit .jupiter .api .Assertions .*;
3738
3839public class DocumentIT {
@@ -44,6 +45,37 @@ public void createXml() {
4445 final ExtractableResponse <Response > documentResponse = createXml (docPath , "<time>" + now + "</time>" );
4546 assertEquals (docPath , documentResponse .jsonPath ().getString ("uri" ));
4647 assertFalse (documentResponse .jsonPath ().getBoolean ("binaryDoc" ));
48+ readDocument (docPath );
49+ }
50+
51+ @ Test
52+ public void createXmlWithSpaceInName () {
53+ final String docPath = "/db/fusion-studio-api-test-document-it 2.xml" ;
54+ final long now = System .currentTimeMillis ();
55+ final ExtractableResponse <Response > documentResponse = createXml (docPath , "<time>" + now + "</time>" );
56+ assertEquals (docPath , documentResponse .jsonPath ().getString ("uri" ));
57+ assertFalse (documentResponse .jsonPath ().getBoolean ("binaryDoc" ));
58+ readDocument (docPath );
59+ }
60+
61+ @ Test
62+ public void createXmlWithPlusInName () {
63+ final String docPath = "/db/fusion-studio-api-test-document-it+3.xml" ;
64+ final long now = System .currentTimeMillis ();
65+ final ExtractableResponse <Response > documentResponse = createXml (docPath , "<time>" + now + "</time>" );
66+ assertEquals (docPath , documentResponse .jsonPath ().getString ("uri" ));
67+ assertFalse (documentResponse .jsonPath ().getBoolean ("binaryDoc" ));
68+ readDocument (docPath );
69+ }
70+
71+ @ Test
72+ public void createXmlWithUnicodeCharactersInName () {
73+ final String docPath = "/db/وثيقة-فيوجن-ستوديو.xml-4" ;
74+ final long now = System .currentTimeMillis ();
75+ final ExtractableResponse <Response > documentResponse = createXml (docPath , "<time >" + now + "</time>" );
76+ assertEquals (docPath , documentResponse .jsonPath ().getString ("uri" ));
77+ assertFalse (documentResponse .jsonPath ().getBoolean ("binaryDoc" ));
78+ readDocument (docPath );
4779 }
4880
4981 @ Test
@@ -200,4 +232,18 @@ private ExtractableResponse<Response> createXml(final String path, final String
200232 body (matchesJsonSchemaInClasspath ("document-schema.json" )).
201233 extract ();
202234 }
235+
236+ private ExtractableResponse <Response > readDocument (final String path ) {
237+ return
238+ given ().
239+ auth ().preemptive ().basic (DEFAULT_ADMIN_USERNAME , DEFAULT_ADMIN_PASSWORD ).
240+ when ().
241+ get (getApiBaseUri () + "/explorer?uri=" + path ).
242+ then ().
243+ statusCode (SC_OK ).
244+ assertThat ().
245+ body (matchesJsonSchemaInClasspath ("document-schema.json" )).
246+ body ("uri" , equalTo (path )).
247+ extract ();
248+ }
203249}
0 commit comments