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.sheet;
25 
26 import lib.MultiMethodTest;
27 import util.ValueChanger;
28 
29 import com.sun.star.beans.PropertyValue;
30 import com.sun.star.beans.XPropertySet;
31 import com.sun.star.util.XImportable;
32 
33 /**
34 * Testing <code>com.sun.star.sheet.DatabaseImportDescriptor</code>
35 * service properties:
36 * <ul>
37 *   <li><code>DatabaseName</code></li>
38 *   <li><code>SourceObject</code></li>
39 *   <li><code>SourceType</code></li>
40 * </ul> <p>
41 * @see com.sun.star.sheet.DatabaseImportDescriptor
42 */
43 public class _DatabaseImportDescriptor extends MultiMethodTest {
44 
45     public XPropertySet oObj = null;
46     public XImportable xIMP = null;
47     public PropertyValue[] props = null;
48 
_DatabaseName()49     public void _DatabaseName() {
50         xIMP = (XImportable) tEnv.getObjRelation("xIMP");
51         props = xIMP.createImportDescriptor(true);
52         changeProp("DatabaseName",0);
53     }
54 
_SourceObject()55     public void _SourceObject() {
56         changeProp("SourceObject",2);
57     }
58 
_SourceType()59     public void _SourceType() {
60         changeProp("SourceType",1);
61     }
62 
changeProp(String name, int nr)63     public void changeProp(String name, int nr) {
64 
65         Object gValue = null;
66         Object sValue = null;
67         Object ValueToSet = null;
68 
69         if ( ! name.equals(props[nr].Name) ) {
70             log.println("Property '"+props[nr].Name+"' is tested");
71             log.println("But the status is for '"+name+"'");
72         }
73 
74 
75         try {
76             //waitForAllThreads();
77             gValue = props[nr].Value;
78             //waitForAllThreads();
79             ValueToSet = ValueChanger.changePValue(gValue);
80             //waitForAllThreads();
81             props[nr].Value=ValueToSet;
82             sValue = props[nr].Value;
83 
84             //check get-set methods
85             if ( (gValue.equals(sValue)) || (sValue == null) ) {
86                 log.println("Value for '"+name+"' hasn't changed");
87                 tRes.tested(name, false);
88             }
89             else {
90                 log.println("Property '"+name+"' OK");
91                 tRes.tested(name, true);
92             }
93         } catch (Exception e) {
94              log.println("Exception occured while testing property '" +
95                  name + "'");
96              e.printStackTrace(log);
97              tRes.tested(name, false);
98         }
99     }// end of changeProp
100 
101 
102 }  // finish class _DatabaseImportDescriptor
103 
104 
105