String ch_desc = "Just a very simple short description.";
ChannelBuilder builder = new ChannelBuilder();
// create dummy channel
ChannelIF channel = new Channel(ch_title);
channel.setDescription(ch_desc);
channel.setSite(new URL("http://nava.de"));
ItemIF itemA = new Item("Bugo", "All about it!",
new URL("http://nava.de/huhu2002"));
itemA.setFound(new Date());
CategoryIF cat1 = builder.createCategory(null, "cat1");
CategoryIF cat1a = builder.createCategory(cat1, "cat1a");
builder.createCategory(cat1a, "cat1aa");
CategoryIF cat1ab = builder.createCategory(cat1a, "cat1ab");
builder.createCategory(cat1ab, "cat1aba");
builder.createCategory(cat1ab, "cat1abb");
builder.createCategory(cat1a, "cat1ac");
builder.createCategory(cat1, "cat1b");
CategoryIF cat1c = builder.createCategory(cat1, "cat1c");
builder.createCategory(cat1c, "cat1ca");
CategoryIF cat2 = builder.createCategory(null, "cat2");
itemA.addCategory(cat1);
itemA.addCategory(cat2);
assertEquals(2, itemA.getCategories().size());
channel.addItem(itemA);
// TODO: what about markup here ???
ItemIF itemB = new Item("SoCool",
"????**$12 @??? # <strong>should</strong> work",
new URL("http://nava.de/very/nested/98"));
itemB.setFound(new Date());
CategoryIF catX = builder.createCategory(null, "catX");
itemB.addCategory(catX);
assertEquals(1, itemB.getCategories().size());
channel.addItem(itemB);
assertEquals(2, channel.getItems().size());
// export this channel to file (encoding: utf-8)
String basename = "export-rss20.xml";
String exp_file = getOutputDir() + FS + basename;
RSS_2_0_Exporter exporter = new RSS_2_0_Exporter(exp_file);
exporter.write(channel);
// clean channel object
channel = null;
// read in again
File inpFile = new File(exp_file);
channel = FeedParser.parse(new ChannelBuilder(), inpFile);
assertEquals(ch_title, channel.getTitle());
assertEquals(ch_desc, channel.getDescription());
Collection items = channel.getItems();
assertEquals(2, items.size());
Iterator it = items.iterator();
ItemIF item = (ItemIF) it.next();
if (item.equals(itemA)) {
assertEquals(item, itemA);