Пример #1
0
 @Test
 public void testExtractRel() {
   assertEquals("", AtomUtil.extractRel(""));
   assertEquals("foo", AtomUtil.extractRel("foo"));
   assertEquals("bar", AtomUtil.extractRel("foo bar"));
   assertEquals("foo", AtomUtil.extractRel("foo "));
 }
Пример #2
0
 @Test
 public void testExtractDescription() {
   assertEquals("", AtomUtil.extractDescription(""));
   assertEquals("foo", AtomUtil.extractDescription("foo bar"));
   assertEquals("", AtomUtil.extractDescription("foo"));
   assertEquals("foo", AtomUtil.extractDescription(" foo bar "));
   assertEquals("foo", AtomUtil.extractDescription(" foo bar whatever"));
 }
Пример #3
0
  @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);
    }
  }
Пример #4
0
 @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));
 }