[webbeans-commits] Webbeans SVN: r1407 - tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Wed Feb 4 03:21:26 EST 2009
Author: shane.bryzak at jboss.com
Date: 2009-02-04 03:21:25 -0500 (Wed, 04 Feb 2009)
New Revision: 1407
Modified:
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java
tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java
Log:
fix section ordering, include @SpecAssertions
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java 2009-02-04 07:47:37 UTC (rev 1406)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/AuditParser.java 2009-02-04 08:21:25 UTC (rev 1407)
@@ -3,6 +3,7 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -51,6 +52,49 @@
return assertions;
}
+ public List<String> getSectionIds()
+ {
+ List<String> sectionIds = new ArrayList<String>(assertions.keySet());
+
+ Collections.sort(sectionIds, new Comparator<String>() {
+ public int compare(String value1, String value2)
+ {
+ String[] parts1 = value1.split("[.]");
+ String[] parts2 = value2.split("[.]");
+
+ for (int i = 0;;i++)
+ {
+ if (parts1.length < (i + 1))
+ {
+ return parts2.length < (i + 1) ? 0 : 0;
+ }
+ else if (parts2.length < (i + 1))
+ {
+ return parts1.length < (i + 1) ? 0 : 1;
+ }
+
+ try
+ {
+ int val1 = Integer.parseInt(parts1[i]);
+ int val2 = Integer.parseInt(parts2[i]);
+
+ if (val1 != val2) return val1 - val2;
+ }
+ catch (NumberFormatException ex)
+ {
+ int comp = parts1[i].compareTo(parts2[i]);
+ if (comp != 0)
+ {
+ return comp;
+ }
+ }
+ }
+ }
+ });
+
+ return sectionIds;
+ }
+
/**
* Returns a sorted list of assertions for the specified section ID
*
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java 2009-02-04 07:47:37 UTC (rev 1406)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageProcessor.java 2009-02-04 08:21:25 UTC (rev 1407)
@@ -6,6 +6,7 @@
import java.util.List;
import org.jboss.webbeans.tck.SpecAssertion;
+import org.jboss.webbeans.tck.SpecAssertions;
import com.sun.mirror.apt.AnnotationProcessor;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
@@ -64,6 +65,15 @@
new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
}
+ annotationType = (AnnotationTypeDeclaration)
+ env.getTypeDeclaration(SpecAssertions.class.getCanonicalName());
+ for (Declaration d : env.getDeclarationsAnnotatedWith(annotationType))
+ {
+ d.accept(DeclarationVisitors.getDeclarationScanner(
+ new CreateReferenceVisitor(), DeclarationVisitors.NO_OP));
+ }
+
+
new CoverageReport(references, auditParser).writeToFile(new File(baseDir, REPORT_FILE_NAME));
}
@@ -71,11 +81,26 @@
{
public void visitMethodDeclaration(MethodDeclaration d)
{
- SpecAssertion annotation = d.getAnnotation( SpecAssertion.class );
- SpecReference ref = new SpecReference(
- annotation.section(), annotation.id(),
- d.getDeclaringType().getSimpleName(), d.getSimpleName());
- references.add( ref );
+ SpecAssertions assertions = d.getAnnotation ( SpecAssertions.class );
+ if (assertions != null)
+ {
+ for (SpecAssertion assertion : assertions.value())
+ {
+ SpecReference ref = new SpecReference(
+ assertion.section(), assertion.id(),
+ d.getDeclaringType().getSimpleName(), d.getSimpleName());
+ references.add( ref );
+ }
+ }
+
+ SpecAssertion assertion = d.getAnnotation( SpecAssertion.class );
+ if (assertion != null)
+ {
+ SpecReference ref = new SpecReference(
+ assertion.section(), assertion.id(),
+ d.getDeclaringType().getSimpleName(), d.getSimpleName());
+ references.add( ref );
+ }
}
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java 2009-02-04 07:47:37 UTC (rev 1406)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/impl/report/CoverageReport.java 2009-02-04 08:21:25 UTC (rev 1407)
@@ -101,14 +101,11 @@
}
private void writeCoverage(OutputStream out) throws IOException
- {
- List<String> sectionIds = new ArrayList<String>(auditParser.getAssertions().keySet());
- Collections.sort(sectionIds);
-
- for (String sectionId : sectionIds)
+ {
+ for (String sectionId : auditParser.getSectionIds())
{
- out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " + auditParser.getSectionTitle(sectionId) +
- "</div>\n").getBytes());
+ out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " +
+ auditParser.getSectionTitle(sectionId) + "</div>\n").getBytes());
List<AuditAssertion> sectionAssertions = auditParser.getAssertionsForSection(sectionId);
@@ -180,7 +177,8 @@
StringBuilder sb = new StringBuilder();
sb.append("<h3>Unmatched tests</h3>\n");
- sb.append("<p>The following tests do not match any known assertions</p>");
+ sb.append(String.format("<p>The following %d tests do not match any known assertions:</p>",
+ unmatched.size()));
sb.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n");
sb.append(" <tr><th>Section</th><th>Assertion</th><th>Test Class</th><th>Test Method</th></tr>\n");
More information about the weld-commits
mailing list