@Test public void testGetBaseUrlForInvalidValue() { Entry newEntry = new Abdera().newEntry(); // illegal argument exception newEntry.setBaseUri(new IRI("foo")); try { AtomUtil.getBaseUrl(newEntry); fail("IllegalArgumentException should have thrown"); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } // malformed url exception newEntry.setBaseUri(new IRI("foo://test:8080/bar")); try { AtomUtil.getBaseUrl(newEntry); fail("IllegalArgumentException should have thrown"); } catch (Exception e) { assertTrue(e.getCause() instanceof MalformedURLException); } }
@Test public void testGetBaseUrl() { Entry newEntry = new Abdera().newEntry(); newEntry.setBaseUri(new IRI("http://myserver:8080/myservice/Test.svc")); assertEquals("http://myserver:8080/myservice/Test.svc", AtomUtil.getBaseUrl(newEntry)); }