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