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._cnt; 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.container.XIndexContainer; 38 import com.sun.star.lang.XMultiServiceFactory; 39 import com.sun.star.uno.UnoRuntime; 40 import com.sun.star.uno.XInterface; 41 42 /** 43 * Test for object which is represented by service 44 * <code>com.sun.star.cnt.CntUnoDataContainer</code>. <p> 45 * Object implements the following interfaces : 46 * <ul> 47 * <li> <code>com::sun::star::io::XActiveDataSink</code></li> 48 * <li> <code>com::sun::star::container::XIndexContainer</code></li> 49 * <li> <code>com::sun::star::ucb::XDataContainer</code></li> 50 * <li> <code>com::sun::star::container::XIndexAccess</code></li> 51 * <li> <code>com::sun::star::container::XElementAccess</code></li> 52 * <li> <code>com::sun::star::container::XIndexReplace</code></li> 53 * </ul> 54 * This object test <b> is NOT </b> designed to be run in several 55 * threads concurently. 56 * @see com.sun.star.io.XActiveDataSink 57 * @see com.sun.star.container.XIndexContainer 58 * @see com.sun.star.ucb.XDataContainer 59 * @see com.sun.star.container.XIndexAccess 60 * @see com.sun.star.container.XElementAccess 61 * @see com.sun.star.container.XIndexReplace 62 * @see ifc.io._XActiveDataSink 63 * @see ifc.container._XIndexContainer 64 * @see ifc.ucb._XDataContainer 65 * @see ifc.container._XIndexAccess 66 * @see ifc.container._XElementAccess 67 * @see ifc.container._XIndexReplace 68 */ 69 public class CntUnoDataContainer extends TestCase { 70 71 /** 72 * Creating a Testenvironment for the interfaces to be tested. 73 * Creates an instance of the service 74 * <code>com.sun.star.cnt.CntUnoDataContainer</code> and adds 75 * to it one <code>CntUnoDataContainer</code> instance. <p> 76 * Object relations created : 77 * <ul> 78 * <li> <code>'INSTANCE1'</code> for 79 * {@link ifc.container._XIndexContainer}, 80 * {@link ifc.container._XIndexReplace} : for this object 81 * elements contained in it are <code>CntUnoDataContainer</code> 82 * instances. (only one relation for one interface thread is now 83 * passed).</li> 84 * <li> <code>'InputStream'</code> for 85 * {@link ifc.io._XActiveDataSink} : a stream to set and get. 86 * </li> 87 * </ul> 88 */ 89 protected TestEnvironment createTestEnvironment( 90 TestParameters Param, PrintWriter log) { 91 XInterface oObj = null; 92 Object oInterface = null; 93 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF(); 94 Object relationContainer = null ; 95 Object xIn = null; 96 97 try { 98 oInterface = xMSF.createInstance 99 ( "com.sun.star.ucb.DataContainer" ); 100 101 // adding one child container 102 XIndexContainer xIC = (XIndexContainer) UnoRuntime.queryInterface 103 (XIndexContainer.class, oInterface) ; 104 105 Object child = xMSF.createInstance 106 ( "com.sun.star.ucb.DataContainer" ); 107 xIC.insertByIndex(0, child) ; 108 109 relationContainer = xMSF.createInstance 110 ( "com.sun.star.ucb.DataContainer" ); 111 112 xIn = xMSF.createInstance 113 ( "com.sun.star.io.DataInputStream" ); 114 } 115 catch( com.sun.star.uno.Exception e ) { 116 log.println("Can't create an object." ); 117 throw new StatusException( "Can't create an object", e ); 118 } 119 120 oObj = (XInterface) oInterface; 121 122 TestEnvironment tEnv = new TestEnvironment( oObj ); 123 124 tEnv.addObjRelation("INSTANCE1", relationContainer) ; 125 tEnv.addObjRelation("InputStream", xIn) ; 126 127 return tEnv; 128 } // finish method getTestEnvironment 129 130 } // finish class BreakIterator 131 132