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 mod._inv; 29 30 import java.io.PrintWriter; 31 32 import lib.StatusException; 33 import lib.TestCase; 34 import lib.TestEnvironment; 35 import lib.TestParameters; 36 37 import com.sun.star.lang.XMultiServiceFactory; 38 import com.sun.star.uno.XInterface; 39 40 /** 41 * Test for object which is represented by service 42 * <code>com.sun.star.script.Invocation</code>. <p> 43 * Object implements the following interfaces : 44 * <ul> 45 * <li> <code>com::sun::star::lang::XSingleServiceFactory</code></li> 46 * </ul> 47 * @see com.sun.star.script.Invocation 48 * @see com.sun.star.lang.XSingleServiceFactory 49 * @see ifc.lang._XSingleServiceFactory 50 */ 51 public class Invocation extends TestCase { 52 53 /** 54 * Creating a Testenvironment for the interfaces to be tested. 55 * Creates service <code>com.sun.star.script.Invocation</code>. 56 * Object relations created : 57 * <ul> 58 * <li> <code>'XSingleServiceFactory.createInstance.negative'</code> : 59 * for interface {@link _ifc.lang.XSingleServiceFactory} ; 60 * <code>String</code> relation; If its value 'true' then 61 * <code>createInstance</code> method for the object isn't 62 * supported. In this case object doesn't support this method.</li> 63 * <li> <code>'XSingleServiceFactory.arguments'</code> : 64 * for interface {@link _ifc.lang.XSingleServiceFactory} ; 65 * has <code>Object[]</code> type. This relation is used as 66 * a parameter for <code>createInstanceWithArguments</code> 67 * method call. If this relation doesn't exist test pass 68 * zerro length array as argument. Here 69 * <code>com.sun.star.io.Pipe</code> instance is passed.</li> 70 * <li> <code>'XSingleServiceFactory.MustSupport'</code> : 71 * for interface {@link _ifc.lang.XSingleServiceFactory}. 72 * Specifies that created instance must support 73 * <code>com.sun.star.script.XInvocation</code> interface. 74 * </ul> 75 */ 76 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { 77 XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF(); 78 79 try { 80 XInterface xInt = (XInterface)xMSF.createInstance( 81 "com.sun.star.script.Invocation"); 82 83 TestEnvironment tEnv = new TestEnvironment(xInt); 84 85 // the createInstance should fail according to the documentation 86 tEnv.addObjRelation( 87 "XSingleServiceFactory.createInstance.negative", "true"); 88 89 // creating parameters to createInstanceWithArguments 90 Object[] args = new Object[1]; 91 92 args[0] = xMSF.createInstance("com.suns.star.io.Pipe"); 93 94 tEnv.addObjRelation( 95 "XSingleServiceFactory.arguments", args); 96 97 tEnv.addObjRelation("XSingleServiceFactory.MustSupport", 98 new Class[] {com.sun.star.script.XInvocation.class}); 99 100 return tEnv; 101 } catch (com.sun.star.uno.Exception e) { 102 e.printStackTrace(log); 103 throw new StatusException("Unexpected exception", e); 104 } 105 } 106 } 107