提交 7ac155c8 编写于 作者: K kohsuke

Tests the plugin installation.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@22101 71c3de6d-444a-0410-be80-ed276b4c234a
上级 2e68f753
......@@ -66,6 +66,7 @@ import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -212,11 +213,11 @@ public class UpdateCenter extends AbstractModelObject {
rsp.sendRedirect2(".");
}
private void addJob(UpdateCenterJob job) {
private Future<UpdateCenterJob> addJob(UpdateCenterJob job) {
// the first job is always the connectivity check
if(jobs.size()==0)
new ConnectionCheckJob().schedule();
job.schedule();
new ConnectionCheckJob().submit();
return job.submit();
}
/**
......@@ -502,6 +503,14 @@ public class UpdateCenter extends AbstractModelObject {
return true;
}
/**
* @deprecated as of 1.326
* Use {@link #deploy()}.
*/
public void install() {
deploy();
}
/**
* Schedules the installation of this plugin.
*
......@@ -509,9 +518,9 @@ public class UpdateCenter extends AbstractModelObject {
* This is mainly intended to be called from the UI. The actual installation work happens
* asynchronously in another thread.
*/
public void install() {
public Future<UpdateCenterJob> deploy() {
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
addJob(new InstallationJob(this, Hudson.getAuthentication()));
return addJob(new InstallationJob(this, Hudson.getAuthentication()));
}
/**
......@@ -705,10 +714,23 @@ public class UpdateCenter extends AbstractModelObject {
* This object will have the <tt>row.jelly</tt> which renders the job on UI.
*/
public abstract class UpdateCenterJob implements Runnable {
/**
* @deprecated as of 1.326
* Use {@link #submit()} instead.
*/
public void schedule() {
submit();
}
/**
* Schedules this job for an execution
* @return
* {@link Future} to keeps track of the status of the execution.
*/
public Future<UpdateCenterJob> submit() {
LOGGER.fine("Scheduling "+this+" to installerService");
jobs.add(this);
installerService.submit(this);
return installerService.submit(this,this);
}
}
......@@ -926,7 +948,7 @@ public class UpdateCenter extends AbstractModelObject {
@Override
public void _run() throws IOException {
super.run();
super._run();
// if this is a bundled plugin, make sure it won't get overwritten
PluginWrapper pw = plugin.getInstalled();
......
/*
* The MIT License
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model
import org.jvnet.hudson.test.HudsonTestCase
import hudson.model.UpdateCenter.DownloadJob.Success
/**
*
*
* @author Kohsuke Kawaguchi
*/
public class UpdateCenter2Test extends HudsonTestCase {
/**
* Makes sure a plugin installs fine.
*/
void testInstall() {
UpdateCenter.neverUpdate = false;
createWebClient().goTo("/") // load the metadata
def job = hudson.updateCenter.getPlugin("changelog-history").deploy().get(); // this seems like one of the smallest plugin
println job.status;
assertTrue(job.status instanceof Success)
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册