nuget publish runner integration test added
[teamcity/dotNetPackagesSupport.git] / nuget-tests / src / jetbrains / buildServer / nuget / tests / integration / InstallPackageIntegtatoinTest.java
index 32e75a732ece62e2c67d7ce115fbff2c16255381..cc213a86013612c036426c85b94d57641dd4f24b 100644 (file)
 \r
 package jetbrains.buildServer.nuget.tests.integration;\r
 \r
 \r
 package jetbrains.buildServer.nuget.tests.integration;\r
 \r
-import com.intellij.execution.configurations.GeneralCommandLine;\r
-import jetbrains.buildServer.ExecResult;\r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.RunBuildException;\r
-import jetbrains.buildServer.SimpleCommandLineProcessRunner;\r
-import jetbrains.buildServer.agent.*;\r
+import jetbrains.buildServer.agent.BuildFinishedStatus;\r
+import jetbrains.buildServer.agent.BuildProcess;\r
 import jetbrains.buildServer.nuget.agent.commands.impl.CommandFactoryImpl;\r
 import jetbrains.buildServer.nuget.agent.commands.impl.NuGetActionFactoryImpl;\r
 import jetbrains.buildServer.nuget.agent.install.PackageUsages;\r
 import jetbrains.buildServer.nuget.agent.commands.impl.CommandFactoryImpl;\r
 import jetbrains.buildServer.nuget.agent.commands.impl.NuGetActionFactoryImpl;\r
 import jetbrains.buildServer.nuget.agent.install.PackageUsages;\r
@@ -28,22 +26,12 @@ import jetbrains.buildServer.nuget.agent.install.PackagesInstallerRunner;
 import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesCollectorImpl;\r
 import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesConfigParser;\r
 import jetbrains.buildServer.nuget.agent.install.impl.PackageUsagesImpl;\r
 import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesCollectorImpl;\r
 import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesConfigParser;\r
 import jetbrains.buildServer.nuget.agent.install.impl.PackageUsagesImpl;\r
-import jetbrains.buildServer.nuget.agent.parameters.NuGetFetchParameters;\r
-import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
-import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\r
-import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
-import jetbrains.buildServer.nuget.agent.util.BuildProcessBase;\r
-import jetbrains.buildServer.nuget.agent.util.CommandlineBuildProcessFactory;\r
 import jetbrains.buildServer.nuget.common.PackageInfo;\r
 import jetbrains.buildServer.nuget.common.PackagesUpdateMode;\r
 import jetbrains.buildServer.nuget.common.PackageInfo;\r
 import jetbrains.buildServer.nuget.common.PackagesUpdateMode;\r
-import jetbrains.buildServer.nuget.tests.util.BuildProcessTestCase;\r
 import jetbrains.buildServer.util.ArchiveUtil;\r
 import jetbrains.buildServer.util.ArchiveUtil;\r
-import org.jetbrains.annotations.NotNull;\r
 import org.jetbrains.annotations.Nullable;\r
 import org.jmock.Expectations;\r
 import org.jetbrains.annotations.Nullable;\r
 import org.jmock.Expectations;\r
-import org.jmock.Mockery;\r
 import org.testng.Assert;\r
 import org.testng.Assert;\r
-import org.testng.annotations.BeforeMethod;\r
 import org.testng.annotations.Test;\r
 \r
 import java.io.File;\r
 import org.testng.annotations.Test;\r
 \r
 import java.io.File;\r
@@ -53,55 +41,7 @@ import java.util.*;
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 08.07.11 2:15\r
  */\r
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 08.07.11 2:15\r
  */\r
-public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {\r
-  private File myRoot;\r
-  private Mockery m;\r
-  private AgentRunningBuild myBuild;\r
-  private BuildRunnerContext myContext;\r
-  private BuildProgressLogger myLogger;\r
-  private PackagesParametersFactory myParametersFactory;\r
-  private PackagesInstallParameters myInstall;\r
-  private PackagesUpdateParameters myUpdate;\r
-  private NuGetFetchParameters myNuGet;\r
-  private BuildProcess myMockProcess;\r
-\r
-  @BeforeMethod\r
-  @Override\r
-  protected void setUp() throws Exception {\r
-    super.setUp();\r
-    myRoot = createTempDir();\r
-    m = new Mockery();\r
-    myBuild = m.mock(AgentRunningBuild.class);\r
-    myContext = m.mock(BuildRunnerContext.class);\r
-    myLogger = m.mock(BuildProgressLogger.class);\r
-    myParametersFactory = m.mock(PackagesParametersFactory.class);\r
-    myInstall = m.mock(PackagesInstallParameters.class);\r
-    myUpdate = m.mock(PackagesUpdateParameters.class);\r
-    myMockProcess = m.mock(BuildProcess.class);\r
-    myNuGet = m.mock(NuGetFetchParameters.class);\r
-\r
-    m.checking(new Expectations() {{\r
-      allowing(myContext).getBuild();\r
-      will(returnValue(myBuild));\r
-      allowing(myBuild).getBuildLogger();\r
-      will(returnValue(myLogger));\r
-      allowing(myBuild).getCheckoutDirectory();\r
-      will(returnValue(myRoot));\r
-\r
-      allowing(myMockProcess).start();\r
-      allowing(myMockProcess).waitFor();\r
-      will(returnValue(BuildFinishedStatus.FINISHED_SUCCESS));\r
-\r
-      allowing(myLogger).message(with(any(String.class)));\r
-      allowing(myLogger).activityStarted(with(equal("install")), with(any(String.class)), with(any(String.class)));\r
-      allowing(myLogger).activityFinished(with(equal("install")), with(any(String.class)));\r
-\r
-      allowing(myInstall).getNuGetParameters();\r
-      will(returnValue(myNuGet));\r
-      allowing(myUpdate).getNuGetParameters();\r
-      will(returnValue(myNuGet));\r
-    }});\r
-  }\r
+public class InstallPackageIntegtatoinTest extends IntegrationTestBase {\r
 \r
   @Test\r
   public void test_01_online_sources() throws RunBuildException {\r
 \r
   @Test\r
   public void test_01_online_sources() throws RunBuildException {\r
@@ -123,11 +63,6 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
     Assert.assertEquals(4, packageses.size());\r
   }\r
 \r
     Assert.assertEquals(4, packageses.size());\r
   }\r
 \r
-  @NotNull\r
-  private File getTestDataPath(final String path) {\r
-    return Paths.getTestDataPath("integration/" + path);\r
-  }\r
-\r
   @Test\r
   public void test_01_online_sources_update_forConfig() throws RunBuildException {\r
     ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
   @Test\r
   public void test_01_online_sources_update_forConfig() throws RunBuildException {\r
     ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
@@ -295,36 +230,4 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
     m.assertIsSatisfied();\r
   }\r
 \r
     m.assertIsSatisfied();\r
   }\r
 \r
-  private CommandlineBuildProcessFactory executingFactory() {\r
-    return new CommandlineBuildProcessFactory() {\r
-      public BuildProcess executeCommandLine(@NotNull final BuildRunnerContext hostContext,\r
-                                             @NotNull final File program,\r
-                                             @NotNull final Collection<String> argz,\r
-                                             @NotNull final File workingDir) throws RunBuildException {\r
-        return new BuildProcessBase() {\r
-          @NotNull\r
-          @Override\r
-          protected BuildFinishedStatus waitForImpl() throws RunBuildException {\r
-            GeneralCommandLine cmd = new GeneralCommandLine();\r
-            cmd.setExePath(program.getPath());\r
-            for (String arg : argz) {\r
-              cmd.addParameter(arg);\r
-            }\r
-            cmd.setWorkingDirectory(workingDir);\r
-\r
-            System.out.println("Run: " + cmd.getCommandLineString());\r
-\r
-            ExecResult result = SimpleCommandLineProcessRunner.runCommand(cmd, new byte[0]);\r
-\r
-            System.out.println(result.getStdout());\r
-            System.out.println(result.getStderr());\r
-\r
-            return result.getExitCode() == 0\r
-                    ? BuildFinishedStatus.FINISHED_SUCCESS\r
-                    : BuildFinishedStatus.FINISHED_FAILED;\r
-          }\r
-        };\r
-      }\r
-    };\r
-  }\r
 }\r
 }\r