<bean class="jetbrains.buildServer.nuget.server.install.PackagesInstallerRunType"/>\r
\r
\r
+ <bean class="jetbrains.buildServer.nuget.server.exec.NuGetTeamCityProviderImpl"/>\r
<bean class="jetbrains.buildServer.nuget.server.exec.NuGetExecutorImpl"/>\r
<bean class="jetbrains.buildServer.nuget.server.exec.ListPackagesCommand"/>\r
\r
import com.intellij.openapi.diagnostic.Logger;\r
import jetbrains.buildServer.ExecResult;\r
import jetbrains.buildServer.SimpleCommandLineProcessRunner;\r
-import jetbrains.buildServer.plugins.bean.PluginInfo;\r
import org.jetbrains.annotations.NotNull;\r
\r
import java.io.File;\r
public class NuGetExecutorImpl implements NuGetExecutor {\r
private static final Logger LOG = Logger.getInstance(NuGetExecutorImpl.class.getName());\r
\r
- private final PluginInfo myPluginInfo;\r
+ private final NuGetTeamCityProvider myNuGetTeamCityProvider;\r
\r
- public NuGetExecutorImpl(PluginInfo pluginInfo) {\r
- myPluginInfo = pluginInfo;\r
- }\r
-\r
- @NotNull\r
- private File getNuGetRunnerPath() {\r
- return new File(myPluginInfo.getPluginRoot(), "bin/JetBrains.TeamCity.NuGetRunner.exe");\r
+ public NuGetExecutorImpl(@NotNull final NuGetTeamCityProvider nuGetTeamCityProvider) {\r
+ myNuGetTeamCityProvider = nuGetTeamCityProvider;\r
}\r
\r
@NotNull\r
@NotNull final NuGetOutputProcessor<T> listener) {\r
\r
GeneralCommandLine cmd = new GeneralCommandLine();\r
- cmd.setExePath(getNuGetRunnerPath().getPath());\r
+ cmd.setExePath(myNuGetTeamCityProvider.getNuGetRunnerPath().getPath());\r
cmd.addParameter(nugetExePath.getPath());\r
cmd.addParameters(arguments);\r
\r
--- /dev/null
+/*\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.server.exec;\r
+\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: 14.07.11 18:49\r
+ */\r
+public interface NuGetTeamCityProvider {\r
+ @NotNull\r
+ File getNuGetRunnerPath();\r
+}\r
--- /dev/null
+/*\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.server.exec;\r
+\r
+import jetbrains.buildServer.plugins.bean.PluginInfo;\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: 14.07.11 18:47\r
+ */\r
+public class NuGetTeamCityProviderImpl implements NuGetTeamCityProvider {\r
+ private final PluginInfo myPluginInfo;\r
+\r
+ public NuGetTeamCityProviderImpl(@NotNull final PluginInfo pluginInfo) {\r
+ myPluginInfo = pluginInfo;\r
+ }\r
+\r
+ @NotNull\r
+ public File getNuGetRunnerPath() {\r
+ return new File(myPluginInfo.getPluginRoot(), "bin/JetBrains.TeamCity.NuGetRunner.exe");\r
+ }\r
+\r
+}\r
<orderEntry type="library" name="log4j" level="project" />\r
<orderEntry type="library" scope="RUNTIME" name="TeamCity server runtime" level="project" />\r
<orderEntry type="library" scope="RUNTIME" name="TeamCity agent runtime" level="project" />\r
+ <orderEntry type="library" name="Common-Impl" level="project" />\r
</component>\r
</module>\r
\r
import jetbrains.buildServer.RunBuildException;\r
import jetbrains.buildServer.SimpleCommandLineProcessRunner;\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.install.PackagesInstallerRunner;\r
import jetbrains.buildServer.nuget.agent.install.impl.NuGetActionFactoryImpl;\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.util.BuildProcessBase;\r
import jetbrains.buildServer.nuget.agent.util.CommandlineBuildProcessFactory;\r
import jetbrains.buildServer.nuget.tests.util.BuildProcessTestCase;\r
import jetbrains.buildServer.util.ArchiveUtil;\r
-import jetbrains.buildServer.util.FileUtil;\r
import junit.framework.Assert;\r
import org.jetbrains.annotations.NotNull;\r
import org.jmock.Expectations;\r
\r
@Test\r
public void test_01_online_sources() throws RunBuildException {\r
- ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
+ ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
\r
fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, false);\r
\r
\r
@Test\r
public void test_01_online_sources_update() throws RunBuildException {\r
- ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\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
\r
@Test\r
public void test_01_online_sources_update_safe() throws RunBuildException {\r
- ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\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
\r
@Test\r
public void test_01_online_sources_ecludeVersion() throws RunBuildException {\r
- ArchiveUtil.unpackZip(getTestDataPath("test-01.zip"), "", myRoot);\r
+ ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
\r
fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), true, false);\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
+ ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
File sourcesDir = new File(myRoot, "js");\r
- ArchiveUtil.unpackZip(getTestDataPath("test-01-sources.zip"), "", sourcesDir);\r
+ ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01-sources.zip"), "", sourcesDir);\r
\r
fetchPackages(new File(myRoot, "sln1-lib.sln"), Arrays.asList("file:///" + sourcesDir.getPath()), false, false);\r
\r
allowing(myParametersFactory).loadNuGetParameters(myContext); will(returnValue(myNuGet));\r
allowing(myParametersFactory).loadInstallPackagesParameters(myContext, myNuGet); will(returnValue(myInstall));\r
\r
- allowing(myNuGet).getNuGetExeFile(); will(returnValue(getPathToNuGet()));\r
+ allowing(myNuGet).getNuGetExeFile();\r
+ will(returnValue(Paths.getPathToNuGet()));\r
allowing(myNuGet).getSolutionFile(); will(returnValue(sln));\r
allowing(myNuGet).getNuGetPackageSources(); will(returnValue(sources));\r
allowing(myInstall).getExcludeVersion(); will(returnValue(excludeVersion));\r
m.assertIsSatisfied();\r
}\r
\r
-\r
- @NotNull\r
- private File getTestDataPath() {\r
- return FileUtil.getCanonicalFile(new File("./nuget-tests/testData/integration"));\r
- }\r
-\r
- @NotNull\r
- private File getTestDataPath(@NotNull final String p) {\r
- return FileUtil.getCanonicalFile(new File(getTestDataPath(), p));\r
- }\r
-\r
- @NotNull\r
- private File getPathToNuGet() {\r
- return FileUtil.getCanonicalFile(new File("./nuget-tests/testData/nuget/1.4/NuGet.exe"));\r
- }\r
-\r
private CommandlineBuildProcessFactory executingFactory() {\r
return new CommandlineBuildProcessFactory() {\r
public BuildProcess executeCommandLine(@NotNull final BuildRunnerContext hostContext,\r
--- /dev/null
+/*\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.integration;\r
+\r
+import jetbrains.buildServer.BaseTestCase;\r
+import jetbrains.buildServer.nuget.server.exec.NuGetExecutor;\r
+import jetbrains.buildServer.nuget.server.exec.NuGetExecutorImpl;\r
+import jetbrains.buildServer.nuget.server.exec.NuGetOutputProcessor;\r
+import jetbrains.buildServer.nuget.server.exec.NuGetTeamCityProvider;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jmock.Expectations;\r
+import org.jmock.Mockery;\r
+import org.testng.Assert;\r
+import org.testng.annotations.BeforeMethod;\r
+import org.testng.annotations.Test;\r
+\r
+import java.util.Arrays;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 14.07.11 18:40\r
+ */\r
+public class NuGetExecutorTest extends BaseTestCase {\r
+ private Mockery m;\r
+ private NuGetTeamCityProvider info;\r
+ private NuGetExecutor exec;\r
+\r
+ @BeforeMethod\r
+ @Override\r
+ protected void setUp() throws Exception {\r
+ super.setUp();\r
+ m = new Mockery();\r
+ info = m.mock(NuGetTeamCityProvider.class);\r
+ exec = new NuGetExecutorImpl(info);\r
+\r
+ m.checking(new Expectations(){{\r
+ allowing(info).getNuGetRunnerPath(); will(returnValue(Paths.getNuGetRunnerPath()));\r
+ }});\r
+ }\r
+\r
+ @Test\r
+ public void test_teamcityPing() {\r
+\r
+ int code = exec.executeNuGet(\r
+ Paths.getPathToNuGet(),\r
+ Arrays.asList("TeamCity.Ping"),\r
+ new NuGetOutputProcessor<Integer>() {\r
+ private int myExitCode;\r
+ public void onStdOutput(String text) {\r
+ System.out.println(text);\r
+ }\r
+\r
+ public void onStdError(String text) {\r
+ System.out.println(text);\r
+ }\r
+\r
+ public void onFinished(int exitCode) {\r
+ System.out.println("Exit Code: " + exitCode);\r
+ myExitCode = exitCode;\r
+ }\r
+\r
+ @NotNull\r
+ public Integer getResult() {\r
+ return myExitCode;\r
+ }\r
+ });\r
+\r
+ Assert.assertEquals(code, 0);\r
+ }\r
+}\r
--- /dev/null
+/*\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.integration;\r
+\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: 14.07.11 18:44\r
+ */\r
+public class Paths {\r
+ @NotNull\r
+ public static File getTestDataPath() {\r
+ return FileUtil.getCanonicalFile(new File("./nuget-tests/testData/integration"));\r
+ }\r
+\r
+ @NotNull\r
+ public static File getTestDataPath(@NotNull final String p) {\r
+ return FileUtil.getCanonicalFile(new File(getTestDataPath(), p));\r
+ }\r
+\r
+ @NotNull\r
+ public static File getPathToNuGet() {\r
+ return FileUtil.getCanonicalFile(new File("./nuget-tests/testData/nuget/1.4/NuGet.exe"));\r
+ }\r
+\r
+ @NotNull\r
+ public static File getNuGetRunnerPath() {\r
+ return FileUtil.getCanonicalFile(new File("./nuget-extensions/bin/JetBrains.TeamCity.NuGetRunner.exe"));\r
+ }\r
+\r
+\r
+}\r
<test name="nuget integration test">\r
<classes>\r
<class name="jetbrains.buildServer.nuget.tests.integration.InstallPackageIntegtatoinTest"/>\r
+ <class name="jetbrains.buildServer.nuget.tests.integration.NuGetExecutorTest"/>\r
</classes>\r
</test>\r
</suite>\r