# HG changeset patch # User Jaroslav Tulach # Date 1362692115 -3600 # Node ID d87558f94d9224eb1b425cef633cb0c6e513ed86 # Parent 8f5ba6e4efa6b6abef96c9f81899dd31488a7691 Making sure the archetype always uses current version of bck2brwsr diff -r 8f5ba6e4efa6 -r d87558f94d92 rt/mojo/pom.xml --- a/rt/mojo/pom.xml Tue Mar 05 23:09:28 2013 +0100 +++ b/rt/mojo/pom.xml Thu Mar 07 22:35:15 2013 +0100 @@ -81,5 +81,11 @@ launcher ${project.version} + + org.testng + testng + 6.5.2 + test + diff -r 8f5ba6e4efa6 -r d87558f94d92 rt/mojo/src/main/resources/archetype-resources/pom.xml --- a/rt/mojo/src/main/resources/archetype-resources/pom.xml Tue Mar 05 23:09:28 2013 +0100 +++ b/rt/mojo/src/main/resources/archetype-resources/pom.xml Thu Mar 07 22:35:15 2013 +0100 @@ -44,7 +44,7 @@ org.apidesign.bck2brwsr mojo - 0.3-SNAPSHOT + 0.4-SNAPSHOT @@ -103,13 +103,13 @@ org.apidesign.bck2brwsr emul - 0.3-SNAPSHOT + 0.4-SNAPSHOT rt org.apidesign.bck2brwsr javaquery.api - 0.3-SNAPSHOT + 0.4-SNAPSHOT org.testng @@ -122,13 +122,13 @@ vm4brwsr js zip - 0.3-SNAPSHOT + 0.4-SNAPSHOT provided org.apidesign.bck2brwsr vmtest - 0.3-SNAPSHOT + 0.4-SNAPSHOT test diff -r 8f5ba6e4efa6 -r d87558f94d92 rt/mojo/src/test/java/org/apidesign/bck2brwsr/mojo/ArchetypeVersionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/mojo/src/test/java/org/apidesign/bck2brwsr/mojo/ArchetypeVersionTest.java Thu Mar 07 22:35:15 2013 +0100 @@ -0,0 +1,72 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.mojo; + +import java.net.URL; +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathFactory; +import org.testng.annotations.Test; +import org.xml.sax.InputSource; +import static org.testng.Assert.*; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; + +/** + * + * @author Jaroslav Tulach + */ +public class ArchetypeVersionTest { + + public ArchetypeVersionTest() { + } + + @Test public void testCompareOwnAndArchtetypeVersion() throws Exception { + final ClassLoader l = ArchetypeVersionTest.class.getClassLoader(); + URL u = l.getResource("META-INF/maven/org.apidesign.bck2brwsr/mojo/plugin-help.xml"); + assertNotNull(u, "Own pom found"); + + final XPathFactory fact = XPathFactory.newInstance(); + fact.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + + XPathExpression xp = fact.newXPath().compile("plugin/version/text()"); + String version = xp.evaluate(new InputSource(u.openStream())); + + assertFalse(version.isEmpty(), "There should be some version string"); + + URL r = l.getResource("archetype-resources/pom.xml"); + assertNotNull(r, "Archetype pom found"); + + XPathExpression xp2 = fact.newXPath().compile( + "//version[../groupId/text() = 'org.apidesign.bck2brwsr']/text()" + ); + + Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream()); + NodeList arch = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET); + + if (arch.getLength() < 3) { + fail("There should be at least three dependencies to bck2brwsr APIs: " + arch.getLength()); + } + + for (int i = 0; i < arch.getLength(); i++) { + assertEquals(arch.item(i).getTextContent(), version, i + "th dependency needs to be on latest version of bck2brwsr"); + } + } +}