integration tests
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 23 Aug 2011 14:37:36 +0000 (16:37 +0200)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 23 Aug 2011 14:37:36 +0000 (16:37 +0200)
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetPackActionFactoryTest.java [new file with mode: 0644]
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetPushActoinFactoryTest.java
nuget-tests/src/testng-nuget-fast.xml

diff --git a/nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetPackActionFactoryTest.java b/nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetPackActionFactoryTest.java
new file mode 100644 (file)
index 0000000..1aa6235
--- /dev/null
@@ -0,0 +1,199 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.tests.agent;\r
+\r
+import jetbrains.buildServer.BaseTestCase;\r
+import jetbrains.buildServer.RunBuildException;\r
+import jetbrains.buildServer.agent.AgentRunningBuild;\r
+import jetbrains.buildServer.agent.BuildRunnerContext;\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.parameters.NuGetPackParameters;\r
+import jetbrains.buildServer.nuget.agent.util.CommandlineBuildProcessFactory;\r
+import org.jmock.Expectations;\r
+import org.jmock.Mockery;\r
+import org.testng.annotations.BeforeMethod;\r
+import org.testng.annotations.Test;\r
+\r
+import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.Collection;\r
+\r
+/**\r
+ * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ *         Date: 23.08.11 16:23\r
+ */\r
+public class NuGetPackActionFactoryTest extends BaseTestCase {\r
+  private Mockery m;\r
+  private CommandlineBuildProcessFactory myProcessFactory;\r
+  private NuGetActionFactoryImpl i;\r
+  private BuildRunnerContext ctx;\r
+  private AgentRunningBuild build;\r
+  private NuGetPackParameters myPackParameters;\r
+  private File myFile;\r
+  private File myNuGet;\r
+  private File myRoot;\r
+  private File myOut;\r
+  private File myWorkingDir;\r
+  private Collection<String> myExcludes;\r
+  private Collection<String> myProperties;\r
+  private Collection<String> myExtra;\r
+\r
+\r
+  @BeforeMethod\r
+  @Override\r
+  protected void setUp() throws Exception {\r
+    super.setUp();\r
+    m = new Mockery();\r
+    myProcessFactory = m.mock(CommandlineBuildProcessFactory.class);\r
+    PackageUsages pu = m.mock(PackageUsages.class);\r
+    i = new NuGetActionFactoryImpl(myProcessFactory, pu, new CommandFactoryImpl());\r
+    ctx = m.mock(BuildRunnerContext.class);\r
+    myPackParameters = m.mock(NuGetPackParameters.class);\r
+    build = m.mock(AgentRunningBuild.class);\r
+\r
+    myFile = createTempFile();\r
+    myNuGet = createTempFile();\r
+    myRoot = createTempDir();\r
+    myOut = createTempDir();\r
+    myWorkingDir = createTempDir();\r
+\r
+    myExcludes = new ArrayList<String>();\r
+    myProperties = new ArrayList<String>();\r
+    myExtra = new ArrayList<String>();\r
+\r
+    m.checking(new Expectations(){{\r
+      allowing(ctx).getBuild(); will(returnValue(build));\r
+      allowing(build).getCheckoutDirectory(); will(returnValue(myWorkingDir));\r
+      allowing(myPackParameters).getSpecFile(); will(returnValue(myFile));\r
+      allowing(myPackParameters).getNuGetExeFile(); will(returnValue(myNuGet));\r
+      allowing(myPackParameters).getBaseDirectory(); will(returnValue(myRoot));\r
+      allowing(myPackParameters).getOutputDirectory(); will(returnValue(myOut));\r
+      allowing(myPackParameters).getVersion(); will(returnValue("45.239.32.12"));\r
+\r
+      allowing(myPackParameters).getCustomCommandline(); will(returnValue(myExtra));\r
+      allowing(myPackParameters).getProperties(); will(returnValue(myProperties));\r
+      allowing(myPackParameters).getExclude(); will(returnValue(myExcludes));\r
+    }});\r
+  }\r
+\r
+\r
+  @Test\r
+  public void test_package() throws RunBuildException {\r
+    m.checking(new Expectations(){{\r
+      allowing(myPackParameters).packTool(); will(returnValue(false));\r
+      allowing(myPackParameters).packSymbols(); will(returnValue(false));\r
+\r
+      oneOf(myProcessFactory).executeCommandLine(ctx, myNuGet,\r
+              Arrays.asList(\r
+                      "pack", myFile.getPath(), "-OutputDirectory", myOut.getPath(), "-BasePath", myRoot.getPath(), "-Verbose", "-Version", "45.239.32.12")\r
+              , myWorkingDir);\r
+    }});\r
+\r
+    i.createPack(ctx, myPackParameters);\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+  @Test\r
+  public void test_properties() throws RunBuildException {\r
+    myProperties.add("p1=p2");\r
+    myProperties.add("p3=p24");\r
+    m.checking(new Expectations(){{\r
+      allowing(myPackParameters).packTool(); will(returnValue(false));\r
+      allowing(myPackParameters).packSymbols(); will(returnValue(false));\r
+\r
+      oneOf(myProcessFactory).executeCommandLine(ctx, myNuGet,\r
+              Arrays.asList(\r
+                      "pack", myFile.getPath(), "-OutputDirectory", myOut.getPath(), "-BasePath", myRoot.getPath(), "-Verbose", "-Version", "45.239.32.12", "-Properties", "p1=p2", "-Properties", "p3=p24")\r
+              , myWorkingDir);\r
+    }});\r
+\r
+    i.createPack(ctx, myPackParameters);\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+  @Test\r
+  public void test_custom_commandline() throws RunBuildException {\r
+    myExtra.add("arg1");\r
+    myExtra.add("arg2");\r
+    m.checking(new Expectations(){{\r
+      allowing(myPackParameters).packTool(); will(returnValue(false));\r
+      allowing(myPackParameters).packSymbols(); will(returnValue(false));\r
+\r
+      oneOf(myProcessFactory).executeCommandLine(ctx, myNuGet,\r
+              Arrays.asList(\r
+                      "pack", myFile.getPath(), "-OutputDirectory", myOut.getPath(), "-BasePath", myRoot.getPath(), "-Verbose", "-Version", "45.239.32.12", "arg1", "arg2")\r
+              , myWorkingDir);\r
+    }});\r
+\r
+    i.createPack(ctx, myPackParameters);\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+  @Test\r
+  public void test_excludes() throws RunBuildException {\r
+    myExcludes.add("aaa");\r
+    myExcludes.add("d/v/de");\r
+    m.checking(new Expectations(){{\r
+      allowing(myPackParameters).packTool(); will(returnValue(false));\r
+      allowing(myPackParameters).packSymbols(); will(returnValue(false));\r
+\r
+      oneOf(myProcessFactory).executeCommandLine(ctx, myNuGet,\r
+              Arrays.asList(\r
+                      "pack", myFile.getPath(), "-OutputDirectory", myOut.getPath(), "-BasePath", myRoot.getPath(), "-Verbose", "-Version", "45.239.32.12", "-Exclude", "aaa", "-Exclude", "d/v/de")\r
+              , myWorkingDir);\r
+    }});\r
+\r
+    i.createPack(ctx, myPackParameters);\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+  @Test\r
+  public void test_package_tool() throws RunBuildException {\r
+    m.checking(new Expectations(){{\r
+      allowing(myPackParameters).packTool(); will(returnValue(true));\r
+      allowing(myPackParameters).packSymbols(); will(returnValue(false));\r
+\r
+      oneOf(myProcessFactory).executeCommandLine(ctx, myNuGet,\r
+              Arrays.asList(\r
+                      "pack", myFile.getPath(), "-OutputDirectory", myOut.getPath(), "-BasePath", myRoot.getPath(), "-Verbose", "-Version", "45.239.32.12", "-Tool")\r
+              , myWorkingDir);\r
+    }});\r
+\r
+    i.createPack(ctx, myPackParameters);\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+  @Test\r
+  public void test_package_symbols() throws RunBuildException {\r
+    m.checking(new Expectations(){{\r
+      allowing(myPackParameters).packTool(); will(returnValue(false));\r
+      allowing(myPackParameters).packSymbols(); will(returnValue(true));\r
+\r
+      oneOf(myProcessFactory).executeCommandLine(ctx, myNuGet,\r
+              Arrays.asList(\r
+                      "pack", myFile.getPath(), "-OutputDirectory", myOut.getPath(), "-BasePath", myRoot.getPath(), "-Verbose", "-Version", "45.239.32.12", "-Symbols")\r
+              , myWorkingDir);\r
+    }});\r
+\r
+    i.createPack(ctx, myPackParameters);\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+}\r
index 78b3a2c4dd02098cde0c8bf0ba32f13b54f11323..b2c5a33c655294c56b334436fea3a48efd605c30 100644 (file)
@@ -72,6 +72,8 @@ public class NuGetPushActoinFactoryTest extends BaseTestCase {
     }});\r
 \r
     i.createPush(ctx, ps, myFile);\r
+\r
+    m.assertIsSatisfied();\r
   }\r
 \r
   @Test\r
@@ -86,6 +88,8 @@ public class NuGetPushActoinFactoryTest extends BaseTestCase {
     }});\r
 \r
     i.createPush(ctx, ps, myFile);\r
+\r
+    m.assertIsSatisfied();\r
   }\r
 \r
   @Test\r
@@ -100,6 +104,8 @@ public class NuGetPushActoinFactoryTest extends BaseTestCase {
     }});\r
 \r
     i.createPush(ctx, ps, myFile);\r
+\r
+    m.assertIsSatisfied();\r
   }\r
 \r
 }\r
index 22db85a9833e210800c867fca2ebf153b561a6d2..83619a51fe728b6b65997de96d1e0dae1e1f033f 100644 (file)
@@ -31,6 +31,8 @@
 \r
       <class name="jetbrains.buildServer.nuget.tests.server.tools.ToolPackerTest"/>\r
       <class name="jetbrains.buildServer.nuget.tests.server.tools.NuGetToolsInstallerTest"/>\r
+\r
+      <class name="jetbrains.buildServer.nuget.tests.agent.NuGetPackActionFactoryTest"/>\r
     </classes>\r
   </test>\r
 </suite>\r