1 37 package net.sourceforge.cruisecontrol.publishers.rss; 38 39 import java.io.BufferedWriter ; 40 import java.io.File ; 41 import java.io.FileOutputStream ; 42 import java.io.OutputStreamWriter ; 43 44 import junit.framework.TestCase; 45 46 49 public class CruiseControlFeedTest extends TestCase { 50 51 private File tmpFile; 52 53 public void setUp() throws Exception { 54 tmpFile = File.createTempFile("CruiseControlFeedTest", ".tmp"); 55 tmpFile.deleteOnExit(); 56 57 BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (tmpFile))); 58 bw.write("<rss><channel/></rss>"); 59 bw.close(); 60 } 61 62 public void tearDown() throws Exception { 63 if (tmpFile != null) { 64 tmpFile.delete(); 65 } 66 } 67 68 public void testProjectCount() { 69 70 CruiseControlFeed feed = new CruiseControlFeed(tmpFile); 71 assertEquals(0, feed.getProjectCount()); 72 feed.incrementProjectCount(); 73 assertEquals(1, feed.getProjectCount()); 74 feed.incrementProjectCount(); 75 assertEquals(2, feed.getProjectCount()); 76 } 77 78 79 public void testProjectName() { 80 81 CruiseControlFeed feed = new CruiseControlFeed(tmpFile); 82 assertNull(feed.getProjectName()); 83 84 feed.setProjectName("Project1"); 85 assertEquals("Project1", feed.getProjectName()); 86 87 feed.setProjectName("Project2"); 88 assertEquals("Project1, Project2", feed.getProjectName()); 89 90 feed.setProjectName("Project3"); 91 assertEquals("Project1, Project2, Project3", feed.getProjectName()); 92 } 93 94 public void testTitle() { 95 96 CruiseControlFeed feed = new CruiseControlFeed(tmpFile); 97 assertEquals("CruiseControl Build Results", feed.getTitle()); 98 99 feed.setProjectName("Project1"); 100 assertEquals("CruiseControl Build Results", feed.getTitle()); 101 102 feed.setTitle("new title"); 103 assertEquals("new title", feed.getTitle()); 104 } 105 106 public void testDescription() { 107 108 CruiseControlFeed feed = new CruiseControlFeed(tmpFile); 109 assertEquals("Automated build results for CruiseControl.", feed.getDescription()); 110 111 feed.setProjectName("Project1"); 112 assertEquals("Automated build results for CruiseControl project(s) Project1", feed.getDescription()); 113 114 feed.setDescription("new"); 115 assertEquals("new", feed.getDescription()); 116 } 117 } 118 | Popular Tags |