Skip to content

Commit 994869a

Browse files
committed
Added tests for special characters in names
1 parent 1295f0e commit 994869a

File tree

2 files changed

+94
-9
lines changed

2 files changed

+94
-9
lines changed

src/test/java/com/fusiondb/studio/api/CollectionIT.java

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,31 @@ public void createCollection() {
4141
final String colPath = "/db/fusion-studio-api-test-document-it-col-1";
4242
final ExtractableResponse<Response> collectionResponse = createCollection(colPath);
4343
assertEquals(colPath, collectionResponse.jsonPath().getString("uri"));
44+
readCollection(colPath);
45+
}
46+
47+
@Test
48+
public void createCollectionWithSpaceInName() {
49+
final String colPath = "/db/fusion-studio-api-test-document-it-col 2";
50+
final ExtractableResponse<Response> collectionResponse = createCollection(colPath);
51+
assertEquals(colPath, collectionResponse.jsonPath().getString("uri"));
52+
readCollection(colPath);
53+
}
54+
55+
@Test
56+
public void createCollectionWithPlusInName() {
57+
final String colPath = "/db/fusion-studio-api-test-document-it-col+3";
58+
final ExtractableResponse<Response> collectionResponse = createCollection(colPath);
59+
assertEquals(colPath, collectionResponse.jsonPath().getString("uri"));
60+
readCollection(colPath);
61+
}
62+
63+
@Test
64+
public void createCollectionWithUnicodeCharactersInName() {
65+
final String colPath = "/db/مجموعة-فيوجن-ستوديو";
66+
final ExtractableResponse<Response> collectionResponse = createCollection(colPath);
67+
assertEquals(colPath, collectionResponse.jsonPath().getString("uri"));
68+
readCollection(colPath);
4469
}
4570

4671
@Test
@@ -196,14 +221,28 @@ public void moveCollection() {
196221

197222
private ExtractableResponse<Response> createCollection(final String path) {
198223
return
199-
given().
200-
auth().preemptive().basic(DEFAULT_ADMIN_USERNAME, DEFAULT_ADMIN_PASSWORD).
201-
when().
202-
put(getApiBaseUri() + "/collection?uri=" + path).
203-
then().
204-
statusCode(SC_CREATED).
205-
assertThat().
206-
body(matchesJsonSchemaInClasspath("collection-schema.json")).
207-
extract();
224+
given().
225+
auth().preemptive().basic(DEFAULT_ADMIN_USERNAME, DEFAULT_ADMIN_PASSWORD).
226+
when().
227+
put(getApiBaseUri() + "/collection?uri=" + path).
228+
then().
229+
statusCode(SC_CREATED).
230+
assertThat().
231+
body(matchesJsonSchemaInClasspath("collection-schema.json")).
232+
extract();
233+
}
234+
235+
private ExtractableResponse<Response> readCollection(final String path) {
236+
return
237+
given().
238+
auth().preemptive().basic(DEFAULT_ADMIN_USERNAME, DEFAULT_ADMIN_PASSWORD).
239+
when().
240+
get(getApiBaseUri() + "/explorer?uri=" + path).
241+
then().
242+
statusCode(SC_OK).
243+
assertThat().
244+
body(matchesJsonSchemaInClasspath("collection-schema.json")).
245+
body("uri", equalTo(path)).
246+
extract();
208247
}
209248
}

src/test/java/com/fusiondb/studio/api/DocumentIT.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
3434
import static java.nio.charset.StandardCharsets.UTF_8;
3535
import static org.apache.http.HttpStatus.*;
36+
import static org.hamcrest.core.IsEqual.equalTo;
3637
import static org.junit.jupiter.api.Assertions.*;
3738

3839
public 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

Comments
 (0)