2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
28 import com
.sun
.star
.container
.XIndexContainer
;
29 import com
.sun
.star
.lang
.XMultiServiceFactory
;
30 import com
.sun
.star
.uno
.UnoRuntime
;
31 import com
.sun
.star
.uno
.XInterface
;
34 * Test for object which is represented by service
35 * <code>com.sun.star.cnt.CntUnoDataContainer</code>. <p>
36 * Object implements the following interfaces :
38 * <li> <code>com::sun::star::io::XActiveDataSink</code></li>
39 * <li> <code>com::sun::star::container::XIndexContainer</code></li>
40 * <li> <code>com::sun::star::ucb::XDataContainer</code></li>
41 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
42 * <li> <code>com::sun::star::container::XElementAccess</code></li>
43 * <li> <code>com::sun::star::container::XIndexReplace</code></li>
45 * This object test <b> is NOT </b> designed to be run in several
46 * threads concurently.
47 * @see com.sun.star.io.XActiveDataSink
48 * @see com.sun.star.container.XIndexContainer
49 * @see com.sun.star.ucb.XDataContainer
50 * @see com.sun.star.container.XIndexAccess
51 * @see com.sun.star.container.XElementAccess
52 * @see com.sun.star.container.XIndexReplace
53 * @see ifc.io._XActiveDataSink
54 * @see ifc.container._XIndexContainer
55 * @see ifc.ucb._XDataContainer
56 * @see ifc.container._XIndexAccess
57 * @see ifc.container._XElementAccess
58 * @see ifc.container._XIndexReplace
60 public class CntUnoDataContainer
extends TestCase
{
63 * Creating a Testenvironment for the interfaces to be tested.
64 * Creates an instance of the service
65 * <code>com.sun.star.cnt.CntUnoDataContainer</code> and adds
66 * to it one <code>CntUnoDataContainer</code> instance. <p>
67 * Object relations created :
69 * <li> <code>'INSTANCE1'</code> for
70 * {@link ifc.container._XIndexContainer},
71 * {@link ifc.container._XIndexReplace} : for this object
72 * elements contained in it are <code>CntUnoDataContainer</code>
73 * instances. (only one relation for one interface thread is now
75 * <li> <code>'InputStream'</code> for
76 * {@link ifc.io._XActiveDataSink} : a stream to set and get.
81 protected TestEnvironment
createTestEnvironment(
82 TestParameters Param
, PrintWriter log
) {
83 XInterface oObj
= null;
84 Object oInterface
= null;
85 XMultiServiceFactory xMSF
= Param
.getMSF();
86 Object relationContainer
= null ;
90 oInterface
= xMSF
.createInstance
91 ( "com.sun.star.ucb.DataContainer" );
93 // adding one child container
94 XIndexContainer xIC
= UnoRuntime
.queryInterface
95 (XIndexContainer
.class, oInterface
) ;
97 Object child
= xMSF
.createInstance
98 ( "com.sun.star.ucb.DataContainer" );
99 xIC
.insertByIndex(0, child
) ;
101 relationContainer
= xMSF
.createInstance
102 ( "com.sun.star.ucb.DataContainer" );
104 xIn
= xMSF
.createInstance
105 ( "com.sun.star.io.DataInputStream" );
107 catch( com
.sun
.star
.uno
.Exception e
) {
108 log
.println("Can't create an object." );
109 throw new StatusException( "Can't create an object", e
);
112 oObj
= (XInterface
) oInterface
;
114 TestEnvironment tEnv
= new TestEnvironment( oObj
);
116 tEnv
.addObjRelation("INSTANCE1", relationContainer
) ;
117 tEnv
.addObjRelation("InputStream", xIn
) ;
120 } // finish method getTestEnvironment
122 } // finish class BreakIterator