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