提交 017e4456 编写于 作者: N Nigel Magnay

Move hudson.model.Jenkins to be jenkins.model.Jenkins - part III

Fix code that accesses functionality though package protected interfaces;
- access through AbstractCIBase
- make FullDuplexHttpChannel and OverallLoadStatistics public

Test case utility function for adjusting the quiet period variable
Signed-off-by: NNigel Magnay <nigel.magnay@gmail.com>
上级 5679d019
......@@ -112,7 +112,7 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
* Mark this monitor as disabled, to prevent this from showing up in the UI.
*/
public void disable(boolean value) throws IOException {
Jenkins hudson = Jenkins.getInstance();
AbstractCIBase hudson = Jenkins.getInstance();
Set<String> set = hudson.disabledAdministrativeMonitors;
if(value) set.add(id);
else set.remove(id);
......@@ -127,7 +127,7 @@ public abstract class AdministrativeMonitor extends AbstractModelObject implemen
* he wants to ignore.
*/
public boolean isEnabled() {
return !Jenkins.getInstance().disabledAdministrativeMonitors.contains(id);
return !((AbstractCIBase)Jenkins.getInstance()).disabledAdministrativeMonitors.contains(id);
}
/**
......
......@@ -733,7 +733,10 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
executors.remove(e);
addNewExecutorIfNecessary();
if(!isAlive())
Jenkins.getInstance().removeComputer(this);
{
AbstractCIBase ciBase = Jenkins.getInstance();
ciBase.removeComputer(this);
}
}
/**
......
......@@ -43,7 +43,7 @@ import java.util.logging.Logger;
*
* @author Kohsuke Kawaguchi
*/
abstract class FullDuplexHttpChannel {
abstract public class FullDuplexHttpChannel {
private Channel channel;
private InputStream upload;
......
......@@ -159,7 +159,8 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
* such as when this node has no executors at all.
*/
public final Computer toComputer() {
return Jenkins.getInstance().getComputer(this);
AbstractCIBase ciBase = Jenkins.getInstance();
return ciBase.getComputer(this);
}
/**
......
......@@ -48,7 +48,7 @@ public class OverallLoadStatistics extends LoadStatistics {
public final MultiStageTimeSeries totalQueueLength = new MultiStageTimeSeries(
Messages._LoadStatistics_Legends_QueueLength(), ColorPalette.GREY, 0,DECAY);
/*package*/ OverallLoadStatistics() {
public OverallLoadStatistics() {
super(0,0);
}
......
package jenkins.model;
/**
* Access the package protected quiet period
*/
public class JenkinsAdaptor {
public static void setQuietPeriod(Jenkins jenkins, int quietPeriod) {
jenkins.quietPeriod = quietPeriod;
}
}
......@@ -1150,6 +1150,10 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
}
}
protected void setQuietPeriod(int qp) {
JenkinsAdaptor.setQuietPeriod(hudson, qp);
}
/**
* Works like {@link #assertEqualBeans(Object, Object, String)} but figure out the properties
* via {@link DataBoundConstructor}
......
......@@ -44,7 +44,7 @@ public class DependencyGraphTest extends HudsonTestCase {
* Tests triggering downstream projects with DependencyGraph.Dependency
*/
public void testTriggerJob() throws Exception {
hudson.quietPeriod = 3;
setQuietPeriod(3);
Project p = createFreeStyleProject(),
down1 = createFreeStyleProject(), down2 = createFreeStyleProject();
// Add one standard downstream job:
......
......@@ -178,7 +178,7 @@ public class QueueTest extends HudsonTestCase {
final OneShotEvent buildStarted = new OneShotEvent();
final OneShotEvent buildShouldComplete = new OneShotEvent();
hudson.quietPeriod = 0;
setQuietPeriod(0);
FreeStyleProject project = createFreeStyleProject();
// Make build sleep a while so it blocks new builds
project.getBuildersList().add(new TestBuilder() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册