Skip to content

Commit 5dd0be3

Browse files
authored
Basic test on URI create to improve coverage (#923)
1 parent 48ca8c3 commit 5dd0be3

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/test/java/com/networknt/schema/UriMappingTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ public class UriMappingTest {
4040
private final ClasspathURLFactory classpathURLFactory = new ClasspathURLFactory();
4141
private final URLFactory urlFactory = new URLFactory();
4242

43+
/**
44+
* Validate URI Create API
45+
*/
46+
@Test
47+
public void testUrlFactoryCreate() {
48+
try {
49+
this.urlFactory.create("://example.com/invalid/schema/url");
50+
fail("Invalid URI, should throw error.");
51+
}
52+
catch(IllegalArgumentException e){
53+
54+
}
55+
catch(Exception e){
56+
fail("Unknown Exception occured ");
57+
}
58+
59+
}
60+
4361
/**
4462
* Validate that a JSON URI Mapping file containing the URI Mapping schema is
4563
* schema valid.
@@ -113,7 +131,7 @@ public void testValidatorConfigUriMappingUri() throws IOException {
113131
SchemaValidatorsConfig config = new SchemaValidatorsConfig();
114132
config.addUriTranslator(getUriMappingsFromUrl(mappings));
115133
JsonSchema schema = instance.getSchema(this.urlFactory.create(
116-
"https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json"),
134+
"https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json"),
117135
config);
118136
assertEquals(0, schema.validate(mapper.readTree(mappings)).size());
119137
}

0 commit comments

Comments
 (0)