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.server;
\r
19 import jetbrains.buildServer.BaseTestCase;
\r
20 import jetbrains.buildServer.nuget.server.exec.ListPackagesCommandProcessor;
\r
21 import jetbrains.buildServer.nuget.server.exec.PackageInfo;
\r
22 import org.testng.Assert;
\r
23 import org.testng.annotations.BeforeMethod;
\r
24 import org.testng.annotations.Test;
\r
26 import java.util.Collection;
\r
27 import java.util.Iterator;
\r
30 * Created by Eugene Petrenko (eugene.petrenko@gmail.com)
\r
31 * Date: 14.07.11 14:28
\r
33 public class ListPackagesCommandProcessorTest extends BaseTestCase {
\r
34 private ListPackagesCommandProcessor p;
\r
38 protected void setUp() throws Exception {
\r
40 p = new ListPackagesCommandProcessor("source5");
\r
44 public void test_empty() {
\r
45 Assert.assertTrue(p.getResult().isEmpty());
\r
49 public void test_should_throw_on_exit_code() {
\r
52 } catch (RuntimeException e) {
\r
55 Assert.fail("Exception expected");
\r
59 public void test_some_output() {
\r
60 for(int i =0; i <100; i++) {
\r
61 p.onStdError("asdasd");
\r
62 p.onStdOutput("3434");
\r
64 Assert.assertTrue(p.getResult().isEmpty());
\r
68 public void test_parse_service_message() {
\r
69 p.onStdOutput("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");
\r
71 Collection<PackageInfo> result = p.getResult();
\r
72 Assert.assertEquals(result.size(), 1);
\r
73 PackageInfo next = result.iterator().next();
\r
75 Assert.assertEquals(next.getSource(), "source5");
\r
76 Assert.assertEquals(next.getPackageId(), "NUnit");
\r
77 Assert.assertEquals(next.getVersion(), "2.5.10.11092");
\r
81 public void test_parse_service_message_multiple() {
\r
82 p.onStdOutput("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");
\r
83 p.onStdOutput("##teamcity[nuget-package Id='JUnit' Version='1.2.0.92']");
\r
85 Collection<PackageInfo> result = p.getResult();
\r
86 Assert.assertEquals(result.size(), 2);
\r
87 Iterator<PackageInfo> it = result.iterator();
\r
88 PackageInfo next = it.next();
\r
90 Assert.assertEquals(next.getSource(), "source5");
\r
91 Assert.assertEquals(next.getPackageId(), "NUnit");
\r
92 Assert.assertEquals(next.getVersion(), "2.5.10.11092");
\r
95 Assert.assertEquals(next.getSource(), "source5");
\r
96 Assert.assertEquals(next.getPackageId(), "JUnit");
\r
97 Assert.assertEquals(next.getVersion(), "1.2.0.92");
\r