re-implement hide of nuget api key in build logs, add more tests for it
[teamcity/dotNetPackagesSupport.git] / nuget-tests / src / jetbrains / buildServer / nuget / tests / integration / IntegrationTestBase.java
index b0c245221e1ebe39a726d935fd2ef95156065f0d..2d518fbb0c72ff5e9ca4dbf33c0a77fc69220dfc 100644 (file)
@@ -41,6 +41,7 @@ import org.testng.annotations.BeforeMethod;
 \r
 import java.io.File;\r
 import java.util.Collection;\r
+import java.util.Collections;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
@@ -60,6 +61,8 @@ public class IntegrationTestBase extends BuildProcessTestCase {
   protected NuGetPackagesCollector myCollector;\r
   protected NuGetActionFactory myActionFactory;\r
   private BuildProcess myMockProcess;\r
+  protected BuildParametersMap myBuildParametersMap;\r
+  protected String cmd;\r
 \r
   @NotNull\r
   protected String getCommandsOutput() {\r
@@ -79,8 +82,14 @@ public class IntegrationTestBase extends BuildProcessTestCase {
     myParametersFactory = m.mock(PackagesParametersFactory.class);\r
     myMockProcess = m.mock(BuildProcess.class);\r
     myNuGet = m.mock(NuGetFetchParameters.class);\r
+    myBuildParametersMap = m.mock(BuildParametersMap.class);\r
+\r
+    cmd = System.getenv("ComSpec");\r
+\r
+    m.checking(new Expectations(){{\r
+      allowing(myContext).getBuildParameters(); will(returnValue(myBuildParametersMap));\r
+      allowing(myBuildParametersMap).getEnvironmentVariables(); will(returnValue(Collections.singletonMap("ComSpec", cmd)));\r
 \r
-    m.checking(new Expectations() {{\r
       allowing(myContext).getBuild();\r
       will(returnValue(myBuild));\r
       allowing(myBuild).getBuildLogger();\r
@@ -114,7 +123,7 @@ public class IntegrationTestBase extends BuildProcessTestCase {
     return new CommandlineBuildProcessFactory() {\r
       @NotNull\r
       public BuildProcess executeCommandLine(@NotNull final BuildRunnerContext hostContext,\r
-                                             @NotNull final File program,\r
+                                             @NotNull final String program,\r
                                              @NotNull final Collection<String> argz,\r
                                              @NotNull final File workingDir,\r
                                              @NotNull final Map<String, String> additionalEnvironment) throws RunBuildException {\r
@@ -123,9 +132,9 @@ public class IntegrationTestBase extends BuildProcessTestCase {
           @Override\r
           protected BuildFinishedStatus waitForImpl() throws RunBuildException {\r
             GeneralCommandLine cmd = new GeneralCommandLine();\r
-            cmd.setExePath(program.getPath());\r
+            cmd.setExePath(program);\r
             for (String arg : argz) {\r
-              cmd.addParameter(arg);\r
+              cmd.addParameter(arg.replaceAll("%+", "%"));\r
             }\r
             cmd.setWorkingDirectory(workingDir);\r
 \r