Commits

Matthias Nüßler committed 150ea8d

Complete integration tests for all goals using a common parent POM.

But there is still too much duplication, has to be refactored.

  • Participants
  • Parent commits 93568fa

Comments (0)

Files changed (18)

File src/it/common.xml

     <packaging>pom</packaging>
 
     <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.nuessler.maven.plugins</groupId>
+                    <artifactId>cakupan-maven-plugin</artifactId>
+                    <version>@project.version@</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
         <plugins>
             <plugin>
                 <groupId>org.codehaus.gmaven</groupId>

File src/it/goal-cakupan/pom.xml

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
-    <groupId>org.nuessler.maven.plugins</groupId>
+    <parent>
+        <groupId>org.nuessler.maven.plugins.cakupan.it</groupId>
+        <artifactId>common</artifactId>
+        <version>@project.version@</version>
+        <relativePath>../common.xml</relativePath>
+    </parent>
     <artifactId>cakupan-maven-plugin-it-cakupan</artifactId>
-    <version>@project.version@</version>
-    <packaging>jar</packaging>
-
-    <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.10</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-library</artifactId>
-            <version>1.3.RC2</version>
-        </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>10.0.1</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.0.1</version>
-        </dependency>
-    </dependencies>
-
 </project>

File src/it/goal-cakupan/src/main/resources/sample.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<rss version="2.0">
+
+    <channel>
+        <title>Feed title</title>
+        <link>http://xyz.com/sample-feed.xml</link>
+        <description>A sample feed</description>
+        <language>en-en</language>
+        <copyright>Matthias Nuessler</copyright>
+        <pubDate>Sun, 06 Nov 2011 15:02:00</pubDate>
+        <image>
+            <url>URL einer einzubindenden Grafik</url>
+            <title>Bildtitel</title>
+            <link>URL, mit der das Bild verknüpft ist</link>
+        </image>
+
+        <item>
+            <title>Item title</title>
+            <description>A sample item</description>
+            <link></link>
+            <author>Autor des Artikels, E-Mail-Adresse</author>
+            <guid>Eindeutige Identifikation des Eintrages</guid>
+            <pubDate>Datum des Items</pubDate>
+        </item>
+    </channel>
+
+</rss>

File src/it/goal-cakupan/src/main/resources/sample.xsl

+<?xml version="1.0"?>
+<!--
+
+    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:template match="/">
+        <html>
+            <xsl:apply-templates />
+        </html>
+    </xsl:template>
+    <xsl:template match="PERIODIC_TABLE">
+        <body>
+            <xsl:apply-templates />
+        </body>
+    </xsl:template>
+    <xsl:template match="ATOM">
+        An Atom
+    </xsl:template>
+</xsl:stylesheet>

File src/it/goal-cakupan/src/test/groovy/SampleTransformationTest.groovy

+/**
+ * Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.nuessler.maven.plugin.cakupan.it
+
+import java.io.File
+
+import javax.xml.transform.Source
+import javax.xml.transform.Templates
+import javax.xml.transform.Transformer
+import javax.xml.transform.TransformerFactory
+import javax.xml.transform.stream.StreamResult
+import javax.xml.transform.stream.StreamSource
+
+import org.junit.Assert
+import org.junit.Test
+import org.nuessler.maven.plugin.cakupan.testutil.DomUtil
+import org.nuessler.maven.plugin.cakupan.testutil.XslTransformationTestCase
+import org.w3c.dom.Document
+
+class TransformationTest extends XslTransformationTestCase {
+
+    protected File getTransformationFile() {
+        return new File(getClass().getResource("/sample.xsl").getFile())
+    }
+
+    protected File getXmlInputFile() {
+        return new File(getClass().getResource("/sample.xml").getFile())
+    }
+
+    protected File getTargetSchemaFile() {
+        return null
+    }
+
+    protected void checkResult(Document doc) {
+        println('Check result: ' + DomUtil.documentToString(doc))
+    }
+
+}

File src/it/goal-cakupan/verify.groovy

  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import static org.junit.Assert.assertThat;
-import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertTrue
+import static org.junit.Assert.assertThat
+import static org.hamcrest.Matchers.greaterThan
 
-def instrumentFile = new File(basedir, 'target/cakupan-instrument/coverage.xml');
+def outDir = new File(basedir, 'target/cakupan-instrument')
 
-assert instrumentFile.exists();
+def instrumentFile = new File(outDir, 'coverage.xml')
+def traceFile = new File(outDir, 'sample.xsl.xml')
+def datFile = new File(outDir, 'sample.xsl.dat')
 
-return true;
+[instrumentFile, traceFile, datFile].each { file ->
+    println "Checking that file exists: $file"
+    assertTrue("File does not exist: '$file'", file.exists())
+}
+
+// assert that there are lines with coverage > 0
+def rootNode = new XmlSlurper().parse(instrumentFile)
+def lineCountNodes = rootNode.depthFirst().grep { node ->
+    node.name() == 'lineCount' && node.text().toInteger() > 0
+}
+
+def reason = 'All line counts are 0, no coverage!'
+assertThat(reason, lineCountNodes.size(), greaterThan(0))
+
+return true

File src/it/goal-clean/pom.xml

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
-    <groupId>org.nuessler.maven.plugins</groupId>
+    <parent>
+        <groupId>org.nuessler.maven.plugins.cakupan.it</groupId>
+        <artifactId>common</artifactId>
+        <version>@project.version@</version>
+        <relativePath>../common.xml</relativePath>
+    </parent>
     <artifactId>cakupan-maven-plugin-it-clean</artifactId>
-    <version>@project.version@</version>
-    <packaging>jar</packaging>
-
-    <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.10</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-library</artifactId>
-            <version>1.3.RC2</version>
-        </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>10.0.1</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.0.1</version>
-        </dependency>
-    </dependencies>
-
 </project>

File src/it/goal-clean/src/main/resources/sample.xsl

 
 <!-- Sample XSL: Standard copy template  -->
 <xsl:template match="@*|node()">
-	<xsl:copy>
-		<xsl:apply-templates select="@*|node()" />
-	</xsl:copy>
+    <xsl:copy>
+        <xsl:apply-templates select="@*|node()" />
+    </xsl:copy>
 </xsl:template>

File src/it/goal-clean/verify.groovy

  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import static org.junit.Assert.assertThat;
-import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertFalse
 
-def instrumentFile = new File(basedir, 'target/cakupan-instrument/coverage.xml');
+def outDir = new File(basedir, 'target/cakupan-instrument')
 
-assert !instrumentFile.exists();
+def instrumentFile = new File(outDir, 'coverage.xml')
+def traceFile = new File(outDir, 'sample.xsl.xml')
+def datFile = new File(outDir, 'sample.xsl.dat')
 
-return true;
+[instrumentFile, traceFile, datFile].each { file ->
+    println "Checking that file does not exist: $file"
+    assertFalse("File does exist: '$file'", file.exists())
+}
+
+return true

File src/it/goal-instrument/pom.xml

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
-    <groupId>org.nuessler.maven.plugins</groupId>
+    <parent>
+        <groupId>org.nuessler.maven.plugins.cakupan.it</groupId>
+        <artifactId>common</artifactId>
+        <version>@project.version@</version>
+        <relativePath>../common.xml</relativePath>
+    </parent>
     <artifactId>cakupan-maven-plugin-it-instrument</artifactId>
-    <version>@project.version@</version>
-    <packaging>jar</packaging>
-
-    <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.10</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-library</artifactId>
-            <version>1.3.RC2</version>
-        </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>10.0.1</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.0.1</version>
-        </dependency>
-    </dependencies>
-
 </project>

File src/it/goal-test/src/main/resources/feed.xml

             <description>Ticket 3 has been modified: Maven 3 compatibility
                 Edited By: Matthias Nuessler (mnuessler)
                 Status updated: u'in-progress' =&gt; u'closed'
-                _resolution updated: u'to-fix' =&gt; u'fixed'
+                _resolution updated: u'to-fix' =&gt;
+                u'fixed'
                 _milestone updated: u'0.4' =&gt; u'none'</description>
             <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthias Nuessler</dc:creator>
             <pubDate>Thu, 03 Nov 2011 09:24:25 -0000</pubDate>
             <link>https://sourceforge.net/p/cakupan-maven/tickets/3/</link>
             <description>Ticket 3 has been modified: Maven 3 compatibility
                 Edited By: Matthias Nuessler (mnuessler)
-                Summary updated: u'Compatibility with Maven 3' =&gt; u'Maven 3 compatibility'</description>
+                Summary updated: u'Compatibility with Maven 3' =&gt; u'Maven 3 compatibility'
+            </description>
             <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthias Nuessler</dc:creator>
             <pubDate>Thu, 22 Sep 2011 21:43:58 -0000</pubDate>
             <guid>43f6d7f2a714704077e756951a99ac75d9aafb40</guid>
             <description>Ticket 3 has been modified: Compatibility with Maven 3
                 Edited By: Matthias Nuessler (mnuessler)
                 _type updated: '' =&gt; u'Feature'
-                _milestone updated: u'0.3' =&gt; u'v0.3'</description>
+                _milestone updated: u'0.3' =&gt; u'v0.3'
+            </description>
             <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthias Nuessler</dc:creator>
             <pubDate>Thu, 22 Sep 2011 18:15:19 -0000</pubDate>
             <guid>20539f8917063adeac0d534dbde7419e018d8b5d</guid>

File src/it/goal-test/verify.groovy

  */
 import static org.junit.Assert.assertTrue
 
-def outDir = new File(basedir, 'target/cakupan-instrumentX')
+def outDir = new File(basedir, 'target/cakupan-instrument')
 
 def instrumentFile = new File(outDir, 'coverage.xml')
 def traceFile = new File(outDir, 'sample.xsl.xml')

File src/it/site/invoker.properties

 invoker.name=Test site generation
 invoker.description=Checks that the cakupan report is generated during site generation.
 
-invoker.goals=site:site
+invoker.goals=compile cakupan:cakupan site:site
 invoker.mavenOpts=-Dcakupan-maven-plugin.version=${project.version}

File src/it/site/pom.xml

-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	<groupId>org.nuessler.maven.plugins</groupId>
-	<artifactId>cakupan-maven-plugin-it-site</artifactId>
-	<version>@project.version@</version>
-	<packaging>jar</packaging>
-
-	<dependencies>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.10</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.hamcrest</groupId>
-			<artifactId>hamcrest-library</artifactId>
-			<version>1.3.RC2</version>
-		</dependency>
-		<dependency>
-			<groupId>com.google.guava</groupId>
-			<artifactId>guava</artifactId>
-			<version>10.0.1</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.commons</groupId>
-			<artifactId>commons-lang3</artifactId>
-			<version>3.0.1</version>
-		</dependency>
-	</dependencies>
-
-	<reporting>
-		<plugins>
-			<plugin>
-				<groupId>org.nuessler.maven.plugins</groupId>
-				<artifactId>cakupan-maven-plugin</artifactId>
-				<version>${cakupan-maven-plugin.version}</version>
-			</plugin>
-		</plugins>
-	</reporting>	
-
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.nuessler.maven.plugins.cakupan.it</groupId>
+        <artifactId>common</artifactId>
+        <version>@project.version@</version>
+        <relativePath>../common.xml</relativePath>
+    </parent>
+    <artifactId>cakupan-maven-plugin-it-site</artifactId>
 </project>

File src/it/site/src/main/resources/sample.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<rss version="2.0">
+
+    <channel>
+        <title>Feed title</title>
+        <link>http://xyz.com/sample-feed.xml</link>
+        <description>A sample feed</description>
+        <language>en-en</language>
+        <copyright>Matthias Nuessler</copyright>
+        <pubDate>Sun, 06 Nov 2011 15:02:00</pubDate>
+        <image>
+            <url>URL einer einzubindenden Grafik</url>
+            <title>Bildtitel</title>
+            <link>URL, mit der das Bild verknüpft ist</link>
+        </image>
+
+        <item>
+            <title>Item title</title>
+            <description>A sample item</description>
+            <link></link>
+            <author>Autor des Artikels, E-Mail-Adresse</author>
+            <guid>Eindeutige Identifikation des Eintrages</guid>
+            <pubDate>Datum des Items</pubDate>
+        </item>
+    </channel>
+
+</rss>

File src/it/site/src/main/resources/sample.xsl

+<?xml version="1.0"?>
+<!--
+
+    Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:template match="/">
+        <html>
+            <xsl:apply-templates />
+        </html>
+    </xsl:template>
+    <xsl:template match="PERIODIC_TABLE">
+        <body>
+            <xsl:apply-templates />
+        </body>
+    </xsl:template>
+    <xsl:template match="ATOM">
+        An Atom
+    </xsl:template>
+</xsl:stylesheet>

File src/it/site/src/test/groovy/SampleTransformationTest.groovy

+/**
+ * Copyright 2011 Matthias Nuessler <m.nuessler@web.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.nuessler.maven.plugin.cakupan.it
+
+import java.io.File
+
+import javax.xml.transform.Source
+import javax.xml.transform.Templates
+import javax.xml.transform.Transformer
+import javax.xml.transform.TransformerFactory
+import javax.xml.transform.stream.StreamResult
+import javax.xml.transform.stream.StreamSource
+
+import org.junit.Assert
+import org.junit.Test
+import org.nuessler.maven.plugin.cakupan.testutil.DomUtil
+import org.nuessler.maven.plugin.cakupan.testutil.XslTransformationTestCase
+import org.w3c.dom.Document
+
+class TransformationTest extends XslTransformationTestCase {
+
+    protected File getTransformationFile() {
+        return new File(getClass().getResource("/sample.xsl").getFile())
+    }
+
+    protected File getXmlInputFile() {
+        return new File(getClass().getResource("/sample.xml").getFile())
+    }
+
+    protected File getTargetSchemaFile() {
+        return null
+    }
+
+    protected void checkResult(Document doc) {
+        println('Check result: ' + DomUtil.documentToString(doc))
+    }
+
+}

File src/it/site/verify.groovy

  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+import static org.hamcrest.Matchers.greaterThan;
 import static org.junit.Assert.assertThat;
-import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertTrue;
 
 def instrumentFile = new File(basedir, 'target/cakupan-instrument/coverage.xml');
 def reportDir = new File(basedir, 'target/site/cakupan/');
-
-assert !instrumentFile.exists();
+def indexFile = new File(reportDir, 'index.html')
+def sampleXslReport = new File(reportDir, 'sample.xsl.html')
 
 assert reportDir.exists();
 assert reportDir.isDirectory();
 
-def File[] reportFiles = reportDir.listFiles();
-assert reportFiles.length > 0
-reportFiles.each {
-    assert it.length() > 0;
+assert indexFile.exists()
+assert indexFile.length() > 0
+
+assert sampleXslReport.exists()
+assert sampleXslReport.length() > 0
+
+resourceFiles = [
+    'blank.png',
+    'customsorttypes.js',
+    'downsimple.png',
+    'main.css',
+    'sortabletable.css',
+    'sortabletable.js',
+    'source-viewer.css',
+    'upsimple.png'
+    ].collect { new File(reportDir, it) }
+
+resourceFiles.each { file ->
+    assertTrue("File '$file' does not exits", file.exists())
+    assertThat("File '$file' is empty", file.length(), greaterThan(0L))
 }
 
 return true;