INTEGRATION: CWS jl3 (1.2.58); FILE MERGED

2003/12/11 11:05:32 sb 1.2.58.1: #114133# Refactored to support Bug114133_Test.java.
This commit is contained in:
Kurt Zenker
2004-03-25 13:57:46 +00:00
parent 4c495e17fe
commit 7395817e86

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: TestBed.java,v $ * $RCSfile: TestBed.java,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: vg $ $Date: 2003-05-22 08:37:42 $ * last change: $Author: kz $ $Date: 2004-03-25 14:57:46 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -145,30 +145,33 @@ public final class TestBed {
} }
public static abstract class Client { public static abstract class Client {
protected final void execute() { protected abstract boolean run(XBridge bridge) throws Throwable;
int status = CLIENT_FAILED;
try { protected final XBridge getBridge() throws com.sun.star.uno.Exception {
XComponentContext context
= Bootstrap.createInitialComponentContext(null);
XMultiComponentFactory factory = context.getServiceManager(); XMultiComponentFactory factory = context.getServiceManager();
XConnector connector = (XConnector) UnoRuntime.queryInterface(
XConnector.class,
factory.createInstanceWithContext(
"com.sun.star.connection.Connector", context));
XBridgeFactory bridgeFactory XBridgeFactory bridgeFactory
= (XBridgeFactory) UnoRuntime.queryInterface( = (XBridgeFactory) UnoRuntime.queryInterface(
XBridgeFactory.class, XBridgeFactory.class,
factory.createInstanceWithContext( factory.createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context)); "com.sun.star.bridge.BridgeFactory", context));
XConnector connector = (XConnector) UnoRuntime.queryInterface(
XConnector.class,
factory.createInstanceWithContext(
"com.sun.star.connection.Connector", context));
System.out.println("Client: Connecting..."); System.out.println("Client: Connecting...");
XConnection connection XConnection connection = connector.connect(connectionDescription);
= connector.connect(connectionDescription);
System.out.println("Client: ...connected..."); System.out.println("Client: ...connected...");
XBridge bridge = bridgeFactory.createBridge("", XBridge bridge = bridgeFactory.createBridge(
protocolDescription, "", protocolDescription, connection, null);
connection, null);
System.out.println("Client: ...bridged."); System.out.println("Client: ...bridged.");
if (run(bridge)) { return bridge;
}
protected final void execute() {
int status = CLIENT_FAILED;
try {
context = Bootstrap.createInitialComponentContext(null);
if (run(getBridge())) {
status = CLIENT_DONE; status = CLIENT_DONE;
} }
} catch (Throwable e) { } catch (Throwable e) {
@@ -177,7 +180,7 @@ public final class TestBed {
System.exit(status); System.exit(status);
} }
protected abstract boolean run(XBridge bridge) throws Throwable; private XComponentContext context;
} }
private static final class Server extends Thread { private static final class Server extends Thread {
@@ -206,13 +209,14 @@ public final class TestBed {
state = ACCEPTING; state = ACCEPTING;
notifyAll(); notifyAll();
} }
XConnection connection = acceptor.accept(connectionDescription); for (;;) {
XConnection connection = acceptor.accept(
connectionDescription);
System.out.println("Server: ...connected..."); System.out.println("Server: ...connected...");
XBridge bridge = bridgeFactory.createBridge("", XBridge bridge = bridgeFactory.createBridge(
protocolDescription, "", protocolDescription, connection, provider);
connection,
provider);
System.out.println("Server: ...bridged."); System.out.println("Server: ...bridged.");
}
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(System.err); e.printStackTrace(System.err);
} }