@Test public void testWaitForNextBuild() throws InterruptedException, CruiseControlException { projectConfig.add(new MockSchedule()); MockProject mockProject = new MockProject() { private static final long serialVersionUID = 4262693344992901684L; public void run() { loop(); } void checkWait() throws InterruptedException { waitForNextBuild(); } }; mockProject.overrideBuildInterval(1000); mockProject.setProjectConfig(projectConfig); mockProject.init(); new Thread(mockProject).start(); Thread.sleep(100); assertEquals(1, mockProject.getLoopCount()); Thread.sleep(100); assertEquals(1, mockProject.getLoopCount()); mockProject.forceBuild(); Thread.sleep(100); assertEquals(2, mockProject.getLoopCount()); mockProject.stopLooping(); }
void waitForNextBuild() throws InterruptedException { long waitTime = getTimeToNextBuild(new Date()); if (needToWaitForNextBuild(waitTime) && !buildForced) { final String msg = "next build in " + DateUtil.formatTime(waitTime); info(msg); synchronized (waitMutex) { setState(ProjectState.WAITING); progress.setValue(msg); waitMutex.wait(waitTime); } } }
Project implements Serializable, Runnable { void waitForNextBuild() throws InterruptedException { long waitTime = getTimeToNextBuild(new Date()); if (needToWaitForNextBuild(waitTime) && !buildForced) { final String msg = "next build in " + DateUtil.formatTime(waitTime); info(msg); synchronized (waitMutex) { setState(ProjectState.WAITING); progress.setValue(msg); waitMutex.wait(waitTime); } } } }
Project implements Serializable, Runnable { void waitForNextBuild() throws InterruptedException { long waitTime = getTimeToNextBuild(new Date()); if (needToWaitForNextBuild(waitTime) && !buildForced) { final String msg = "next build in " + DateUtil.formatTime(waitTime); info(msg); synchronized (waitMutex) { setState(ProjectState.WAITING); progress.setValue(msg); waitMutex.wait(waitTime); } } } Project(); }
Project implements Serializable, Runnable { void waitForNextBuild() throws InterruptedException { long waitTime = getTimeToNextBuild(new Date()); if (needToWaitForNextBuild(waitTime) && !buildForced) { final String msg = "next build in " + DateUtil.formatTime(waitTime); info(msg); synchronized (waitMutex) { setState(ProjectState.WAITING); progress.setValue(msg); waitMutex.wait(waitTime); } } } Project(); void execute(); void run(); void forceBuildWithTarget(String buildTarget); void forceBuildWithTarget(String buildTarget, Map<String, String> addedProperties); void serializeProject(); void setLabelIncrementer(final LabelIncrementer incrementer); LabelIncrementer getLabelIncrementer(); void setName(final String projectName); String getName(); void setLabel(final String newLabel); String getLabel(); void setLastBuild(final String newLastBuild); void setLastSuccessfulBuild(final String newLastSuccessfulBuild); String getLastBuild(); boolean getBuildForced(); void setBuildForced(boolean forceNewBuildNow); String getLastSuccessfulBuild(); String getLogDir(); long getBuildInterval(); void overrideBuildInterval(final long sleepMillis); boolean isPaused(); void setPaused(final boolean paused); void setBuildAfterFailed(final boolean rebuildEvenWithNoNewModifications); String getStatus(); String getStatusWithQueuePosition(); ProjectState getState(); void setBuildQueue(final BuildQueue buildQueue); String getBuildStartTime(); Log getLog(); boolean isLastBuildSuccessful(); void start(); void stop(); String toString(); void addBuildProgressListener(final BuildProgressListener listener); void addBuildResultListener(final BuildResultListener listener); void setProjectConfig(final ProjectConfig projectConfig); boolean equals(final Object arg0); int hashCode(); void register(final MBeanServer server); ProjectConfig getProjectConfig(); Date getLastBuildDate(); Progress getProgress(); List<String> getLogLabels(); String[] getLogLabelLines(final String logLabel, final int firstLine); }
Project implements Serializable, Runnable { void waitForNextBuild() throws InterruptedException { long waitTime = getTimeToNextBuild(new Date()); if (needToWaitForNextBuild(waitTime) && !buildForced) { final String msg = "next build in " + DateUtil.formatTime(waitTime); info(msg); synchronized (waitMutex) { setState(ProjectState.WAITING); progress.setValue(msg); waitMutex.wait(waitTime); } } } Project(); void execute(); void run(); void forceBuildWithTarget(String buildTarget); void forceBuildWithTarget(String buildTarget, Map<String, String> addedProperties); void serializeProject(); void setLabelIncrementer(final LabelIncrementer incrementer); LabelIncrementer getLabelIncrementer(); void setName(final String projectName); String getName(); void setLabel(final String newLabel); String getLabel(); void setLastBuild(final String newLastBuild); void setLastSuccessfulBuild(final String newLastSuccessfulBuild); String getLastBuild(); boolean getBuildForced(); void setBuildForced(boolean forceNewBuildNow); String getLastSuccessfulBuild(); String getLogDir(); long getBuildInterval(); void overrideBuildInterval(final long sleepMillis); boolean isPaused(); void setPaused(final boolean paused); void setBuildAfterFailed(final boolean rebuildEvenWithNoNewModifications); String getStatus(); String getStatusWithQueuePosition(); ProjectState getState(); void setBuildQueue(final BuildQueue buildQueue); String getBuildStartTime(); Log getLog(); boolean isLastBuildSuccessful(); void start(); void stop(); String toString(); void addBuildProgressListener(final BuildProgressListener listener); void addBuildResultListener(final BuildResultListener listener); void setProjectConfig(final ProjectConfig projectConfig); boolean equals(final Object arg0); int hashCode(); void register(final MBeanServer server); ProjectConfig getProjectConfig(); Date getLastBuildDate(); Progress getProgress(); List<String> getLogLabels(); String[] getLogLabelLines(final String logLabel, final int firstLine);  }