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: NamingService.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 ************************************************************************/
31 package mod
._namingservice
.uno
;
33 import com
.sun
.star
.lang
.XMultiServiceFactory
;
34 import com
.sun
.star
.uno
.XInterface
;
35 import java
.io
.PrintWriter
;
36 import lib
.StatusException
;
38 import lib
.TestEnvironment
;
39 import lib
.TestParameters
;
42 * Test for object which is represented by service
43 * <code>com.sun.star.uno.NamingService</code>. <p>
44 * Object implements the following interfaces :
46 * <li> <code>com::sun::star::uno::XNamingService</code></li>
48 * This object test <b> is NOT </b> designed to be run in several
49 * threads concurently.
50 * @see com.sun.star.uno.XNamingService
51 * @see com.sun.star.uno.NamingService
52 * @see ifc.uno._XNamingService
54 public class NamingService
extends TestCase
{
57 * Creating a Testenvironment for the interfaces to be tested.
58 * Creates an instance of the service
59 * <code>com.sun.star.uno.NamingService</code>.
60 * Object relations created :
62 * <li> <code>'XNamingService.RegisterObject'</code> for
63 * {@link ifc.uno._XNamingService} : an object
64 * which can be registered. Here it is an instance
65 * of <code>com.sun.star.lang.ServiceManager</code>
69 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
70 XInterface oObj
= null;
71 Object oInterface
= null;
72 XMultiServiceFactory xMSF
= null;
75 xMSF
= (XMultiServiceFactory
)Param
.getMSF();
76 oInterface
= xMSF
.createInstance
77 ( "com.sun.star.uno.NamingService" );
79 catch( com
.sun
.star
.uno
.Exception e
) {
80 log
.println("Service not available" );
83 oObj
= (XInterface
) oInterface
;
85 log
.println( " creating a new environment for object" );
86 TestEnvironment tEnv
= new TestEnvironment( oObj
);
88 // objRelation for XNamingService as object to be registered
90 tEnv
.addObjRelation("XNamingService.RegisterObject",
92 ("com.sun.star.lang.ServiceManager")) ;
93 } catch (com
.sun
.star
.uno
.Exception e
) {
94 log
.println("Can't create object relation") ;
95 throw new StatusException("Can't create object relation", e
) ;
99 } // finish method getTestEnvironment