1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CntUnoDataContainer.java,v $
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 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
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
;
46 * Test for object which is represented by service
47 * <code>com.sun.star.cnt.CntUnoDataContainer</code>. <p>
48 * Object implements the following interfaces :
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>
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
{
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 :
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
87 * <li> <code>'InputStream'</code> for
88 * {@link ifc.io._XActiveDataSink} : a stream to set and get.
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 ;
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
) ;
131 } // finish method getTestEnvironment
133 } // finish class BreakIterator