Lines 152-157
Link Here
|
152 |
} |
152 |
} |
153 |
|
153 |
|
154 |
/* |
154 |
/* |
|
|
155 |
* Ensures that the default value for an annotation method is correct. |
156 |
*/ |
157 |
public void testDefaultValue1() throws CoreException { |
158 |
try { |
159 |
String cuSource = |
160 |
"package p;\n" + |
161 |
"public @interface Y {\n" + |
162 |
" public String member() default \"abc\";\n" + |
163 |
"}"; |
164 |
createFile("/P/src/p/Y.java", cuSource); |
165 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
166 |
assertMemberValuePairEquals( |
167 |
"member=\"abc\"", |
168 |
method.getDefaultValue()); |
169 |
} finally { |
170 |
deleteFile("/P/src/p/Y.java"); |
171 |
} |
172 |
} |
173 |
|
174 |
/* |
175 |
* Ensures that the default value for an annotation method is correct. |
176 |
*/ |
177 |
public void testDefaultValue2() throws CoreException { |
178 |
try { |
179 |
String cuSource = |
180 |
"package p;\n" + |
181 |
"public @interface Y {\n" + |
182 |
" public int member() default 1;\n" + |
183 |
"}"; |
184 |
createFile("/P/src/p/Y.java", cuSource); |
185 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
186 |
assertMemberValuePairEquals( |
187 |
"member=(int)1", |
188 |
method.getDefaultValue()); |
189 |
} finally { |
190 |
deleteFile("/P/src/p/Y.java"); |
191 |
} |
192 |
} |
193 |
|
194 |
/* |
195 |
* Ensures that the default value for an annotation method is correct. |
196 |
*/ |
197 |
public void testDefaultValue3() throws CoreException { |
198 |
try { |
199 |
String cuSource = |
200 |
"package p;\n" + |
201 |
"public @interface Y {\n" + |
202 |
" public int member();\n" + |
203 |
"}"; |
204 |
createFile("/P/src/p/Y.java", cuSource); |
205 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
206 |
assertMemberValuePairEquals( |
207 |
"<null>", |
208 |
method.getDefaultValue()); |
209 |
} finally { |
210 |
deleteFile("/P/src/p/Y.java"); |
211 |
} |
212 |
} |
213 |
|
214 |
/* |
215 |
* Ensures that the default value for a non annotation method is correct. |
216 |
*/ |
217 |
public void testDefaultValue4() throws CoreException { |
218 |
try { |
219 |
String cuSource = |
220 |
"package p;\n" + |
221 |
"public class Y {\n" + |
222 |
" public int member() {}\n" + |
223 |
"}"; |
224 |
createFile("/P/src/p/Y.java", cuSource); |
225 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
226 |
assertMemberValuePairEquals( |
227 |
"<null>", |
228 |
method.getDefaultValue()); |
229 |
} finally { |
230 |
deleteFile("/P/src/p/Y.java"); |
231 |
} |
232 |
} |
233 |
|
234 |
/* |
235 |
* Ensures that the default value for an annotation method is correct. |
236 |
*/ |
237 |
public void testDefaultValue5() throws CoreException { |
238 |
try { |
239 |
String cuSource = |
240 |
"package p;\n" + |
241 |
"public @interface Y {\n" + |
242 |
" public String member() default \"abc\" + 1;\n" + |
243 |
"}"; |
244 |
createFile("/P/src/p/Y.java", cuSource); |
245 |
IMethod method = getCompilationUnit("/P/src/p/Y.java").getType("Y").getMethod("member", new String[0]); |
246 |
assertMemberValuePairEquals( |
247 |
"member=<null>", |
248 |
method.getDefaultValue()); |
249 |
} finally { |
250 |
deleteFile("/P/src/p/Y.java"); |
251 |
} |
252 |
} |
253 |
|
254 |
/* |
155 |
* Ensure that the deprecated flag is correctly reported |
255 |
* Ensure that the deprecated flag is correctly reported |
156 |
* (regression test fo bug 23207 Flags.isDeprecated(IMethod.getFlags()) doesn't work) |
256 |
* (regression test fo bug 23207 Flags.isDeprecated(IMethod.getFlags()) doesn't work) |
157 |
*/ |
257 |
*/ |