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: Bootstrap_Test.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 com
.sun
.star
.comp
.helper
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.AnyConverter
;
36 import com
.sun
.star
.uno
.XComponentContext
;
37 import com
.sun
.star
.lang
.XComponent
;
38 import com
.sun
.star
.lang
.XMultiServiceFactory
;
41 public class Bootstrap_Test
{
43 static public boolean test( String ini_file
, java
.util
.Hashtable bootstrap_parameters
)
44 throws java
.lang
.Exception
46 boolean passed
= false;
48 System
.out
.println("*******************************************************************");
49 System
.err
.println("Bootstrap - doing tests...");
53 XComponentContext xContext
=
54 com
.sun
.star
.comp
.helper
.Bootstrap
.defaultBootstrap_InitialComponentContext(
55 ini_file
, bootstrap_parameters
);
57 if (AnyConverter
.isVoid(
58 xContext
.getValueByName(
59 "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ))
62 "no /singletons/com.sun.star.reflection.theTypeDescriptionManager!" );
65 XMultiServiceFactory msf
= UnoRuntime
.queryInterface(
66 XMultiServiceFactory
.class, xContext
.getServiceManager() );
67 String services
[] = msf
.getAvailableServiceNames();
68 System
.out
.println("Available services are:");
70 if (services
.length
== 0)
71 System
.out
.println("No services avialable!");
74 for ( int i
=0; i
<services
.length
; i
++ )
75 System
.out
.println(services
[i
]);
77 XComponent xComp
= UnoRuntime
.queryInterface(
78 XComponent
.class, xContext
);
87 System
.err
.println("Bootstrap test passed? " + passed
);
88 System
.out
.println("*******************************************************************");
93 private static void usage() {
95 System
.out
.println("usage:");
96 System
.out
.println("java com.sun.star.comp.helper.Bootstrap_Test ini-file name=value ...");
97 System
.out
.println("example:");
98 System
.out
.println("java com.sun.star.comp.helper.Bootstrap_Test file:///c:/ooo10/program/uno.ini SYSBINDIR=file:///c:/ooo10/program");
102 static public void main(String args
[]) throws java
.lang
.Exception
{
103 if ( args
.length
== 0 )
106 java
.util
.Hashtable bootstrap_parameters
= new java
.util
.Hashtable();
107 for ( int nPos
= 1; nPos
< args
.length
; ++nPos
)
109 String arg
= args
[ nPos
];
110 int n
= arg
.indexOf( '=' );
113 bootstrap_parameters
.put( arg
.substring( 0, n
), arg
.substring( n
+1 ) );
117 System
.exit( test(args
[0], bootstrap_parameters
) == true ?
0: -1 );