MockArticle mock = new MockArticle();
Topic[] topics = new Topic[NUMBER];
for (int i=0; i < NUMBER; i++) {
topics[i] = new Topic(URI+i, NAME+i);
}
mock.setTopics(topics);
try {
Article article = new Article("test", mock.toXML());
Iterator iter = article.getTopics();
int count = 0;
while (iter.hasNext()) {
Topic topic = (Topic) iter.next();
if (count >= NUMBER) {
fail("Too many topics returned");
}
assertEquals("Topic uri "+count+" was wrong",
topics[count].getUri(), topic.getUri());
assertEquals("Topic name "+count+" was wrong",
topics[count].getName(), topic.getName());
count++;
}
assertEquals("Too few topics returned", NUMBER, count);
} catch (IOException e) {
fail("Failed to parse article");