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