/******************************************************************************* * * Copyright (c) 2004-2009 Oracle Corporation. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * * Kohsuke Kawaguchi, Steven Christou * * *******************************************************************************/ package org.jvnet.hudson.test; import hudson.Launcher; import hudson.Extension; import hudson.model.AbstractBuild; import hudson.model.BuildListener; import hudson.model.Descriptor; import hudson.tasks.Builder; import java.io.IOException; import org.kohsuke.stapler.DataBoundConstructor; /** * {@link Builder} that just sleeps for the specified amount of milli-seconds. * * @author Kohsuke Kawaguchi */ public class SleepBuilder extends Builder { public final long time; @DataBoundConstructor public SleepBuilder(long time) { this.time = time; } public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { listener.getLogger().println("Sleeping " + time + "ms"); Thread.sleep(time); return true; } @Extension public static final class DescriptorImpl extends Descriptor<Builder> { public String getDisplayName() { return "Sleep"; } } }