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 |
AbstractJavaTestCase subclass:#JavaRefTests
|
|
45 |
instanceVariableNames:''
|
|
46 |
classVariableNames:''
|
|
47 |
poolDictionaries:''
|
|
48 |
category:'Languages-Java-Tests-RuntimeConstantPool'
|
|
49 |
!
|
|
50 |
|
|
51 |
!JavaRefTests 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 |
!JavaRefTests methodsFor:'javaRef tests'!
|
|
99 |
|
|
100 |
testCorrectInstanceCreation
|
|
101 |
| javaRef |
|
|
102 |
|
|
103 |
javaRef := JavaRef2 new.
|
|
104 |
self assertFalse: (javaRef isResolved).
|
|
105 |
self assertTrue: (javaRef valueCache isNil).
|
|
106 |
self should: [ javaRef resolve ] raise: SubclassResponsibilityError.
|
|
107 |
self should: [ javaRef resolveStatic ] raise: SubclassResponsibilityError.
|
|
108 |
|
|
109 |
"Created: / 08-04-2011 / 11:40:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
110 |
"Modified: / 26-04-2011 / 13:21:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
111 |
!
|
|
112 |
|
|
113 |
testMockedInvalidating
|
|
114 |
| javaRefMock |
|
|
115 |
|
|
116 |
javaRefMock := JavaRefMock new.
|
|
117 |
self assertFalse: (javaRefMock isResolved).
|
|
118 |
self assertTrue: (javaRefMock valueCache isNil).
|
|
119 |
self assertTrue: (javaRefMock resolve = 'ok').
|
|
120 |
self assertTrue: (javaRefMock isResolved).
|
|
121 |
javaRefMock invalidate.
|
|
122 |
self assertFalse: (javaRefMock isResolved).
|
|
123 |
self assertTrue: (javaRefMock valueCache isNil).
|
|
124 |
self assertTrue: (javaRefMock resolveStatic = 'static').
|
|
125 |
self assertTrue: (javaRefMock isResolved).
|
|
126 |
javaRefMock invalidate.
|
|
127 |
self assertFalse: (javaRefMock isResolved).
|
|
128 |
self assertTrue: (javaRefMock valueCache isNil).
|
|
129 |
|
|
130 |
"Created: / 08-04-2011 / 11:50:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
131 |
"Modified: / 26-04-2011 / 13:21:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
132 |
!
|
|
133 |
|
|
134 |
testMockedInvalidatingForClassNegative
|
|
135 |
| javaRefMock |
|
|
136 |
|
|
137 |
javaRefMock := JavaRefMock new.
|
|
138 |
self assertTrue: (javaRefMock isResolved not).
|
|
139 |
javaRefMock resolve.
|
|
140 |
self assertTrue: (javaRefMock isResolved).
|
|
141 |
javaRefMock invalidateForClass: 'Ljava/lang/String;'.
|
|
142 |
self assertTrue: (javaRefMock isResolved).
|
|
143 |
javaRefMock invalidate.
|
|
144 |
self assertTrue: (javaRefMock isResolved not).
|
|
145 |
javaRefMock resolveStatic.
|
|
146 |
self assertTrue: (javaRefMock isResolved).
|
|
147 |
javaRefMock invalidateForClass: 'Ljava/lang/String;'.
|
|
148 |
self assertTrue: (javaRefMock isResolved).
|
|
149 |
|
|
150 |
"Created: / 08-04-2011 / 16:19:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
151 |
"Modified: / 26-04-2011 / 13:22:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
152 |
!
|
|
153 |
|
|
154 |
testMockedInvalidatingForClassPositive
|
|
155 |
| javaRefMock |
|
|
156 |
|
|
157 |
javaRefMock := JavaRefMock new.
|
|
158 |
self assertTrue: (javaRefMock isResolved not).
|
|
159 |
javaRefMock resolve.
|
|
160 |
self assertTrue: (javaRefMock isResolved).
|
|
161 |
javaRefMock invalidateForClass: 'mock'.
|
|
162 |
self assertTrue: (javaRefMock isResolved not).
|
|
163 |
javaRefMock resolveStatic.
|
|
164 |
self assertTrue: (javaRefMock isResolved).
|
|
165 |
javaRefMock invalidateForClass: 'mock'.
|
|
166 |
self assertTrue: (javaRefMock isResolved not).
|
|
167 |
|
|
168 |
"Created: / 08-04-2011 / 16:19:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
169 |
"Modified: / 26-04-2011 / 13:23:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
170 |
!
|
|
171 |
|
|
172 |
testMockedResolving
|
|
173 |
| javaRefMock |
|
|
174 |
|
|
175 |
javaRefMock := JavaRefMock new.
|
|
176 |
self assertFalse: (javaRefMock isResolved).
|
|
177 |
self assertTrue: (javaRefMock valueCache isNil).
|
|
178 |
self assertTrue: (javaRefMock resolve = 'ok').
|
|
179 |
self assertTrue: (javaRefMock isResolved).
|
|
180 |
|
|
181 |
"Created: / 08-04-2011 / 11:47:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
182 |
!
|
|
183 |
|
|
184 |
testMockedResolvingStatic
|
|
185 |
| javaRefMock |
|
|
186 |
|
|
187 |
javaRefMock := JavaRefMock new.
|
|
188 |
self assertFalse: (javaRefMock isResolved).
|
|
189 |
self assertTrue: (javaRefMock valueCache isNil).
|
|
190 |
self assertTrue: (javaRefMock resolveStatic = 'static').
|
|
191 |
self assertTrue: (javaRefMock isResolved).
|
|
192 |
|
|
193 |
"Created: / 26-04-2011 / 13:23:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
194 |
! !
|
|
195 |
|
|
196 |
!JavaRefTests class methodsFor:'documentation'!
|
|
197 |
|
|
198 |
version_SVN
|
2152
|
199 |
^ '$Id: JavaRefTests.st,v 1.1 2011-08-18 19:06:53 vrany Exp $'
|
|
200 |
! !
|