2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package test
.codemaker
.javamaker
;
21 import com
.sun
.star
.comp
.helper
.Bootstrap
;
22 import com
.sun
.star
.lang
.XEventListener
;
23 import com
.sun
.star
.uno
.Any
;
24 import com
.sun
.star
.uno
.DeploymentException
;
25 import com
.sun
.star
.uno
.Type
;
26 import com
.sun
.star
.uno
.XComponentContext
;
27 import com
.sun
.star
.uno
.XNamingService
;
28 import complexlib
.ComplexTestCase
;
29 import java
.util
.EventListener
;
30 import test
.codemaker
.javamaker
.Enum1
;
31 import test
.codemaker
.javamaker
.Enum2
;
32 import test
.codemaker
.javamaker
.PolyStruct
;
33 import test
.codemaker
.javamaker
.S2
;
34 import test
.codemaker
.javamaker
.Struct2
;
35 import test
.codemaker
.javamaker
.services
.service_abstract
;
36 import test
.codemaker
.javamaker
.services
.service_assert
;
37 import test
.codemaker
.javamaker
.services
.service_break
;
38 import test
.codemaker
.javamaker
.services
.service_catch
;
39 import test
.codemaker
.javamaker
.services
.service_class
;
40 import test
.codemaker
.javamaker
.services
.service_continue
;
41 import test
.codemaker
.javamaker
.services
.service_do
;
42 import test
.codemaker
.javamaker
.services
.service_else
;
43 import test
.codemaker
.javamaker
.services
.service_extends
;
44 import test
.codemaker
.javamaker
.services
.service_final
;
45 import test
.codemaker
.javamaker
.services
.service_finally
;
46 import test
.codemaker
.javamaker
.services
.service_for
;
47 import test
.codemaker
.javamaker
.services
.service_goto
;
48 import test
.codemaker
.javamaker
.services
.service_if
;
49 import test
.codemaker
.javamaker
.services
.service_implements
;
50 import test
.codemaker
.javamaker
.services
.service_import
;
51 import test
.codemaker
.javamaker
.services
.service_instanceof
;
52 import test
.codemaker
.javamaker
.services
.service_int
;
53 import test
.codemaker
.javamaker
.services
.service_native
;
54 import test
.codemaker
.javamaker
.services
.service_new
;
55 import test
.codemaker
.javamaker
.services
.service_package
;
56 import test
.codemaker
.javamaker
.services
.service_private
;
57 import test
.codemaker
.javamaker
.services
.service_protected
;
58 import test
.codemaker
.javamaker
.services
.service_public
;
59 import test
.codemaker
.javamaker
.services
.service_return
;
60 import test
.codemaker
.javamaker
.services
.service_static
;
61 import test
.codemaker
.javamaker
.services
.service_strictfp
;
62 import test
.codemaker
.javamaker
.services
.service_super
;
63 import test
.codemaker
.javamaker
.services
.service_synchronized
;
64 import test
.codemaker
.javamaker
.services
.service_this
;
65 import test
.codemaker
.javamaker
.services
.service_throw
;
66 import test
.codemaker
.javamaker
.services
.service_throws
;
67 import test
.codemaker
.javamaker
.services
.service_try
;
68 import test
.codemaker
.javamaker
.services
.service_volatile
;
69 import test
.codemaker
.javamaker
.services
.service_while
;
70 import test
.codemaker
.javamaker
.singleton_abstract
;
72 public final class Test
extends ComplexTestCase
{
73 public String
[] getTestMethodNames() {
75 "testEnum1", "testEnum2", "testPolyStruct", "testEmptyStruct2",
76 "testFullStruct2", "testXEventListener", "testS1", "testS2",
77 "testKeywordServices", "testSingletons" };
80 public void before() throws Exception
{
81 context
= Bootstrap
.createInitialComponentContext(null);
84 public void testEnum1() {
85 assure(Enum1
.VALUE1
.getValue() == -100);
86 assure(Enum1
.VALUE2
.getValue() == 100);
87 assure(Enum1
.VALUE1_value
== -100);
88 assure(Enum1
.VALUE2_value
== 100);
89 assure(Enum1
.getDefault() == Enum1
.VALUE1
);
90 assure(Enum1
.fromInt(-101) == null);
91 assure(Enum1
.fromInt(-100) == Enum1
.VALUE1
);
92 assure(Enum1
.fromInt(-99) == null);
93 assure(Enum1
.fromInt(0) == null);
94 assure(Enum1
.fromInt(99) == null);
95 assure(Enum1
.fromInt(100) == Enum1
.VALUE2
);
96 assure(Enum1
.fromInt(101) == null);
99 public void testEnum2() {
100 assure(Enum2
.VALUE0
.getValue() == 0);
101 assure(Enum2
.VALUE1
.getValue() == 1);
102 assure(Enum2
.VALUE2
.getValue() == 2);
103 assure(Enum2
.VALUE4
.getValue() == 4);
104 assure(Enum2
.VALUE0_value
== 0);
105 assure(Enum2
.VALUE1_value
== 1);
106 assure(Enum2
.VALUE2_value
== 2);
107 assure(Enum2
.VALUE4_value
== 4);
108 assure(Enum2
.getDefault() == Enum2
.VALUE0
);
109 assure(Enum2
.fromInt(-1) == null);
110 assure(Enum2
.fromInt(0) == Enum2
.VALUE0
);
111 assure(Enum2
.fromInt(1) == Enum2
.VALUE1
);
112 assure(Enum2
.fromInt(2) == Enum2
.VALUE2
);
113 assure(Enum2
.fromInt(3) == null);
114 assure(Enum2
.fromInt(4) == Enum2
.VALUE4
);
115 assure(Enum2
.fromInt(5) == null);
118 public void testPolyStruct() {
119 PolyStruct s
= new PolyStruct();
120 assure(s
.member1
== null);
121 assure(s
.member2
== 0);
122 s
= new PolyStruct("ABC", 5);
123 assure(s
.member1
.equals("ABC"));
124 assure(s
.member2
== 5);
127 public void testEmptyStruct2() {
128 Struct2 s
= new Struct2();
137 assure(s
.p9
== 0.0f
);
138 assure(s
.p10
== 0.0);
139 assure(s
.p11
== '\u0000');
140 assure(s
.p12
.equals(""));
141 assure(s
.p13
.equals(Type
.VOID
));
142 assure(s
.p14
.equals(Any
.VOID
));
143 assure(s
.p15
== Enum2
.VALUE0
);
144 assure(s
.p16
.member1
== 0);
145 assure(s
.p17
== null);
146 assure(s
.p18
== null);
155 assure(s
.t9
== 0.0f
);
156 assure(s
.t10
== 0.0);
157 assure(s
.t11
== '\u0000');
158 assure(s
.t12
.equals(""));
159 assure(s
.t13
.equals(Type
.VOID
));
160 assure(s
.t14
.equals(Any
.VOID
));
161 assure(s
.t15
== Enum2
.VALUE0
);
162 assure(s
.t16
.member1
== 0);
163 assure(s
.t17
== null);
164 assure(s
.t18
== null);
165 assure(s
.a1
.length
== 0);
166 assure(s
.a2
.length
== 0);
167 assure(s
.a3
.length
== 0);
168 assure(s
.a4
.length
== 0);
169 assure(s
.a5
.length
== 0);
170 assure(s
.a6
.length
== 0);
171 assure(s
.a7
.length
== 0);
172 assure(s
.a8
.length
== 0);
173 assure(s
.a9
.length
== 0);
174 assure(s
.a10
.length
== 0);
175 assure(s
.a11
.length
== 0);
176 assure(s
.a12
.length
== 0);
177 assure(s
.a13
.length
== 0);
178 assure(s
.a14
.length
== 0);
179 assure(s
.a15
.length
== 0);
180 assure(s
.a16
.length
== 0);
181 assure(s
.a17
.length
== 0);
182 assure(s
.a18
.length
== 0);
183 assure(s
.aa1
.length
== 0);
184 assure(s
.aa2
.length
== 0);
185 assure(s
.aa3
.length
== 0);
186 assure(s
.aa4
.length
== 0);
187 assure(s
.aa5
.length
== 0);
188 assure(s
.aa6
.length
== 0);
189 assure(s
.aa7
.length
== 0);
190 assure(s
.aa8
.length
== 0);
191 assure(s
.aa9
.length
== 0);
192 assure(s
.aa10
.length
== 0);
193 assure(s
.aa11
.length
== 0);
194 assure(s
.aa12
.length
== 0);
195 assure(s
.aa13
.length
== 0);
196 assure(s
.aa14
.length
== 0);
197 assure(s
.aa15
.length
== 0);
198 assure(s
.aa16
.length
== 0);
199 assure(s
.aa17
.length
== 0);
200 assure(s
.aa18
.length
== 0);
201 assure(s
.at1
.length
== 0);
202 assure(s
.at2
.length
== 0);
203 assure(s
.at3
.length
== 0);
204 assure(s
.at4
.length
== 0);
205 assure(s
.at5
.length
== 0);
206 assure(s
.at6
.length
== 0);
207 assure(s
.at7
.length
== 0);
208 assure(s
.at8
.length
== 0);
209 assure(s
.at9
.length
== 0);
210 assure(s
.at10
.length
== 0);
211 assure(s
.at11
.length
== 0);
212 assure(s
.at12
.length
== 0);
213 assure(s
.at13
.length
== 0);
214 assure(s
.at14
.length
== 0);
215 assure(s
.at15
.length
== 0);
216 assure(s
.at16
.length
== 0);
217 assure(s
.at17
.length
== 0);
218 assure(s
.at18
.length
== 0);
221 public void testFullStruct2() {
223 Struct2 s
= new Struct2(
224 true, (byte) 1, (short) 2, (short) 3, 4, 5, 6L, 7L, 0.8f
, 0.9, 'A',
225 "BCD", Type
.UNSIGNED_HYPER
, Integer
.valueOf(22), Enum2
.VALUE4
,
226 new Struct1(1), null, null, false, (byte) 0, (short) 0, (short) 0,
227 0, 0, 0L, 0L, 0.0f
, 0.0, '\u0000', "", Type
.VOID
, Any
.VOID
,
228 Enum2
.VALUE0
, new Struct1(), null, null,
229 new boolean[] { false, true }, new byte[] { (byte) 1, (byte) 2 },
230 new short[0], new short[0], new int[0], new int[0],
231 new long[0], new long[0], new float[0], new double[0], new char[0],
232 new String
[0], new Type
[0], new Object
[0], new Enum2
[0],
233 new Struct1
[] { new Struct1(1), new Struct1(2) }, new Object
[0],
234 new XNamingService
[0], new boolean[0][], new byte[0][],
235 new short[0][], new short[0][], new int[0][], new int[0][],
236 new long[0][], new long[0][], new float[0][], new double[0][],
237 new char[0][], new String
[0][], new Type
[0][], new Object
[0][],
238 new Enum2
[0][], new Struct1
[0][], new Object
[0][],
239 new XNamingService
[0][], new boolean[0][], new byte[0][],
240 new short[0][], new short[0][], new int[0][], new int[0][],
241 new long[0][], new long[0][], new float[0][], new double[0][],
242 new char[0][], new String
[0][], new Type
[0][], new Object
[0][],
243 new Enum2
[0][], new Struct1
[0][], new Object
[0][],
244 new XNamingService
[0][]);
253 assure(s
.p9
== 0.8f
);
254 assure(s
.p10
== 0.9);
255 assure(s
.p11
== 'A');
256 assure(s
.p12
.equals("BCD"));
257 assure(s
.p13
.equals(Type
.UNSIGNED_HYPER
));
258 assure(s
.p14
.equals(Integer
.valueOf(22)));
259 assure(s
.p15
== Enum2
.VALUE4
);
260 assure(s
.p16
.member1
== 1);
261 assure(s
.p17
== null);
262 assure(s
.p18
== null);
271 assure(s
.t9
== 0.0f
);
272 assure(s
.t10
== 0.0);
273 assure(s
.t11
== '\u0000');
274 assure(s
.t12
.equals(""));
275 assure(s
.t13
.equals(Type
.VOID
));
276 assure(s
.t14
.equals(Any
.VOID
));
277 assure(s
.t15
== Enum2
.VALUE0
);
278 assure(s
.t16
.member1
== 0);
279 assure(s
.t17
== null);
280 assure(s
.t18
== null);
281 assure(s
.a1
.length
== 2);
284 assure(s
.a2
.length
== 2);
285 assure(s
.a2
[0] == 1);
286 assure(s
.a2
[1] == 2);
287 assure(s
.a3
.length
== 0);
288 assure(s
.a4
.length
== 0);
289 assure(s
.a5
.length
== 0);
290 assure(s
.a6
.length
== 0);
291 assure(s
.a7
.length
== 0);
292 assure(s
.a8
.length
== 0);
293 assure(s
.a9
.length
== 0);
294 assure(s
.a10
.length
== 0);
295 assure(s
.a11
.length
== 0);
296 assure(s
.a12
.length
== 0);
297 assure(s
.a13
.length
== 0);
298 assure(s
.a14
.length
== 0);
299 assure(s
.a15
.length
== 0);
300 assure(s
.a16
.length
== 2);
301 assure(s
.a16
[0].member1
== 1);
302 assure(s
.a16
[1].member1
== 2);
303 assure(s
.a17
.length
== 0);
304 assure(s
.a18
.length
== 0);
305 assure(s
.aa1
.length
== 0);
306 assure(s
.aa2
.length
== 0);
307 assure(s
.aa3
.length
== 0);
308 assure(s
.aa4
.length
== 0);
309 assure(s
.aa5
.length
== 0);
310 assure(s
.aa6
.length
== 0);
311 assure(s
.aa7
.length
== 0);
312 assure(s
.aa8
.length
== 0);
313 assure(s
.aa9
.length
== 0);
314 assure(s
.aa10
.length
== 0);
315 assure(s
.aa11
.length
== 0);
316 assure(s
.aa12
.length
== 0);
317 assure(s
.aa13
.length
== 0);
318 assure(s
.aa14
.length
== 0);
319 assure(s
.aa15
.length
== 0);
320 assure(s
.aa16
.length
== 0);
321 assure(s
.aa17
.length
== 0);
322 assure(s
.aa18
.length
== 0);
323 assure(s
.at1
.length
== 0);
324 assure(s
.at2
.length
== 0);
325 assure(s
.at3
.length
== 0);
326 assure(s
.at4
.length
== 0);
327 assure(s
.at5
.length
== 0);
328 assure(s
.at6
.length
== 0);
329 assure(s
.at7
.length
== 0);
330 assure(s
.at8
.length
== 0);
331 assure(s
.at9
.length
== 0);
332 assure(s
.at10
.length
== 0);
333 assure(s
.at11
.length
== 0);
334 assure(s
.at12
.length
== 0);
335 assure(s
.at13
.length
== 0);
336 assure(s
.at14
.length
== 0);
337 assure(s
.at15
.length
== 0);
338 assure(s
.at16
.length
== 0);
339 assure(s
.at17
.length
== 0);
340 assure(s
.at18
.length
== 0);
343 public void testXEventListener() {
344 assure(EventListener
.class.isAssignableFrom(XEventListener
.class));
347 public void testS1() throws com
.sun
.star
.uno
.Exception
{
351 failed("S1.create1");
352 } catch (DeploymentException e
) {}
354 S1
.create2(context
, new Any
[0]);
355 failed("S1.create2");
356 } catch (com
.sun
.star
.uno
.Exception e
) {}
358 S1
.create3(context
, new Any
[0]);
359 failed("S1.create3");
360 } catch (DeploymentException e
) {}
362 S1
.create4(context
, 0, 0, 0);
363 failed("S1.create4");
364 } catch (DeploymentException e
) {}
367 context
, false, (byte) 0, (short) 0, (short) 0, 0, 0, 0L, 0L,
368 0.0f
, 0.0, '\u0000', "", Type
.VOID
, Any
.VOID
, Enum2
.VALUE0
,
369 new Struct1(), null, null, false, (byte) 0, (short) 0,
370 (short) 0, 0, 0, 0L, 0L, 0.0f
, 0.0, '\u0000', "", Type
.VOID
,
371 Any
.VOID
, Enum2
.VALUE0
, new Struct1(), null, null,
372 new boolean[0], new byte[0], new short[0], new short[0],
373 new int[0], new int[0], new long[0], new long[0], new float[0],
374 new double[0], new char[0], new String
[0], new Type
[0],
375 new Object
[0], new Enum2
[0], new Struct1
[0], new Object
[0],
376 new XNamingService
[0], new boolean[0][], new byte[0][],
377 new short[0][], new short[0][], new int[0][], new int[0][],
378 new long[0][], new long[0][], new float[0][], new double[0][],
379 new char[0][], new String
[0][], new Type
[0][], new Object
[0][],
380 new Enum2
[0][], new Struct1
[0][], new Object
[0][],
381 new XNamingService
[0][], new boolean[0][], new byte[0][],
382 new short[0][], new short[0][], new int[0][], new int[0][],
383 new long[0][], new long[0][], new float[0][], new double[0][],
384 new char[0][], new String
[0][], new Type
[0][], new Object
[0][],
385 new Enum2
[0][], new Struct1
[0][], new Object
[0][],
386 new XNamingService
[0][]);
387 failed("S1.create4");
388 } catch (DeploymentException e
) {}
391 public void testS2() {
395 public void testKeywordServices() {
397 service_abstract
.method_abstract(context
, 0);
398 failed("service_abstract.method_abstract");
399 } catch (DeploymentException e
) {}
401 service_assert
.method_assert(context
, 0);
402 failed("service_assert.method_assert");
403 } catch (DeploymentException e
) {}
405 service_break
.method_break(context
, 0);
406 failed("service_break.method_break");
407 } catch (DeploymentException e
) {}
409 service_catch
.method_catch(context
, 0);
410 failed("service_catch.method_catch");
411 } catch (DeploymentException e
) {}
413 service_class
.method_class(context
, 0);
414 failed("service_class.method_class");
415 } catch (DeploymentException e
) {}
417 service_continue
.method_continue(context
, 0);
418 failed("service_continue.method_continue");
419 } catch (DeploymentException e
) {}
421 service_do
.method_do(context
, 0);
422 failed("service_do.method_do");
423 } catch (DeploymentException e
) {}
425 service_else
.method_else(context
, 0);
426 failed("service_else.method_else");
427 } catch (DeploymentException e
) {}
429 service_extends
.method_extends(context
, 0);
430 failed("service_extends.method_extends");
431 } catch (DeploymentException e
) {}
433 service_final
.method_final(context
, 0);
434 failed("service_final.method_final");
435 } catch (DeploymentException e
) {}
437 service_finally
.method_finally(context
, 0);
438 failed("service_finally.method_finally");
439 } catch (DeploymentException e
) {}
441 service_for
.method_for(context
, 0);
442 failed("service_for.method_for");
443 } catch (DeploymentException e
) {}
445 service_goto
.method_goto(context
, 0);
446 failed("service_goto.method_goto");
447 } catch (DeploymentException e
) {}
449 service_if
.method_if(context
, 0);
450 failed("service_if.method_if");
451 } catch (DeploymentException e
) {}
453 service_implements
.method_implements(context
, 0);
454 failed("service_implements.method_implements");
455 } catch (DeploymentException e
) {}
457 service_import
.method_import(context
, 0);
458 failed("service_import.method_import");
459 } catch (DeploymentException e
) {}
461 service_instanceof
.method_instanceof(context
, 0);
462 failed("service_instanceof.method_instanceof");
463 } catch (DeploymentException e
) {}
465 service_int
.method_int(context
, 0);
466 failed("service_int.method_int");
467 } catch (DeploymentException e
) {}
469 service_native
.method_native(context
, 0);
470 failed("service_native.method_native");
471 } catch (DeploymentException e
) {}
473 service_new
.method_new(context
, 0);
474 failed("service_new.method_new");
475 } catch (DeploymentException e
) {}
477 service_package
.method_package(context
, 0);
478 failed("service_package.method_package");
479 } catch (DeploymentException e
) {}
481 service_private
.method_private(context
, 0);
482 failed("service_private.method_private");
483 } catch (DeploymentException e
) {}
485 service_protected
.method_protected(context
, 0);
486 failed("service_protected.method_protected");
487 } catch (DeploymentException e
) {}
489 service_public
.method_public(context
, 0);
490 failed("service_public.method_public");
491 } catch (DeploymentException e
) {}
493 service_return
.method_return(context
, 0);
494 failed("service_return.method_return");
495 } catch (DeploymentException e
) {}
497 service_static
.method_static(context
, 0);
498 failed("service_static.method_static");
499 } catch (DeploymentException e
) {}
501 service_strictfp
.method_strictfp(context
, 0);
502 failed("service_strictfp.method_strictfp");
503 } catch (DeploymentException e
) {}
505 service_super
.method_super(context
, 0);
506 failed("service_super.method_super");
507 } catch (DeploymentException e
) {}
509 service_synchronized
.method_synchronized(context
, 0);
510 failed("service_synchronized.method_synchronized");
511 } catch (DeploymentException e
) {}
513 service_this
.method_this(context
, 0);
514 failed("service_this.method_this");
515 } catch (DeploymentException e
) {}
517 service_throw
.method_throw(context
, 0);
518 failed("service_throw.method_throw");
519 } catch (DeploymentException e
) {}
521 service_throws
.method_throws(context
, 0);
522 failed("service_throws.method_throws");
523 } catch (DeploymentException e
) {}
525 service_try
.method_try(context
, 0);
526 failed("service_try.method_try");
527 } catch (DeploymentException e
) {}
529 service_volatile
.method_volatile(context
, 0);
530 failed("service_volatile.method_volatile");
531 } catch (DeploymentException e
) {}
533 service_while
.method_while(context
, 0);
534 failed("service_while.method_while");
535 } catch (DeploymentException e
) {}
538 public void testSingletons() {
542 } catch (DeploymentException e
) {}
544 singleton_abstract
.get(context
);
545 failed("singleton_abstract");
546 } catch (DeploymentException e
) {}
549 private XComponentContext context
;