ko/archetype-test/src/test/java/org/apidesign/bck2brwsr/ko/archetype/test/VerifyArchetypeTest.java
Rewritting the archetype to be simpler and more easily modifiable to one's needs
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.bck2brwsr.ko.archetype.test;
21 import java.util.Properties;
22 import java.util.zip.ZipFile;
23 import org.apache.maven.it.Verifier;
24 import org.testng.annotations.Test;
25 import static org.testng.Assert.*;
29 * @author Jaroslav Tulach <jtulach@netbeans.org>
31 public class VerifyArchetypeTest {
32 @Test public void fxBrwsrCompiles() throws Exception {
33 final File dir = new File("target/tests/fxcompile/").getAbsoluteFile();
34 generateFromArchetype(dir);
36 File created = new File(dir, "o-a-test");
37 assertTrue(created.isDirectory(), "Project created");
38 assertTrue(new File(created, "pom.xml").isFile(), "Pom file is in there");
40 Verifier v = new Verifier(created.getAbsolutePath());
41 v.executeGoal("verify");
43 v.verifyErrorFreeLog();
45 for (String l : v.loadFile(v.getBasedir(), v.getLogFileName(), false)) {
46 if (l.contains("j2js")) {
47 fail("No pre-compilaton:\n" + l);
51 v.verifyTextInLog("org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher");
52 v.verifyTextInLog("fxcompile/o-a-test/target/o-a-test-1.0-SNAPSHOT-fxbrwsr.zip");
55 @Test public void bck2BrwsrCompiles() throws Exception {
56 final File dir = new File("target/tests/b2bcompile/").getAbsoluteFile();
57 generateFromArchetype(dir);
59 File created = new File(dir, "o-a-test");
60 assertTrue(created.isDirectory(), "Project created");
61 assertTrue(new File(created, "pom.xml").isFile(), "Pom file is in there");
63 Verifier v = new Verifier(created.getAbsolutePath());
64 Properties sysProp = v.getSystemProperties();
65 if (Boolean.getBoolean("java.awt.headless")) {
66 sysProp.put("java.awt.headless", "true");
68 v.addCliOption("-Pbck2brwsr");
69 v.executeGoal("verify");
71 v.verifyErrorFreeLog();
73 // does pre-compilation to JavaScript
74 v.verifyTextInLog("j2js");
75 // uses Bck2BrwsrLauncher
76 v.verifyTextInLog("BaseHTTPLauncher showBrwsr");
78 v.verifyTextInLog("b2bcompile/o-a-test/target/o-a-test-1.0-SNAPSHOT-bck2brwsr.zip");
80 for (String l : v.loadFile(v.getBasedir(), v.getLogFileName(), false)) {
81 if (l.contains("fxbrwsr")) {
82 fail("No fxbrwsr:\n" + l);
86 File zip = new File(new File(created, "target"), "o-a-test-1.0-SNAPSHOT-bck2brwsr.zip");
87 assertTrue(zip.isFile(), "Zip file with website was created");
89 ZipFile zf = new ZipFile(zip);
90 assertNotNull(zf.getEntry("public_html/index.html"), "index.html found");
94 private Verifier generateFromArchetype(final File dir, String... params) throws Exception {
95 Verifier v = new Verifier(dir.getAbsolutePath());
96 v.setAutoclean(false);
97 v.setLogFileName("generate.log");
98 v.deleteDirectory("");
100 Properties sysProp = v.getSystemProperties();
101 sysProp.put("groupId", "org.apidesign.test");
102 sysProp.put("artifactId", "o-a-test");
103 sysProp.put("package", "org.apidesign.test.oat");
104 sysProp.put("archetypeGroupId", "org.apidesign.bck2brwsr");
105 sysProp.put("archetypeArtifactId", "knockout4j-archetype");
106 sysProp.put("archetypeVersion", ArchetypeVersionTest.findCurrentVersion());
108 for (String p : params) {
111 v.executeGoal("archetype:generate");
112 v.verifyErrorFreeLog();