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 abstract boolean run(XBridge bridge) throws Throwable;
protected final XBridge getBridge() throws com.sun.star.uno.Exception {
XMultiComponentFactory factory = context.getServiceManager();
XConnector connector = (XConnector) UnoRuntime.queryInterface(
XConnector.class,
factory.createInstanceWithContext(
"com.sun.star.connection.Connector", context));
XBridgeFactory bridgeFactory
= (XBridgeFactory) UnoRuntime.queryInterface(
XBridgeFactory.class,
factory.createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
System.out.println("Client: Connecting...");
XConnection connection = connector.connect(connectionDescription);
System.out.println("Client: ...connected...");
XBridge bridge = bridgeFactory.createBridge(
"", protocolDescription, connection, null);
System.out.println("Client: ...bridged.");
return bridge;
}
protected final void execute() { protected final void execute() {
int status = CLIENT_FAILED; int status = CLIENT_FAILED;
try { try {
XComponentContext context context = Bootstrap.createInitialComponentContext(null);
= Bootstrap.createInitialComponentContext(null); if (run(getBridge())) {
XMultiComponentFactory factory = context.getServiceManager();
XBridgeFactory bridgeFactory
= (XBridgeFactory) UnoRuntime.queryInterface(
XBridgeFactory.class,
factory.createInstanceWithContext(
"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...");
XConnection connection
= connector.connect(connectionDescription);
System.out.println("Client: ...connected...");
XBridge bridge = bridgeFactory.createBridge("",
protocolDescription,
connection, null);
System.out.println("Client: ...bridged.");
if (run(bridge)) {
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 (;;) {
System.out.println("Server: ...connected..."); XConnection connection = acceptor.accept(
XBridge bridge = bridgeFactory.createBridge("", connectionDescription);
protocolDescription, System.out.println("Server: ...connected...");
connection, XBridge bridge = bridgeFactory.createBridge(
provider); "", protocolDescription, 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);
} }