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

Merged revisions 31912-31913 via svnmerge from

https://svn.dev.java.net/svn/hudson/branches/rc

........
  r31912 | kohsuke | 2010-06-09 22:13:50 -0700 (Wed, 09 Jun 2010) | 1 line
  
  fixed a test failure
........
  r31913 | kohsuke | 2010-06-09 22:41:02 -0700 (Wed, 09 Jun 2010) | 1 line
  
  fill in CLICommand basics
........


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@31914 71c3de6d-444a-0410-be80-ed276b4c234a
上级 902803df
......@@ -30,6 +30,7 @@ import hudson.Util;
import hudson.cli.CLICommand;
import hudson.cli.CloneableCLICommand;
import hudson.model.Hudson;
import hudson.remoting.Channel;
import hudson.security.CliAuthenticator;
import org.acegisecurity.Authentication;
import org.acegisecurity.context.SecurityContext;
......@@ -107,6 +108,11 @@ public class CLIRegisterer extends ExtensionFinder {
@Override
public int main(List<String> args, Locale locale, InputStream stdin, PrintStream stdout, PrintStream stderr) {
this.stdout = stdout;
this.stderr = stderr;
this.locale = locale;
this.channel = Channel.current();
CmdLineParser parser = new CmdLineParser(null);
try {
SecurityContext sc = SecurityContextHolder.getContext();
......
......@@ -23,14 +23,14 @@
*/
package hudson.model.listeners;
import hudson.cli.CreateJobCommand;
import hudson.cli.CLI;
import hudson.model.Item;
import org.jvnet.hudson.test.HudsonTestCase;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Collections;
import java.util.Locale;
import org.jvnet.hudson.test.HudsonTestCase;
import java.util.Arrays;
/**
* Tests for ItemListener events.
......@@ -53,14 +53,13 @@ public class ItemListenerTest extends HudsonTestCase {
ItemListener.all().add(0, listener);
}
public void testOnCreatedviaCLI() {
CreateJobCommand cmd = new CreateJobCommand();
public void testOnCreatedViaCLI() throws Exception {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
PrintStream out = new PrintStream(buf);
cmd.main(Collections.singletonList("testJob"), Locale.ENGLISH,
new CLI(getURL()).execute(Arrays.asList("create-job","testJob"),
new ByteArrayInputStream(("<project><actions/><builders/><publishers/>"
+ "<buildWrappers/></project>").getBytes()),
out, out);
out, out);
out.flush();
assertNotNull("job should be created: " + buf, hudson.getItem("testJob"));
assertEquals("onCreated event should be triggered: " + buf, "C", events.toString());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册