예제 #1
0
  public void testParse() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new File(super.getTestFile("xml/custom-tags-example.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI);
    final Iterator<CustomTag> it = customTags.getValues().iterator();
    while (it.hasNext()) {
      final CustomTag tag = it.next();
      LOG.debug("{}", tag);
      if (tag.getName().equals("language_skills")) {
        Assert.assertEquals("Fluent in English and German", tag.getValue());
      }
      if (tag.getName().equals("prior_experience_years")) {
        Assert.assertEquals(new Integer(5), tag.getValue());
      } else if (tag.getName().equals("start_date")) {
        final Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(0);
        cal.set(2005, 10, 15, 0, 0, 0);
        Assert.assertEquals(cal.getTime(), tag.getValue());
      } else if (tag.getName().equals("test_url")) {
        Assert.assertEquals(new URL("http://www.screaming-penguin.com"), tag.getValue());
      } else if (tag.getName().equals("test_boolean")) {
        Assert.assertEquals(new Boolean(true), tag.getValue());
      } else if (tag.getName().equals("test_intUnit")) {
        Assert.assertEquals(new IntUnit(25, "horses"), tag.getValue());
      } else if (tag.getName().equals("test_floatUnit")) {
        Assert.assertEquals(new FloatUnit((float) 2.5, "cows"), tag.getValue());
      } else if (tag.getName().equals("test_location")) {
        Assert.assertEquals(
            new CustomTagImpl.Location("125 Main St, Sometown, GA"), tag.getValue());
      } else if (tag.getName().equals("test_dateRange")) {
        final Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(0);
        cal.set(2005, 06, 04, 20, 0, 0);
        final Date start = cal.getTime();
        cal.set(2005, 06, 04, 23, 0, 0);
        final DateTimeRange dtr = new DateTimeRange(start, cal.getTime());
        Assert.assertEquals(dtr, tag.getValue());
      }
    }
  }