/** * Set the namespace for this configuration * * <p>All schema loading via URIs (using {@link SchemaLoader#get(URI)} or * when encountering a JSON Reference in a schema) will be resolved against * the provided namespace.</p> * * @param uri the URI * @return this * @throws NullPointerException URI is null * @throws IllegalArgumentException URI is not absolute, or is not a path * URI (ie, does not end with {@code /}) */ public URITranslatorConfigurationBuilder setNamespace(final URI uri) { BUNDLE.checkNotNull(uri, "uriChecks.nullInput"); final URI normalized = URIUtils.normalizeURI(uri); URIUtils.checkPathURI(normalized); namespace = normalized; return this; }
/** * Set the namespace for this configuration * * <p>All schema loading via URIs (using {@link SchemaLoader#get(URI)} or * when encountering a JSON Reference in a schema) will be resolved against * the provided namespace.</p> * * @param uri the URI * @return this * @throws NullPointerException URI is null * @throws IllegalArgumentException URI is not absolute, or is not a path * URI (ie, does not end with {@code /}) */ public URITranslatorConfigurationBuilder setNamespace(final URI uri) { BUNDLE.checkNotNull(uri, "uriChecks.nullInput"); final URI normalized = URIUtils.normalizeURI(uri); URIUtils.checkPathURI(normalized); namespace = normalized; return this; }
/** * Set the namespace for this configuration * * <p>All schema loading via URIs (using {@link SchemaLoader#get(URI)} or * when encountering a JSON Reference in a schema) will be resolved against * the provided namespace.</p> * * @param uri the URI * @return this * @throws NullPointerException URI is null * @throws IllegalArgumentException URI is not absolute, or is not a path * URI (ie, does not end with {@code /}) */ public URITranslatorConfigurationBuilder setNamespace(final URI uri) { BUNDLE.checkNotNull(uri, "uriChecks.nullInput"); final URI normalized = URIUtils.normalizeURI(uri); URIUtils.checkPathURI(normalized); namespace = normalized; return this; }
@Test(dataProvider = "invalidPathURIs") public void invalidPathURIsAreRejected(final String uri, final String key) { try { URIUtils.checkPathURI(URI.create(uri)); fail("No exception thrown!"); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), BUNDLE.printf(key, uri)); } }