1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package com.sun.star.comp.helper; 29 30 import com.sun.star.uno.UnoRuntime; 31 import com.sun.star.uno.AnyConverter; 32 33 import com.sun.star.uno.XComponentContext; 34 import com.sun.star.lang.XComponent; 35 import com.sun.star.lang.XMultiServiceFactory; 36 37 38 public class Bootstrap_Test { 39 40 static public boolean test( String ini_file, java.util.Hashtable bootstrap_parameters ) 41 throws java.lang.Exception 42 { 43 boolean passed = false; 44 System.err.println(); 45 System.out.println("*******************************************************************"); 46 System.err.println("Bootstrap - doing tests..."); 47 System.err.println(); 48 49 try { 50 XComponentContext xContext = 51 com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext( 52 ini_file, bootstrap_parameters ); 53 54 if (AnyConverter.isVoid( 55 xContext.getValueByName( 56 "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) )) 57 { 58 throw new Exception( 59 "no /singletons/com.sun.star.reflection.theTypeDescriptionManager!" ); 60 } 61 62 XMultiServiceFactory msf = UnoRuntime.queryInterface( 63 XMultiServiceFactory.class, xContext.getServiceManager() ); 64 String services[] = msf.getAvailableServiceNames(); 65 System.out.println("Available services are:"); 66 System.err.println(); 67 if (services.length == 0) 68 System.out.println("No services avialable!"); 69 70 else 71 for ( int i=0; i<services.length; i++ ) 72 System.out.println(services[i]); 73 74 XComponent xComp = UnoRuntime.queryInterface( 75 XComponent.class, xContext ); 76 xComp.dispose(); 77 78 passed = true; 79 } 80 catch (Exception e) { 81 e.printStackTrace(); 82 } 83 System.err.println(); 84 System.err.println("Bootstrap test passed? " + passed); 85 System.out.println("*******************************************************************"); 86 System.err.println(); 87 return passed; 88 } 89 90 private static void usage() { 91 System.out.println(); 92 System.out.println("usage:"); 93 System.out.println("java com.sun.star.comp.helper.Bootstrap_Test ini-file name=value ..."); 94 System.out.println("example:"); 95 System.out.println("java com.sun.star.comp.helper.Bootstrap_Test file:///c:/ooo10/program/uno.ini SYSBINDIR=file:///c:/ooo10/program"); 96 System.exit( -1 ); 97 } 98 99 static public void main(String args[]) throws java.lang.Exception { 100 if ( args.length == 0 ) 101 usage(); 102 103 java.util.Hashtable bootstrap_parameters = new java.util.Hashtable(); 104 for ( int nPos = 1; nPos < args.length; ++nPos ) 105 { 106 String arg = args[ nPos ]; 107 int n = arg.indexOf( '=' ); 108 if (n > 0) 109 { 110 bootstrap_parameters.put( arg.substring( 0, n ), arg.substring( n +1 ) ); 111 } 112 } 113 114 System.exit( test(args[0], bootstrap_parameters) == true ? 0: -1 ); 115 } 116 } 117 118