xref: /aoo41x/main/qadevOOo/tests/java/ifc/task/_XJob.java (revision ef39d40d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.task;
25 
26 import lib.MultiMethodTest;
27 import lib.Status;
28 import lib.StatusException;
29 
30 import com.sun.star.beans.NamedValue;
31 import com.sun.star.task.XJob;
32 
33 /**
34  * Testing <code>com.sun.star.frame._XJobExecutor</code>
35  * interface methods:
36  * <ul>
37  *  <li><code> trigger() </code></li>
38  * </ul><p>
39  *
40  * This test needs the following object relations :
41  * <ul>
42  *  <li> <code>'CallCounter'</code>
43  *      (of type <code>com.sun.star.container.XNamed</code>):
44  *      the <code>getName()</code> method of which must
45  *      return number of calls to <code>XJob.execute</code>
46  *      method which is registered for event 'TestEvent'
47  *  </li>
48  * <ul> <p>
49  * @see com.sun.star.frame.XJobExecutor
50  */
51 public class _XJob extends MultiMethodTest {
52 	public static XJob oObj = null;
53 
54     /**
55      * Tries to query the tested component for object relation
56      * <code>XJobArgs</code> [<code>Object[]</code>] which contains
57      * <code>executeArgs</code> [<code>NamedValue[]</code>]
58      * @throw StatusException If relations are not found
59      */
before()60     public void before() {
61         Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs") ;
62         if (XJobArgs == null)
63             throw new StatusException(Status.failed
64                 ("'XJobArgs' relation not found ")) ;
65     }
66 
67 
68 
69     /**
70      * Gets the number of Job calls before and after triggering event.
71      *
72      * Has <b>OK</b> status if the Job was called on triggering
73      * event.
74      */
_execute()75     public void _execute() {
76         Object[] XJobArgs = (Object[]) tEnv.getObjRelation("XJobArgs");
77 
78 	boolean bOK = true;
79 
80         for (int n = 0; n<XJobArgs.length; n++) {
81             log.println("running XJobArgs[" + n + "]");
82             try {
83                 oObj.execute((NamedValue[])XJobArgs[n]);
84             } catch ( com.sun.star.lang.IllegalArgumentException e) {
85                 bOK = false;
86                 log.println("Could not success XJobArgs[" + n + "]: " + e);
87             } catch ( com.sun.star.uno.Exception e) {
88                 bOK = false;
89                 log.println("Could not success XJobArgs[" + n + "]: " + e);
90             }
91         }
92         tRes.tested("execute()", bOK);
93     }
94 }
95