2525import static com .github .tomakehurst .wiremock .client .WireMock .aResponse ;
2626import static com .github .tomakehurst .wiremock .client .WireMock .get ;
2727import static com .github .tomakehurst .wiremock .client .WireMock .urlPathMatching ;
28- import static org .testng .Assert .assertNotNull ;
29- import static org .testng .Assert .assertTrue ;
3028
3129public class OpenAPIV31ParserSchemaTest {
3230 protected int serverPort = getDynamicPort ();
@@ -167,54 +165,54 @@ private void tearDownWireMockServer() {
167165 public void test$idUrlExternal () throws Exception {
168166 ParseOptions p = new ParseOptions ();
169167 p .setResolve (true );
170- SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$id-uri-external/root.json" ).getAbsolutePath (), null , p );
168+ SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$id-uri-external/root.json" ).toURI (). toASCIIString (), null , p );
171169 compare ("$id-uri-external" , swaggerParseResult );
172170 }
173171
174172 @ Test
175173 public void test$idUrlEnclosing () throws Exception {
176174 ParseOptions p = new ParseOptions ();
177175 p .setResolve (true );
178- SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$id-uri-enclosing/root.json" ).getAbsolutePath (), null , p );
176+ SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$id-uri-enclosing/root.json" ).toURI (). toASCIIString (), null , p );
179177 compare ("$id-uri-enclosing" , swaggerParseResult );
180178 }
181179
182180 @ Test
183181 public void test$idUrlDirect () throws Exception {
184182 ParseOptions p = new ParseOptions ();
185183 p .setResolve (true );
186- SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$id-uri-direct/root.json" ).getAbsolutePath (), null , p );
184+ SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$id-uri-direct/root.json" ).toURI (). toASCIIString (), null , p );
187185 compare ("$id-uri-direct" , swaggerParseResult );
188186 }
189187 @ Test
190188 public void test$idUrlUnresolvable () throws Exception {
191189 ParseOptions p = new ParseOptions ();
192190 p .setResolve (true );
193- SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$id-unresolvable/root.json" ).getAbsolutePath (), null , p );
191+ SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$id-unresolvable/root.json" ).toURI (). toASCIIString (), null , p );
194192 compare ("$id-unresolvable" , swaggerParseResult );
195193 }
196194
197195 @ Test
198196 public void testAnchorExt () throws Exception {
199197 ParseOptions p = new ParseOptions ();
200198 p .setResolve (true );
201- SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$anchor-external/root.json" ).getAbsolutePath (), null , p );
199+ SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$anchor-external/root.json" ).toURI (). toASCIIString (), null , p );
202200 compare ("$anchor-external" , swaggerParseResult );
203201 }
204202
205203 @ Test
206204 public void testAnchorInt () throws Exception {
207205 ParseOptions p = new ParseOptions ();
208206 p .setResolve (true );
209- SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$anchor-internal/root.json" ).getAbsolutePath (), null , p );
207+ SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$anchor-internal/root.json" ).toURI (). toASCIIString (), null , p );
210208 compare ("$anchor-internal" , swaggerParseResult );
211209 }
212210
213211 @ Test
214212 public void testAnchorUnresolve () throws Exception {
215213 ParseOptions p = new ParseOptions ();
216214 p .setResolve (true );
217- SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$anchor-not-found/root.json" ).getAbsolutePath (), null , p );
215+ SwaggerParseResult swaggerParseResult = new OpenAPIV3Parser ().readLocation (new File ("src/test/resources/3.1.0/dereference/schema/$anchor-not-found/root.json" ).toURI (). toASCIIString (), null , p );
218216 compare ("$anchor-not-found" , swaggerParseResult );
219217 }
220218
@@ -223,7 +221,7 @@ public void compare(String dir, SwaggerParseResult result) throws Exception {
223221 ObjectMapper mapper = Json31 .mapper ().copy ();
224222 mapper .configure (SerializationFeature .ORDER_MAP_ENTRIES_BY_KEYS , true );
225223 mapper .configure (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY , true );
226- String actual = mapper .writer (new DefaultPrettyPrinter ()).writeValueAsString (result .getOpenAPI ());
224+ String actual = mapper .writer (new DefaultPrettyPrinter ()).writeValueAsString (result .getOpenAPI ()). replace ( " \r \n " , " \n " ) ;
227225 org .testng .Assert .assertEquals (actual ,
228226 FileUtils .readFileToString (new File ("src/test/resources/3.1.0/dereference/schema/" + dir + "/dereferenced.json" )));
229227 }
0 commit comments