Skip to content

Commit

Permalink
Added invalid json file as a test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurd86 committed Oct 5, 2023
1 parent f4db8ec commit 9c7d02a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Testing the local URL issue with OpenAPI, 4 test cases:
- a local file which does not exist and a valid URL
- a local file which exists and an invalid URL
- a local file which does not exist and an invalid URL
- a local file which is not a valid swagger
- a local file which is not a valid swagger but a valid JSON
- a local file which is not a valid JSON
- an invalid url
*/
class OpenAPILocalURLIssueTest {
Expand Down Expand Up @@ -208,6 +209,32 @@ class OpenAPILocalURLIssueTest {
"schema at file location: $urlToTest"))
}

@Test
fun testInvalidJSON() {

// get the current directory
val urlToTest = "file://$executionPath/src/test" +
"/resources/invalid_json.json";

// exception to throw
val exception = Assertions.assertThrows(
SutProblemException::class.java
) {
// create swagger
swagger = OpenApiAccess.getOpenAPIFromURL(urlToTest);
}

/*
An empty swagger should be created
*/
//Assertions.assertTrue(swagger.paths.size == 0)

print(exception.message)

Assertions.assertTrue( exception.message!!.contains("Failed to parse OpenApi schema"))

}



}
1 change: 1 addition & 0 deletions core/src/test/resources/invalid_json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AAAAAAAAAAA

0 comments on commit 9c7d02a

Please sign in to comment.