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 .
19 package com
.sun
.star
.comp
.helper
;
21 import com
.sun
.star
.uno
.UnoRuntime
;
22 import com
.sun
.star
.uno
.AnyConverter
;
24 import com
.sun
.star
.uno
.XComponentContext
;
25 import com
.sun
.star
.lang
.XComponent
;
26 import com
.sun
.star
.lang
.XMultiServiceFactory
;
28 import java
.util
.logging
.Logger
;
29 import java
.util
.logging
.Level
;
32 public class Bootstrap_Test
{
34 private static final Logger logger
= Logger
.getLogger(Bootstrap_Test
.class.getName());
36 public static boolean test( String ini_file
, Map
<String
,String
> bootstrap_parameters
)
37 throws java
.lang
.Exception
39 boolean passed
= false;
40 logger
.log(Level
.INFO
, "Bootstrap - doing tests...");
43 XComponentContext xContext
=
44 com
.sun
.star
.comp
.helper
.Bootstrap
.defaultBootstrap_InitialComponentContext(
45 ini_file
, bootstrap_parameters
);
47 if (AnyConverter
.isVoid(
48 xContext
.getValueByName(
49 "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ))
52 "no /singletons/com.sun.star.reflection.theTypeDescriptionManager!" );
55 XMultiServiceFactory msf
= UnoRuntime
.queryInterface(
56 XMultiServiceFactory
.class, xContext
.getServiceManager() );
57 String services
[] = msf
.getAvailableServiceNames();
58 logger
.log(Level
.FINE
, "Available services are:");
59 if (services
.length
== 0)
60 logger
.log(Level
.FINE
, "No services available!");
63 for ( int i
=0; i
<services
.length
; i
++ )
64 logger
.log(Level
.FINE
, services
[i
]);
66 XComponent xComp
= UnoRuntime
.queryInterface(
67 XComponent
.class, xContext
);
75 logger
.log(Level
.INFO
, "Bootstrap test passed? " + passed
);
79 private static void usage() {
81 System
.out
.println("usage:");
82 System
.out
.println("java com.sun.star.comp.helper.Bootstrap_Test ini-file name=value ...");
83 System
.out
.println("example:");
84 System
.out
.println("java com.sun.star.comp.helper.Bootstrap_Test file:///c:/ooo10/program/uno.ini SYSBINDIR=file:///c:/ooo10/program");
88 public static void main(String args
[]) throws java
.lang
.Exception
{
89 if ( args
.length
== 0 )
92 java
.util
.HashMap
<String
,String
> bootstrap_parameters
= new java
.util
.HashMap
<String
,String
>();
93 for ( int nPos
= 1; nPos
< args
.length
; ++nPos
) {
94 if (args
[nPos
].contains("=")) {
95 String bootstrap_parameter
[] = args
[nPos
].split("=",2);
96 if (bootstrap_parameter
[0].length() > 0) {
97 bootstrap_parameters
.put( bootstrap_parameter
[0], bootstrap_parameter
[1] );
100 System
.out
.println("The 1st argument in a bootstrap parameter is the key of a HashMap element and can't be null : '" + args
[nPos
] + "'");
104 System
.out
.println();
105 System
.out
.println("Missing '=' in bootstrap parameter : '" + args
[nPos
] + "'");
110 System
.exit( test(args
[0], bootstrap_parameters
) ?
0: -1 );