Search in sources :

Example 1 with GitAgentSSHService

use of jetbrains.buildServer.buildTriggers.vcs.git.agent.GitAgentSSHService in project teamcity-git by JetBrains.

the class SSLInvestigatorTest method createFactory.

private GitFactory createFactory() {
    final GitAgentSSHService ssh = myMockery.mock(GitAgentSSHService.class);
    final GitProgressLogger logger = myMockery.mock(GitProgressLogger.class);
    final Context context = myMockery.mock(Context.class);
    myMockery.checking(new Expectations() {

        {
            atLeast(1).of(context).getGitVersion();
            will(returnValue(GitVersion.MIN));
            atLeast(1).of(context).isDeleteTempFiles();
            will(returnValue(false));
            atLeast(1).of(context).getGitExec();
            will(returnValue(new GitExec("git", GitVersion.MIN)));
            atLeast(1).of(context).getCustomConfig();
            will(returnValue(Collections.emptyList()));
            atLeast(1).of(context).getLogger();
            will(returnValue(logger));
            atLeast(1).of(context).getTempDir();
            will(returnValue(myTempDirectory));
            atLeast(1).of(context).getEnv();
            will(returnValue(Collections.emptyMap()));
        }
    });
    return myLoggingFactory.createFactory(ssh, context);
}
Also used : Context(jetbrains.buildServer.buildTriggers.vcs.git.command.Context) Expectations(org.jmock.Expectations) GitAgentSSHService(jetbrains.buildServer.buildTriggers.vcs.git.agent.GitAgentSSHService) GitExec(jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec) GitProgressLogger(jetbrains.buildServer.buildTriggers.vcs.git.GitProgressLogger)

Example 2 with GitAgentSSHService

use of jetbrains.buildServer.buildTriggers.vcs.git.agent.GitAgentSSHService in project teamcity-git by JetBrains.

the class SSHAgentServiceTest method check_classpath_is_correct.

public void check_classpath_is_correct() throws IOException {
    File tempDir = createTempDir();
    Mockery m = new Mockery();
    BuildAgent agent = m.mock(BuildAgent.class);
    BuildAgentConfiguration agentConf = m.mock(BuildAgentConfiguration.class);
    CurrentBuildTracker buildTracker = m.mock(CurrentBuildTracker.class);
    m.checking(new Expectations() {

        {
            allowing(agentConf).getConfigurationParameters();
            will(returnValue(Collections.emptyMap()));
            allowing(agentConf).getTempDirectory();
            will(returnValue(tempDir));
            allowing(buildTracker).getCurrentBuild();
            will(throwException(new NoRunningBuildException()));
        }
    });
    GitAgentSSHService agentSSHService = new GitAgentSSHService(agent, agentConf, new MockGitPluginDescriptor(), new MockVcsRootSshKeyManagerProvider(), buildTracker);
    String scriptPath = agentSSHService.getScriptPath();
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(scriptPath);
    commandLine.addParameter("localhost");
    Map<String, String> env = new HashMap<>();
    env.put(GitSSHHandler.TEAMCITY_DEBUG_SSH, "true");
    commandLine.setEnvParams(env);
    ExecResult res = SimpleCommandLineProcessRunner.runCommand(commandLine, new byte[0]);
    then(res.getStderr()).doesNotContain("NoClassDefFoundError").doesNotContain("ClassNotFoundError");
}
Also used : Expectations(org.jmock.Expectations) GitAgentSSHService(jetbrains.buildServer.buildTriggers.vcs.git.agent.GitAgentSSHService) HashMap(java.util.HashMap) BuildAgent(jetbrains.buildServer.agent.BuildAgent) Mockery(org.jmock.Mockery) NoRunningBuildException(jetbrains.buildServer.agent.NoRunningBuildException) MockVcsRootSshKeyManagerProvider(jetbrains.buildServer.buildTriggers.vcs.git.tests.MockVcsRootSshKeyManagerProvider) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) CurrentBuildTracker(jetbrains.buildServer.agent.CurrentBuildTracker) File(java.io.File) BuildAgentConfiguration(jetbrains.buildServer.agent.BuildAgentConfiguration) MockGitPluginDescriptor(jetbrains.buildServer.buildTriggers.vcs.git.tests.MockGitPluginDescriptor) ExecResult(jetbrains.buildServer.ExecResult)

Aggregations

GitAgentSSHService (jetbrains.buildServer.buildTriggers.vcs.git.agent.GitAgentSSHService)2 Expectations (org.jmock.Expectations)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 File (java.io.File)1 HashMap (java.util.HashMap)1 ExecResult (jetbrains.buildServer.ExecResult)1 BuildAgent (jetbrains.buildServer.agent.BuildAgent)1 BuildAgentConfiguration (jetbrains.buildServer.agent.BuildAgentConfiguration)1 CurrentBuildTracker (jetbrains.buildServer.agent.CurrentBuildTracker)1 NoRunningBuildException (jetbrains.buildServer.agent.NoRunningBuildException)1 GitProgressLogger (jetbrains.buildServer.buildTriggers.vcs.git.GitProgressLogger)1 Context (jetbrains.buildServer.buildTriggers.vcs.git.command.Context)1 GitExec (jetbrains.buildServer.buildTriggers.vcs.git.command.GitExec)1 MockGitPluginDescriptor (jetbrains.buildServer.buildTriggers.vcs.git.tests.MockGitPluginDescriptor)1 MockVcsRootSshKeyManagerProvider (jetbrains.buildServer.buildTriggers.vcs.git.tests.MockVcsRootSshKeyManagerProvider)1 Mockery (org.jmock.Mockery)1