rt/mojo/src/test/java/org/apidesign/bck2brwsr/mojo/ArchetypeVersionTest.java
branchelements
changeset 1072 3800d11c0bdb
parent 913 146ae7b52b64
parent 1071 2894b9a9dbfc
child 1073 9321b4016d5c
     1.1 --- a/rt/mojo/src/test/java/org/apidesign/bck2brwsr/mojo/ArchetypeVersionTest.java	Tue Apr 02 15:40:51 2013 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,102 +0,0 @@
     1.4 -/**
     1.5 - * Back 2 Browser Bytecode Translator
     1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.7 - *
     1.8 - * This program is free software: you can redistribute it and/or modify
     1.9 - * it under the terms of the GNU General Public License as published by
    1.10 - * the Free Software Foundation, version 2 of the License.
    1.11 - *
    1.12 - * This program is distributed in the hope that it will be useful,
    1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 - * GNU General Public License for more details.
    1.16 - *
    1.17 - * You should have received a copy of the GNU General Public License
    1.18 - * along with this program. Look for COPYING file in the top folder.
    1.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    1.20 - */
    1.21 -package org.apidesign.bck2brwsr.mojo;
    1.22 -
    1.23 -import java.net.URL;
    1.24 -import javax.xml.XMLConstants;
    1.25 -import javax.xml.parsers.DocumentBuilderFactory;
    1.26 -import javax.xml.xpath.XPathConstants;
    1.27 -import javax.xml.xpath.XPathExpression;
    1.28 -import javax.xml.xpath.XPathFactory;
    1.29 -import org.testng.annotations.Test;
    1.30 -import org.xml.sax.InputSource;
    1.31 -import static org.testng.Assert.*;
    1.32 -import org.testng.annotations.BeforeClass;
    1.33 -import org.w3c.dom.Document;
    1.34 -import org.w3c.dom.NodeList;
    1.35 -
    1.36 -/**
    1.37 - *
    1.38 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.39 - */
    1.40 -public class ArchetypeVersionTest {
    1.41 -    private String version;
    1.42 -    
    1.43 -    public ArchetypeVersionTest() {
    1.44 -    }
    1.45 -    
    1.46 -    @BeforeClass public void readCurrentVersion() throws Exception {
    1.47 -        final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
    1.48 -        URL u = l.getResource("META-INF/maven/org.apidesign.bck2brwsr/mojo/plugin-help.xml");
    1.49 -        assertNotNull(u, "Own pom found");
    1.50 -
    1.51 -        final XPathFactory fact = XPathFactory.newInstance();
    1.52 -        fact.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    1.53 -
    1.54 -        XPathExpression xp = fact.newXPath().compile("plugin/version/text()");
    1.55 -        version = xp.evaluate(new InputSource(u.openStream()));
    1.56 -
    1.57 -        assertFalse(version.isEmpty(), "There should be some version string");
    1.58 -    }
    1.59 -    
    1.60 -
    1.61 -    @Test public void testComparePomDepsVersions() throws Exception {
    1.62 -        final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
    1.63 -        URL r = l.getResource("archetype-resources/pom.xml");
    1.64 -        assertNotNull(r, "Archetype pom found");
    1.65 -        
    1.66 -        final XPathFactory fact = XPathFactory.newInstance();
    1.67 -        XPathExpression xp2 = fact.newXPath().compile(
    1.68 -            "//version[../groupId/text() = 'org.apidesign.bck2brwsr']/text()"
    1.69 -        );
    1.70 -        
    1.71 -        Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
    1.72 -        NodeList arch = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
    1.73 -
    1.74 -        if (arch.getLength() < 3) {
    1.75 -            fail("There should be at least three dependencies to bck2brwsr APIs: " + arch.getLength());
    1.76 -        }
    1.77 -        
    1.78 -        for (int i = 0; i < arch.getLength(); i++) {
    1.79 -            assertEquals(arch.item(i).getTextContent(), version, i + "th dependency needs to be on latest version of bck2brwsr");
    1.80 -        }
    1.81 -    }
    1.82 -    
    1.83 -    @Test public void testNbActions() throws Exception {
    1.84 -        final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
    1.85 -        URL r = l.getResource("archetype-resources/nbactions.xml");
    1.86 -        assertNotNull(r, "Archetype nb file found");
    1.87 -        
    1.88 -        final XPathFactory fact = XPathFactory.newInstance();
    1.89 -        XPathExpression xp2 = fact.newXPath().compile(
    1.90 -            "//goal/text()"
    1.91 -        );
    1.92 -        
    1.93 -        Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
    1.94 -        NodeList goals = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
    1.95 -        
    1.96 -        for (int i = 0; i < goals.getLength(); i++) {
    1.97 -            String s = goals.item(i).getTextContent();
    1.98 -            if (s.contains("bck2brwsr")) {
    1.99 -                String[] arr = s.split(":");
   1.100 -                assertEquals(arr.length, 4, "Three :");
   1.101 -                assertEquals(arr[2], version, "Proper version is used");
   1.102 -            }
   1.103 -        }
   1.104 -    }
   1.105 -}