1 37 package net.sourceforge.cruisecontrol.webtest; 38 39 import net.sourceforge.jwebunit.WebTestCase; 40 import net.sourceforge.cruisecontrol.Configuration; 41 42 public class PublisherDetailsWebTest extends WebTestCase { 43 private static final String BASE = "/cruisecontrol/load-details.jspa?" 44 + "project=connectfour&pluginType=publisher"; 45 private static final String FTP_URL = BASE + "&pluginName=ftppublisher"; 46 private static final String XSLT_URL = BASE + "&pluginName=xsltlogpublisher"; 47 48 private Configuration configuration; 49 private String contents; 50 51 protected void setUp() throws Exception { 52 super.setUp(); 53 54 getTestContext().setBaseUrl("http://localhost:7854"); 55 56 configuration = new Configuration("localhost", 7856); 57 contents = configuration.getConfiguration(); 58 } 59 60 protected void tearDown() throws Exception { 61 super.tearDown(); 62 63 configuration.setConfiguration(contents); 64 } 65 66 public void testShouldBeAccessibleFromPublishersPage() { 67 String pluginsUrl = "/cruisecontrol/plugins.jspa?project=connectfour&pluginType=publisher"; 68 69 beginAt(pluginsUrl); 70 assertLinkPresentWithText("onsuccess"); 71 } 72 73 public void testShouldLoadFTPPublisherConfiguration() { 74 beginAt(FTP_URL); 75 assertFormPresent("ftppublisher-details"); 76 assertFormElementPresent("deleteArtifacts"); 77 assertFormElementPresent("destDir"); 78 assertFormElementPresent("srcDir"); 79 } 80 81 public void testShouldLoadXSLTLogPublisherConfiguration() { 82 beginAt(XSLT_URL); 83 assertFormPresent("xsltlogpublisher-details"); 84 assertFormElementPresent("directory"); 85 assertFormElementPresent("outFileName"); 86 assertFormElementPresent("publishOnFail"); 87 assertFormElementPresent("xsltFile"); 88 } 89 90 public void testShouldSaveFTPPublisherConfiguration() { 91 beginAt(FTP_URL); 92 setWorkingForm("ftppublisher-details"); 93 setFormElement("destDir", "/tmp"); 94 submit(); 95 assertTextPresent("Updated configuration."); 96 assertFormPresent("ftppublisher-details"); 97 assertFormElementPresent("destDir"); 98 assertTextPresent("/tmp"); 99 } 100 101 public void testShouldSaveXSLTLogPublisherConfiguration() { 102 beginAt(XSLT_URL); 103 setWorkingForm("xsltlogpublisher-details"); 104 setFormElement("xsltFile", "templates/foobar.xslt"); 105 submit(); 106 assertTextPresent("Updated configuration."); 107 assertFormPresent("xsltlogpublisher-details"); 108 assertFormElementPresent("xsltFile"); 109 assertTextPresent("templates/foobar.xslt"); 110 } 111 112 public void testShouldAllowUsersToClearFTPPublisherAttributes() { 113 String destDir = "/tmp"; 114 115 beginAt(FTP_URL); 116 setWorkingForm("ftppublisher-details"); 117 setFormElement("destDir", destDir); 118 submit(); 119 assertTextPresent("Updated configuration."); 120 assertTextPresent(destDir); 121 122 gotoPage(FTP_URL); 123 assertTextPresent(destDir); 124 setWorkingForm("ftppublisher-details"); 125 setFormElement("destDir", ""); 126 submit(); 127 assertTextPresent("Updated configuration."); 128 assertTextNotPresent(destDir); 129 130 gotoPage(FTP_URL); 131 assertTextNotPresent(destDir); 132 } 133 134 public void testShouldAllowUsersToClearXSLTLogPublisherAttributes() { 135 String xsltFile = "templates/foo.xslt"; 136 137 beginAt(XSLT_URL); 138 setWorkingForm("xsltlogpublisher-details"); 139 setFormElement("xsltFile", xsltFile); 140 submit(); 141 assertTextPresent("Updated configuration."); 142 assertTextPresent(xsltFile); 143 144 gotoPage(XSLT_URL); 145 assertTextPresent(xsltFile); 146 setWorkingForm("xsltlogpublisher-details"); 147 setFormElement("xsltFile", ""); 148 submit(); 149 assertTextPresent("Updated configuration."); 150 assertTextNotPresent(xsltFile); 151 152 gotoPage(XSLT_URL); 153 assertTextNotPresent(xsltFile); 154 } 155 } 156 | Popular Tags |