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.beans;
25 
26 import com.sun.star.beans.PropertyState;
27 import com.sun.star.uno.XInterface;
28 import lib.MultiMethodTest;
29 
30 import com.sun.star.beans.XPropertyWithState;
31 import lib.Status;
32 import lib.StatusException;
33 
34 /**
35 * Testing <code>com.sun.star.beans.XPropertyWithState</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> getDefaultAsProperty()</code></li>
39 *  <li><code> getStateAsProperty()</code></li>
40 *  <li><code> setToDefaultAsProperty()</code></li>
41 * </ul> <p>
42 * @see com.sun.star.beans.XPropertyWithState
43 */
44 
45 public class _XPropertyWithState extends MultiMethodTest {
46 
47     /**
48      * the test object
49      */
50     public XPropertyWithState oObj;
51 
52 
53     /**
54      * Test calls the method.
55      * Test has ok status if no
56      * <CODE>com.sun.star.lang.WrappedTargetException</CODE>
57      * was thrown
58      */
_getDefaultAsProperty()59     public void _getDefaultAsProperty() {
60         try{
61 
62             XInterface defaultState = (XInterface) oObj.getDefaultAsProperty();
63 
64         } catch (com.sun.star.lang.WrappedTargetException e){
65             e.printStackTrace(log);
66             throw new StatusException(Status.failed("'com.sun.star.lang.WrappedTargetException' was thrown"));
67         }
68 
69         tRes.tested("getDefaultAsProperty()", true);
70     }
71 
72     /**
73      * Test is ok if <CODE>getStateAsProperty()</CODE> returns
74      * as <CODE>PropertyState</CODE> which is not <CODE>null</CODE>
75      */
_getStateAsProperty()76     public void _getStateAsProperty() {
77 
78         boolean res = true;
79 
80         PropertyState propState = oObj.getStateAsProperty();
81 
82         if (propState == null) {
83             log.println("the returned PropertyState is null -> FALSE");
84             res = false;
85         }
86 
87         tRes.tested("getStateAsProperty()", res);
88     }
89 
90     /**
91      * Test calls the method.
92      * Test has ok status if no
93      * <CODE>com.sun.star.lang.WrappedTargetException</CODE>
94      * was thrown
95      */
_setToDefaultAsProperty()96     public void _setToDefaultAsProperty() {
97         try{
98 
99             oObj.setToDefaultAsProperty();
100 
101         } catch (com.sun.star.lang.WrappedTargetException e){
102             e.printStackTrace(log);
103             throw new StatusException(Status.failed("'com.sun.star.lang.WrappedTargetException' was thrown"));
104         }
105 
106         tRes.tested("setToDefaultAsProperty()", true);
107     }
108 
109 }
110