TwitterPublisher implements Publisher { public void publish(Element cruisecontrolLog) throws CruiseControlException { XMLLogHelper helper = new XMLLogHelper(cruisecontrolLog); proxy.twitter(helper.getProjectName() + " " + helper.getStatusMessage(), username, password); } TwitterPublisher();   TwitterPublisher(TwitterProxy proxy); void publish(Element cruisecontrolLog); void validate(); void setPassword(String s); void setUsername(String s);  }
@Test public void messageShouldBeBuildFailure() throws CruiseControlException { TestTwitterProxy proxy = new TestTwitterProxy(); TwitterPublisher twitter = new TwitterPublisher(proxy); Element failed = TestUtil.createFailedBuild(); twitter.publish(failed); assertEquals("someproject failed", proxy.status); }
@Test public void messageShouldBePassedWhenBuildPasses() throws CruiseControlException { TestTwitterProxy proxy = new TestTwitterProxy(); TwitterPublisher twitter = new TwitterPublisher(proxy); Element passed = TestUtil.createPassingBuild(); twitter.publish(passed); assertEquals("someproject successful", proxy.status); }
@Test public void messageShouldBeFixedWhenBuildIsFixed() throws CruiseControlException { TestTwitterProxy proxy = new TestTwitterProxy(); TwitterPublisher twitter = new TwitterPublisher(proxy); Element fixed = TestUtil.createFixedBuild(); twitter.publish(fixed); assertEquals("someproject fixed", proxy.status); }
@Test public void messageShouldIncludeProjectName() throws CruiseControlException { TestTwitterProxy proxy = new TestTwitterProxy(); TwitterPublisher twitter = new TwitterPublisher(proxy); Element passed = TestUtil.createPassingBuild(); String projectName = "myProject" + System.currentTimeMillis(); setProjectName(passed, projectName); twitter.publish(passed); assertEquals(projectName + " successful", proxy.status); }