2 * Copyright 2000-2011 JetBrains s.r.o.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package jetbrains.buildServer.nuget.tests.agent;
\r
19 import jetbrains.buildServer.BaseTestCase;
\r
20 import jetbrains.buildServer.nuget.agent.install.PackageInfo;
\r
21 import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesCollectorImpl;
\r
22 import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesConfigParser;
\r
23 import jetbrains.buildServer.nuget.tests.integration.Paths;
\r
24 import org.jetbrains.annotations.NotNull;
\r
25 import org.testng.Assert;
\r
26 import org.testng.annotations.Test;
\r
28 import java.io.IOException;
\r
29 import java.util.Arrays;
\r
30 import java.util.TreeSet;
\r
33 * Created by Eugene Petrenko (eugene.petrenko@gmail.com)
\r
34 * Date: 19.07.11 2:01
\r
36 public class NuGetPackagesConfigParserTest extends BaseTestCase {
\r
39 public void test_01() throws IOException {
\r
40 doTest("test-01.xml", new PackageInfo("elmah", "1.1"));
\r
44 public void test_02() throws IOException {
\r
45 doTest("test-02.xml", new PackageInfo("elmah", "1.1"));
\r
49 public void test_03() throws IOException {
\r
50 doTest("test-03.xml",
\r
51 new PackageInfo("Machine.Specifications", "0.4.13.0"),
\r
52 new PackageInfo("NUnit", "2.5.7.10213")
\r
57 public void test_04() throws IOException {
\r
58 doTest("test-04.xml",
\r
59 new PackageInfo("EasyHttp", "1.0.6"),
\r
60 new PackageInfo("JsonFx", "2.0.1106.2610"),
\r
61 new PackageInfo("structuremap", "2.6.2"));
\r
64 public void doTest(@NotNull String testData,
\r
65 @NotNull PackageInfo... packages) throws IOException {
\r
66 NuGetPackagesConfigParser p = new NuGetPackagesConfigParser();
\r
67 NuGetPackagesCollectorImpl i = new NuGetPackagesCollectorImpl();
\r
68 p.parseNuGetPackages(Paths.getTestDataPath("config/" + testData), i);
\r
70 if (packages.length != i.getPackages().size()) {
\r
71 System.out.println(i.getPackages());
\r
74 Assert.assertEquals(i.getPackages(), new TreeSet<PackageInfo>(Arrays.asList(packages)));
\r