34
34
* Main class for executing the JSR 354 TCK.
35
35
* Created by Anatole on 12.06.2014.
36
36
*/
37
- public class TCKRunner extends XmlSuite {
38
- public TCKRunner (){
37
+ public class TCKRunner extends XmlSuite {
38
+ public TCKRunner () {
39
39
setName ("JSR354-TCK 1.0" );
40
40
XmlTest test = new XmlTest (this );
41
41
test .setName ("TCK/Test Setup" );
@@ -55,7 +55,7 @@ public TCKRunner(){
55
55
test .setXmlClasses (classes );
56
56
}
57
57
58
- public static void main (String ... args ){
58
+ public static void main (String ... args ) {
59
59
System .out .println ("-- JSR 354 TCK started --" );
60
60
List <XmlSuite > suites = new ArrayList <>();
61
61
suites .add (new TCKRunner ());
@@ -72,7 +72,7 @@ public static void main(String... args){
72
72
System .out .println ("-- JSR 354 TCK finished --" );
73
73
}
74
74
75
- public static final class TCKReporter extends TestListenerAdapter {
75
+ public static final class TCKReporter extends TestListenerAdapter {
76
76
private int count = 0 ;
77
77
private int skipped = 0 ;
78
78
private int failed = 0 ;
@@ -81,101 +81,92 @@ public static final class TCKReporter extends TestListenerAdapter{
81
81
private StringWriter internalBuffer = new StringWriter (3000 );
82
82
private FileWriter w ;
83
83
84
- public TCKReporter (File file ){
85
- try {
86
- if (!file .exists ()){
84
+ public TCKReporter (File file ) {
85
+ try {
86
+ if (!file .exists ()) {
87
87
file .createNewFile ();
88
88
}
89
89
w = new FileWriter (file );
90
90
w .write ("*****************************************************************************************\n " );
91
91
w .write ("**** JSR 354 - Money & Currency, Technical Compatibility Kit, version 1.0\n " );
92
92
w .write ("*****************************************************************************************\n \n " );
93
- w .write ("Executed on " + new java .util .Date () +"\n \n " );
93
+ w .write ("Executed on " + new java .util .Date () + "\n \n " );
94
94
95
95
// System.out:
96
96
internalBuffer .write ("*****************************************************************************************\n " );
97
97
internalBuffer .write ("**** JSR 354 - Money & Currency, Technical Compatibility Kit, version 1.0\n " );
98
98
internalBuffer .write ("*****************************************************************************************\n \n " );
99
99
internalBuffer .write ("Executed on " + new java .util .Date () + "\n \n " );
100
- }
101
- catch (IOException e ){
100
+ } catch (IOException e ) {
102
101
e .printStackTrace ();
103
102
System .exit (-1 );
104
103
}
105
104
}
106
105
107
106
@ Override
108
- public void onTestFailure (ITestResult tr ){
107
+ public void onTestFailure (ITestResult tr ) {
109
108
failed ++;
110
- String location = tr .getTestClass ().getRealClass ().getSimpleName ()+ '#' + tr .getMethod ().getMethodName ();
111
- try {
109
+ String location = tr .getTestClass ().getRealClass ().getSimpleName () + '#' + tr .getMethod ().getMethodName ();
110
+ try {
112
111
Method realTestMethod = tr .getMethod ().getMethod ();
113
112
Test testAnnot = realTestMethod .getAnnotation (Test .class );
114
- if (testAnnot != null && testAnnot .description ()!= null && !testAnnot .description ().isEmpty ()){
115
- if (tr .getThrowable ()!= null ){
113
+ if (testAnnot != null && testAnnot .description () != null && !testAnnot .description ().isEmpty ()) {
114
+ if (tr .getThrowable () != null ) {
116
115
StringWriter sw = new StringWriter ();
117
116
PrintWriter w = new PrintWriter (sw );
118
117
tr .getThrowable ().printStackTrace (w );
119
118
w .flush ();
120
- log ("[FAILED] " + testAnnot .description () + "(" +location +"):\n " +sw .toString ());
121
- }
122
- else {
123
- log ("[FAILED] " + testAnnot .description ()+ "(" +location +")" );
119
+ log ("[FAILED] " + testAnnot .description () + "(" + location + "):\n " + sw .toString ());
120
+ } else {
121
+ log ("[FAILED] " + testAnnot .description () + "(" + location + ")" );
124
122
}
125
- }
126
- else {
123
+ } else {
127
124
128
- if (tr .getThrowable ()!= null ){
125
+ if (tr .getThrowable () != null ) {
129
126
StringWriter sw = new StringWriter ();
130
127
PrintWriter w = new PrintWriter (sw );
131
128
tr .getThrowable ().printStackTrace (w );
132
129
w .flush ();
133
- log ("[FAILED] " + location + ":\n " +sw .toString ());
134
- }
135
- else {
130
+ log ("[FAILED] " + location + ":\n " + sw .toString ());
131
+ } else {
136
132
log ("[FAILED] " + location );
137
133
}
138
134
}
139
- }
140
- catch (IOException e ){
135
+ } catch (IOException e ) {
141
136
throw new IllegalStateException ("IO Error" , e );
142
137
}
143
138
}
144
139
145
140
@ Override
146
- public void onTestSkipped (ITestResult tr ){
141
+ public void onTestSkipped (ITestResult tr ) {
147
142
skipped ++;
148
- String location = tr .getTestClass ().getRealClass ().getSimpleName ()+ '#' + tr .getMethod ().getMethodName ();
149
- try {
143
+ String location = tr .getTestClass ().getRealClass ().getSimpleName () + '#' + tr .getMethod ().getMethodName ();
144
+ try {
150
145
Method realTestMethod = tr .getMethod ().getMethod ();
151
146
Test specAssert = realTestMethod .getAnnotation (Test .class );
152
- if (specAssert !=null && specAssert .description ()!=null && !specAssert .description ().isEmpty ()){
153
- log ("[SKIPPED] " + specAssert .description ()+ "(" +location +")" );
154
- }
155
- else {
147
+ if (specAssert != null && specAssert .description () != null && !specAssert .description ().isEmpty ()) {
148
+ log ("[SKIPPED] " + specAssert .description () + "(" + location + ")" );
149
+ } else {
156
150
log ("[SKIPPED] " + location );
157
151
}
158
- }
159
- catch (IOException e ){
152
+ } catch (IOException e ) {
160
153
throw new IllegalStateException ("IO Error" , e );
161
154
}
162
155
}
163
156
164
157
@ Override
165
- public void onTestSuccess (ITestResult tr ){
158
+ public void onTestSuccess (ITestResult tr ) {
166
159
success ++;
167
- String location = tr .getTestClass ().getRealClass ().getSimpleName ()+ '#' + tr .getMethod ().getMethodName ();
168
- try {
160
+ String location = tr .getTestClass ().getRealClass ().getSimpleName () + '#' + tr .getMethod ().getMethodName ();
161
+ try {
169
162
Method realTestMethod = tr .getMethod ().getMethod ();
170
163
Test specAssert = realTestMethod .getAnnotation (Test .class );
171
- if (specAssert !=null && specAssert .description ()!=null && !specAssert .description ().isEmpty ()){
172
- log ("[SUCCESS] " + specAssert .description ()+ "(" +location +")" );
173
- }
174
- else {
164
+ if (specAssert != null && specAssert .description () != null && !specAssert .description ().isEmpty ()) {
165
+ log ("[SUCCESS] " + specAssert .description () + "(" + location + ")" );
166
+ } else {
175
167
log ("[SUCCESS] " + location );
176
168
}
177
- }
178
- catch (IOException e ){
169
+ } catch (IOException e ) {
179
170
throw new IllegalStateException ("IO Error" , e );
180
171
}
181
172
}
@@ -188,8 +179,8 @@ private void log(String text) throws IOException {
188
179
internalBuffer .write ('\n' );
189
180
}
190
181
191
- public void writeSummary (){
192
- try {
182
+ public void writeSummary () {
183
+ try {
193
184
log ("\n JSR 354 TCP version 1.0 Summary" );
194
185
log ("-------------------------------" );
195
186
log ("\n TOTAL TESTS EXECUTED : " + count );
@@ -201,8 +192,7 @@ public void writeSummary(){
201
192
internalBuffer .flush ();
202
193
System .out .println ();
203
194
System .out .println (internalBuffer );
204
- }
205
- catch (IOException e ){
195
+ } catch (IOException e ) {
206
196
throw new IllegalStateException ("IO Error" , e );
207
197
}
208
198
}
0 commit comments