You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by pr...@apache.org on 2006/11/13 15:52:58 UTC
svn commit: r474345 - in
/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/geronimo/
src/main/java/org/apache/geronimo/mavenplugins/ src/m...
Author: prasad
Date: Mon Nov 13 06:52:56 2006
New Revision: 474345
URL: http://svn.apache.org/viewvc?view=rev&rev=474345
Log:
* Plugin to help Geronimo testsuite
* surefire xml and reports are not generated for 'pom' packagings.
* 'generate-surefire-xml' goal generates a surefire xml for suite poms that invoke test poms.
* 'generate-surefire-report' goal generates surefire-report.html from the above xml
Added:
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/LICENSE.txt (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/NOTICE.txt (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/pom.xml (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestCase.java (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestSuite.java (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportGenerator.java (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportMojo.java (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportParser.java (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/surefire-report.properties (with props)
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/apt/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/apt/usage/
geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/site.xml (with props)
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/LICENSE.txt
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/LICENSE.txt?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/LICENSE.txt (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/LICENSE.txt Mon Nov 13 06:52:56 2006
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/LICENSE.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/LICENSE.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/NOTICE.txt
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/NOTICE.txt?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/NOTICE.txt (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/NOTICE.txt Mon Nov 13 06:52:56 2006
@@ -0,0 +1,5 @@
+Apache Geronimo
+Copyright 2006 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/NOTICE.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/NOTICE.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/pom.xml?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/pom.xml (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/pom.xml Mon Nov 13 06:52:56 2006
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<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.apache.geronimo.plugins</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>1.2-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>testsuite-maven-plugin</artifactId>
+ <name>Geronimo Maven2 Plugins :: Testsuite Plugin</name>
+ <packaging>maven-plugin</packaging>
+
+ <description> Plugin to help Geronimo testsuite </description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.geronimo.genesis.plugins</groupId>
+ <artifactId>plugin-support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-impl</artifactId>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <configuration>
+ <goalPrefix>geronimo</goalPrefix>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java Mon Nov 13 06:52:56 2006
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.geronimo.mavenplugins.testsuite;
+
+import java.io.File;
+import java.io.IOException;
+
+import java.util.ArrayList;
+
+import org.apache.geronimo.genesis.MojoSupport;
+import org.apache.geronimo.genesis.ant.AntHelper;
+
+import org.apache.maven.project.MavenProject;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.FileUtils;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Property;
+import org.apache.tools.ant.taskdefs.XmlProperty;
+
+/**
+ * Create a surefire xml file by concatenating the surefire xmls of the child poms that are invoked using maven-maven-plugin:invoke
+ *
+ * @goal generate-surefire-xml
+ *
+ * @version $Rev$ $Date$
+ */
+public class SurefireXMLGeneratorMojo
+ extends MojoSupport
+{
+ /**
+ * @component
+ */
+ protected AntHelper ant;
+
+ /**
+ * @parameter default-value="${project.build.directory}/surefire-reports"
+ * @read-only
+ */
+ private File currentReportsDirectory;
+
+ /**
+ * @parameter default-value="${project.basedir}"
+ * @read-only
+ */
+ private File currentBaseDirectory;
+
+ /**
+ * @parameter default-value="${project.parent.basedir}/target/surefire-reports"
+ * @read-only
+ */
+ private File parentReportsDirectory;
+
+ //
+ // MojoSupport Hooks
+ //
+
+ /**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project = null;
+
+ protected MavenProject getProject() {
+ return project;
+ }
+
+ protected void init() throws MojoExecutionException, MojoFailureException {
+ super.init();
+
+ ant.setProject(getProject());
+ }
+
+ protected void doExecute() throws Exception {
+
+ if (currentReportsDirectory == null) {
+ log.info("No surefire-reports directory here");
+ return;
+ }
+
+ String parent_tests = "0";
+ String parent_skipped = "0";
+ String parent_errors = "0";
+ String parent_failures = "0";
+ String parent_time = "0";
+
+ String artifactName = FileUtils.filename(currentBaseDirectory.getAbsolutePath());
+ parentReportsDirectory.mkdirs();
+ File parentSurefireXMLFile = new File(parentReportsDirectory, "TEST-" + artifactName + ".xml");
+
+ ArrayList xmlFiles = (ArrayList) FileUtils.getFiles(currentReportsDirectory, "TEST*.xml", null);
+ for (int i=0; i < xmlFiles.size(); i++) {
+ File xmlFile = (File) xmlFiles.get(i);
+ log.info("Loading surefire xml for xmlproperty: " + xmlFile.getAbsolutePath());
+
+ String prefix = String.valueOf(System.currentTimeMillis());
+ loadXMLProperty(xmlFile, prefix);
+
+ String tests = ant.getAnt().getProperty(prefix + ".testsuite.tests");
+ String skipped = ant.getAnt().getProperty(prefix + ".testsuite.skipped");
+ String errors = ant.getAnt().getProperty(prefix + ".testsuite.errors");
+ String failures = ant.getAnt().getProperty(prefix + ".testsuite.failures");
+ String time = ant.getAnt().getProperty(prefix + ".testsuite.time");
+ log.debug("tests=" + tests + "; skipped=" + skipped + ", errors=" + errors + ", failures=" + failures + ", time=" + time);
+
+ if (parentSurefireXMLFile.exists()) {
+ log.info("Loading parent surefire xml for xmlproperty");
+ String parentPrefix = "parent" + prefix;
+ loadXMLProperty(parentSurefireXMLFile, parentPrefix);
+
+ parent_tests = ant.getAnt().getProperty(parentPrefix + ".testsuite.tests");
+ parent_skipped = ant.getAnt().getProperty(parentPrefix + ".testsuite.skipped");
+ parent_errors = ant.getAnt().getProperty(parentPrefix + ".testsuite.errors");
+ parent_failures = ant.getAnt().getProperty(parentPrefix + ".testsuite.failures");
+ parent_time = ant.getAnt().getProperty(parentPrefix + ".testsuite.time");
+ log.debug("tests=" + parent_tests + "; skipped=" + parent_skipped + ", errors=" + parent_errors + ", failures=" + parent_failures + ", time=" + parent_time);
+ }
+
+ int testsNum = Integer.parseInt(parent_tests) + Integer.parseInt(tests);
+ int skippedNum = Integer.parseInt(parent_skipped) + Integer.parseInt(skipped);
+ int errorsNum = Integer.parseInt(parent_errors) + Integer.parseInt(errors);
+ int failuresNum = Integer.parseInt(parent_failures) + Integer.parseInt(failures);
+ float timeNum = Float.parseFloat(parent_time) + Float.parseFloat(time);
+
+ writeParentXML(testsNum,skippedNum,errorsNum,failuresNum,timeNum,artifactName,parentSurefireXMLFile);
+ }
+ }
+
+
+
+ /**
+ * http://ant.apache.org/manual/CoreTasks/xmlproperty.html
+ */
+ private void loadXMLProperty(File src, String prefix) {
+ XmlProperty xmlProperty = (XmlProperty)ant.createTask("xmlproperty");
+ xmlProperty.setFile(src);
+ if (prefix != null) {
+ xmlProperty.setPrefix(prefix);
+ }
+ xmlProperty.setCollapseAttributes(true);
+ xmlProperty.execute();
+ }
+
+
+ /**
+ * (over)writes the surefire xml file in the parent's surefire-reports dir
+ */
+ private void writeParentXML(int testsNum,int skippedNum,int errorsNum,
+ int failuresNum, float timeNum,
+ String artifactName, File parentSurefireXMLFile ) throws IOException {
+
+ final String header = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
+ String testSuite = "<testsuite errors=\"" + errorsNum + "\" skipped=\"" + skippedNum + "\" tests=\"" + testsNum + "\" time=\"" + timeNum + "\" failures=\"" + failuresNum + "\" name=\"" + artifactName + "#.\"/>";
+
+ String parentSurefireXMLFileName = parentSurefireXMLFile.getAbsolutePath();
+
+ log.debug(testSuite);
+
+ FileUtils.fileWrite(parentSurefireXMLFileName, header + "\n" + testSuite);
+
+ return;
+ }
+
+}
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestCase.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestCase.java?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestCase.java (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestCase.java Mon Nov 13 06:52:56 2006
@@ -0,0 +1,97 @@
+package org.apache.geronimo.mavenplugins.testsuite.report;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ReportTestCase
+{
+ private String fullClassName;
+
+ private String className;
+
+ private String fullName;
+
+ private String name;
+
+ private float time;
+
+ private Map failure;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getFullClassName()
+ {
+ return fullClassName;
+ }
+
+ public void setFullClassName( String name )
+ {
+ this.fullClassName = name;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName( String name )
+ {
+ this.className = name;
+ }
+
+ public float getTime()
+ {
+ return time;
+ }
+
+ public void setTime( float time )
+ {
+ this.time = time;
+ }
+
+ public Map getFailure()
+ {
+ return failure;
+ }
+
+ public String getFullName()
+ {
+ return fullName;
+ }
+
+ public void setFullName( String fullName )
+ {
+ this.fullName = fullName;
+ }
+
+ public void addFailure( String message, String type )
+ {
+ failure = new HashMap();
+ failure.put( "message", message );
+ failure.put( "type", type );
+ }
+}
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestCase.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestCase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestSuite.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestSuite.java?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestSuite.java (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestSuite.java Mon Nov 13 06:52:56 2006
@@ -0,0 +1,319 @@
+package org.apache.geronimo.mavenplugins.testsuite.report;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.File;
+import java.io.IOException;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+public class ReportTestSuite
+ extends DefaultHandler
+{
+ private List testCases;
+
+ private int numberOfErrors;
+
+ private int numberOfFailures;
+
+ private int numberOfSkipped;
+
+ private int numberOfTests;
+
+ private String name;
+
+ private String fullClassName;
+
+ private String packageName;
+
+ private float timeElapsed;
+
+ private NumberFormat numberFormat = NumberFormat.getInstance();
+
+ /**
+ * @noinspection StringBufferField
+ */
+ private StringBuffer currentElement;
+
+ private ReportTestCase testCase;
+
+ public void parse( String xmlPath )
+ throws ParserConfigurationException, SAXException, IOException
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+
+ SAXParser saxParser = factory.newSAXParser();
+
+ saxParser.parse( new File( xmlPath ), this );
+ }
+
+
+ private int getAttributeAsInt( Attributes attributes, String name )
+ {
+ // may or may not exist
+ String valueAsString = attributes.getValue( name );
+ if ( valueAsString != null )
+ {
+ return Integer.parseInt( valueAsString );
+ }
+ return 0;
+ }
+
+ public void startElement( String uri, String localName, String qName, Attributes attributes )
+ throws SAXException
+ {
+ try
+ {
+ if ( "testsuite".equals( qName ) )
+ {
+ numberOfErrors = getAttributeAsInt( attributes, "errors" );
+ numberOfFailures = getAttributeAsInt( attributes, "failures" );
+ numberOfSkipped = getAttributeAsInt( attributes, "skipped" );
+ numberOfTests = getAttributeAsInt( attributes, "tests" );
+
+ Number time = numberFormat.parse( attributes.getValue( "time" ) );
+
+ timeElapsed = time.floatValue();
+
+ //check if group attribute is existing
+ if ( attributes.getValue( "group" ) != null && !"".equals( attributes.getValue( "group" ) ) )
+ {
+ packageName = attributes.getValue( "group" );
+
+ name = attributes.getValue( "name" );
+
+ fullClassName = packageName + "." + name;
+ }
+ else
+ {
+ fullClassName = attributes.getValue( "name" );
+
+ name = fullClassName.substring( fullClassName.lastIndexOf( "." ) + 1, fullClassName.length() );
+
+ int lastDotPosition = fullClassName.lastIndexOf( "." );
+ if ( lastDotPosition < 0 )
+ {
+ /* no package name */
+ packageName = "";
+ }
+ else
+ {
+ packageName = fullClassName.substring( 0, lastDotPosition );
+ }
+ }
+
+ testCases = new ArrayList();
+ }
+ else if ( "testcase".equals( qName ) )
+ {
+ currentElement = new StringBuffer();
+
+ testCase = new ReportTestCase();
+
+ testCase.setFullClassName( fullClassName );
+
+ testCase.setName( attributes.getValue( "name" ) );
+
+ testCase.setClassName( name );
+
+ String timeAsString = attributes.getValue( "time" );
+
+ Number time = new Integer( 0 );
+
+ if ( timeAsString != null )
+ {
+ time = numberFormat.parse( timeAsString );
+ }
+
+ testCase.setTime( time.floatValue() );
+
+ testCase.setFullName( packageName + "." + name + "." + testCase.getName() );
+ }
+ else if ( "failure".equals( qName ) )
+ {
+ testCase.addFailure( attributes.getValue( "message" ), attributes.getValue( "type" ) );
+ }
+ else if ( "error".equals( qName ) )
+ {
+ testCase.addFailure( attributes.getValue( "message" ), attributes.getValue( "type" ) );
+ }
+ }
+ catch ( ParseException e )
+ {
+ throw new SAXException( e.getMessage(), e );
+ }
+ }
+
+ public void endElement( String uri, String localName, String qName )
+ throws SAXException
+ {
+ if ( "testcase".equals( qName ) )
+ {
+ testCases.add( testCase );
+ }
+ else if ( "failure".equals( qName ) )
+ {
+ Map failure = testCase.getFailure();
+
+ failure.put( "detail", parseCause( currentElement.toString() ) );
+ }
+ else if ( "error".equals( qName ) )
+ {
+ Map error = testCase.getFailure();
+
+ error.put( "detail", parseCause( currentElement.toString() ) );
+ }
+ }
+
+ public void characters( char[] ch, int start, int length )
+ throws SAXException
+ {
+ String s = new String( ch, start, length );
+
+ if ( ! "".equals( s.trim() ) )
+ {
+ currentElement.append( s );
+ }
+ }
+
+ public List getTestCases()
+ {
+ return this.testCases;
+ }
+
+ public int getNumberOfErrors()
+ {
+ return numberOfErrors;
+ }
+
+ public void setNumberOfErrors( int numberOfErrors )
+ {
+ this.numberOfErrors = numberOfErrors;
+ }
+
+ public int getNumberOfFailures()
+ {
+ return numberOfFailures;
+ }
+
+ public void setNumberOfFailures( int numberOfFailures )
+ {
+ this.numberOfFailures = numberOfFailures;
+ }
+
+ public int getNumberOfSkipped()
+ {
+ return numberOfSkipped;
+ }
+
+ public void setNumberOfSkipped( int numberOfSkipped )
+ {
+ this.numberOfSkipped = numberOfSkipped;
+ }
+
+ public int getNumberOfTests()
+ {
+ return numberOfTests;
+ }
+
+ public void setNumberOfTests( int numberOfTests )
+ {
+ this.numberOfTests = numberOfTests;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getFName()
+ {
+ return name;
+ }
+
+ public void setFName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getPackageName()
+ {
+ return packageName;
+ }
+
+ public void setPackageName( String packageName )
+ {
+ this.packageName = packageName;
+ }
+
+ public float getTimeElapsed()
+ {
+ return this.timeElapsed;
+ }
+
+ public void setTimeElapsed( float timeElapsed )
+ {
+ this.timeElapsed = timeElapsed;
+ }
+
+ private List parseCause( String detail )
+ {
+ String fullName = testCase.getFullName();
+ String name = fullName.substring( fullName.lastIndexOf( "." ) + 1 );
+ return parseCause( detail, name );
+ }
+
+ private List parseCause( String detail, String compareTo )
+ {
+ StringTokenizer stringTokenizer = new StringTokenizer( detail, "\n" );
+ List parsedDetail = new ArrayList( stringTokenizer.countTokens() );
+
+ while ( stringTokenizer.hasMoreTokens() )
+ {
+ String lineString = stringTokenizer.nextToken().trim();
+ parsedDetail.add( lineString );
+ if ( lineString.indexOf( compareTo ) >= 0 )
+ {
+ break;
+ }
+ }
+
+ return parsedDetail;
+ }
+
+ public void setTestCases( List testCases )
+ {
+ this.testCases = Collections.unmodifiableList( testCases );
+ }
+}
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestSuite.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestSuite.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/ReportTestSuite.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportGenerator.java?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportGenerator.java (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportGenerator.java Mon Nov 13 06:52:56 2006
@@ -0,0 +1,719 @@
+package org.apache.geronimo.mavenplugins.testsuite.report;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.doxia.sink.Sink;
+
+import java.io.File;
+import java.text.NumberFormat;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
+
+public class SurefireReportGenerator
+{
+ private SurefireReportParser report;
+
+ private List testSuites;
+
+ private boolean showSuccess;
+
+ private String xrefLocation;
+
+ public SurefireReportGenerator( File reportsDirectory, Locale locale, boolean showSuccess, String xrefLocation )
+ {
+ report = new SurefireReportParser( reportsDirectory, locale );
+
+ this.xrefLocation = xrefLocation;
+
+ this.showSuccess = showSuccess;
+ }
+
+ public void doGenerateReport( ResourceBundle bundle, Sink sink )
+ throws MavenReportException
+ {
+ testSuites = report.parseXMLReportFiles();
+
+ sink.head();
+
+ sink.text( bundle.getString( "report.surefire.description" ) );
+
+ StringBuffer str = new StringBuffer();
+ str.append( "<script type=\"text/javascript\">\n" );
+ str.append( "function toggleDisplay(elementId) {\n" );
+ str.append( " var elm = document.getElementById(elementId + 'error');\n" );
+ str.append( " if (elm && typeof elm.style != \"undefined\") {\n" );
+ str.append( " if (elm.style.display == \"none\") {\n" );
+ str.append( " elm.style.display = \"\";\n" );
+ str.append( " document.getElementById(elementId + 'off').style.display = \"none\";\n" );
+ str.append( " document.getElementById(elementId + 'on').style.display = \"inline\";\n" );
+ str.append( " }" );
+ str.append( " else if (elm.style.display == \"\") {" );
+ str.append( " elm.style.display = \"none\";\n" );
+ str.append( " document.getElementById(elementId + 'off').style.display = \"inline\";\n" );
+ str.append( " document.getElementById(elementId + 'on').style.display = \"none\";\n" );
+ str.append( " } \n" );
+ str.append( " } \n" );
+ str.append( " }\n" );
+ str.append( "</script>" );
+ sink.rawText( str.toString() );
+
+ sink.head_();
+
+ sink.body();
+
+ constructSummarySection( bundle, sink );
+
+ Map suitePackages = report.getSuitesGroupByPackage( testSuites );
+ if ( !suitePackages.isEmpty() )
+ {
+ constructPackagesSection( bundle, sink, suitePackages );
+ }
+
+ if ( !testSuites.isEmpty() )
+ {
+ constructTestCasesSection( bundle, sink );
+ }
+
+ List failureList = report.getFailureDetails( testSuites );
+ if ( !failureList.isEmpty() )
+ {
+ constructFailureDetails( sink, bundle, failureList );
+ }
+
+ sinkLineBreak( sink );
+
+ sink.body_();
+
+ sink.flush();
+
+ sink.close();
+ }
+
+ private void constructSummarySection( ResourceBundle bundle, Sink sink )
+ {
+ Map summary = report.getSummary( testSuites );
+
+ sink.sectionTitle1();
+
+ sinkAnchor( sink, "Summary" );
+
+ sink.text( bundle.getString( "report.surefire.label.summary" ) );
+
+ sink.sectionTitle1_();
+
+ constructHotLinks( sink, bundle );
+
+ sinkLineBreak( sink );
+
+ sink.table();
+
+ sink.tableRow();
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.tests" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.errors" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.failures" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.skipped" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.successrate" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.time" ) );
+
+ sink.tableRow_();
+
+ sink.tableRow();
+
+ sinkCell( sink, (String) summary.get( "totalTests" ) );
+
+ sinkCell( sink, (String) summary.get( "totalErrors" ) );
+
+ sinkCell( sink, (String) summary.get( "totalFailures" ) );
+
+ sinkCell( sink, (String) summary.get( "totalSkipped" ) );
+
+ sinkCell( sink, summary.get( "totalPercentage" ) + "%" );
+
+ sinkCell( sink, (String) summary.get( "totalElapsedTime" ) );
+
+ sink.tableRow_();
+
+ sink.table_();
+
+ sink.lineBreak();
+
+ sink.rawText( bundle.getString( "report.surefire.text.note1" ) );
+
+ sinkLineBreak( sink );
+ }
+
+ private void constructPackagesSection( ResourceBundle bundle, Sink sink, Map suitePackages )
+ {
+ NumberFormat numberFormat = report.getNumberFormat();
+
+ sink.sectionTitle1();
+
+ sinkAnchor( sink, "Package_List" );
+
+ sink.text( bundle.getString( "report.surefire.label.packagelist" ) );
+
+ sink.sectionTitle1_();
+
+ constructHotLinks( sink, bundle );
+
+ sinkLineBreak( sink );
+
+ sink.table();
+
+ sink.tableRow();
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.package" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.tests" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.errors" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.failures" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.skipped" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.successrate" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.time" ) );
+
+ sink.tableRow_();
+
+ Iterator packIter = suitePackages.keySet().iterator();
+
+ while ( packIter.hasNext() )
+ {
+ sink.tableRow();
+
+ String packageName = (String) packIter.next();
+
+ List testSuiteList = (List) suitePackages.get( packageName );
+
+ Map packageSummary = report.getSummary( testSuiteList );
+
+ sinkCellLink( sink, packageName, getLink(packageName) );
+
+ sinkCell( sink, (String) packageSummary.get( "totalTests" ) );
+
+ sinkCell( sink, (String) packageSummary.get( "totalErrors" ) );
+
+ sinkCell( sink, (String) packageSummary.get( "totalFailures" ) );
+
+ sinkCell( sink, (String) packageSummary.get( "totalSkipped" ) );
+
+ sinkCell( sink, packageSummary.get( "totalPercentage" ) + "%" );
+
+ sinkCell( sink, (String) packageSummary.get( "totalElapsedTime" ) );
+
+ sink.tableRow_();
+ }
+
+ sink.table_();
+
+ sink.lineBreak();
+
+ sink.rawText( bundle.getString( "report.surefire.text.note2" ) );
+
+ packIter = suitePackages.keySet().iterator();
+
+ while ( packIter.hasNext() )
+ {
+ String packageName = (String) packIter.next();
+
+ if (packageName.endsWith("#")) {
+ continue;
+ }
+
+ List testSuiteList = (List) suitePackages.get( packageName );
+
+ Iterator suiteIterator = testSuiteList.iterator();
+
+ sink.sectionTitle2();
+
+ sinkAnchor( sink, packageName );
+
+ sink.text( packageName );
+
+ sink.sectionTitle2_();
+
+ sink.table();
+
+ sink.tableRow();
+
+ sinkHeader( sink, "" );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.class" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.tests" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.errors" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.failures" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.skipped" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.successrate" ) );
+
+ sinkHeader( sink, bundle.getString( "report.surefire.label.time" ) );
+
+ sink.tableRow_();
+
+ while ( suiteIterator.hasNext() )
+ {
+ ReportTestSuite suite = (ReportTestSuite) suiteIterator.next();
+
+ if ( showSuccess || suite.getNumberOfErrors() != 0 || suite.getNumberOfFailures() != 0 )
+ {
+
+ sink.tableRow();
+
+ sink.tableCell();
+
+ sink.link( "#" + suite.getPackageName() + suite.getName() );
+
+ if ( suite.getNumberOfErrors() > 0 )
+ {
+ sinkIcon( "error", sink );
+ }
+ else if ( suite.getNumberOfFailures() > 0 )
+ {
+ sinkIcon( "junit.framework", sink );
+ }
+ else
+ {
+ sinkIcon( "success", sink );
+ }
+
+ sink.link_();
+
+ sink.tableCell_();
+
+ sinkCellLink( sink, suite.getName(), "#" + suite.getPackageName() + suite.getName() );
+
+ sinkCell( sink, Integer.toString( suite.getNumberOfTests() ) );
+
+ sinkCell( sink, Integer.toString( suite.getNumberOfErrors() ) );
+
+ sinkCell( sink, Integer.toString( suite.getNumberOfFailures() ) );
+
+ sinkCell( sink, Integer.toString( suite.getNumberOfSkipped() ) );
+
+ String percentage = report.computePercentage( suite.getNumberOfTests(), suite.getNumberOfErrors(),
+ suite.getNumberOfFailures(), suite
+ .getNumberOfSkipped() );
+ sinkCell( sink, percentage + "%" );
+
+ sinkCell( sink, numberFormat.format( suite.getTimeElapsed() ) );
+
+ sink.tableRow_();
+ }
+ }
+
+ sink.table_();
+ }
+
+ sinkLineBreak( sink );
+ }
+
+ private void constructTestCasesSection( ResourceBundle bundle, Sink sink )
+ {
+ NumberFormat numberFormat = report.getNumberFormat();
+
+ sink.sectionTitle1();
+
+ sinkAnchor( sink, "Test_Cases" );
+
+ sink.text( bundle.getString( "report.surefire.label.testcases" ) );
+
+ sink.sectionTitle1_();
+
+ constructHotLinks( sink, bundle );
+
+ ListIterator suiteIterator = testSuites.listIterator();
+
+ while ( suiteIterator.hasNext() )
+ {
+ ReportTestSuite suite = (ReportTestSuite) suiteIterator.next();
+ if ( suite.getPackageName().endsWith("#") ) {
+ continue;
+ }
+
+ List testCases = suite.getTestCases();
+
+ if ( testCases != null )
+ {
+ ListIterator caseIterator = testCases.listIterator();
+
+ sink.sectionTitle2();
+
+ sinkAnchor( sink, suite.getPackageName() + suite.getName() );
+
+ sink.text( suite.getName() );
+
+ sink.sectionTitle2_();
+
+ sink.table();
+
+ while ( caseIterator.hasNext() )
+ {
+ ReportTestCase testCase = (ReportTestCase) caseIterator.next();
+
+ if ( testCase.getFailure() != null || showSuccess )
+ {
+ sink.tableRow();
+
+ sink.tableCell();
+
+ Map failure = testCase.getFailure();
+
+ if ( failure != null )
+ {
+ sink.link( "#" + testCase.getFullName() );
+
+ sinkIcon( (String) failure.get( "type" ), sink );
+
+ sink.link_();
+ }
+ else
+ {
+ sinkIcon( "success", sink );
+ }
+
+ sink.tableCell_();
+
+ if ( failure != null )
+ {
+ sink.tableCell();
+
+ sinkLink( sink, testCase.getName(), "#" + testCase.getFullName() );
+
+ sink.rawText( " <div class=\"detailToggle\" style=\"display:inline\">" );
+
+ sink.link( "javascript:toggleDisplay('" + testCase.getName() + "');" );
+
+ sink.rawText( "<span style=\"display: inline;\" " + "id=\"" + testCase.getName() +
+ "off\">+</span><span id=\"" + testCase.getName() + "on\" " +
+ "style=\"display: none;\">-</span> " );
+ sink.text( "[ Detail ]" );
+ sink.link_();
+
+ sink.rawText( "</div>" );
+
+ sink.tableCell_();
+ }
+ else
+ {
+ sinkCell( sink, testCase.getName() );
+ }
+
+ sinkCell( sink, numberFormat.format( testCase.getTime() ) );
+
+ sink.tableRow_();
+
+ if ( failure != null )
+ {
+ sink.tableRow();
+
+ sinkCell( sink, "" );
+ sinkCell( sink, (String) failure.get( "message" ) );
+ sinkCell( sink, "" );
+ sink.tableRow_();
+
+ List detail = (List) failure.get( "detail" );
+ if ( detail != null )
+ {
+
+ sink.tableRow();
+ sinkCell( sink, "" );
+
+ sink.tableCell();
+ sink.rawText(
+ " <div id=\"" + testCase.getName() + "error\" style=\"display:none;\">" );
+
+ Iterator it = detail.iterator();
+
+ sink.verbatim( true );
+ while ( it.hasNext() )
+ {
+ sink.text( it.next().toString() );
+ sink.lineBreak();
+ }
+ sink.verbatim_();
+
+ sink.rawText( "</div>" );
+ sink.tableCell_();
+
+ sinkCell( sink, "" );
+
+ sink.tableRow_();
+ }
+ }
+ }
+ }
+
+ sink.table_();
+ }
+ }
+
+ sinkLineBreak( sink );
+ }
+
+ private void constructFailureDetails( Sink sink, ResourceBundle bundle, List failureList )
+ {
+ Iterator failIter = failureList.iterator();
+
+ if ( failIter != null )
+ {
+ sink.sectionTitle1();
+
+ sinkAnchor( sink, "Failure_Details" );
+
+ sink.text( bundle.getString( "report.surefire.label.failuredetails" ) );
+
+ sink.sectionTitle1_();
+
+ constructHotLinks( sink, bundle );
+
+ sinkLineBreak( sink );
+
+ sink.table();
+
+ while ( failIter.hasNext() )
+ {
+ ReportTestCase tCase = (ReportTestCase) failIter.next();
+
+ Map failure = tCase.getFailure();
+
+ sink.tableRow();
+
+ sink.tableCell();
+
+ String type = (String) failure.get( "type" );
+ sinkIcon( type, sink );
+
+ sink.tableCell_();
+
+ sinkCellAnchor( sink, tCase.getName(), tCase.getFullName() );
+
+ sink.tableRow_();
+
+ String message = (String) failure.get( "message" );
+
+ sink.tableRow();
+
+ sinkCell( sink, "" );
+
+ StringBuffer sb = new StringBuffer();
+ sb.append( type );
+
+ if ( message != null )
+ {
+ sb.append( ": " );
+ sb.append( message );
+ }
+
+ sinkCell( sink, sb.toString() );
+
+ sink.tableRow_();
+
+ List detail = (List) failure.get( "detail" );
+ if ( detail != null )
+ {
+ Iterator it = detail.iterator();
+
+ boolean firstLine = true;
+
+ String techMessage = "";
+ while ( it.hasNext() )
+ {
+ techMessage = it.next().toString();
+ if ( firstLine )
+ {
+ firstLine = false;
+ }
+ else
+ {
+ sink.text( " " );
+ }
+ }
+
+ sink.tableRow();
+
+ sinkCell( sink, "" );
+
+ sink.tableCell();
+ sink.rawText( " <div id=\"" + tCase.getName() + "error\" >" );
+
+ if ( xrefLocation != null )
+ {
+ String path = tCase.getFullClassName().replace( '.', '/' );
+
+ sink.link( xrefLocation + "/" + path + ".html#" +
+ getErrorLineNumber( tCase.getFullName(), techMessage ) );
+ }
+ sink.text(
+ tCase.getFullClassName() + ":" + getErrorLineNumber( tCase.getFullName(), techMessage ) );
+
+ if ( xrefLocation != null )
+ {
+ sink.link_();
+ }
+ sink.rawText( "</div>" );
+
+ sink.tableCell_();
+
+ sink.tableRow_();
+ }
+ }
+
+ sink.table_();
+ }
+
+ sinkLineBreak( sink );
+ }
+
+ private String getErrorLineNumber( String className, String source )
+ {
+ StringTokenizer tokenizer = new StringTokenizer( source );
+
+ String lineNo = "";
+
+ while ( tokenizer.hasMoreTokens() )
+ {
+ String token = tokenizer.nextToken();
+ if ( token.startsWith( className ) )
+ {
+ int idx = token.indexOf( ":" );
+ lineNo = token.substring( idx + 1, token.indexOf( ")" ) );
+ break;
+ }
+ }
+ return lineNo;
+ }
+
+ private void constructHotLinks( Sink sink, ResourceBundle bundle )
+ {
+ if ( !testSuites.isEmpty() )
+ {
+ sink.section2();
+
+ sink.rawText( "[" );
+ sinkLink( sink, bundle.getString( "report.surefire.label.summary" ), "#Summary" );
+ sink.rawText( "]" );
+
+ sink.rawText( "[" );
+ sinkLink( sink, bundle.getString( "report.surefire.label.packagelist" ), "#Package_List" );
+ sink.rawText( "]" );
+
+ sink.rawText( "[" );
+ sinkLink( sink, bundle.getString( "report.surefire.label.testcases" ), "#Test_Cases" );
+ sink.rawText( "]" );
+ sink.section2_();
+ }
+ }
+
+ private void sinkLineBreak( Sink sink )
+ {
+ sink.table();
+ sink.tableRow();
+ sink.tableRow_();
+ sink.tableRow();
+ sink.tableRow_();
+ sink.table_();
+ }
+
+ private void sinkIcon( String type, Sink sink )
+ {
+ sink.figure();
+
+ if ( type.startsWith( "junit.framework" ) )
+ {
+ sink.figureGraphics( "images/icon_warning_sml.gif" );
+ }
+ else if ( type.startsWith( "success" ) )
+ {
+ sink.figureGraphics( "images/icon_success_sml.gif" );
+ }
+ else
+ {
+ sink.figureGraphics( "images/icon_error_sml.gif" );
+ }
+
+ sink.figure_();
+ }
+
+ private void sinkHeader( Sink sink, String header )
+ {
+ sink.tableHeaderCell();
+ sink.text( header );
+ sink.tableHeaderCell_();
+ }
+
+ private void sinkCell( Sink sink, String text )
+ {
+ sink.tableCell();
+ sink.text( text );
+ sink.tableCell_();
+ }
+
+ private void sinkLink( Sink sink, String text, String link )
+ {
+ sink.link( link );
+ sink.text( text );
+ sink.link_();
+ }
+
+ private void sinkCellLink( Sink sink, String text, String link )
+ {
+ sink.tableCell();
+ sinkLink( sink, text, link );
+ sink.tableCell_();
+ }
+
+ private void sinkCellAnchor( Sink sink, String text, String anchor )
+ {
+ sink.tableCell();
+ sinkAnchor( sink, anchor );
+ sink.text( text );
+ sink.tableCell_();
+ }
+
+ private void sinkAnchor( Sink sink, String anchor )
+ {
+ sink.anchor( anchor );
+ sink.anchor_();
+ }
+
+ private String getLink(String link) {
+ if ( link.endsWith("#") ) {
+ int index = link.lastIndexOf("#");
+ return link.substring(0, index) + "/surefire-report.html";
+ }
+ return "#" + link;
+ }
+}
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportGenerator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportGenerator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportMojo.java?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportMojo.java (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportMojo.java Mon Nov 13 06:52:56 2006
@@ -0,0 +1,205 @@
+package org.apache.geronimo.mavenplugins.testsuite.report;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.doxia.site.renderer.SiteRenderer;
+import org.codehaus.plexus.util.PathTool;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+
+/**
+ * Creates a nicely formatted Surefire Test Report in html format.
+ *
+ * @author <a href="mailto:jruiz@exist.com">Johnny R. Ruiz III</a>
+ * @version $Id: SurefireReportMojo.java 433277 2006-08-21 16:28:06Z vsiveton $
+ * @goal generate-surefire-report
+ */
+public class SurefireReportMojo
+ extends AbstractMavenReport
+{
+ /**
+ * Location where generated html will be created.
+ *
+ * @parameter expression="${project.build.directory}/site"
+ */
+ private String outputDirectory;
+
+ /**
+ * Doxia Site Renderer
+ *
+ * @parameter expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}"
+ * @required @readonly
+ */
+ private SiteRenderer siteRenderer;
+
+ /**
+ * Maven Project
+ *
+ * @parameter expression="${project}"
+ * @required @readonly
+ */
+ private MavenProject project;
+
+ /**
+ * If set to false, only failures are shown.
+ *
+ * @parameter expression="${showSuccess}" default-value="true"
+ * @required
+ */
+ private boolean showSuccess;
+
+ /**
+ * This directory contains the XML Report files that will be parsed and rendered to HTML format.
+ *
+ * @parameter expression="${project.build.directory}/surefire-reports"
+ * @required
+ */
+ private File reportsDirectory;
+
+ /**
+ * The filename to use for the report.
+ *
+ * @parameter expression="${outputName}" default-value="surefire-report"
+ * @required
+ */
+ private String outputName;
+
+ /**
+ * Location of the Xrefs to link.
+ *
+ * @parameter default-value="${project.reporting.outputDirectory}/xref-test"
+ */
+ private File xrefLocation;
+
+ /**
+ * Whether to link the XRef if found.
+ *
+ * @parameter expression="${linkXRef}" default-value="true"
+ */
+ private boolean linkXRef;
+
+ public void executeReport( Locale locale )
+ throws MavenReportException
+ {
+ if ( !"pom".equalsIgnoreCase(project.getPackaging()) ) {
+ System.out.println("Not a pom packaging.");
+ return;
+ }
+
+ SurefireReportGenerator report =
+ new SurefireReportGenerator( reportsDirectory, locale, showSuccess, determineXrefLocation() );
+
+ report.doGenerateReport( getBundle( locale ), getSink() );
+
+ System.out.println("surefire-report.html generated.");
+ }
+
+ private String determineXrefLocation()
+ {
+ String location = null;
+
+ if ( linkXRef )
+ {
+ String relativePath = PathTool.getRelativePath( outputDirectory, xrefLocation.getAbsolutePath() );
+ if ( StringUtils.isEmpty( relativePath ) )
+ {
+ relativePath = ".";
+ }
+ relativePath = relativePath + "/" + xrefLocation.getName();
+ if ( xrefLocation.exists() )
+ {
+ // XRef was already generated by manual execution of a lifecycle binding
+ location = relativePath;
+ }
+ else
+ {
+ // Not yet generated - check if the report is on its way
+ for ( Iterator reports = project.getReportPlugins().iterator(); reports.hasNext(); )
+ {
+ ReportPlugin report = (ReportPlugin) reports.next();
+
+ String artifactId = report.getArtifactId();
+ if ( "maven-jxr-plugin".equals( artifactId ) || "jxr-maven-plugin".equals( artifactId ) )
+ {
+ location = relativePath;
+ }
+ }
+ }
+
+ if ( location == null )
+ {
+ getLog().warn( "Unable to locate Test Source XRef to link to - DISABLED" );
+ }
+ }
+ return location;
+ }
+
+ public String getName( Locale locale )
+ {
+ return getBundle( locale ).getString( "report.surefire.name" );
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return getBundle( locale ).getString( "report.surefire.description" );
+ }
+
+ protected SiteRenderer getSiteRenderer()
+ {
+ return siteRenderer;
+ }
+
+ protected MavenProject getProject()
+ {
+ return project;
+ }
+
+ public String getOutputName()
+ {
+ return outputName;
+ }
+
+ protected String getOutputDirectory()
+ {
+ return outputDirectory;
+ }
+
+ private ResourceBundle getBundle( Locale locale )
+ {
+ return ResourceBundle.getBundle( "surefire-report", locale, this.getClass().getClassLoader() );
+ }
+
+ /**
+ * @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
+ */
+ public boolean canGenerateReport()
+ {
+ // Only execute reports for java projects
+ ArtifactHandler artifactHandler = this.project.getArtifact().getArtifactHandler();
+ return "java".equals( artifactHandler.getLanguage() );
+ }
+}
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportMojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportParser.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportParser.java?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportParser.java (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportParser.java Mon Nov 13 06:52:56 2006
@@ -0,0 +1,275 @@
+package org.apache.geronimo.mavenplugins.testsuite.report;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.StringUtils;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Map;
+
+public class SurefireReportParser
+{
+ private NumberFormat numberFormat = NumberFormat.getInstance();
+
+ private File reportsDirectory;
+
+ private List testSuites = new ArrayList();
+
+ private Locale locale;
+
+ private static final int PCENT = 100;
+
+ public SurefireReportParser()
+ {
+ }
+
+ public SurefireReportParser( File reportsDirectory, Locale locale )
+ {
+ this.reportsDirectory = reportsDirectory;
+
+ setLocale( locale );
+ }
+
+ public List parseXMLReportFiles()
+ throws MavenReportException
+ {
+ if ( reportsDirectory.exists() )
+ {
+ String[] xmlReportFiles = getIncludedFiles( reportsDirectory, "*.xml", "*.txt" );
+
+ for ( int index = 0; index < xmlReportFiles.length; index++ )
+ {
+ ReportTestSuite testSuite = new ReportTestSuite();
+
+ String currentReport = xmlReportFiles[index];
+
+ try
+ {
+ testSuite.parse( reportsDirectory + "/" + currentReport );
+ }
+ catch ( ParserConfigurationException e )
+ {
+ throw new MavenReportException( "Error setting up parser for JUnit XML report", e );
+ }
+ catch ( SAXException e )
+ {
+ throw new MavenReportException( "Error parsing JUnit XML report " + currentReport, e );
+ }
+ catch ( IOException e )
+ {
+ throw new MavenReportException( "Error reading JUnit XML report " + currentReport, e );
+ }
+
+ testSuites.add( testSuite );
+ }
+ }
+
+ return testSuites;
+ }
+
+ protected String parseTestSuiteName( String lineString )
+ {
+ return lineString.substring( lineString.lastIndexOf( "." ) + 1, lineString.length() );
+ }
+
+ protected String parseTestSuitePackageName( String lineString )
+ {
+ return lineString.substring( lineString.indexOf( ":" ) + 2, lineString.lastIndexOf( "." ) );
+ }
+
+ protected String parseTestCaseName( String lineString )
+ {
+ return lineString.substring( 0, lineString.indexOf( "(" ) );
+ }
+
+ public Map getSummary( List suites )
+ {
+ Map totalSummary = new HashMap();
+
+ ListIterator iter = suites.listIterator();
+
+ int totalNumberOfTests = 0;
+
+ int totalNumberOfErrors = 0;
+
+ int totalNumberOfFailures = 0;
+
+ int totalNumberOfSkipped = 0;
+
+ float totalElapsedTime = 0.0f;
+
+ while ( iter.hasNext() )
+ {
+ ReportTestSuite suite = (ReportTestSuite) iter.next();
+
+ totalNumberOfTests += suite.getNumberOfTests();
+
+ totalNumberOfErrors += suite.getNumberOfErrors();
+
+ totalNumberOfFailures += suite.getNumberOfFailures();
+
+ totalNumberOfSkipped += suite.getNumberOfSkipped();
+
+ totalElapsedTime += suite.getTimeElapsed();
+ }
+
+ String totalPercentage = computePercentage( totalNumberOfTests, totalNumberOfErrors, totalNumberOfFailures,
+ totalNumberOfSkipped );
+
+ totalSummary.put( "totalTests", Integer.toString( totalNumberOfTests ) );
+
+ totalSummary.put( "totalErrors", Integer.toString( totalNumberOfErrors ) );
+
+ totalSummary.put( "totalFailures", Integer.toString( totalNumberOfFailures ) );
+
+ totalSummary.put( "totalSkipped", Integer.toString( totalNumberOfSkipped ) );
+
+ totalSummary.put( "totalElapsedTime", numberFormat.format( totalElapsedTime ) );
+
+ totalSummary.put( "totalPercentage", totalPercentage );
+
+ return totalSummary;
+ }
+
+ public void setReportsDirectory( File reportsDirectory )
+ {
+ this.reportsDirectory = reportsDirectory;
+ }
+
+ public File getReportsDirectory()
+ {
+ return this.reportsDirectory;
+ }
+
+ public final void setLocale( Locale locale )
+ {
+ this.locale = locale;
+ numberFormat = NumberFormat.getInstance( locale );
+ }
+
+ public Locale getLocale()
+ {
+ return this.locale;
+ }
+
+ public void setNumberFormat( NumberFormat numberFormat )
+ {
+ this.numberFormat = numberFormat;
+ }
+
+ public NumberFormat getNumberFormat()
+ {
+ return this.numberFormat;
+ }
+
+ public Map getSuitesGroupByPackage( List testSuitesList )
+ {
+ ListIterator iter = testSuitesList.listIterator();
+
+ Map suitePackage = new HashMap();
+
+ while ( iter.hasNext() )
+ {
+ ReportTestSuite suite = (ReportTestSuite) iter.next();
+
+ List suiteList = new ArrayList();
+
+ if ( suitePackage.get( suite.getPackageName() ) != null )
+ {
+ suiteList = (List) suitePackage.get( suite.getPackageName() );
+ }
+
+ suiteList.add( suite );
+
+ suitePackage.put( suite.getPackageName(), suiteList );
+ }
+
+ return suitePackage;
+ }
+
+ public String computePercentage( int tests, int errors, int failures, int skipped )
+ {
+ float percentage;
+ if ( tests == 0 )
+ {
+ percentage = 0;
+ }
+ else
+ {
+ percentage = ( (float) ( tests - errors - failures - skipped ) / (float) tests ) * PCENT;
+ }
+
+ return numberFormat.format( percentage );
+ }
+
+ public List getFailureDetails( List testSuitesList )
+ {
+ ListIterator iter = testSuitesList.listIterator();
+
+ List failureDetailList = new ArrayList();
+
+ while ( iter.hasNext() )
+ {
+ ReportTestSuite suite = (ReportTestSuite) iter.next();
+
+ List testCaseList = suite.getTestCases();
+
+ if ( testCaseList != null )
+ {
+ ListIterator caseIter = testCaseList.listIterator();
+
+ while ( caseIter.hasNext() )
+ {
+ ReportTestCase tCase = (ReportTestCase) caseIter.next();
+
+ if ( tCase.getFailure() != null )
+ {
+ failureDetailList.add( tCase );
+ }
+ }
+ }
+ }
+
+ return failureDetailList;
+ }
+
+ private String[] getIncludedFiles( File directory, String includes, String excludes )
+ {
+ DirectoryScanner scanner = new DirectoryScanner();
+
+ scanner.setBasedir( directory );
+
+ scanner.setIncludes( StringUtils.split( includes, "," ) );
+
+ scanner.setExcludes( StringUtils.split( excludes, "," ) );
+
+ scanner.scan();
+
+ return scanner.getIncludedFiles();
+ }
+}
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportParser.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/report/SurefireReportParser.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/surefire-report.properties
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/surefire-report.properties?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/surefire-report.properties (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/surefire-report.properties Mon Nov 13 06:52:56 2006
@@ -0,0 +1,18 @@
+report.surefire.name=Maven Surefire Report
+report.surefire.description=Report on the test results of the project.
+report.surefire.header=Maven Surefire Report
+report.surefire.label.summary=Summary
+report.surefire.label.tests=Tests
+report.surefire.label.errors=Errors
+report.surefire.label.failures=Failures
+report.surefire.label.skipped=Skipped
+report.surefire.label.successrate=Success Rate
+report.surefire.label.time=Time
+report.surefire.label.packagelist=Package List
+report.surefire.label.package=Package
+report.surefire.label.class=Class
+report.surefire.label.testcases=Test Cases
+report.surefire.label.failuredetails=Failure Details
+report.surefire.text.note1=Note: failures are anticipated and checked for with assertions while errors are unanticipated.
+report.surefire.text.note2=Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
+
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/surefire-report.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/surefire-report.properties
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/resources/surefire-report.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/site.xml?view=auto&rev=474345
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/site.xml (added)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/site.xml Mon Nov 13 06:52:56 2006
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<!-- $Rev$ Date$ -->
+
+<project name="${project.name}">
+
+ <body>
+
+ ${parentProject}
+
+ ${modules}
+
+ <menu name="${project.name}">
+ <item name="Overview" href="index.html"/>
+ <item name="Configuration" href="plugin-info.html"/>
+ </menu>
+
+ <menu name="Usage">
+ <item name="Server Goals" href="usage/server.html"/>
+ <item name="Module Goals" href="usage/modules.html"/>
+ </menu>
+
+ ${reports}
+
+ </body>
+
+</project>
+
+
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/site/site.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml