25
25
import static com .github .tomakehurst .wiremock .client .WireMock .aResponse ;
26
26
import static com .github .tomakehurst .wiremock .client .WireMock .get ;
27
27
import static com .github .tomakehurst .wiremock .client .WireMock .urlPathMatching ;
28
- import static org .testng .Assert .assertNotNull ;
29
- import static org .testng .Assert .assertTrue ;
30
28
31
29
public class OpenAPIV31ParserSchemaTest {
32
30
protected int serverPort = getDynamicPort ();
@@ -167,54 +165,54 @@ private void tearDownWireMockServer() {
167
165
public void test$idUrlExternal () throws Exception {
168
166
ParseOptions p = new ParseOptions ();
169
167
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 );
171
169
compare ("$id-uri-external" , swaggerParseResult );
172
170
}
173
171
174
172
@ Test
175
173
public void test$idUrlEnclosing () throws Exception {
176
174
ParseOptions p = new ParseOptions ();
177
175
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 );
179
177
compare ("$id-uri-enclosing" , swaggerParseResult );
180
178
}
181
179
182
180
@ Test
183
181
public void test$idUrlDirect () throws Exception {
184
182
ParseOptions p = new ParseOptions ();
185
183
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 );
187
185
compare ("$id-uri-direct" , swaggerParseResult );
188
186
}
189
187
@ Test
190
188
public void test$idUrlUnresolvable () throws Exception {
191
189
ParseOptions p = new ParseOptions ();
192
190
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 );
194
192
compare ("$id-unresolvable" , swaggerParseResult );
195
193
}
196
194
197
195
@ Test
198
196
public void testAnchorExt () throws Exception {
199
197
ParseOptions p = new ParseOptions ();
200
198
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 );
202
200
compare ("$anchor-external" , swaggerParseResult );
203
201
}
204
202
205
203
@ Test
206
204
public void testAnchorInt () throws Exception {
207
205
ParseOptions p = new ParseOptions ();
208
206
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 );
210
208
compare ("$anchor-internal" , swaggerParseResult );
211
209
}
212
210
213
211
@ Test
214
212
public void testAnchorUnresolve () throws Exception {
215
213
ParseOptions p = new ParseOptions ();
216
214
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 );
218
216
compare ("$anchor-not-found" , swaggerParseResult );
219
217
}
220
218
@@ -223,7 +221,7 @@ public void compare(String dir, SwaggerParseResult result) throws Exception {
223
221
ObjectMapper mapper = Json31 .mapper ().copy ();
224
222
mapper .configure (SerializationFeature .ORDER_MAP_ENTRIES_BY_KEYS , true );
225
223
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 " ) ;
227
225
org .testng .Assert .assertEquals (actual ,
228
226
FileUtils .readFileToString (new File ("src/test/resources/3.1.0/dereference/schema/" + dir + "/dereferenced.json" )));
229
227
}
0 commit comments