Update ooo320-m1
[ooovba.git] / javaunohelper / test / com / sun / star / comp / helper / Bootstrap_Test.java
blob05b123d34ff3c0b7e253c4967778379c3f1a7f80
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: Bootstrap_Test.java,v $
10 * $Revision: 1.4 $
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;
47 System.err.println();
48 System.out.println("*******************************************************************");
49 System.err.println("Bootstrap - doing tests...");
50 System.err.println();
52 try {
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" ) ))
61 throw new Exception(
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:");
69 System.err.println();
70 if (services.length == 0)
71 System.out.println("No services avialable!");
73 else
74 for ( int i=0; i<services.length; i++ )
75 System.out.println(services[i]);
77 XComponent xComp = UnoRuntime.queryInterface(
78 XComponent.class, xContext );
79 xComp.dispose();
81 passed = true;
83 catch (Exception e) {
84 e.printStackTrace();
86 System.err.println();
87 System.err.println("Bootstrap test passed? " + passed);
88 System.out.println("*******************************************************************");
89 System.err.println();
90 return passed;
93 private static void usage() {
94 System.out.println();
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");
99 System.exit( -1 );
102 static public void main(String args[]) throws java.lang.Exception {
103 if ( args.length == 0 )
104 usage();
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( '=' );
111 if (n > 0)
113 bootstrap_parameters.put( arg.substring( 0, n ), arg.substring( n +1 ) );
117 System.exit( test(args[0], bootstrap_parameters) == true ? 0: -1 );