Author: bdaw
Date: 2008-02-25 04:35:22 -0500 (Mon, 25 Feb 2008)
New Revision: 10104
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAPF.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java
Modified:
modules/portlet/trunk/controller/pom.xml
modules/portlet/trunk/portlet/pom.xml
Log:
- dummy test coverage reporting
Modified: modules/portlet/trunk/controller/pom.xml
===================================================================
--- modules/portlet/trunk/controller/pom.xml 2008-02-25 05:13:33 UTC (rev 10103)
+++ modules/portlet/trunk/controller/pom.xml 2008-02-25 09:35:22 UTC (rev 10104)
@@ -33,7 +33,7 @@
<artifactId>portlet-portlet</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
- <scope>test</scope>
+ <!--<scope>test</scope>-->
</dependency>
<!--TEST SCOPE-->
Modified: modules/portlet/trunk/portlet/pom.xml
===================================================================
--- modules/portlet/trunk/portlet/pom.xml 2008-02-25 05:13:33 UTC (rev 10103)
+++ modules/portlet/trunk/portlet/pom.xml 2008-02-25 09:35:22 UTC (rev 10104)
@@ -40,14 +40,6 @@
<artifactId>jaxb-api</artifactId>
</dependency>
- <!--<dependency>-->
- <!--<groupId>sun.jdk</groupId>-->
- <!--<artifactId>tools</artifactId>-->
- <!--<version>1.5.0</version>-->
- <!--<scope>system</scope>-->
- <!--<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>-->
- <!--</dependency>-->
-
<!--TEST SCOPE-->
<dependency>
<groupId>org.jboss.unit</groupId>
@@ -56,8 +48,123 @@
</dependency>
</dependencies>
+
+
+ <profiles>
+ <!--By default Annotation Processing Tool related classes need to be
disabled-->
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <testExcludes>
+ <exclude>org/jboss/portal/unit/reports/*</exclude>
+ </testExcludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>apt</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.myfaces.tobago</groupId>
+ <artifactId>maven-apt-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <configuration>
+
<factory>org.jboss.portal.unit.reports.TestCaseAPF</factory>
+ <force>true</force>
+ <target>1.5</target>
+ <nocompile>true</nocompile>
+ <showWarnings>true</showWarnings>
+ </configuration>
+ <goals>
+ <goal>testExecute</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>sun.jdk</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.5.0</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/../lib/tools.jar</systemPath>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <!--On MacOSX the tools.jar should be already in the classpath-->
+ <profile>
+ <id>apt-mac</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.myfaces.tobago</groupId>
+ <artifactId>maven-apt-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <configuration>
+
<factory>org.jboss.portal.unit.reports.TestCaseAPF</factory>
+ <force>true</force>
+ <target>1.5</target>
+ <nocompile>true</nocompile>
+ <showWarnings>true</showWarnings>
+ </configuration>
+ <goals>
+ <goal>testExecute</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
+
+
<build>
<plugins>
+ <!--<plugin>-->
+ <!--<groupId>org.apache.maven.plugins</groupId>-->
+ <!--<artifactId>maven-compiler-plugin</artifactId>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<goals>-->
+ <!--<goal>testCompile</goal>-->
+ <!--</goals>-->
+ <!--</execution>-->
+ <!--</executions>-->
+ <!--<configuration>-->
+ <!--<testExcludes>-->
+
<!--<exclude>org/jboss/portal/unit/reports/*</exclude>-->
+ <!--</testExcludes>-->
+ <!--</configuration>-->
+ <!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java 2008-02-25
09:35:22 UTC (rev 10104)
@@ -0,0 +1,107 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.unit.reports;
+
+import com.sun.mirror.apt.RoundCompleteListener;
+import com.sun.mirror.apt.RoundCompleteEvent;
+
+import java.io.File;
+import java.io.Writer;
+import java.io.FileWriter;
+import java.util.Set;
+import java.util.Map;
+import java.util.Collections;
+import java.util.SortedSet;
+import java.util.List;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class ResultProducingListener implements RoundCompleteListener
+{
+ public static String jsr168File = "./target/apt-jsr168-testcases.csv";
+
+ public static int jsr168Max = 179;
+
+ public static String jsr286File = "./target/apt-jsr286-testcases.csv";
+
+ public static int jsr286Max = 350;
+
+ public void roundComplete(RoundCompleteEvent event)
+ {
+ if (event.getRoundState().finalRound())
+ {
+ System.out.println("#END");
+
+
+ try
+ {
+ if (!TestCaseAnnotationProcessor.jsr168Assertions.keySet().isEmpty())
+ {
+ print(TestCaseAnnotationProcessor.jsr168Assertions, jsr168File,
"JSR168_", jsr168Max);
+ }
+
+ if (!TestCaseAnnotationProcessor.jsr286Assertions.keySet().isEmpty())
+ {
+ print(TestCaseAnnotationProcessor.jsr286Assertions, jsr286File,
"JSR286_", jsr286Max);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings
| File Templates.
+ }
+
+
+ }
+ }
+
+ private void print(Map<String, Set<String>> map, String fileName, String
pre, int max) throws Exception
+ {
+
+ File f = new File(fileName);
+
+ Writer writer = new FileWriter(f, false);
+
+ for (int i = 1; i <= max; i++)
+ {
+ String assertion = pre + i;
+
+ writer.write(assertion + ",\n");
+
+ Set<String> testCases = map.get(assertion);
+
+ if (testCases != null)
+ {
+ for (String testCase : testCases)
+ {
+ writer.write(" ," + testCase + "\n");
+ }
+ }
+ }
+
+ writer.close();
+
+ }
+}
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAPF.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAPF.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAPF.java 2008-02-25
09:35:22 UTC (rev 10104)
@@ -0,0 +1,68 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.unit.reports;
+
+import com.sun.mirror.apt.AnnotationProcessorFactory;
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.apt.AnnotationProcessors;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.Collections;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class TestCaseAPF implements AnnotationProcessorFactory
+{
+ public Collection<String> supportedOptions()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection<String> supportedAnnotationTypes()
+ {
+ return
Collections.singletonList("org.jboss.portal.unit.annotations.TestCase");
+ }
+
+ public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration>
annotationTypeDeclarations, AnnotationProcessorEnvironment
annotationProcessorEnvironment)
+ {
+ AnnotationProcessor result;
+ if(annotationTypeDeclarations.isEmpty()) {
+ result = AnnotationProcessors.NO_OP;
+ }
+ else {
+ // Next Step - implement this class:
+ result = new TestCaseAnnotationProcessor(annotationProcessorEnvironment);
+ annotationProcessorEnvironment.addListener(new ResultProducingListener());
+ }
+ return result;
+
+ }
+
+
+}
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java 2008-02-25
09:35:22 UTC (rev 10104)
@@ -0,0 +1,173 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.unit.reports;
+
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+import com.sun.mirror.declaration.Declaration;
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
+import com.sun.mirror.declaration.AnnotationValue;
+import com.sun.mirror.declaration.EnumConstantDeclaration;
+import com.sun.mirror.util.SourcePosition;
+import com.sun.tools.apt.mirror.declaration.AnnotationValueImpl;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.List;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.io.File;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.jboss.portal.unit.Assertion;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class TestCaseAnnotationProcessor implements AnnotationProcessor
+{
+
+ private AnnotationProcessorEnvironment environment;
+
+ private AnnotationTypeDeclaration testCaseDeclaration;
+
+
+
+ public static String jsr168Pre = "org.jboss.portal.test.portlet.jsr168";
+
+ public static String jsr286Pre = "org.jboss.portal.test.portlet.jsr286";
+
+ public static String jsr168AssertionPre = "JSR168";
+
+ public static String jsr286AssertionPre = "JSR286";
+
+
+ public static Map<String, Set<String>> jsr168Assertions = new
HashMap<String, Set<String>>();
+
+ public static Map<String, Set<String>> jsr286Assertions = new
HashMap<String, Set<String>>();
+
+ //private int counter;
+
+ public TestCaseAnnotationProcessor(AnnotationProcessorEnvironment env) {
+
+ environment = env;
+ testCaseDeclaration = (AnnotationTypeDeclaration) environment
+ .getTypeDeclaration("org.jboss.portal.unit.annotations.TestCase");
+ }
+
+ public void process()
+ {
+ Collection<Declaration> declarations = environment
+ .getDeclarationsAnnotatedWith(testCaseDeclaration);
+ for (Declaration declaration : declarations) {
+ processAnnotations(declaration);
+ }
+ }
+
+ private void processAnnotations(Declaration declaration) {
+ // Get all of the annotation usage for this declaration.
+ // the annotation mirror is a reflection of what is in the source.
+
+ Collection<AnnotationMirror> annotations = declaration
+ .getAnnotationMirrors();
+ // iterate over the mirrors.
+ for (AnnotationMirror mirror : annotations) {
+ // if the mirror in this iteration is for our note declaration...
+
+ System.out.println("#Annotation processing... " +
mirror.getAnnotationType().getDeclaration().toString());
+
+ if(mirror.getAnnotationType().getDeclaration().equals(
+ testCaseDeclaration)) {
+
+
+ // print out the goodies.
+ Map<AnnotationTypeElementDeclaration, AnnotationValue> values =
mirror
+ .getElementValues();
+
+ for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>
entry : values
+ .entrySet()) {
+
+ Collection<AnnotationValue> annotationValues =
(Collection<AnnotationValue>)entry.getValue().getValue();
+
+ for (AnnotationValue value : annotationValues)
+ {
+
+ String tck = value.toString();
+
+ String[] parts = tck.split("\\.");
+
+ tck = parts[parts.length - 1];
+
+ Map<String, Set<String>> am = null;
+
+ if (tck.startsWith(jsr168AssertionPre))
+ {
+ am = jsr168Assertions;
+ }
+ else if (tck.startsWith(jsr286AssertionPre))
+ {
+ am = jsr286Assertions;
+ }
+ else
+ {
+ continue;
+ }
+
+
+ addAssertion(am, tck, declaration.toString());
+
+ System.out.println("#TCK: " + tck );
+
+ }
+ }
+ }
+ }
+
+
+ }
+
+ private void addAssertion(Map<String, Set<String>> map, String assertion,
String testCase)
+ {
+ if (map.get(assertion) != null)
+ {
+ Set<String> set = map.get(assertion);
+ set.add(testCase);
+ }
+ else
+ {
+ Set<String> set = new HashSet<String>();
+ set.add(testCase);
+ map.put(assertion, set);
+ }
+ }
+}