merge the formfield patch from ooo-build
[ooovba.git] / ure / source / uretest / JavaClient.java
blob3caadf8e1feb71a593d1431f904c511d73dc4a50
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: JavaClient.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 test.java.javaclient;
33 import com.sun.star.bridge.XBridge;
34 import com.sun.star.bridge.XBridgeFactory;
35 import com.sun.star.comp.helper.Bootstrap;
36 import com.sun.star.connection.Connector;
37 import com.sun.star.lang.XComponent;
38 import com.sun.star.lang.XMultiComponentFactory;
39 import com.sun.star.lib.uno.helper.UnoUrl;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XComponentContext;
42 import test.types.Data;
43 import test.types.XServer;
45 public final class JavaClient {
46 public static void main(String[] arguments) throws Exception {
47 XComponentContext context = Bootstrap.createInitialComponentContext(
48 null);
49 XMultiComponentFactory manager = context.getServiceManager();
50 if (manager == null) {
51 throw new NullPointerException("no service manager");
53 XBridgeFactory factory = UnoRuntime.queryInterface(
54 XBridgeFactory.class,
55 manager.createInstanceWithContext(
56 "com.sun.star.bridge.BridgeFactory", context));
57 if (factory == null) {
58 throw new NullPointerException("no bridge factory");
60 UnoUrl url = UnoUrl.parseUnoUrl(arguments[0]);
61 XBridge bridge = factory.createBridge(
62 "", url.getProtocolAndParametersAsString(),
63 Connector.create(context).connect(
64 url.getConnectionAndParametersAsString()),
65 null);
66 Data d = UnoRuntime.queryInterface(
67 XServer.class, bridge.getInstance(url.getRootOid())).getData();
68 UnoRuntime.queryInterface(XComponent.class, bridge).dispose();
69 if (!d.m1.equals("Hello") || d.m2 != 42) {
70 throw new RuntimeException("Data object contains bad values");
74 private JavaClient() {}