1.1 --- a/rt/mojo/pom.xml Tue Mar 05 23:09:28 2013 +0100
1.2 +++ b/rt/mojo/pom.xml Thu Mar 07 22:35:15 2013 +0100
1.3 @@ -81,5 +81,11 @@
1.4 <artifactId>launcher</artifactId>
1.5 <version>${project.version}</version>
1.6 </dependency>
1.7 + <dependency>
1.8 + <groupId>org.testng</groupId>
1.9 + <artifactId>testng</artifactId>
1.10 + <version>6.5.2</version>
1.11 + <scope>test</scope>
1.12 + </dependency>
1.13 </dependencies>
1.14 </project>
2.1 --- a/rt/mojo/src/main/resources/archetype-resources/pom.xml Tue Mar 05 23:09:28 2013 +0100
2.2 +++ b/rt/mojo/src/main/resources/archetype-resources/pom.xml Thu Mar 07 22:35:15 2013 +0100
2.3 @@ -44,7 +44,7 @@
2.4 <plugin>
2.5 <groupId>org.apidesign.bck2brwsr</groupId>
2.6 <artifactId>mojo</artifactId>
2.7 - <version>0.3-SNAPSHOT</version>
2.8 + <version>0.4-SNAPSHOT</version>
2.9 <executions>
2.10 <execution>
2.11 <goals>
2.12 @@ -103,13 +103,13 @@
2.13 <dependency>
2.14 <groupId>org.apidesign.bck2brwsr</groupId>
2.15 <artifactId>emul</artifactId>
2.16 - <version>0.3-SNAPSHOT</version>
2.17 + <version>0.4-SNAPSHOT</version>
2.18 <classifier>rt</classifier>
2.19 </dependency>
2.20 <dependency>
2.21 <groupId>org.apidesign.bck2brwsr</groupId>
2.22 <artifactId>javaquery.api</artifactId>
2.23 - <version>0.3-SNAPSHOT</version>
2.24 + <version>0.4-SNAPSHOT</version>
2.25 </dependency>
2.26 <dependency>
2.27 <groupId>org.testng</groupId>
2.28 @@ -122,13 +122,13 @@
2.29 <artifactId>vm4brwsr</artifactId>
2.30 <classifier>js</classifier>
2.31 <type>zip</type>
2.32 - <version>0.3-SNAPSHOT</version>
2.33 + <version>0.4-SNAPSHOT</version>
2.34 <scope>provided</scope>
2.35 </dependency>
2.36 <dependency>
2.37 <groupId>org.apidesign.bck2brwsr</groupId>
2.38 <artifactId>vmtest</artifactId>
2.39 - <version>0.3-SNAPSHOT</version>
2.40 + <version>0.4-SNAPSHOT</version>
2.41 <scope>test</scope>
2.42 </dependency>
2.43 </dependencies>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/rt/mojo/src/test/java/org/apidesign/bck2brwsr/mojo/ArchetypeVersionTest.java Thu Mar 07 22:35:15 2013 +0100
3.3 @@ -0,0 +1,72 @@
3.4 +/**
3.5 + * Back 2 Browser Bytecode Translator
3.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
3.7 + *
3.8 + * This program is free software: you can redistribute it and/or modify
3.9 + * it under the terms of the GNU General Public License as published by
3.10 + * the Free Software Foundation, version 2 of the License.
3.11 + *
3.12 + * This program is distributed in the hope that it will be useful,
3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.15 + * GNU General Public License for more details.
3.16 + *
3.17 + * You should have received a copy of the GNU General Public License
3.18 + * along with this program. Look for COPYING file in the top folder.
3.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
3.20 + */
3.21 +package org.apidesign.bck2brwsr.mojo;
3.22 +
3.23 +import java.net.URL;
3.24 +import javax.xml.XMLConstants;
3.25 +import javax.xml.parsers.DocumentBuilderFactory;
3.26 +import javax.xml.xpath.XPathConstants;
3.27 +import javax.xml.xpath.XPathExpression;
3.28 +import javax.xml.xpath.XPathFactory;
3.29 +import org.testng.annotations.Test;
3.30 +import org.xml.sax.InputSource;
3.31 +import static org.testng.Assert.*;
3.32 +import org.w3c.dom.Document;
3.33 +import org.w3c.dom.NodeList;
3.34 +
3.35 +/**
3.36 + *
3.37 + * @author Jaroslav Tulach <jtulach@netbeans.org>
3.38 + */
3.39 +public class ArchetypeVersionTest {
3.40 +
3.41 + public ArchetypeVersionTest() {
3.42 + }
3.43 +
3.44 + @Test public void testCompareOwnAndArchtetypeVersion() throws Exception {
3.45 + final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
3.46 + URL u = l.getResource("META-INF/maven/org.apidesign.bck2brwsr/mojo/plugin-help.xml");
3.47 + assertNotNull(u, "Own pom found");
3.48 +
3.49 + final XPathFactory fact = XPathFactory.newInstance();
3.50 + fact.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
3.51 +
3.52 + XPathExpression xp = fact.newXPath().compile("plugin/version/text()");
3.53 + String version = xp.evaluate(new InputSource(u.openStream()));
3.54 +
3.55 + assertFalse(version.isEmpty(), "There should be some version string");
3.56 +
3.57 + URL r = l.getResource("archetype-resources/pom.xml");
3.58 + assertNotNull(r, "Archetype pom found");
3.59 +
3.60 + XPathExpression xp2 = fact.newXPath().compile(
3.61 + "//version[../groupId/text() = 'org.apidesign.bck2brwsr']/text()"
3.62 + );
3.63 +
3.64 + Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
3.65 + NodeList arch = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
3.66 +
3.67 + if (arch.getLength() < 3) {
3.68 + fail("There should be at least three dependencies to bck2brwsr APIs: " + arch.getLength());
3.69 + }
3.70 +
3.71 + for (int i = 0; i < arch.getLength(); i++) {
3.72 + assertEquals(arch.item(i).getTextContent(), version, i + "th dependency needs to be on latest version of bck2brwsr");
3.73 + }
3.74 + }
3.75 +}