Pages

Sunday, July 17, 2011

JUnit

package examples.test;

import java.io.*;
import java.net.*;

import examples.rss.*;
import junit.framework.Assert;
import junit.framework.TestCase;


public class RSSReaderTest extends TestCase {

    public void testParsLocalfile() {
        String resourceLocation="/examples/documents/ABC_Catalyst.xml";
        URL result = getClass().getResource(resourceLocation);
        InputStream stream=null;
        try {
            stream = result.openStream();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        RSSReader reader=RSSReader.getInstance(stream);
        Feed feed=    reader.readFeed();

        Assert.assertTrue("Invalid Feed Title", feed.getTitle().equals("Learning, reference repository Cli"));
        Assert.assertTrue("Invalid Feed Link", feed.getLink().equals("http://lrr.cli.det.nsw.edu.au/"));

        Assert.assertTrue("Invalid Feed Entries", feed.getEntries().toArray().length>0);

    }
}

No comments:

Post a Comment