This project has retired. For details please refer to its
Attic page.
CmisTckAntTask xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.tck.runner;
20
21 import java.io.File;
22
23 import org.apache.chemistry.opencmis.tck.CmisTest;
24 import org.apache.chemistry.opencmis.tck.CmisTestGroup;
25 import org.apache.chemistry.opencmis.tck.CmisTestProgressMonitor;
26 import org.apache.chemistry.opencmis.tck.CmisTestReport;
27 import org.apache.chemistry.opencmis.tck.report.HtmlReport;
28 import org.apache.chemistry.opencmis.tck.report.TextReport;
29 import org.apache.chemistry.opencmis.tck.report.XmlReport;
30 import org.apache.tools.ant.BuildException;
31 import org.apache.tools.ant.Task;
32
33
34
35
36 public class CmisTckAntTask extends Task {
37
38 private static final String REPORT_TEXT = "text";
39 private static final String REPORT_XML = "xml";
40 private static final String REPORT_HTML = "html";
41
42 private static final String DEFAULT_REPORT_NAME = "cmis-tck-report";
43
44 private File parameters;
45 private File groups;
46 private File output;
47 private String format;
48
49 @Override
50 public void init() {
51 super.init();
52 parameters = null;
53 groups = null;
54 output = null;
55 format = REPORT_TEXT;
56 }
57
58 public void setParameters(File parameters) {
59 this.parameters = parameters;
60 }
61
62 public void setGroups(File groups) {
63 this.groups = groups;
64 }
65
66 public void setOutput(File output) {
67 this.output = output;
68 }
69
70 public void setFormat(String format) {
71 this.format = format;
72 }
73
74 @Override
75 public void execute() {
76 try {
77 AntRunner runner = new AntRunner();
78
79 if (parameters == null) {
80 runner.setParameters(null);
81 } else {
82 runner.loadParameters(parameters);
83 }
84
85 if (groups == null) {
86 runner.loadDefaultTckGroups();
87 } else {
88 runner.loadGroups(groups);
89 }
90
91 CmisTestReport report = null;
92
93 if (format == null) {
94 report = new TextReport();
95 if (output == null) {
96 output = new File(DEFAULT_REPORT_NAME + ".txt");
97 }
98 } else {
99 format = format.trim().toLowerCase();
100 if (REPORT_TEXT.equals(format)) {
101 report = new TextReport();
102 if (output == null) {
103 output = new File(DEFAULT_REPORT_NAME + ".txt");
104 }
105 } else if (REPORT_XML.equals(format)) {
106 report = new XmlReport();
107 if (output == null) {
108 output = new File(DEFAULT_REPORT_NAME + ".xml");
109 }
110 } else if (REPORT_HTML.equals(format)) {
111 report = new HtmlReport();
112 if (output == null) {
113 output = new File(DEFAULT_REPORT_NAME + ".html");
114 }
115 } else {
116 throw new Exception("Unknown format!");
117 }
118 }
119
120 runner.run(new AntProgressMonitor());
121
122 log("CMIS TCK Report: " + output.getAbsolutePath());
123 report.createReport(runner.getParameters(), runner.getGroups(), output);
124 } catch (Exception e) {
125 throw new BuildException("OpenCMIS TCK run failed!", e);
126 }
127 }
128
129 private static class AntRunner extends AbstractRunner {
130
131 }
132
133 private class AntProgressMonitor implements CmisTestProgressMonitor {
134 public void startGroup(CmisTestGroup group) {
135 log(group.getName() + " (" + group.getTests().size() + " tests)");
136 }
137
138 public void endGroup(CmisTestGroup group) {
139 }
140
141 public void startTest(CmisTest test) {
142 log(" " + test.getName());
143 }
144
145 public void endTest(CmisTest test) {
146 }
147
148 public void message(String msg) {
149 log(msg);
150 }
151 }
152 }