| 1 |
/* |
| 2 |
* Copyright 2012 Ludovic Claude. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package org.debian.maven.packager.util; |
| 18 |
|
| 19 |
import static org.junit.Assert.assertEquals; |
| 20 |
|
| 21 |
import java.util.ArrayList; |
| 22 |
import java.util.List; |
| 23 |
|
| 24 |
import org.junit.Test; |
| 25 |
|
| 26 |
public class GetPackageVersionResultTest { |
| 27 |
|
| 28 |
private GetPackageVersionResult result = new GetPackageVersionResult(); |
| 29 |
|
| 30 |
@Test |
| 31 |
public void testFilterDpkgOutput() throws Exception { |
| 32 |
//dpkg --status libjavacc-maven-plugin-java |
| 33 |
List<String> dpkgOut = new ArrayList<String>(); |
| 34 |
dpkgOut.add("Package: libjavacc-maven-plugin-java"); |
| 35 |
dpkgOut.add("Status: install ok installed"); |
| 36 |
dpkgOut.add("Priority: optional"); |
| 37 |
dpkgOut.add("Section: java"); |
| 38 |
dpkgOut.add("Installed-Size: 144"); |
| 39 |
dpkgOut.add("Maintainer: Ubuntu Developers <[email protected]>"); |
| 40 |
dpkgOut.add("Architecture: all"); |
| 41 |
dpkgOut.add("Source: javacc-maven-plugin"); |
| 42 |
dpkgOut.add("Version: 2.6-1"); |
| 43 |
dpkgOut.add("Depends: javacc, jtb, libdoxia-java, libdoxia-sitetools-java, libmaven-reporting-impl-java, libmaven2-core-java, libplexus-utils-java"); |
| 44 |
dpkgOut.add("Description: maven plugin which uses JavaCC to process JavaCC grammar files"); |
| 45 |
|
| 46 |
for (String line : dpkgOut) { |
| 47 |
result.newLine(line); |
| 48 |
} |
| 49 |
assertEquals("2.6", result.getResult()); |
| 50 |
} |
| 51 |
|
| 52 |
@Test |
| 53 |
public void testFilterAptFileOutput() throws Exception { |
| 54 |
// apt-get --no-act --verbose-versions install libmaven-war-plugin-java |
| 55 |
List<String> dpkgOut = new ArrayList<String>(); |
| 56 |
dpkgOut.add("NOTE: Ceci n'est qu'une simulation !"); |
| 57 |
dpkgOut.add(" apt-get a besoin des privilèges du superutilisateur"); |
| 58 |
dpkgOut.add(" pour pouvoir vraiment fonctionner."); |
| 59 |
dpkgOut.add(" Veuillez aussi noter que le verrouillage est désactivé,"); |
| 60 |
dpkgOut.add(" et la situation n'est donc pas forcément représentative"); |
| 61 |
dpkgOut.add(" de la réalité !"); |
| 62 |
dpkgOut.add("Lecture des listes de paquets... Fait"); |
| 63 |
dpkgOut.add("Construction de l'arbre des dépendances"); |
| 64 |
dpkgOut.add("Lecture des informations d'état... Fait"); |
| 65 |
dpkgOut.add("Les NOUVEAUX paquets suivants seront installés :"); |
| 66 |
dpkgOut.add(" libmaven-war-plugin-java (2.1~beta1-1build1)"); |
| 67 |
dpkgOut.add("0 mis à jour, 1 nouvellement installés, 0 à enlever et 7 non mis à jour."); |
| 68 |
dpkgOut.add("Inst libmaven-war-plugin-java (2.1~beta1-1build1 Ubuntu:11.10/oneiric [all])"); |
| 69 |
dpkgOut.add("Conf libmaven-war-plugin-java (2.1~beta1-1build1 Ubuntu:11.10/oneiric [all])"); |
| 70 |
|
| 71 |
for (String line : dpkgOut) { |
| 72 |
result.newLine(line); |
| 73 |
} |
| 74 |
assertEquals("2.1-beta1", result.getResult()); |
| 75 |
} |
| 76 |
|
| 77 |
} |