result = 31 * result + myVersion.hashCode();\r
return result;\r
}\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "PackageInfo{" +\r
+ "myId='" + myId + '\'' +\r
+ ", myVersion='" + myVersion + '\'' +\r
+ '}';\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.agent;\r
+\r
+import jetbrains.buildServer.BaseTestCase;\r
+import jetbrains.buildServer.nuget.agent.install.PackageInfo;\r
+import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesCollectorImpl;\r
+import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesConfigParser;\r
+import jetbrains.buildServer.nuget.tests.integration.Paths;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.testng.Assert;\r
+import org.testng.annotations.Test;\r
+\r
+import java.io.IOException;\r
+import java.util.Arrays;\r
+import java.util.TreeSet;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 19.07.11 2:01\r
+ */\r
+public class NuGetPackagesConfigParserTest extends BaseTestCase {\r
+\r
+ @Test\r
+ public void test_01() throws IOException {\r
+ doTest("test-01.xml", new PackageInfo("elmah", "1.1"));\r
+ }\r
+\r
+ @Test\r
+ public void test_02() throws IOException {\r
+ doTest("test-02.xml", new PackageInfo("elmah", "1.1"));\r
+ }\r
+\r
+ @Test\r
+ public void test_03() throws IOException {\r
+ doTest("test-03.xml",\r
+ new PackageInfo("Machine.Specifications", "0.4.13.0"),\r
+ new PackageInfo("NUnit", "2.5.7.10213")\r
+ ) ;\r
+ }\r
+\r
+ @Test\r
+ public void test_04() throws IOException {\r
+ doTest("test-04.xml",\r
+ new PackageInfo("EasyHttp", "1.0.6"),\r
+ new PackageInfo("JsonFx", "2.0.1106.2610"),\r
+ new PackageInfo("structuremap", "2.6.2"));\r
+ }\r
+\r
+ public void doTest(@NotNull String testData,\r
+ @NotNull PackageInfo... packages) throws IOException {\r
+ NuGetPackagesConfigParser p = new NuGetPackagesConfigParser();\r
+ NuGetPackagesCollectorImpl i = new NuGetPackagesCollectorImpl();\r
+ p.parseNuGetPackages(Paths.getTestDataPath("config/" + testData), i);\r
+\r
+ if (packages.length != i.getPackages().size()) {\r
+ System.out.println(i.getPackages());\r
+ }\r
+\r
+ Assert.assertEquals(i.getPackages(), new TreeSet<PackageInfo>(Arrays.asList(packages)));\r
+ }\r
+}\r
\r
@Test\r
public void test_01_online_sources() throws RunBuildException {\r
- ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+ ArchiveUtil.unpackZip(getTestDataPath(), "", myRoot);\r
\r
fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, false);\r
\r
Assert.assertEquals(4, packageses.size());\r
}\r
\r
+ @NotNull\r
+ private File getTestDataPath() {\r
+ return Paths.getTestDataPath("integration/test-01.zip");\r
+ }\r
+\r
@Test\r
public void test_01_online_sources_update() throws RunBuildException {\r
- ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+ ArchiveUtil.unpackZip(getTestDataPath(), "", 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_forSln() throws RunBuildException {\r
- ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+ ArchiveUtil.unpackZip(getTestDataPath(), "", 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(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+ ArchiveUtil.unpackZip(getTestDataPath(), "", 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(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+ ArchiveUtil.unpackZip(getTestDataPath(), "", 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(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+ ArchiveUtil.unpackZip(getTestDataPath(), "", myRoot);\r
File sourcesDir = new File(myRoot, "js");\r
ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01-sources.zip"), "", sourcesDir);\r
\r
public class Paths {\r
@NotNull\r
public static File getTestDataPath() {\r
- return FileUtil.getCanonicalFile(new File("./nuget-tests/testData/integration"));\r
+ return FileUtil.getCanonicalFile(new File("./nuget-tests/testData"));\r
}\r
\r
@NotNull\r
\r
<test name="fast tests">\r
<classes>\r
+ <class name="jetbrains.buildServer.nuget.tests.agent.NuGetPackagesConfigParserTest"/>\r
<class name="jetbrains.buildServer.nuget.tests.agent.LocateNuGetConfigBuildProcessTest"/>\r
<class name="jetbrains.buildServer.nuget.tests.agent.PackagesInstallerBuilderTest"/>\r
<class name="jetbrains.buildServer.nuget.tests.agent.NuGetInstallPackageActionFactoryTest"/>\r
--- /dev/null
+\feff<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+ <package id="elmah" version="1.1" />\r
+</packages>
\ No newline at end of file
--- /dev/null
+\feff<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+ <package id="elmah" version="1.1" allowedVersions="(1.0, 5.5)"/>\r
+</packages>
\ No newline at end of file
--- /dev/null
+\feff<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+ <package id="Machine.Specifications" version="0.4.13.0" />\r
+ <package id="NUnit" version="2.5.7.10213" allowedVersions="[2.5.0, 2.5.111)" />\r
+</packages>
\ No newline at end of file
--- /dev/null
+\feff<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+ <package id="structuremap" version="2.6.2" />\r
+ <package id="JsonFx" version="2.0.1106.2610" />\r
+ <package id="EasyHttp" version="1.0.6" />\r
+</packages>
\ No newline at end of file