xref: /AOO41X/main/qadevOOo/tests/java/ifc/sheet/_DatabaseImportDescriptor.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package ifc.sheet;
29 
30 import lib.MultiMethodTest;
31 import util.ValueChanger;
32 
33 import com.sun.star.beans.PropertyValue;
34 import com.sun.star.beans.XPropertySet;
35 import com.sun.star.util.XImportable;
36 
37 /**
38 * Testing <code>com.sun.star.sheet.DatabaseImportDescriptor</code>
39 * service properties:
40 * <ul>
41 *   <li><code>DatabaseName</code></li>
42 *   <li><code>SourceObject</code></li>
43 *   <li><code>SourceType</code></li>
44 * </ul> <p>
45 * @see com.sun.star.sheet.DatabaseImportDescriptor
46 */
47 public class _DatabaseImportDescriptor extends MultiMethodTest {
48 
49     public XPropertySet oObj = null;
50     public XImportable xIMP = null;
51     public PropertyValue[] props = null;
52 
53     public void _DatabaseName() {
54         xIMP = (XImportable) tEnv.getObjRelation("xIMP");
55         props = xIMP.createImportDescriptor(true);
56         changeProp("DatabaseName",0);
57     }
58 
59     public void _SourceObject() {
60         changeProp("SourceObject",2);
61     }
62 
63     public void _SourceType() {
64         changeProp("SourceType",1);
65     }
66 
67     public void changeProp(String name, int nr) {
68 
69         Object gValue = null;
70         Object sValue = null;
71         Object ValueToSet = null;
72 
73         if ( ! name.equals(props[nr].Name) ) {
74             log.println("Property '"+props[nr].Name+"' is tested");
75             log.println("But the status is for '"+name+"'");
76         }
77 
78 
79         try {
80             //waitForAllThreads();
81             gValue = props[nr].Value;
82             //waitForAllThreads();
83             ValueToSet = ValueChanger.changePValue(gValue);
84             //waitForAllThreads();
85             props[nr].Value=ValueToSet;
86             sValue = props[nr].Value;
87 
88             //check get-set methods
89             if ( (gValue.equals(sValue)) || (sValue == null) ) {
90                 log.println("Value for '"+name+"' hasn't changed");
91                 tRes.tested(name, false);
92             }
93             else {
94                 log.println("Property '"+name+"' OK");
95                 tRes.tested(name, true);
96             }
97         } catch (Exception e) {
98              log.println("Exception occured while testing property '" +
99                  name + "'");
100              e.printStackTrace(log);
101              tRes.tested(name, false);
102         }
103     }// end of changeProp
104 
105 
106 }  // finish class _DatabaseImportDescriptor
107 
108 
109