1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XJob.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import lib
.StatusException
;
37 import com
.sun
.star
.beans
.NamedValue
;
38 import com
.sun
.star
.task
.XJob
;
41 * Testing <code>com.sun.star.frame._XJobExecutor</code>
44 * <li><code> trigger() </code></li>
47 * This test needs the following object relations :
49 * <li> <code>'CallCounter'</code>
50 * (of type <code>com.sun.star.container.XNamed</code>):
51 * the <code>getName()</code> method of which must
52 * return number of calls to <code>XJob.execute</code>
53 * method which is registered for event 'TestEvent'
56 * @see com.sun.star.frame.XJobExecutor
58 public class _XJob
extends MultiMethodTest
{
59 public static XJob oObj
= null;
62 * Tries to query the tested component for object relation
63 * <code>XJobArgs</code> [<code>Object[]</code>] which contains
64 * <code>executeArgs</code> [<code>NamedValue[]</code>]
65 * @throw StatusException If relations are not found
67 public void before() {
68 Object
[] XJobArgs
= (Object
[]) tEnv
.getObjRelation("XJobArgs") ;
70 throw new StatusException(Status
.failed
71 ("'XJobArgs' relation not found ")) ;
77 * Gets the number of Job calls before and after triggering event.
79 * Has <b>OK</b> status if the Job was called on triggering
82 public void _execute() {
83 Object
[] XJobArgs
= (Object
[]) tEnv
.getObjRelation("XJobArgs");
87 for (int n
= 0; n
<XJobArgs
.length
; n
++) {
88 log
.println("running XJobArgs[" + n
+ "]");
90 oObj
.execute((NamedValue
[])XJobArgs
[n
]);
91 } catch ( com
.sun
.star
.lang
.IllegalArgumentException e
) {
93 log
.println("Could not success XJobArgs[" + n
+ "]: " + e
);
94 } catch ( com
.sun
.star
.uno
.Exception e
) {
96 log
.println("Could not success XJobArgs[" + n
+ "]: " + e
);
99 tRes
.tested("execute()", bOK
);