jaroslav@1202: /** jaroslav@1202: * HTML via Java(tm) Language Bindings jaroslav@1202: * Copyright (C) 2013 Jaroslav Tulach jaroslav@1202: * jaroslav@1202: * This program is free software: you can redistribute it and/or modify jaroslav@1202: * it under the terms of the GNU General Public License as published by jaroslav@1202: * the Free Software Foundation, version 2 of the License. jaroslav@1202: * jaroslav@1202: * This program is distributed in the hope that it will be useful, jaroslav@1202: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@1202: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@1202: * GNU General Public License for more details. apidesign.org jaroslav@1202: * designates this particular file as subject to the jaroslav@1202: * "Classpath" exception as provided by apidesign.org jaroslav@1202: * in the License file that accompanied this code. jaroslav@1202: * jaroslav@1202: * You should have received a copy of the GNU General Public License jaroslav@1202: * along with this program. Look for COPYING file in the top folder. jaroslav@1202: * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException jaroslav@1202: */ jaroslav@1202: package org.apidesign.html.archetype.test; jaroslav@1202: jaroslav@1202: import java.io.File; jaroslav@1202: import java.util.Properties; jaroslav@1202: import org.apache.maven.it.Verifier; jaroslav@1202: import org.testng.annotations.Test; jaroslav@1202: import static org.testng.Assert.*; jaroslav@1202: jaroslav@1202: /** jaroslav@1202: * jaroslav@1202: * @author Jaroslav Tulach jaroslav@1202: */ jaroslav@1202: public class VerifyArchetypeTest { jaroslav@1202: @Test public void fxBrwsrCompiles() throws Exception { jaroslav@1202: final File dir = new File("target/tests/fxcompile/").getAbsoluteFile(); jaroslav@1202: generateFromArchetype(dir); jaroslav@1202: jaroslav@1202: File created = new File(dir, "o-a-test"); jaroslav@1202: assertTrue(created.isDirectory(), "Project created"); jaroslav@1202: assertTrue(new File(created, "pom.xml").isFile(), "Pom file is in there"); jaroslav@1202: jaroslav@1202: Verifier v = new Verifier(created.getAbsolutePath()); jaroslav@1202: v.executeGoal("verify"); jaroslav@1202: jaroslav@1202: v.verifyErrorFreeLog(); jaroslav@1203: jaroslav@1203: for (String l : v.loadFile(v.getBasedir(), v.getLogFileName(), false)) { jaroslav@1203: if (l.contains("j2js")) { jaroslav@1203: fail("No pre-compilaton:\n" + l); jaroslav@1203: } jaroslav@1203: } jaroslav@1203: jaroslav@1203: v.verifyTextInLog("org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher"); jaroslav@1203: v.verifyTextInLog("fxcompile/o-a-test/target/o-a-test-1.0-SNAPSHOT-fxbrwsr.zip"); jaroslav@1203: } jaroslav@1203: jaroslav@1203: @Test public void bck2BrwsrCompiles() throws Exception { jaroslav@1203: final File dir = new File("target/tests/b2bcompile/").getAbsoluteFile(); jaroslav@1203: generateFromArchetype(dir); jaroslav@1203: jaroslav@1203: File created = new File(dir, "o-a-test"); jaroslav@1203: assertTrue(created.isDirectory(), "Project created"); jaroslav@1203: assertTrue(new File(created, "pom.xml").isFile(), "Pom file is in there"); jaroslav@1203: jaroslav@1203: Verifier v = new Verifier(created.getAbsolutePath()); jaroslav@1203: v.addCliOption("-Pbck2brwsr"); jaroslav@1203: v.executeGoal("verify"); jaroslav@1203: jaroslav@1203: v.verifyErrorFreeLog(); jaroslav@1203: jaroslav@1203: // does pre-compilation to JavaScript jaroslav@1203: v.verifyTextInLog("j2js"); jaroslav@1203: // uses Bck2BrwsrLauncher jaroslav@1203: v.verifyTextInLog("org.apidesign.bck2brwsr.launcher.Bck2BrwsrLauncher stopServerAndBrwsr"); jaroslav@1203: // building zip: jaroslav@1203: v.verifyTextInLog("b2bcompile/o-a-test/target/o-a-test-1.0-SNAPSHOT-bck2brwsr.zip"); jaroslav@1203: jaroslav@1203: for (String l : v.loadFile(v.getBasedir(), v.getLogFileName(), false)) { jaroslav@1203: if (l.contains("fxbrwsr")) { jaroslav@1203: fail("No fxbrwsr:\n" + l); jaroslav@1203: } jaroslav@1203: } jaroslav@1203: jaroslav@1202: } jaroslav@1202: jaroslav@1203: private Verifier generateFromArchetype(final File dir, String... params) throws Exception { jaroslav@1202: Verifier v = new Verifier(dir.getAbsolutePath()); jaroslav@1202: v.setAutoclean(false); jaroslav@1203: v.setLogFileName("generate.log"); jaroslav@1202: v.deleteDirectory(""); jaroslav@1202: dir.mkdirs(); jaroslav@1202: Properties sysProp = v.getSystemProperties(); jaroslav@1202: sysProp.put("groupId", "org.apidesign.test"); jaroslav@1202: sysProp.put("artifactId", "o-a-test"); jaroslav@1202: sysProp.put("package", "org.apidesign.test.oat"); jaroslav@1202: sysProp.put("archetypeGroupId", "org.apidesign.html"); jaroslav@1202: sysProp.put("archetypeArtifactId", "knockout4j-archetype"); jaroslav@1202: sysProp.put("archetypeVersion", ArchetypeVersionTest.findCurrentVersion()); jaroslav@1203: jaroslav@1203: for (String p : params) { jaroslav@1203: v.addCliOption(p); jaroslav@1203: } jaroslav@1202: v.executeGoal("archetype:generate"); jaroslav@1202: v.verifyErrorFreeLog(); jaroslav@1202: return v; jaroslav@1202: } jaroslav@1202: }