public MetadataLinkInfo createMetadataLink() { return new MetadataLinkInfoImpl(); }
public void setContent(String content) { validate(content); this.content = content; }
@Test public void testSetAbsoluteHttps() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); info.setContent("https://example.com/foo"); }
coverage.getAlias().add("alias"); coverage.getKeywords().add(new Keyword("key")); MetadataLinkInfoImpl metadataLink = new MetadataLinkInfoImpl(); metadataLink.setAbout("about"); coverage.getMetadataLinks().add(metadataLink); CoverageDimensionImpl coverageDimension = new CoverageDimensionImpl("time");
@Test public void testSetRelativeUrlRelativePath() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); info.setContent("foo/bar"); }
@Test public void testSetRelativeUrlRelativeCurrentPath() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); info.setContent("./foo"); }
public MetadataLinkInfo createMetadataLink() { return new MetadataLinkInfoImpl(); }
private Object readResolve() { validate(content); return this; }
@Test public void testSetAbsoluteFtp() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); info.setContent("ftp://example.com/foo"); }
@Test public void testProxyMetadataURLBackReferenceNoProxyBaseUrl() throws Exception { createAppContext(null); MetadataLinkInfo link = new MetadataLinkInfoImpl(); link.setContent("/metadata.xml?foo=bar"); String url = ResponseUtils.proxifyMetadataLink(link, "http://localhost/geoserver"); assertEquals("http://localhost/geoserver/metadata.xml?foo=bar", url); }
@Override public void validate(IValidatable validatable) { String url = (String) validatable.getValue(); if (url != null) { try { MetadataLinkInfoImpl.validate(url); } catch (IllegalArgumentException ex) { IValidationError err = new ValidationError("invalidURL") .addKey("invalidURL") .setVariable("url", url); validatable.error(err); } } } }
@Test public void testSetRelativeUrlRelativeParentPath() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); info.setContent("../foo"); }
@Test public void testProxyMetadataURLBackReference() throws Exception { createAppContext("http://foo.org/geoserver"); MetadataLinkInfo link = new MetadataLinkInfoImpl(); link.setContent("/metadata.xml?foo=bar"); String url = ResponseUtils.proxifyMetadataLink(link, "http://localhost/geoserver"); assertEquals("http://foo.org/geoserver/metadata.xml?foo=bar", url); }
@Test public void testSetAbsoluteHttp() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); info.setContent("http://example.com/foo"); }
@Test public void testProxyMetadataURL() throws Exception { createAppContext("http://foo.org/geoserver"); MetadataLinkInfo link = new MetadataLinkInfoImpl(); link.setContent("http://bar.com/geoserver/metadata.xml?foo=bar"); String url = ResponseUtils.proxifyMetadataLink(link, "http://localhost/geoserver"); assertEquals(link.getContent(), url); }
@Test public void testSetRelativeUrlAbsolutePath() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); info.setContent("/foo"); }
@Test public void testNotAURLButStartsOK() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); thrown.expect(IllegalArgumentException.class); info.setContent("https://example.com/::^%/[*] FOO ::"); } }
@Test public void testSetAbsoluteTelnet() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); thrown.expect(IllegalArgumentException.class); info.setContent("telnet:example.com"); }
@Test public void testSetNotAURL() { MetadataLinkInfoImpl info = new MetadataLinkInfoImpl(); thrown.expect(IllegalArgumentException.class); info.setContent("::^%/[*] FOO ::"); }