org.apache.abdera.model.AtomDate

Here are the examples of the java api class org.apache.abdera.model.AtomDate taken from open source projects.

1. FeedValidatorTest#testSection11BriefNoError()

Project: abdera
Source File: FeedValidatorTest.java
View license
public static void testSection11BriefNoError() throws Exception {
    // http://feedvalidator.org/testcases/atom/1.1/brief-noerror.xml
    URI uri = baseURI.resolve("1.1/brief-noerror.xml");
    Document<Feed> doc = get(uri);
    assertNotNull(doc);
    Feed feed = doc.getRoot();
    assertNotNull(feed);
    Text title = feed.getTitleElement();
    assertNotNull(title);
    assertEquals(title.getTextType(), Text.Type.TEXT);
    String value = title.getValue();
    assertNotNull(value);
    assertEquals(value, "Example Feed");
    List<Link> links = feed.getLinks();
    assertEquals(1, links.size());
    for (Link link : links) {
        // it's an alternate link
        assertNull(link.getRel());
        assertEquals(link.getHref(), new URI("http://example.org/"));
        assertNull(link.getHrefLang());
        assertNull(link.getMimeType());
        assertNull(link.getTitle());
        assertEquals(link.getLength(), -1);
    }
    links = feed.getLinks(Link.REL_ALTERNATE);
    assertEquals(links.size(), 1);
    links = feed.getLinks(Link.REL_RELATED);
    assertEquals(links.size(), 0);
    assertNotNull(feed.getUpdatedElement());
    DateTime dte = feed.getUpdatedElement();
    AtomDate dt = dte.getValue();
    assertNotNull(dt);
    Calendar c = dt.getCalendar();
    AtomDate cdt = new AtomDate(c);
    assertEquals(dt.getTime(), cdt.getTime());
    Person person = feed.getAuthor();
    assertNotNull(person);
    assertEquals(person.getName(), "John Doe");
    assertNull(person.getEmail());
    assertNull(person.getUri());
    IRI id = feed.getIdElement();
    assertNotNull(id);
    assertEquals(id.getValue(), new URI("urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"));
    List<Entry> entries = feed.getEntries();
    assertEquals(entries.size(), 1);
    for (Entry entry : entries) {
        title = entry.getTitleElement();
        assertNotNull(title);
        assertEquals(title.getTextType(), Text.Type.TEXT);
        value = title.getValue();
        assertEquals(value, "Atom-Powered Robots Run Amok");
        links = entry.getLinks();
        assertEquals(1, links.size());
        for (Link link : links) {
            // it's an alternate link
            assertNull(link.getRel());
            assertEquals(link.getHref(), new URI("http://example.org/2003/12/13/atom03"));
            assertNull(link.getHrefLang());
            assertNull(link.getMimeType());
            assertNull(link.getTitle());
            assertEquals(link.getLength(), -1);
        }
        links = entry.getLinks(Link.REL_ALTERNATE);
        assertEquals(links.size(), 1);
        links = entry.getLinks(Link.REL_RELATED);
        assertEquals(links.size(), 0);
        id = entry.getIdElement();
        assertNotNull(id);
        assertEquals(id.getValue(), new URI("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a"));
        assertNotNull(entry.getUpdatedElement());
        dte = entry.getUpdatedElement();
        dt = dte.getValue();
        assertNotNull(dt);
        c = dt.getCalendar();
        cdt = new AtomDate(c);
        assertEquals(dt.getTime(), cdt.getTime());
        Text summary = entry.getSummaryElement();
        assertNotNull(summary);
        assertEquals(summary.getTextType(), Text.Type.TEXT);
        value = summary.getValue();
        assertEquals(value, "Some text.");
    }
}

2. CoreTest#testAtomDate()

Project: abdera
Source File: CoreTest.java
View license
public static void testAtomDate() {
    Date now = new Date();
    AtomDate atomNow = AtomDate.valueOf(now);
    String rfc3339 = atomNow.getValue();
    atomNow = AtomDate.valueOf(rfc3339);
    Date parsed = atomNow.getDate();
    assertEquals(now, parsed);
}

3. FOMDateTime#getValue()

Project: abdera
Source File: FOMDateTime.java
View license
public AtomDate getValue() {
    AtomDate value = null;
    String v = getText();
    if (v != null) {
        value = AtomDate.valueOf(v);
    }
    return value;
}

4. FOMDateTime#getDate()

Project: abdera
Source File: FOMDateTime.java
View license
public Date getDate() {
    AtomDate ad = getValue();
    return (ad != null) ? ad.getDate() : null;
}

5. FOMDateTime#getCalendar()

Project: abdera
Source File: FOMDateTime.java
View license
public Calendar getCalendar() {
    AtomDate ad = getValue();
    return (ad != null) ? ad.getCalendar() : null;
}

6. FOMDateTime#getTime()

Project: abdera
Source File: FOMDateTime.java
View license
public long getTime() {
    AtomDate ad = getValue();
    return (ad != null) ? ad.getTime() : null;
}

7. FOMDateTime#getString()

Project: abdera
Source File: FOMDateTime.java
View license
public String getString() {
    AtomDate ad = getValue();
    return (ad != null) ? ad.getValue() : null;
}