Author: bdaw
Date: 2008-03-26 18:43:38 -0400 (Wed, 26 Mar 2008)
New Revision: 10383
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
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/TestCaseAnnotationProcessor.java
Log:
- Improve reports formatting
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-03-26
22:30:17 UTC (rev 10382)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-03-26
22:43:38 UTC (rev 10383)
@@ -1900,8 +1900,8 @@
" parameter must be the last entry in the parameter value array."),
EXT_PORTLET_RESPONSES_1(new EXT("PortletResponse"), "Test that
character encoding is ignored as specified by the spec in PLT.12.3.1"),
- EXT_PORTLET_RESPONSES_2(new EXT("PortletResponse"), "Not setting the
content type before getting a stream will use the content type defined\n" +
- " * by the portlet request response content type."),
+ EXT_PORTLET_RESPONSES_2(new EXT("PortletResponse"), "Not setting the
content type before getting a stream will use the content type defined" +
+ " by the portlet request response content type."),
EXT_PORTLET_RESPONSES_3(new EXT("PortletResponse"), "Test adding
coockies to response"),
EXT_PORTLET_RESPONSES_4(new EXT("PortletResponse"), "Test adding HTTP
headers"),
Modified:
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 2008-03-26
22:30:17 UTC (rev 10382)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/ResultProducingListener.java 2008-03-26
22:43:38 UTC (rev 10383)
@@ -43,14 +43,12 @@
{
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 static String api286File = "./target/apt-api286-testcases.csv";
+ public static String extFile = "./target/apt-ext-testcases.csv";
+
public void roundComplete(RoundCompleteEvent event)
{
if (event.getRoundState().finalRound())
@@ -66,18 +64,23 @@
if (!TestCaseAnnotationProcessor.jsr168Assertions.keySet().isEmpty())
{
- printTCKReport(TestCaseAnnotationProcessor.jsr168Assertions, jsr168File,
"JSR168_", jsr168Max);
+ printReport(TestCaseAnnotationProcessor.jsr168Assertions, jsr168File,
"JSR168_");
}
if (!TestCaseAnnotationProcessor.jsr286Assertions.keySet().isEmpty())
{
- printTCKReport(TestCaseAnnotationProcessor.jsr286Assertions, jsr286File,
"JSR286_", jsr286Max);
+ printReport(TestCaseAnnotationProcessor.jsr286Assertions, jsr286File,
"JSR286_");
}
if (!TestCaseAnnotationProcessor.api286Assertions.keySet().isEmpty())
{
- printAPIReport(TestCaseAnnotationProcessor.api286Assertions, api286File);
+ printReport(TestCaseAnnotationProcessor.api286Assertions, api286File,
TestCaseAnnotationProcessor.api286AssertionPre);
}
+
+ if (!TestCaseAnnotationProcessor.extAssertions.keySet().isEmpty())
+ {
+ printReport(TestCaseAnnotationProcessor.extAssertions, extFile,
TestCaseAnnotationProcessor.extAssertionPre);
+ }
}
catch (Exception e)
{
@@ -111,9 +114,7 @@
}
}
-
-
- private void printTCKReport(Map<String, Set<String>> map, String fileName,
String pre, int max) throws Exception
+ private void printReport(Map<String, Set<String>> map, String fileName,
String assertionPre) throws Exception
{
// Simple stats
@@ -124,162 +125,123 @@
int inactive = 0;
File f = new File(fileName);
-
+
Writer writer = new FileWriter(f, false);
StringBuilder output = new StringBuilder();
- for (int i = 1; i <= max; i++)
+
+ // Line 1
+ // Columns
+
+ output
+ .append("ASSERTION:,")
+ .append("REF:,")
+ .append("STATUS:,")
+ .append("TEST_CASES:,")
+ .append("DESCRIPTION:,");
+
+ output.append("\n");
+
+ List<Assertion> apiAssertions = getAssertions(assertionPre);
+
+ for (Assertion assertion : apiAssertions)
{
total++;
- String assertionName = pre + i;
+ String assertionName = assertion.name();
- Set<String> testCases = map.get(assertionName);
+ Set<String> tcs = map.get(assertionName);
+ String[] testCases = null;
+ if (tcs != null)
+ {
+ testCases = tcs.toArray(new String[tcs.size()]);
+ }
- // Grab Assertion object based on name
+ String description = assertion.getDescription().replaceAll(",", "
").trim();
- Assertion assertion = getAssertion(assertionName);
+ // Line 2
- String description = assertion != null ?
assertion.getDescription().replaceAll(",", " ").trim() :
"";
+ // ASSERTION:
+ output.append(assertionName).append(",");
+ // REF:
- if (assertion != null && assertion.getRef() != null)
+ if (assertion.getRef() != null)
{
-
output.append(assertionName).append(",").append(assertion.getRef().toString()).append('\n');
- output.append("DESCRIPTION:
,").append(description).append('\n');
+ output.append(assertion.getRef().toString()).append(",");
}
else
{
-
output.append(assertionName).append(",").append(description).append('\n');
+ output.append(",");
}
+ // STATUS:
- if (assertion != null && assertion.getStatus() != null)
+ if (assertion.getStatus() != null)
{
Assertion.Status status = assertion.getStatus();
- output.append("STATUS:,").append(status).append("\n");
+ output.append(status).append(",");
if (status instanceof Assertion.Inactive || status instanceof
Assertion.Duplicate)
{
inactive++;
}
}
-
-
- if (testCases != null)
- {
- tested++;
- for (String testCase : testCases)
- {
- output.append("TEST_CASE:
,").append(testCase).append("\n");
- }
- }
else
{
- not_tested++;
- output.append("TEST_CASE:,NOT_TESTED\n");
+ output.append(",");
}
- output.append(" ,\n");
- }
+ // TEST_CASES:
- output.append("\n\n");
+ if (testCases != null && testCases.length > 0)
+ {
+ tested++;
- writer.write("STATISTICS:,**************************\n");
- writer.write("TOTAL:," + total + "\n");
- writer.write("TESTED:," + tested + "\n");
- writer.write("NOT TESTED:," + not_tested + "\n");
- writer.write("INACTIVE:," + inactive + " (POSTPONED; TODO; DISABLED;
UNTESTABLE or DUPLICATE) \n");
- float ratio = (float)tested/(float)(total-inactive);
- writer.write("TESTED RATIO:," + ratio + " ( TESTED/(TOTAL-INACTIVE)
) \n");
+ output.append(shortenClassname(testCases[0])).append(",");
- writer.write("\n\n\n\n");
- writer.write(output.toString());
- writer.write("\n");
-
- writer.close();
- }
-
- private void printAPIReport(Map<String, Set<String>> map, String fileName)
throws Exception
- {
-
- // Simple stats
-
- int total = 0;
- int tested = 0;
- int not_tested = 0;
- int inactive = 0;
-
- File f = new File(fileName);
-
- Writer writer = new FileWriter(f, false);
-
- StringBuilder output = new StringBuilder();
-
- List<Assertion> apiAssertions = getApiAssertions();
-
- for (Assertion assertion : apiAssertions)
- {
- total++;
-
- String assertionName = assertion.name();
-
- Set<String> testCases = map.get(assertionName);
-
- String description = assertion.getDescription().replaceAll(",", "
").trim();
-
- if (assertion.getRef() != null)
- {
-
output.append(assertionName).append(",").append(assertion.getRef().toString()).append('\n');
- output.append("DESCRIPTION:
,").append(description).append('\n');
}
else
{
-
output.append(assertionName).append(",").append(description).append('\n');
+ not_tested++;
+ output.append("NOT_TESTED,");
}
+ // DESCRIPTION:
- if (assertion.getStatus() != null)
- {
- Assertion.Status status = assertion.getStatus();
- output.append("STATUS:,").append(status).append("\n");
+ output.append(description).append('\n');
- if (status instanceof Assertion.Inactive || status instanceof
Assertion.Duplicate)
- {
- inactive++;
- }
- }
+ // Rest of testcases
- if (testCases != null)
+ if (testCases != null && testCases.length > 1)
{
- tested++;
- for (String testCase : testCases)
+ for (int i = 1; i < testCases.length; i++)
{
- output.append("TEST_CASE:
,").append(testCase).append("\n");
+ String testCase = testCases[i];
+
output.append(",,,").append(shortenClassname(testCase)).append("\n");
}
}
- else
- {
- not_tested++;
- output.append("TEST_CASE:,NOT_TESTED\n");
- }
- output.append(" ,\n");
+ output.append("\n");
}
output.append("\n\n");
- writer.write("STATISTICS:,**************************\n");
+ writer.write("STATISTICS:,***\n");
writer.write("TOTAL:," + total + "\n");
writer.write("TESTED:," + tested + "\n");
writer.write("NOT TESTED:," + not_tested + "\n");
- writer.write("INACTIVE:," + inactive + " (POSTPONED; TODO; DISABLED;
UNTESTABLE or DUPLICATE) \n");
+
+ // (POSTPONED; TODO; DISABLED; UNTESTABLE or DUPLICATE)
+ writer.write("INACTIVE:," + inactive + "\n");
float ratio = (float)tested/(float)(total-inactive);
- writer.write("TESTED RATIO:," + ratio + " ( TESTED/(TOTAL-INACTIVE)
) \n");
+ // ( TESTED/(TOTAL-INACTIVE) )
+ writer.write("TESTED RATIO:," + ratio + "\n");
+
writer.write("\n\n\n\n");
writer.write(output.toString());
writer.write("\n");
@@ -287,7 +249,9 @@
writer.close();
}
- private List<Assertion> getApiAssertions()
+
+
+ private List<Assertion> getAssertions(String assertionPre)
{
List<Assertion> result = new LinkedList<Assertion>();
@@ -296,7 +260,7 @@
for (Assertion assertion : assertions)
{
- if
(assertion.name().startsWith(TestCaseAnnotationProcessor.api286AssertionPre))
+ if (assertion.name().startsWith(assertionPre))
{
result.add(assertion);
}
@@ -329,4 +293,33 @@
return null;
}
+
+ private String shortenClassname(String className)
+ {
+ if (className == null)
+ {
+ throw new IllegalArgumentException("null argument");
+ }
+
+ String[] parts = className.split("\\.");
+
+ StringBuffer packed = new StringBuffer();
+
+ for (int i = 0; i < parts.length; i++)
+ {
+ String part = parts[i];
+
+ if (i != parts.length - 1)
+ {
+ packed.append(part.substring(0,1)).append(".");
+ }
+ else
+ {
+ packed.append(part);
+ }
+ }
+
+
+ return packed.toString();
+ }
}
Modified:
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 2008-03-26
22:30:17 UTC (rev 10382)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/reports/TestCaseAnnotationProcessor.java 2008-03-26
22:43:38 UTC (rev 10383)
@@ -73,12 +73,16 @@
public static String api286AssertionPre = "API286_";
+ public static String extAssertionPre = "EXT_";
+
public static Map<String, Set<String>> jsr168Assertions = new
HashMap<String, Set<String>>();
public static Map<String, Set<String>> jsr286Assertions = new
HashMap<String, Set<String>>();
public static Map<String, Set<String>> api286Assertions = new
HashMap<String, Set<String>>();
+ public static Map<String, Set<String>> extAssertions = new
HashMap<String, Set<String>>();
+
//private int counter;
public TestCaseAnnotationProcessor(AnnotationProcessorEnvironment env) {
@@ -145,6 +149,10 @@
{
am = api286Assertions;
}
+ else if (tck.startsWith(extAssertionPre))
+ {
+ am = extAssertions;
+ }
else
{
continue;