Update ooo320-m1
[ooovba.git] / javaunohelper / test / com / sun / star / comp / helper / RegistryServiceFactory_Test.java
blob4a545ef6ca9167c8de31f0e4eaf6bda9009ea5fd
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: RegistryServiceFactory_Test.java,v $
10 * $Revision: 1.3 $
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.comp.loader.JavaLoader;
35 import com.sun.star.comp.servicemanager.ServiceManager;
36 import com.sun.star.uno.UnoRuntime;
38 import com.sun.star.container.XSet;
39 import com.sun.star.container.XContentEnumerationAccess;
40 import com.sun.star.container.XEnumeration;
41 import com.sun.star.container.XEnumerationAccess;
42 import com.sun.star.container.XElementAccess;
44 import com.sun.star.lang.XComponent;
46 import com.sun.star.lang.XServiceInfo;
47 import com.sun.star.lang.XMultiServiceFactory;
48 import com.sun.star.lang.XSingleServiceFactory;
49 import com.sun.star.lang.XInitialization;
51 import com.sun.star.loader.XImplementationLoader;
53 import com.sun.star.registry.XSimpleRegistry;
55 public class RegistryServiceFactory_Test {
57 static public boolean test(String applicat) throws java.lang.Exception {
58 boolean passed = false;
59 System.err.println();
60 System.out.println("*******************************************************************");
61 System.err.println("RegistryServiceFactory - doing tests...");
62 System.err.println();
64 try {
65 XMultiServiceFactory msf = RegistryServiceFactory.create( applicat );
66 String services[] = msf.getAvailableServiceNames();
67 System.out.println("Available services are:");
68 System.err.println();
69 if (services.length == 0)
70 System.out.println("No services avialable!");
72 else
73 for ( int i=0; i<services.length; i++ )
74 System.out.println(services[i]);
76 passed = true;
78 catch (Exception e) {
79 e.printStackTrace();
81 System.err.println();
82 System.err.println("RegistryServiceFactory test passed? " + passed);
83 System.out.println("*******************************************************************");
84 System.err.println();
85 return passed;
88 private static void usage() {
89 System.out.println();
90 System.out.println("usage:");
91 System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory [rdb-file]");
92 System.out.println("example:");
93 System.out.println("java com.sun.star.comp.helper.RegistryServiceFactory c:\\applicat.rdb");
94 System.exit( -1 );
97 static public void main(String args[]) throws java.lang.Exception {
98 if ( args.length != 1 )
99 usage();
100 System.exit( test(args[0]) == true ? 0: -1 );