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.beans;
29 
30 import lib.MultiMethodTest;
31 
32 import com.sun.star.beans.Property;
33 import com.sun.star.beans.UnknownPropertyException;
34 import com.sun.star.beans.XPropertySetInfo;
35 
36 /**
37 * Testing <code>com.sun.star.beans.XPropertySetInfo</code>
38 * interface methods :
39 * <ul>
40 *  <li><code>getProperties()</code></li>
41 *  <li><code>getPropertyByName()</code></li>
42 *  <li><code>hasPropertyByName()</code></li>
43 * </ul>
44 * @see com.sun.star.beans.XPropertySetInfo
45 */
46 public class _XPropertySetInfo extends MultiMethodTest {
47 
48     public XPropertySetInfo oObj = null;// oObj filled by MultiMethodTest
49 
50     public Property IsThere = null;
51 
52     /**
53     * Test calls the method and stores one of the properties.<p>
54     * Has <b> OK </b> status if the method successfully returns
55     * value that isn't null.<p>
56     */
57     public void _getProperties() {
58         Property[] properties = oObj.getProperties();
59         IsThere = properties[0];
60         tRes.tested("getProperties()", ( properties != null ));
61         return;
62     }
63 
64     /**
65     * Test calls the method with property name that certainly present
66     * in the property set and again calls the method with property name
67     * that certainly doesn't present in the property set.<p>
68     * Has <b> OK </b> status if the method in one case successfully
69     * returns value that isn't null and no exceptions were thrown and
70     * in other case exception was thrown.<p>
71     * The following method tests are to be completed successfully before :
72     * <ul>
73     *  <li> <code>getProperties()</code> : to have a property that certainly
74     *  present in the property set</li>
75     * </ul>
76     */
77     public void _getPropertyByName() {
78         requiredMethod("getProperties()");
79         boolean result;
80         try {
81             Property prop  = oObj.getPropertyByName(IsThere.Name);
82             result = (prop != null);
83         } catch (com.sun.star.beans.UnknownPropertyException e) {
84             log.println("Exception occurred while testing" +
85                                 " getPropertyByName with existing property");
86             e.printStackTrace(log);
87             result = false;
88         }
89 
90         try {
91             oObj.getPropertyByName("Jupp");
92             log.println("No Exception thrown while testing"+
93                                 " getPropertyByName with non existing property");
94             result = false;
95         }
96         catch (UnknownPropertyException e) {
97             result = true;
98         }
99         tRes.tested("getPropertyByName()", result);
100         return;
101     }
102 
103     /**
104     * Test calls the method with property name that certainly present
105     * in the property set and again calls the method with property name
106     * that certainly doesn't present in the property set.<p>
107     * Has <b> OK </b> status if the method successfully returns true in
108     * one case and false in other case.<p>
109     * The following method tests are to be completed successfully before :
110     * <ul>
111     *  <li> <code>getProperties()</code> : to have a property that certainly
112     *  present in the property set</li>
113     * </ul>
114     */
115     public void _hasPropertyByName() {
116         requiredMethod("getProperties()");
117         tRes.tested("hasPropertyByName()",
118         (
119             (oObj.hasPropertyByName(IsThere.Name)) &&
120             (!oObj.hasPropertyByName("Jupp")) )
121         );
122     }
123 
124 }    /// finish class XPropertySetInfo
125 
126 
127