agent side support of update per solution command.
authorEugene Petrenko <eugene.petrenko@gmail.com>
Mon, 18 Jul 2011 16:18:24 +0000 (20:18 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Mon, 18 Jul 2011 16:18:24 +0000 (20:18 +0400)
13 files changed:
.idea/misc.xml
nuget-agent/src/META-INF/build-agent-plugin-nuget.xml
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/LocateNuGetConfigBuildProcess.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackagesInstallerBuilder.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackagesInstallerRunner.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/LoggingNuGetActionFactoryImpl.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/parameters/PackagesUpdateParameters.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/parameters/impl/PackagesParametersFactoryImpl.java
nuget-common/nuget-common.iml
nuget-common/src/jetbrains/buildServer/nuget/common/PackagesConstants.java
nuget-common/src/jetbrains/buildServer/nuget/common/PackagesUpdateMode.java [new file with mode: 0644]
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/LocateNuGetConfigBuildProcessTest.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/integration/InstallPackageIntegtatoinTest.java

index 9594b8c3e03cd129e06b2d94be7867fd8c30e850..34bba6bdb9629ac136b97eda48b36da2528a5209 100644 (file)
     <option name="LOCALE" />\r
     <option name="OPEN_IN_BROWSER" value="true" />\r
   </component>\r
-  <component name="NullableNotNullManager">\r
-    <option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />\r
-    <option name="myDefaultNotNull" value="org.jetbrains.annotations.NotNull" />\r
-    <option name="myNullables">\r
-      <value>\r
-        <list size="0" />\r
-      </value>\r
-    </option>\r
-    <option name="myNotNulls">\r
-      <value>\r
-        <list size="3">\r
-          <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />\r
-          <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />\r
-          <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />\r
-        </list>\r
-      </value>\r
-    </option>\r
-  </component>\r
   <component name="ProjectResources">\r
     <default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>\r
   </component>\r
index 2af26e40731ce05a68574b7ee40b6dc570c6b00e..7e157a597ceb4f38bfb7129327b9efdeef6ff675 100644 (file)
   <bean class="jetbrains.buildServer.nuget.agent.install.PackagesInstallerRunner"/>\r
   <bean class="jetbrains.buildServer.nuget.agent.install.PackagesInstallerRunnerRegistrar"/>\r
 \r
-  <bean class="jetbrains.buildServer.nuget.agent.install.impl.NuGetActionFactoryImpl"/>\r
+  <bean class="jetbrains.buildServer.nuget.agent.install.impl.LoggingNuGetActionFactoryImpl">\r
+    <constructor-arg>\r
+      <bean class="jetbrains.buildServer.nuget.agent.install.impl.NuGetActionFactoryImpl"/>\r
+    </constructor-arg>\r
+  </bean>\r
+\r
   <bean class="jetbrains.buildServer.nuget.agent.parameters.impl.PackagesParametersFactoryImpl"/>\r
 </beans>
\ No newline at end of file
index fc52a33e0f1668f166a4c0a614568d9d0b671ee5..a047ce9e20c38f33f642adf9bc1f48214d8c14ee 100644 (file)
@@ -58,8 +58,17 @@ public class LocateNuGetConfigBuildProcess extends BuildProcessBase {
      * Called when packages.config is found\r
      * @param config full path to packages.config file\r
      * @param targetFolder target folder to store packages\r
+     * @throws RunBuildException on erorr\r
      */\r
-    void onPackagesConfigFound(@NotNull final File config, @NotNull final File targetFolder);\r
+    void onPackagesConfigFound(@NotNull final File config, @NotNull final File targetFolder) throws RunBuildException;\r
+\r
+    /**\r
+     * Called when solution file is found\r
+     * @param sln path to sln file\r
+     * @param targetFolder target folder to store packages\r
+     * @throws RunBuildException on error\r
+     */\r
+    void onSolutionFileFound(@NotNull final File sln, @NotNull final File targetFolder) throws RunBuildException;\r
   }\r
 \r
   @NotNull\r
@@ -69,6 +78,11 @@ public class LocateNuGetConfigBuildProcess extends BuildProcessBase {
     final File packages = new File(sln.getParentFile(), "packages");\r
     final File repositoriesConfig = new File(packages, "repositories.config");\r
 \r
+    if (sln.isFile()) {\r
+      LOG.debug("Found Visual Studio .sln file: " + sln);\r
+      myCallback.onSolutionFileFound(sln, packages);\r
+    }\r
+\r
     LOG.debug("resources.config path is " + repositoriesConfig);\r
 \r
     if (!repositoriesConfig.isFile()) {\r
index e8a75840c1d398db7fbbc6523971e54c5ea57872..856da9050dbfc34dffc90864ab3ea85a6fec02e4 100644 (file)
 package jetbrains.buildServer.nuget.agent.install;\r
 \r
 import jetbrains.buildServer.RunBuildException;\r
-import jetbrains.buildServer.agent.BuildProcess;\r
-import jetbrains.buildServer.agent.BuildProgressLogger;\r
 import jetbrains.buildServer.agent.BuildRunnerContext;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
 import jetbrains.buildServer.nuget.agent.util.BuildProcessContinuation;\r
-import jetbrains.buildServer.nuget.agent.util.DelegatingBuildProcess;\r
-import jetbrains.buildServer.util.FileUtil;\r
+import jetbrains.buildServer.nuget.common.PackagesUpdateMode;\r
 import org.jetbrains.annotations.NotNull;\r
 import org.jetbrains.annotations.Nullable;\r
 \r
 import java.io.File;\r
 \r
+import static jetbrains.buildServer.nuget.common.PackagesUpdateMode.FOR_EACH_PACKAGES_CONFIG;\r
+\r
 /**\r
-* Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
-* Date: 11.07.11 14:57\r
-*/\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 11.07.11 14:57\r
+ */\r
 public class PackagesInstallerBuilder implements LocateNuGetConfigBuildProcess.Callback {\r
   private final NuGetActionFactory myActionFactory;\r
   private final BuildProcessContinuation myInstall;\r
@@ -60,62 +59,46 @@ public class PackagesInstallerBuilder implements LocateNuGetConfigBuildProcess.C
     myActionFactory = actionFactory;\r
   }\r
 \r
-  public final void onPackagesConfigFound(@NotNull final File config, @NotNull final File targetFolder) {\r
-    myInstall.pushBuildProcess(createInstallAction(config, targetFolder));\r
-\r
+  public void onSolutionFileFound(@NotNull File sln, @NotNull File targetFolder) throws RunBuildException {\r
     if (myUpdateParameters == null) return;\r
-    myUpdate.pushBuildProcess(createUpdateAction(config, targetFolder));\r
-    myPostUpdate.pushBuildProcess(createInstallAction(config, targetFolder));\r
-  }\r
-\r
-  private DelegatingBuildProcess createUpdateAction(final File config, final File targetFolder) {\r
-    return new DelegatingBuildProcess(\r
-            new DelegatingBuildProcess.Action() {\r
-              private final BuildProgressLogger logger = myContext.getBuild().getBuildLogger();\r
-\r
-              @NotNull\r
-              public BuildProcess startImpl() throws RunBuildException {\r
-                String pathToLog = FileUtil.getRelativePath(myContext.getBuild().getCheckoutDirectory(), config);\r
-                if (pathToLog == null) pathToLog = config.getPath();\r
-                logger.activityStarted("update", "Updating NuGet packages for " + pathToLog, "nuget");\r
-\r
-                return myActionFactory.createUpdate(myContext,\r
-                        myUpdateParameters,\r
-                        config,\r
-                        targetFolder)\r
-                        ;\r
-              }\r
-\r
-              public void finishedImpl() {\r
-                logger.activityFinished("update", "nuget");\r
-              }\r
-            }\r
+    if (myUpdateParameters.getUpdateMode() != PackagesUpdateMode.FOR_SLN) return;\r
+\r
+    myUpdate.pushBuildProcess(\r
+            myActionFactory.createUpdate(\r
+                    myContext,\r
+                    myUpdateParameters,\r
+                    sln,\r
+                    targetFolder\r
+            )\r
     );\r
   }\r
 \r
-  private DelegatingBuildProcess createInstallAction(final File config, final File targetFolder) {\r
-    return new DelegatingBuildProcess(\r
-            new DelegatingBuildProcess.Action() {\r
-              private final BuildProgressLogger logger = myContext.getBuild().getBuildLogger();\r
-\r
-              @NotNull\r
-              public BuildProcess startImpl() throws RunBuildException {\r
-                String pathToLog = FileUtil.getRelativePath(myContext.getBuild().getCheckoutDirectory(), config);\r
-                if (pathToLog == null) pathToLog = config.getPath();\r
-                logger.activityStarted("install", "Installing NuGet packages for " + pathToLog, "nuget");\r
-\r
+  public final void onPackagesConfigFound(@NotNull final File config, @NotNull final File targetFolder) throws RunBuildException {\r
+    myInstall.pushBuildProcess(myActionFactory.createInstall(myContext,\r
+            myInstallParameters,\r
+            config,\r
+            targetFolder));\r
 \r
-                return myActionFactory.createInstall(myContext,\r
-                        myInstallParameters,\r
-                        config,\r
-                        targetFolder)\r
-                        ;\r
-              }\r
-\r
-              public void finishedImpl() {\r
-                logger.activityFinished("install", "nuget");\r
-              }\r
-            }\r
+    if (myUpdateParameters == null) return;\r
+    if (myUpdateParameters.getUpdateMode() == FOR_EACH_PACKAGES_CONFIG) {\r
+      myUpdate.pushBuildProcess(\r
+              myActionFactory.createUpdate(\r
+                      myContext,\r
+                      myUpdateParameters,\r
+                      config,\r
+                      targetFolder\r
+              )\r
+      );\r
+    }\r
+\r
+    myPostUpdate.pushBuildProcess(\r
+            myActionFactory.createInstall(\r
+                    myContext,\r
+                    myInstallParameters,\r
+                    config,\r
+                    targetFolder\r
+            )\r
     );\r
   }\r
+\r
 }\r
index 37bfffa0c75bfead9961fc2015ed668af12fc51a..8db97682d4116728d457632b0ae9825b402d3760 100644 (file)
@@ -20,8 +20,8 @@ import com.intellij.openapi.diagnostic.Logger;
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.agent.*;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\r
-import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\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.CompositeBuildProcess;\r
 import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/LoggingNuGetActionFactoryImpl.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/LoggingNuGetActionFactoryImpl.java
new file mode 100644 (file)
index 0000000..d35f855
--- /dev/null
@@ -0,0 +1,104 @@
+/*\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.agent.install.impl;\r
+\r
+import jetbrains.buildServer.RunBuildException;\r
+import jetbrains.buildServer.agent.BuildProcess;\r
+import jetbrains.buildServer.agent.BuildProgressLogger;\r
+import jetbrains.buildServer.agent.BuildRunnerContext;\r
+import jetbrains.buildServer.nuget.agent.install.NuGetActionFactory;\r
+import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
+import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
+import jetbrains.buildServer.nuget.agent.util.DelegatingBuildProcess;\r
+import jetbrains.buildServer.util.FileUtil;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.File;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 19:57\r
+ */\r
+public class LoggingNuGetActionFactoryImpl implements NuGetActionFactory {\r
+  private NuGetActionFactory myActionFactory;\r
+\r
+  public LoggingNuGetActionFactoryImpl(@NotNull final NuGetActionFactory actionFactory) {\r
+    myActionFactory = actionFactory;\r
+  }\r
+\r
+  @NotNull\r
+  public BuildProcess createInstall(@NotNull final BuildRunnerContext context,\r
+                                    @NotNull final PackagesInstallParameters params,\r
+                                    @NotNull final File config,\r
+                                    @NotNull final File targetFolder) {\r
+    return new DelegatingBuildProcess(\r
+            new DelegatingBuildProcess.Action() {\r
+              private final BuildProgressLogger logger = context.getBuild().getBuildLogger();\r
+\r
+              @NotNull\r
+              public BuildProcess startImpl() throws RunBuildException {\r
+                String pathToLog = FileUtil.getRelativePath(context.getBuild().getCheckoutDirectory(), config);\r
+                if (pathToLog == null) pathToLog = config.getPath();\r
+                logger.activityStarted("install", "Installing NuGet packages for " + pathToLog, "nuget");\r
+\r
+\r
+                return myActionFactory.createInstall(\r
+                        context,\r
+                        params,\r
+                        config,\r
+                        targetFolder)\r
+                        ;\r
+              }\r
+\r
+              public void finishedImpl() {\r
+                logger.activityFinished("install", "nuget");\r
+              }\r
+            }\r
+    );\r
+  }\r
+\r
+  @NotNull\r
+  public BuildProcess createUpdate(@NotNull final BuildRunnerContext context,\r
+                                   @NotNull final PackagesUpdateParameters params,\r
+                                   @NotNull final File config,\r
+                                   @NotNull final File targetFolder) {\r
+    return new DelegatingBuildProcess(\r
+            new DelegatingBuildProcess.Action() {\r
+              private final BuildProgressLogger logger = context.getBuild().getBuildLogger();\r
+\r
+              @NotNull\r
+              public BuildProcess startImpl() throws RunBuildException {\r
+                String pathToLog = FileUtil.getRelativePath(context.getBuild().getCheckoutDirectory(), config);\r
+                if (pathToLog == null) pathToLog = config.getPath();\r
+                logger.activityStarted("update", "Updating NuGet packages for " + pathToLog, "nuget");\r
+\r
+                return myActionFactory.createUpdate(\r
+                        context,\r
+                        params,\r
+                        config,\r
+                        targetFolder)\r
+                        ;\r
+              }\r
+\r
+              public void finishedImpl() {\r
+                logger.activityFinished("update", "nuget");\r
+              }\r
+            }\r
+    );\r
+  }\r
+\r
+}\r
index c016b6f5a8004ecb29beffacfc8ed64d414afb3b..e4e410865bba83314c57822cbec97a6f00fe428b 100644 (file)
@@ -16,6 +16,7 @@
 \r
 package jetbrains.buildServer.nuget.agent.parameters;\r
 \r
+import jetbrains.buildServer.nuget.common.PackagesUpdateMode;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
 import java.util.Collection;\r
@@ -25,7 +26,14 @@ import java.util.Collection;
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 10.07.11 14:02\r
  */\r
-public interface PackagesUpdateParameters extends NuGetParametersHolder{\r
+public interface PackagesUpdateParameters extends NuGetParametersHolder {\r
+\r
+  /**\r
+   * @return the way packages are updated\r
+   */\r
+  @NotNull\r
+  PackagesUpdateMode getUpdateMode();\r
+\r
   /**\r
    * @return true if update should be performed\r
    *         with -Safe argument\r
index aeb8ea747fdafb0c66ef37b4972e856173b48b76..25290c07ab8e71ebda7307804af803c086c4bafe 100644 (file)
@@ -18,10 +18,8 @@ package jetbrains.buildServer.nuget.agent.parameters.impl;
 \r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.agent.BuildRunnerContext;\r
-import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\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.parameters.*;\r
+import jetbrains.buildServer.nuget.common.PackagesUpdateMode;\r
 import jetbrains.buildServer.util.FileUtil;\r
 import jetbrains.buildServer.util.StringUtil;\r
 import org.jetbrains.annotations.NotNull;\r
@@ -126,6 +124,12 @@ public class PackagesParametersFactoryImpl implements PackagesParametersFactory
         return nuget;\r
       }\r
 \r
+      @NotNull\r
+      public PackagesUpdateMode getUpdateMode() {\r
+        PackagesUpdateMode mode = PackagesUpdateMode.parse(getParameter(context, NUGET_UPDATE_MODE));\r
+        return mode == null ? PackagesUpdateMode.FOR_SLN : mode;\r
+      }\r
+\r
       public boolean getUseSafeUpdate() {\r
         return getBoolean(context, NUGET_UPDATE_PACKAGES_SAFE);\r
       }\r
index bcd297458cfd2463bfa6317f75a64066359bd48d..b2eeaf1bc3750f59dcf7854214ed64a431a826c9 100644 (file)
@@ -7,6 +7,7 @@
     </content>\r
     <orderEntry type="inheritedJdk" />\r
     <orderEntry type="sourceFolder" forTests="false" />\r
+    <orderEntry type="library" name="idea annotations.jar" level="project" />\r
   </component>\r
 </module>\r
 \r
index 912b72d1f9ad8e699736e24e41fc0216a94c6d26..404819d6d2e80f553aa7e6740a16d7b357c45604 100644 (file)
@@ -31,6 +31,7 @@ public interface PackagesConstants {
   public static final String NUGET_UPDATE_PACKAGES = "nuget.updatePackages";\r
   public static final String NUGET_UPDATE_PACKAGES_SAFE = "nuget.updatePackages.safe";\r
   public static final String NUGET_UPDATE_PACKAGE_IDS = "nuget.updatePackages.ids";\r
+  public static final String NUGET_UPDATE_MODE = "nuget.updatePackages.mode";\r
 \r
   public static final String SLN_PATH = "sln.path";\r
 }\r
diff --git a/nuget-common/src/jetbrains/buildServer/nuget/common/PackagesUpdateMode.java b/nuget-common/src/jetbrains/buildServer/nuget/common/PackagesUpdateMode.java
new file mode 100644 (file)
index 0000000..72fee0a
--- /dev/null
@@ -0,0 +1,61 @@
+/*\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.common;\r
+\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 19:49\r
+ */\r
+public enum PackagesUpdateMode {\r
+  /**\r
+   * This method calls one NuGet command to update all packages\r
+   */\r
+  FOR_SLN("sln"),\r
+\r
+  /**\r
+   * This methos must call a NuGet udpate command per packages.config\r
+   */\r
+  FOR_EACH_PACKAGES_CONFIG("perConfig"),\r
+  ;\r
+  private final String myName;\r
+\r
+  PackagesUpdateMode(@NotNull final String name) {\r
+    myName = name;\r
+  }\r
+\r
+  @NotNull\r
+  public String getName() {\r
+    return myName;\r
+  }\r
+\r
+\r
+  @Override\r
+  public String toString() {\r
+    return myName;\r
+  }\r
+\r
+  @Nullable\r
+  public static PackagesUpdateMode parse(@Nullable String text) {\r
+    for (PackagesUpdateMode mode : values()) {\r
+      if (mode.getName().equals(text)) return mode;\r
+    }\r
+    return null;\r
+  }\r
+}\r
index 91aed588c78bcf7c09a3199796cfd7e31af40a2d..a0ed14cc6eebe29d277094a5d5925aa3b80c79fb 100644 (file)
@@ -73,6 +73,8 @@ public class LocateNuGetConfigBuildProcessTest extends BuildProcessTestCase {
     m.checking(new Expectations() {{\r
       allowing(ps).getSolutionFile();\r
       will(returnValue(sln));\r
+\r
+      oneOf(cb).onSolutionFileFound(sln, new File(sln.getParentFile(), "packages"));\r
     }});\r
 \r
     assertRunException(proc, "Failed to find repositories.config");\r
@@ -82,13 +84,15 @@ public class LocateNuGetConfigBuildProcessTest extends BuildProcessTestCase {
   @Test\r
   public void test_solutionFile_packages_empty() throws RunBuildException {\r
     final File sln = new File(myRoot, "foo.sln");\r
-    final File packages = new File(sln, "../packages");\r
+    final File packages = new File(sln.getParentFile(), "packages");\r
     packages.mkdirs();\r
 \r
     FileUtil.writeFile(sln, "Fake solution file");\r
     m.checking(new Expectations() {{\r
       allowing(ps).getSolutionFile();\r
       will(returnValue(sln));\r
+\r
+      oneOf(cb).onSolutionFileFound(sln, packages);\r
     }});\r
 \r
     assertRunException(proc, "Failed to find repositories.config");\r
@@ -109,6 +113,8 @@ public class LocateNuGetConfigBuildProcessTest extends BuildProcessTestCase {
       allowing(ps).getSolutionFile();\r
       will(returnValue(sln));\r
 \r
+      oneOf(cb).onSolutionFileFound(sln, packages);\r
+\r
       allowing(log).message(with(new StartsWithMatcher("Found packages folder: ")));\r
       allowing(log).message(with(new StartsWithMatcher("Found list of packages.config files: ")));\r
       allowing(log).warning(with(new StartsWithMatcher("No packages.config files were found under solution.")));\r
@@ -131,6 +137,8 @@ public class LocateNuGetConfigBuildProcessTest extends BuildProcessTestCase {
       allowing(ps).getSolutionFile();\r
       will(returnValue(sln));\r
 \r
+      oneOf(cb).onSolutionFileFound(sln, packages);\r
+\r
       allowing(log).message(with(new StartsWithMatcher("Found packages folder: ")));\r
       allowing(log).message(with(new StartsWithMatcher("Found list of packages.config files: ")));\r
       allowing(log).warning(with(new StartsWithMatcher("No packages.config files were found under solution.")));\r
@@ -159,6 +167,7 @@ public class LocateNuGetConfigBuildProcessTest extends BuildProcessTestCase {
       allowing(ps).getSolutionFile();\r
       will(returnValue(sln));\r
 \r
+      oneOf(cb).onSolutionFileFound(sln, packages);\r
       oneOf(cb).onPackagesConfigFound(new File(myRoot, "Mvc/packages.config"), packages);\r
       oneOf(cb).onPackagesConfigFound(new File("c:\\Mvc2/packages.config"), packages);\r
 \r
index baaa43122b51cf4c8d2ebc7f4aa81281fee54e0e..489a5a45b65c479dd4dd4d288a25569ff5adcfcb 100644 (file)
@@ -29,6 +29,7 @@ import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;
 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.PackagesUpdateMode;\r
 import jetbrains.buildServer.nuget.tests.util.BuildProcessTestCase;\r
 import jetbrains.buildServer.util.ArchiveUtil;\r
 import junit.framework.Assert;\r
@@ -117,6 +118,33 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
 \r
       allowing(myUpdate).getUseSafeUpdate(); will(returnValue(false));\r
       allowing(myUpdate).getPackagesToUpdate(); will(returnValue(Collections.<String>emptyList()));\r
+      allowing(myUpdate).getUpdateMode(); will(returnValue(PackagesUpdateMode.FOR_EACH_PACKAGES_CONFIG));\r
+    }});\r
+\r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true);\r
+\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/NUnit.2.5.10.11092").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(5, packageses.size());\r
+  }\r
+\r
+  @Test\r
+  public void test_01_online_sources_update_forSln() throws RunBuildException {\r
+    ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+\r
+    m.checking(new Expectations(){{\r
+      allowing(myLogger).activityStarted(with(equal("update")), with(any(String.class)), with(equal("nuget")));\r
+      allowing(myLogger).activityFinished(with(equal("update")), with(equal("nuget")));\r
+\r
+      allowing(myUpdate).getUseSafeUpdate(); will(returnValue(false));\r
+      allowing(myUpdate).getPackagesToUpdate(); will(returnValue(Collections.<String>emptyList()));\r
+      allowing(myUpdate).getUpdateMode(); will(returnValue(PackagesUpdateMode.FOR_SLN));\r
     }});\r
 \r
     fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true);\r
@@ -142,6 +170,7 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
 \r
       allowing(myUpdate).getUseSafeUpdate(); will(returnValue(true));\r
       allowing(myUpdate).getPackagesToUpdate(); will(returnValue(Collections.<String>emptyList()));\r
+      allowing(myUpdate).getUpdateMode(); will(returnValue(PackagesUpdateMode.FOR_EACH_PACKAGES_CONFIG));\r
     }});\r
 \r
     fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true);\r