forked from rest-assured/rest-assured
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rest-assured#1707: SVG file upload - fatal error :1:1: content is…
… not allowed in prolog
- Loading branch information
Showing
8 changed files
with
211 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"catalog": { | ||
"book": [ | ||
{ | ||
"id": "bk101", | ||
"author": "Gambardella, Matthew", | ||
"title": "XML Developer's Guide", | ||
"genre": "Computer", | ||
"price": 44.95, | ||
"publish_date": "2000-10-01" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<catalog> | ||
<book id="bk101"> | ||
<author>Gambardella, Matthew</author> | ||
<title>XML Developer's Guide</title> | ||
<genre>Computer</genre> | ||
<price>44.95</price> | ||
<publish_date>2000-10-01</publish_date> | ||
</book> | ||
</catalog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
rest-assured/src/test/java/io/restassured/internal/support/PrettifierTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package io.restassured.internal.support; | ||
|
||
import io.restassured.parsing.Parser; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
public class PrettifierTest { | ||
|
||
private File jsonFile; | ||
private File xmlFile; | ||
private final String resultJson = "{\n" + | ||
" \"catalog\": {\n" + | ||
" \"book\": [\n" + | ||
" {\n" + | ||
" \"id\": \"bk101\",\n" + | ||
" \"author\": \"Gambardella, Matthew\",\n" + | ||
" \"title\": \"XML Developer's Guide\",\n" + | ||
" \"genre\": \"Computer\",\n" + | ||
" \"price\": 44.95,\n" + | ||
" \"publish_date\": \"2000-10-01\"\n" + | ||
" }\n" + | ||
" ]\n" + | ||
" }\n" + | ||
"}"; | ||
|
||
private final String resultXml = "<catalog>\n" + | ||
" <book id=\"bk101\">\n" + | ||
" <author>Gambardella, Matthew</author>\n" + | ||
" <title>XML Developer's Guide</title>\n" + | ||
" <genre>Computer</genre>\n" + | ||
" <price>44.95</price>\n" + | ||
" <publish_date>2000-10-01</publish_date>\n" + | ||
" </book>\n" + | ||
"</catalog>"; | ||
|
||
|
||
@Before | ||
public void | ||
setup() throws IOException { | ||
jsonFile = getFile("multipart.json"); | ||
xmlFile = getFile("multipart.xml"); | ||
} | ||
|
||
@Test | ||
public void | ||
jsonPrettify() { | ||
String prettify = new Prettifier().prettify(jsonFile, Parser.JSON); | ||
|
||
assertEquals(prettify, resultJson); | ||
} | ||
|
||
@Test | ||
public void | ||
xml_prettify() { | ||
String prettify = new Prettifier().prettify(xmlFile, Parser.XML); | ||
|
||
assertEquals(prettify, resultXml); | ||
} | ||
|
||
@Test | ||
public void | ||
json_prettify() { | ||
String prettify = new Prettifier().prettify(jsonFile, Parser.JSON); | ||
|
||
assertEquals(prettify, resultJson); | ||
} | ||
|
||
@Test | ||
public void | ||
empty_data() { | ||
String prettify = new Prettifier().prettify("", Parser.XML); | ||
|
||
assertEquals(prettify, ""); | ||
} | ||
|
||
@Test | ||
public void | ||
json_string_data() throws IOException { | ||
String jsonData = new String(Files.readAllBytes(Paths.get(jsonFile.getPath()))); | ||
|
||
String prettify = new Prettifier().prettify(jsonData, Parser.JSON); | ||
|
||
assertEquals(prettify, resultJson); | ||
} | ||
|
||
@Test | ||
public void | ||
xml_string_data() throws IOException { | ||
String xmlData = new String(Files.readAllBytes(Paths.get(xmlFile.getPath()))); | ||
|
||
String prettify = new Prettifier().prettify(xmlData, Parser.XML); | ||
|
||
assertEquals(prettify, resultXml); | ||
} | ||
|
||
private File getFile(String path) throws IOException { | ||
return new File(getClass().getClassLoader().getResource(path).getFile()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"catalog": { | ||
"book": [ | ||
{ | ||
"id": "bk101", | ||
"author": "Gambardella, Matthew", | ||
"title": "XML Developer's Guide", | ||
"genre": "Computer", | ||
"price": 44.95, | ||
"publish_date": "2000-10-01" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<catalog> | ||
<book id="bk101"> | ||
<author>Gambardella, Matthew</author> | ||
<title>XML Developer's Guide</title> | ||
<genre>Computer</genre> | ||
<price>44.95</price> | ||
<publish_date>2000-10-01</publish_date> | ||
</book> | ||
</catalog> |