749
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
4 |
SWING Research Group, Czech Technical University in Prague
|
|
5 |
|
|
6 |
Parts of the code written by Claus Gittinger are under following
|
|
7 |
license:
|
|
8 |
|
|
9 |
This software is furnished under a license and may be used
|
|
10 |
only in accordance with the terms of that license and with the
|
|
11 |
inclusion of the above copyright notice. This software may not
|
|
12 |
be provided or otherwise made available to, or used by, any
|
|
13 |
other person. No title to or ownership of the software is
|
|
14 |
hereby transferred.
|
|
15 |
|
|
16 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
17 |
|
|
18 |
Permission is hereby granted, free of charge, to any person
|
|
19 |
obtaining a copy of this software and associated documentation
|
|
20 |
files (the 'Software'), to deal in the Software without
|
|
21 |
restriction, including without limitation the rights to use,
|
|
22 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23 |
copies of the Software, and to permit persons to whom the
|
|
24 |
Software is furnished to do so, subject to the following
|
|
25 |
conditions:
|
|
26 |
|
|
27 |
The above copyright notice and this permission notice shall be
|
|
28 |
included in all copies or substantial portions of the Software.
|
|
29 |
|
|
30 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
31 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
32 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
33 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
34 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
35 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
36 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
37 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
38 |
|
|
39 |
[1] Code written at SWING Research Group contain a signature
|
|
40 |
of one of the above copright owners.
|
|
41 |
"
|
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
|
44 |
JavaTestCaseProxy subclass:#TestletTestCaseProxy
|
|
45 |
instanceVariableNames:'harness'
|
|
46 |
classVariableNames:'TestCases'
|
|
47 |
poolDictionaries:''
|
|
48 |
category:'Languages-Java-Tests-Proxies'
|
|
49 |
!
|
|
50 |
|
|
51 |
!TestletTestCaseProxy class methodsFor:'documentation'!
|
|
52 |
|
|
53 |
copyright
|
|
54 |
"
|
|
55 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
56 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
57 |
SWING Research Group, Czech Technical University in Prague
|
|
58 |
|
|
59 |
Parts of the code written by Claus Gittinger are under following
|
|
60 |
license:
|
|
61 |
|
|
62 |
This software is furnished under a license and may be used
|
|
63 |
only in accordance with the terms of that license and with the
|
|
64 |
inclusion of the above copyright notice. This software may not
|
|
65 |
be provided or otherwise made available to, or used by, any
|
|
66 |
other person. No title to or ownership of the software is
|
|
67 |
hereby transferred.
|
|
68 |
|
|
69 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
70 |
|
|
71 |
Permission is hereby granted, free of charge, to any person
|
|
72 |
obtaining a copy of this software and associated documentation
|
|
73 |
files (the 'Software'), to deal in the Software without
|
|
74 |
restriction, including without limitation the rights to use,
|
|
75 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
76 |
copies of the Software, and to permit persons to whom the
|
|
77 |
Software is furnished to do so, subject to the following
|
|
78 |
conditions:
|
|
79 |
|
|
80 |
The above copyright notice and this permission notice shall be
|
|
81 |
included in all copies or substantial portions of the Software.
|
|
82 |
|
|
83 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
84 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
85 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
86 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
87 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
88 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
89 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
90 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
91 |
|
|
92 |
[1] Code written at SWING Research Group contain a signature
|
|
93 |
of one of the above copright owners.
|
|
94 |
|
|
95 |
"
|
|
96 |
! !
|
|
97 |
|
|
98 |
!TestletTestCaseProxy class methodsFor:'accessing'!
|
|
99 |
|
|
100 |
lookupHierarchyRoot
|
|
101 |
^ TestletTestCaseProxy
|
|
102 |
|
|
103 |
"Created: / 01-03-2011 / 11:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
104 |
"Modified: / 01-03-2011 / 14:54:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
105 |
"Modified: / 29-04-2011 / 10:25:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
106 |
!
|
|
107 |
|
|
108 |
selector: aSymbol
|
|
109 |
|
|
110 |
^super selector: aSymbol
|
|
111 |
|
|
112 |
"Created: / 01-03-2011 / 11:55:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
113 |
! !
|
|
114 |
|
|
115 |
!TestletTestCaseProxy class methodsFor:'private'!
|
|
116 |
|
|
117 |
testSelectors
|
|
118 |
"testlet always has only one test method, but maybe for the future.."
|
|
119 |
|
|
120 |
^ #( #'test(Lgnu/testlet/TestHarness;)V' ).
|
|
121 |
|
|
122 |
"Created: / 01-03-2011 / 10:49:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
123 |
"Modified: / 03-03-2011 / 00:34:39 / Marcel Hlopko <hlopik@gmail.com>"
|
|
124 |
"Modified: / 29-05-2011 / 22:54:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
125 |
"Modified: / 09-08-2011 / 16:31:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
126 |
! !
|
|
127 |
|
|
128 |
!TestletTestCaseProxy class methodsFor:'queries'!
|
|
129 |
|
|
130 |
isTestlet
|
|
131 |
^ true
|
|
132 |
|
|
133 |
! !
|
|
134 |
|
|
135 |
!TestletTestCaseProxy class methodsFor:'subclass creation'!
|
|
136 |
|
|
137 |
for: javaClass
|
|
138 |
"Answers a new (anonymous) testcase proxy for
|
|
139 |
given javaClass"
|
|
140 |
|
|
141 |
self assert: javaClass isJavaClass description: 'Not a java class'.
|
|
142 |
self assert: javaClass isTestletLike
|
|
143 |
description: 'Not a testcase-like class'.
|
|
144 |
^self forClassNamed: javaClass name
|
|
145 |
|
|
146 |
"Created: / 01-03-2011 / 10:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
147 |
"Modified: / 03-03-2011 / 00:20:49 / Marcel Hlopko <hlopik@gmail.com>"
|
|
148 |
"Modified: / 29-04-2011 / 10:21:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
149 |
"Modified: / 21-06-2011 / 17:08:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
150 |
! !
|
|
151 |
|
|
152 |
!TestletTestCaseProxy methodsFor:'accessing'!
|
|
153 |
|
|
154 |
nameForHDTestReport
|
|
155 |
|
|
156 |
^(self class javaClassName copyReplaceAll:$/ with: $.) copyTo: (self class javaClassName lastIndexOf: $/) - 1.
|
|
157 |
|
|
158 |
"Created: / 01-04-2011 / 16:10:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
159 |
|
|
160 |
!
|
|
161 |
|
|
162 |
selectorForHDTestReport
|
|
163 |
|
|
164 |
^self class javaClassName copyFrom:
|
|
165 |
(self class javaClassName lastIndexOf: $/) + 1
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
! !
|
|
170 |
|
|
171 |
!TestletTestCaseProxy methodsFor:'error handling'!
|
|
172 |
|
|
173 |
doesNotUnderstand: msg
|
|
174 |
|
|
175 |
"Here, we have to emulate stx.libjava.tests.TestHarness.Proxy interface..."
|
|
176 |
| sel |
|
|
177 |
|
|
178 |
sel := msg selector.
|
|
179 |
(sel includes:$() ifTrue:[
|
|
180 |
sel == #'check(Z)V' ifTrue:[
|
|
181 |
^self assert: msg arg1 == 1 description: ('Assertion failed (checkpoint: %1)' bindWith: self checkPointName).
|
|
182 |
].
|
|
183 |
sel == #'message(Ljava/lang/String;I)V' ifTrue:[
|
|
184 |
| text type |
|
|
185 |
text := Java as_ST_String: msg arg1.
|
|
186 |
type := msg arguments at: 2.
|
|
187 |
^self message: text type: type.
|
|
188 |
].
|
|
189 |
sel == #'directory(I)Ljava/lang/String;' ifTrue:[
|
|
190 |
^Java as_String: (self directory: msg arg1) asString.
|
|
191 |
].
|
|
192 |
].
|
|
193 |
^super doesNotUnderstand: msg
|
|
194 |
|
|
195 |
"Created: / 31-05-2011 / 16:30:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
196 |
! !
|
|
197 |
|
|
198 |
!TestletTestCaseProxy methodsFor:'private'!
|
|
199 |
|
|
200 |
checkPointName
|
|
201 |
|
|
202 |
| jstring |
|
|
203 |
jstring := harness instVarNamed: #checkPoint.
|
|
204 |
^jstring notNil ifTrue:[
|
|
205 |
Java as_ST_String: jstring
|
|
206 |
] ifFalse:[
|
|
207 |
'<no checkpoint set>'
|
|
208 |
]
|
|
209 |
|
|
210 |
"Modified: / 29-04-2011 / 10:52:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
211 |
"Created: / 09-08-2011 / 12:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
212 |
!
|
|
213 |
|
|
214 |
createHarness
|
|
215 |
|
|
216 |
harness := (Java classForName: 'stx.libjava.tests.TestHarness') new.
|
|
217 |
harness instVarNamed: #proxy put: self.
|
|
218 |
|
|
219 |
"Modified: / 29-04-2011 / 10:52:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
220 |
"Created: / 09-08-2011 / 11:29:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
221 |
!
|
|
222 |
|
|
223 |
performTest
|
|
224 |
| handlerBlock |
|
|
225 |
|
|
226 |
handlerBlock := [:ex | TestResult failure sunitSignalWith: ex description].
|
|
227 |
|
|
228 |
self createHarness.
|
|
229 |
|
|
230 |
[ JavaVM unimplementedNativeMethodSignal
|
|
231 |
handle:
|
|
232 |
handlerBlock
|
|
233 |
do: [
|
|
234 |
self javaClass new
|
|
235 |
perform: 'test(Lgnu/testlet/TestHarness;)V' sunitAsSymbol
|
|
236 |
with: harness
|
|
237 |
].
|
|
238 |
] on: JavaError do: [:ex |
|
|
239 |
TestResult failure sunitSignalWith: ex description
|
|
240 |
].
|
|
241 |
|
|
242 |
"/((harness instVarNamed: 'passed') = 0 ) ifTrue: [ TestResult failure sunitSignalWith: 'Test failed' ].
|
|
243 |
|
|
244 |
"Created: / 01-03-2011 / 14:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
245 |
"Modified: / 29-05-2011 / 23:19:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
246 |
"Modified: / 09-08-2011 / 12:13:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
247 |
! !
|
|
248 |
|
|
249 |
!TestletTestCaseProxy methodsFor:'private - Proxy interface'!
|
|
250 |
|
|
251 |
directory: type
|
|
252 |
"
|
|
253 |
public static final int DIR_TMP = 1;
|
|
254 |
public static final int DIR_SRC = 2;
|
|
255 |
public static final int DIR_RES = 3;
|
|
256 |
public static final int DIR_BLD = 4;
|
|
257 |
"
|
|
258 |
|
|
259 |
type == 1 ifTrue:[
|
|
260 |
^Filename newTemporaryDirectory.
|
|
261 |
] ifFalse:[type == 2 ifTrue:[
|
|
262 |
^JavaTestsResource classpathForMauve anyOne asFilename directory / 'src'
|
|
263 |
] ifFalse:[type == 3 ifTrue:[
|
|
264 |
^self error:'DIR_RES not yet implemented'
|
|
265 |
] ifFalse:[type == 4 ifTrue:[
|
|
266 |
^JavaTestsResource classpathForMauve anyOne asFilename
|
|
267 |
] ifFalse:[
|
|
268 |
^self error:'Unknown type code'
|
|
269 |
]]]].
|
|
270 |
|
|
271 |
"Created: / 10-08-2011 / 15:03:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
272 |
!
|
|
273 |
|
|
274 |
message:msg type: type
|
|
275 |
"
|
|
276 |
public static final int MSG_DBG = 1;
|
|
277 |
public static final int MSG_INF = 2;
|
|
278 |
public static final int MSG_ERR = 3;
|
|
279 |
"
|
|
280 |
type == 1 ifTrue:[Transcript showCR:' Testlet [DBG]: '] ifFalse:[
|
|
281 |
type == 2 ifTrue:[Transcript showCR:' Testlet [INF]: '] ifFalse:[
|
|
282 |
type == 3 ifTrue:[Transcript showCR:' Testlet [ERR]: '] ifFalse:[
|
|
283 |
Transcript showCR:' Testlet [???]: ']]].
|
|
284 |
Transcript showCR: msg.
|
|
285 |
type == 3 ifTrue:[self error: msg].
|
|
286 |
|
|
287 |
"Created: / 10-08-2011 / 15:06:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
288 |
! !
|
|
289 |
|
|
290 |
!TestletTestCaseProxy class methodsFor:'documentation'!
|
|
291 |
|
|
292 |
version_SVN
|
2152
|
293 |
^ '$Id: TestletTestCaseProxy.st,v 1.1 2011-08-18 19:06:53 vrany Exp $'
|
|
294 |
! !
|