1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir package ifc.beans; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir import lib.MultiMethodTest; 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir import com.sun.star.beans.Property; 33*cdf0e10cSrcweir import com.sun.star.beans.UnknownPropertyException; 34*cdf0e10cSrcweir import com.sun.star.beans.XPropertySetInfo; 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir /** 37*cdf0e10cSrcweir * Testing <code>com.sun.star.beans.XPropertySetInfo</code> 38*cdf0e10cSrcweir * interface methods : 39*cdf0e10cSrcweir * <ul> 40*cdf0e10cSrcweir * <li><code>getProperties()</code></li> 41*cdf0e10cSrcweir * <li><code>getPropertyByName()</code></li> 42*cdf0e10cSrcweir * <li><code>hasPropertyByName()</code></li> 43*cdf0e10cSrcweir * </ul> 44*cdf0e10cSrcweir * @see com.sun.star.beans.XPropertySetInfo 45*cdf0e10cSrcweir */ 46*cdf0e10cSrcweir public class _XPropertySetInfo extends MultiMethodTest { 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir public XPropertySetInfo oObj = null;// oObj filled by MultiMethodTest 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir public Property IsThere = null; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir /** 53*cdf0e10cSrcweir * Test calls the method and stores one of the properties.<p> 54*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 55*cdf0e10cSrcweir * value that isn't null.<p> 56*cdf0e10cSrcweir */ 57*cdf0e10cSrcweir public void _getProperties() { 58*cdf0e10cSrcweir Property[] properties = oObj.getProperties(); 59*cdf0e10cSrcweir IsThere = properties[0]; 60*cdf0e10cSrcweir tRes.tested("getProperties()", ( properties != null )); 61*cdf0e10cSrcweir return; 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir /** 65*cdf0e10cSrcweir * Test calls the method with property name that certainly present 66*cdf0e10cSrcweir * in the property set and again calls the method with property name 67*cdf0e10cSrcweir * that certainly doesn't present in the property set.<p> 68*cdf0e10cSrcweir * Has <b> OK </b> status if the method in one case successfully 69*cdf0e10cSrcweir * returns value that isn't null and no exceptions were thrown and 70*cdf0e10cSrcweir * in other case exception was thrown.<p> 71*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 72*cdf0e10cSrcweir * <ul> 73*cdf0e10cSrcweir * <li> <code>getProperties()</code> : to have a property that certainly 74*cdf0e10cSrcweir * present in the property set</li> 75*cdf0e10cSrcweir * </ul> 76*cdf0e10cSrcweir */ 77*cdf0e10cSrcweir public void _getPropertyByName() { 78*cdf0e10cSrcweir requiredMethod("getProperties()"); 79*cdf0e10cSrcweir boolean result; 80*cdf0e10cSrcweir try { 81*cdf0e10cSrcweir Property prop = oObj.getPropertyByName(IsThere.Name); 82*cdf0e10cSrcweir result = (prop != null); 83*cdf0e10cSrcweir } catch (com.sun.star.beans.UnknownPropertyException e) { 84*cdf0e10cSrcweir log.println("Exception occurred while testing" + 85*cdf0e10cSrcweir " getPropertyByName with existing property"); 86*cdf0e10cSrcweir e.printStackTrace(log); 87*cdf0e10cSrcweir result = false; 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir try { 91*cdf0e10cSrcweir oObj.getPropertyByName("Jupp"); 92*cdf0e10cSrcweir log.println("No Exception thrown while testing"+ 93*cdf0e10cSrcweir " getPropertyByName with non existing property"); 94*cdf0e10cSrcweir result = false; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir catch (UnknownPropertyException e) { 97*cdf0e10cSrcweir result = true; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir tRes.tested("getPropertyByName()", result); 100*cdf0e10cSrcweir return; 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir /** 104*cdf0e10cSrcweir * Test calls the method with property name that certainly present 105*cdf0e10cSrcweir * in the property set and again calls the method with property name 106*cdf0e10cSrcweir * that certainly doesn't present in the property set.<p> 107*cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns true in 108*cdf0e10cSrcweir * one case and false in other case.<p> 109*cdf0e10cSrcweir * The following method tests are to be completed successfully before : 110*cdf0e10cSrcweir * <ul> 111*cdf0e10cSrcweir * <li> <code>getProperties()</code> : to have a property that certainly 112*cdf0e10cSrcweir * present in the property set</li> 113*cdf0e10cSrcweir * </ul> 114*cdf0e10cSrcweir */ 115*cdf0e10cSrcweir public void _hasPropertyByName() { 116*cdf0e10cSrcweir requiredMethod("getProperties()"); 117*cdf0e10cSrcweir tRes.tested("hasPropertyByName()", 118*cdf0e10cSrcweir ( 119*cdf0e10cSrcweir (oObj.hasPropertyByName(IsThere.Name)) && 120*cdf0e10cSrcweir (!oObj.hasPropertyByName("Jupp")) ) 121*cdf0e10cSrcweir ); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir } /// finish class XPropertySetInfo 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir 127