ko-archetype-test/src/test/java/org/apidesign/html/archetype/test/VerifyArchetypeTest.java
branchclassloader
changeset 1225 73c0973e8e0a
parent 1224 7189e9abb928
child 1226 e5b5c7af4f7f
     1.1 --- a/ko-archetype-test/src/test/java/org/apidesign/html/archetype/test/VerifyArchetypeTest.java	Mon Jun 24 17:49:27 2013 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,119 +0,0 @@
     1.4 -/**
     1.5 - * HTML via Java(tm) Language Bindings
     1.6 - * Copyright (C) 2013 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. apidesign.org
    1.16 - * designates this particular file as subject to the
    1.17 - * "Classpath" exception as provided by apidesign.org
    1.18 - * in the License file that accompanied this code.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License
    1.21 - * along with this program. Look for COPYING file in the top folder.
    1.22 - * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
    1.23 - */
    1.24 -package org.apidesign.html.archetype.test;
    1.25 -
    1.26 -import java.io.File;
    1.27 -import java.util.Properties;
    1.28 -import java.util.zip.ZipFile;
    1.29 -import org.apache.maven.it.Verifier;
    1.30 -import org.testng.annotations.Test;
    1.31 -import static org.testng.Assert.*;
    1.32 -
    1.33 -/**
    1.34 - *
    1.35 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.36 - */
    1.37 -public class VerifyArchetypeTest {
    1.38 -    @Test public void fxBrwsrCompiles() throws Exception {
    1.39 -        final File dir = new File("target/tests/fxcompile/").getAbsoluteFile();
    1.40 -        generateFromArchetype(dir);
    1.41 -        
    1.42 -        File created = new File(dir, "o-a-test");
    1.43 -        assertTrue(created.isDirectory(), "Project created");
    1.44 -        assertTrue(new File(created, "pom.xml").isFile(), "Pom file is in there");
    1.45 -        
    1.46 -        Verifier v = new Verifier(created.getAbsolutePath());
    1.47 -        v.executeGoal("verify");
    1.48 -        
    1.49 -        v.verifyErrorFreeLog();
    1.50 -        
    1.51 -        for (String l : v.loadFile(v.getBasedir(), v.getLogFileName(), false)) {
    1.52 -            if (l.contains("j2js")) {
    1.53 -                fail("No pre-compilaton:\n" + l);
    1.54 -            }
    1.55 -        }
    1.56 -        
    1.57 -        v.verifyTextInLog("org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher");
    1.58 -        v.verifyTextInLog("fxcompile/o-a-test/target/o-a-test-1.0-SNAPSHOT-fxbrwsr.zip");
    1.59 -    }
    1.60 -    
    1.61 -    @Test public void bck2BrwsrCompiles() throws Exception {
    1.62 -        final File dir = new File("target/tests/b2bcompile/").getAbsoluteFile();
    1.63 -        generateFromArchetype(dir);
    1.64 -        
    1.65 -        File created = new File(dir, "o-a-test");
    1.66 -        assertTrue(created.isDirectory(), "Project created");
    1.67 -        assertTrue(new File(created, "pom.xml").isFile(), "Pom file is in there");
    1.68 -        
    1.69 -        Verifier v = new Verifier(created.getAbsolutePath());
    1.70 -        Properties sysProp = v.getSystemProperties();
    1.71 -        if (Boolean.getBoolean("java.awt.headless")) {
    1.72 -            sysProp.put("java.awt.headless", "true");
    1.73 -        }
    1.74 -        v.addCliOption("-Pbck2brwsr");
    1.75 -        v.executeGoal("verify");
    1.76 -        
    1.77 -        v.verifyErrorFreeLog();
    1.78 -        
    1.79 -        // does pre-compilation to JavaScript
    1.80 -        v.verifyTextInLog("j2js");
    1.81 -        // uses Bck2BrwsrLauncher
    1.82 -        v.verifyTextInLog("BaseHTTPLauncher stopServerAndBrwsr");
    1.83 -        // building zip:
    1.84 -        v.verifyTextInLog("b2bcompile/o-a-test/target/o-a-test-1.0-SNAPSHOT-bck2brwsr.zip");
    1.85 -        
    1.86 -        for (String l : v.loadFile(v.getBasedir(), v.getLogFileName(), false)) {
    1.87 -            if (l.contains("fxbrwsr")) {
    1.88 -                fail("No fxbrwsr:\n" + l);
    1.89 -            }
    1.90 -        }
    1.91 -
    1.92 -        File zip = new File(new File(created, "target"), "o-a-test-1.0-SNAPSHOT-bck2brwsr.zip");
    1.93 -        assertTrue(zip.isFile(), "Zip file with website was created");
    1.94 -        
    1.95 -        ZipFile zf = new ZipFile(zip);
    1.96 -        assertNotNull(zf.getEntry("public_html/index.html"), "index.html found");
    1.97 -        assertNotNull(zf.getEntry("public_html/twitterExample.css"), "css file found");
    1.98 -        
    1.99 -    }
   1.100 -
   1.101 -    private Verifier generateFromArchetype(final File dir, String... params) throws Exception {
   1.102 -        Verifier v = new Verifier(dir.getAbsolutePath());
   1.103 -        v.setAutoclean(false);
   1.104 -        v.setLogFileName("generate.log");
   1.105 -        v.deleteDirectory("");
   1.106 -        dir.mkdirs();
   1.107 -        Properties sysProp = v.getSystemProperties();
   1.108 -        sysProp.put("groupId", "org.apidesign.test");
   1.109 -        sysProp.put("artifactId", "o-a-test");
   1.110 -        sysProp.put("package", "org.apidesign.test.oat");
   1.111 -        sysProp.put("archetypeGroupId", "org.apidesign.html");
   1.112 -        sysProp.put("archetypeArtifactId", "knockout4j-archetype");
   1.113 -        sysProp.put("archetypeVersion", ArchetypeVersionTest.findCurrentVersion());
   1.114 -        
   1.115 -        for (String p : params) {
   1.116 -            v.addCliOption(p);
   1.117 -        }
   1.118 -        v.executeGoal("archetype:generate");
   1.119 -        v.verifyErrorFreeLog();
   1.120 -        return v;
   1.121 -    }
   1.122 -}