merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _cnt / CntUnoDataContainer.java
blobec1fca144f6a5d9b8ddb80bcdca096b71fe0c46a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CntUnoDataContainer.java,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package mod._cnt;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
40 import com.sun.star.container.XIndexContainer;
41 import com.sun.star.lang.XMultiServiceFactory;
42 import com.sun.star.uno.UnoRuntime;
43 import com.sun.star.uno.XInterface;
45 /**
46 * Test for object which is represented by service
47 * <code>com.sun.star.cnt.CntUnoDataContainer</code>. <p>
48 * Object implements the following interfaces :
49 * <ul>
50 * <li> <code>com::sun::star::io::XActiveDataSink</code></li>
51 * <li> <code>com::sun::star::container::XIndexContainer</code></li>
52 * <li> <code>com::sun::star::ucb::XDataContainer</code></li>
53 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
54 * <li> <code>com::sun::star::container::XElementAccess</code></li>
55 * <li> <code>com::sun::star::container::XIndexReplace</code></li>
56 * </ul>
57 * This object test <b> is NOT </b> designed to be run in several
58 * threads concurently.
59 * @see com.sun.star.io.XActiveDataSink
60 * @see com.sun.star.container.XIndexContainer
61 * @see com.sun.star.ucb.XDataContainer
62 * @see com.sun.star.container.XIndexAccess
63 * @see com.sun.star.container.XElementAccess
64 * @see com.sun.star.container.XIndexReplace
65 * @see ifc.io._XActiveDataSink
66 * @see ifc.container._XIndexContainer
67 * @see ifc.ucb._XDataContainer
68 * @see ifc.container._XIndexAccess
69 * @see ifc.container._XElementAccess
70 * @see ifc.container._XIndexReplace
72 public class CntUnoDataContainer extends TestCase {
74 /**
75 * Creating a Testenvironment for the interfaces to be tested.
76 * Creates an instance of the service
77 * <code>com.sun.star.cnt.CntUnoDataContainer</code> and adds
78 * to it one <code>CntUnoDataContainer</code> instance. <p>
79 * Object relations created :
80 * <ul>
81 * <li> <code>'INSTANCE1'</code> for
82 * {@link ifc.container._XIndexContainer},
83 * {@link ifc.container._XIndexReplace} : for this object
84 * elements contained in it are <code>CntUnoDataContainer</code>
85 * instances. (only one relation for one interface thread is now
86 * passed).</li>
87 * <li> <code>'InputStream'</code> for
88 * {@link ifc.io._XActiveDataSink} : a stream to set and get.
89 * </li>
90 * </ul>
92 protected TestEnvironment createTestEnvironment(
93 TestParameters Param, PrintWriter log) {
94 XInterface oObj = null;
95 Object oInterface = null;
96 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
97 Object relationContainer = null ;
98 Object xIn = null;
100 try {
101 oInterface = xMSF.createInstance
102 ( "com.sun.star.ucb.DataContainer" );
104 // adding one child container
105 XIndexContainer xIC = (XIndexContainer) UnoRuntime.queryInterface
106 (XIndexContainer.class, oInterface) ;
108 Object child = xMSF.createInstance
109 ( "com.sun.star.ucb.DataContainer" );
110 xIC.insertByIndex(0, child) ;
112 relationContainer = xMSF.createInstance
113 ( "com.sun.star.ucb.DataContainer" );
115 xIn = xMSF.createInstance
116 ( "com.sun.star.io.DataInputStream" );
118 catch( com.sun.star.uno.Exception e ) {
119 log.println("Can't create an object." );
120 throw new StatusException( "Can't create an object", e );
123 oObj = (XInterface) oInterface;
125 TestEnvironment tEnv = new TestEnvironment( oObj );
127 tEnv.addObjRelation("INSTANCE1", relationContainer) ;
128 tEnv.addObjRelation("InputStream", xIn) ;
130 return tEnv;
131 } // finish method getTestEnvironment
133 } // finish class BreakIterator