Verify all placeholders are substituted when building final ZIP distribution
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 09 Sep 2013 20:33:52 +0200
changeset 1275913732a84aa3
parent 1274 c4f83529954d
child 1276 0faedeb34895
Verify all placeholders are substituted when building final ZIP distribution
ko/archetype-test/src/test/java/org/apidesign/bck2brwsr/ko/archetype/test/VerifyArchetypeTest.java
ko/archetype/src/main/resources/archetype-resources/src/main/assembly/bck2brwsr.xml
ko/archetype/src/main/resources/archetype-resources/src/main/assembly/fxbrwsr.xml
     1.1 --- a/ko/archetype-test/src/test/java/org/apidesign/bck2brwsr/ko/archetype/test/VerifyArchetypeTest.java	Mon Sep 09 19:35:12 2013 +0200
     1.2 +++ b/ko/archetype-test/src/test/java/org/apidesign/bck2brwsr/ko/archetype/test/VerifyArchetypeTest.java	Mon Sep 09 20:33:52 2013 +0200
     1.3 @@ -18,11 +18,15 @@
     1.4  package org.apidesign.bck2brwsr.ko.archetype.test;
     1.5  
     1.6  import java.io.File;
     1.7 +import java.io.IOException;
     1.8 +import java.io.InputStream;
     1.9  import java.util.Properties;
    1.10 +import java.util.zip.ZipEntry;
    1.11  import java.util.zip.ZipFile;
    1.12  import org.apache.maven.it.Verifier;
    1.13  import org.testng.annotations.Test;
    1.14  import static org.testng.Assert.*;
    1.15 +import org.testng.reporters.Files;
    1.16  
    1.17  /**
    1.18   *
    1.19 @@ -87,8 +91,18 @@
    1.20          assertTrue(zip.isFile(), "Zip file with website was created");
    1.21          
    1.22          ZipFile zf = new ZipFile(zip);
    1.23 -        assertNotNull(zf.getEntry("public_html/index.html"), "index.html found");
    1.24 +        final ZipEntry index = zf.getEntry("public_html/index.html");
    1.25 +        assertNotNull(index, "index.html found");
    1.26          
    1.27 +        String txt = readText(zf.getInputStream(index));
    1.28 +        final int beg = txt.indexOf("${");
    1.29 +        if (beg >= 0) {
    1.30 +            int end = txt.indexOf("}", beg);
    1.31 +            if (end < beg) {
    1.32 +                end = txt.length();
    1.33 +            }
    1.34 +            fail("No substitutions in index.html. Found: " + txt.substring(beg, end));
    1.35 +        }
    1.36      }
    1.37  
    1.38      private Verifier generateFromArchetype(final File dir, String... params) throws Exception {
    1.39 @@ -112,4 +126,8 @@
    1.40          v.verifyErrorFreeLog();
    1.41          return v;
    1.42      }
    1.43 +    
    1.44 +    private static String readText(InputStream is) throws IOException {
    1.45 +        return Files.readFile(is);
    1.46 +    }
    1.47  }
     2.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/main/assembly/bck2brwsr.xml	Mon Sep 09 19:35:12 2013 +0200
     2.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/main/assembly/bck2brwsr.xml	Mon Sep 09 20:33:52 2013 +0200
     2.3 @@ -32,6 +32,7 @@
     2.4        <fileSet>
     2.5            <directory>src/main/webapp/pages</directory>
     2.6            <outputDirectory>/</outputDirectory>
     2.7 +          <filtered>true</filtered>
     2.8        </fileSet>
     2.9    </fileSets>
    2.10    <files>
     3.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/main/assembly/fxbrwsr.xml	Mon Sep 09 19:35:12 2013 +0200
     3.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/main/assembly/fxbrwsr.xml	Mon Sep 09 20:33:52 2013 +0200
     3.3 @@ -27,6 +27,7 @@
     3.4         <includes>
     3.5            <include>pages/**</include>
     3.6         </includes>
     3.7 +       <filtered>true</filtered>
     3.8      </fileSet>
     3.9    </fileSets>
    3.10  </assembly>
    3.11 \ No newline at end of file