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