From: <jbo...@li...> - 2005-10-25 17:48:57
|
Author: aron.gombas Date: 2005-10-25 13:48:52 -0400 (Tue, 25 Oct 2005) New Revision: 1449 Modified: trunk/labs/kosmos/src/test/hu/midori/kosmos/server/sf/SfServiceTest.java Log: Test skeleton added (not running yet) Modified: trunk/labs/kosmos/src/test/hu/midori/kosmos/server/sf/SfServiceTest.java =================================================================== --- trunk/labs/kosmos/src/test/hu/midori/kosmos/server/sf/SfServiceTest.java 2005-10-25 17:48:19 UTC (rev 1448) +++ trunk/labs/kosmos/src/test/hu/midori/kosmos/server/sf/SfServiceTest.java 2005-10-25 17:48:52 UTC (rev 1449) @@ -6,11 +6,53 @@ */ package hu.midori.kosmos.server.sf; +import hu.midori.kosmos.model.SfRelease; +import hu.midori.kosmos.protocol.SfService; + +import java.util.List; +import java.util.Properties; + +import org.apache.log4j.PropertyConfigurator; + +import junit.framework.TestCase; + /** * Unit test. * * @author <a href="mailto:aro...@mi...">Aron Gombas</a> * @version $Id$ */ -public class SfServiceTest {// TODO just pass in test URLs and check the result returned +public class SfServiceTest extends TestCase { + SfService service = new SfServiceImpl(); + + public void setUp() throws Exception {// TODO move to AbstractTestCase + super.setUp(); + + // configure log4j programatically (it doesn't require new files in the webapp class-path) + Properties props = new Properties(); + props.put("log4j.rootLogger", "DEBUG, stdout"); + props.put("log4j.appender.stdout", "org.apache.log4j.ConsoleAppender"); + props.put("log4j.appender.stdout.layout", "org.apache.log4j.PatternLayout"); + props.put("log4j.appender.stdout.layout.ConversionPattern", "%-4r %-5p %c %x - %m%n" ); + PropertyConfigurator.configure(props); + } + + /** Tests with a project that has releases. */ + public void testRelease() { + List<SfRelease> releases = service.getFileReleases("http://sourceforge.net/projects/struts"); + assertTrue(releases.size() > 0); + + // TODO assert for properties + // TODO test other service things + } + + /** Tests with a project that has no release yet. */ + public void testNoRelease() { + assertEquals(0, service.getFileReleases("http://sourceforge.net/projects/pixie-perl")); + } + + /** Tests with invalid URL. */ + public void testInvalidUrl() { + assertEquals(0, service.getFileReleases("http://sourceforge.net/projects/nosuchproject")); + } } |