polish and more tests
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Thu, 7 Jul 2011 23:10:03 +0000 (03:10 +0400)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Thu, 7 Jul 2011 23:10:03 +0000 (03:10 +0400)
nuget-tests/src/jetbrains/buildServer/nuget/tests/integration/InstallPackageIntegtatoinTest.java

index 1a7556af5a00a0f8eaf841c5bf911eb20a86d1e6..f6bb819e75118ebceb2dc5316238416955722e5a 100644 (file)
@@ -77,7 +77,8 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
       will(returnValue(myLogger));\r
 \r
       allowing(myMockProcess).start();\r
-      allowing(myMockProcess).waitFor(); will(returnValue(BuildFinishedStatus.FINISHED_SUCCESS));\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
@@ -88,8 +89,36 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
   @Test\r
   public void test_01_online_sources() throws RunBuildException {\r
     ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
-    final File sln = new File(myRoot, "sln1-lib.sln");\r
 \r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList());\r
+\r
+    List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
+    System.out.println("installed packageses = " + packageses);\r
+\r
+    Assert.assertTrue(new File(myRoot, "packages/NUnit.2.5.7.10213").isDirectory());\r
+    Assert.assertTrue(new File(myRoot, "packages/NInject.2.2.1.4").isDirectory());\r
+    Assert.assertTrue(new File(myRoot, "packages/Machine.Specifications.0.4.13.0").isDirectory());\r
+    Assert.assertEquals(4, packageses.size());\r
+  }\r
+\r
+  @Test(enabled = false, dependsOnGroups = "Need to understand how to check NuGet uses only specified sources")\r
+  public void test_01_local_sources() throws RunBuildException {\r
+    ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
+    File sourcesDir = new File(myRoot, "js");\r
+    ArchiveUtil.unpackZip(getTestDataPath("test-01-sources.zip"), "", sourcesDir);\r
+\r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Arrays.asList("file:///" + sourcesDir.getPath()));\r
+\r
+    List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
+    System.out.println("installed packageses = " + packageses);\r
+\r
+    Assert.assertTrue(new File(myRoot, "packages/NUnit.2.5.7.10213").isDirectory());\r
+    Assert.assertTrue(new File(myRoot, "packages/NInject.2.2.1.4").isDirectory());\r
+    Assert.assertTrue(new File(myRoot, "packages/Machine.Specifications.0.4.13.0").isDirectory());\r
+    Assert.assertEquals(4, packageses.size());\r
+  }\r
+\r
+  private void fetchPackages(final File sln, final List<String> sources) throws RunBuildException {\r
     m.checking(new Expectations() {{\r
       allowing(myParametersFactory).loadParameters(myContext);\r
       will(returnValue(myParameters));\r
@@ -99,26 +128,17 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
       allowing(myParameters).getSolutionFile();\r
       will(returnValue(sln));\r
       allowing(myParameters).getNuGetPackageSources();\r
-      will(returnValue(Collections.<String>emptyList()));\r
+      will(returnValue(sources));\r
     }});\r
 \r
     BuildProcess proc = new PackagesInstallerRunner(\r
             new NuGetInstallPackageActionFactoryImpl(executingFactory()),\r
             myParametersFactory\r
-    )\r
-            .createBuildProcess(myBuild, myContext);\r
+    ).createBuildProcess(myBuild, myContext);\r
 \r
     assertRunSuccessfully(proc, BuildFinishedStatus.FINISHED_SUCCESS);\r
 \r
     m.assertIsSatisfied();\r
-\r
-    List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
-    System.out.println("installed packageses = " + packageses);\r
-\r
-    Assert.assertTrue(new File(myRoot, "packages/NUnit.2.5.7.10213").isDirectory());\r
-    Assert.assertTrue(new File(myRoot, "packages/NInject.2.2.1.4").isDirectory());\r
-    Assert.assertTrue(new File(myRoot, "packages/Machine.Specifications.0.4.13.0").isDirectory());\r
-    Assert.assertEquals(4, packageses.size());\r
   }\r
 \r
 \r
@@ -154,6 +174,8 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
             }\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