PipedConnection leftSide = new PipedConnection(new Object[]{rightSide});
BridgeFactory bridgeFactory = new BridgeFactory(); // create the needed bridgeFactory
// create a bridge
XBridge xBridge = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null);
// test that we get the same bridge
boolean passed = UnoRuntime.areSame(xBridge, bridgeFactory.getBridge("testbridge"));
// test that we can not create another bridge with same name
try {
XBridge dummy = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null);
passed = false;
}
catch(BridgeExistsException bridgeExistsException) {
}
// test getExistingBridges
XBridge xBridges[] = bridgeFactory.getExistingBridges();
passed = UnoRuntime.areSame(xBridge, xBridges[0]) && passed;
// dispose the bridge
XComponent xComponent = (XComponent)UnoRuntime.queryInterface(XComponent.class, xBridge);
xComponent.dispose();
// test that the bridge has been removed
passed = (bridgeFactory.getBridge("testbridge") == null) && passed;
rightSide = new PipedConnection(new Object[0]);
leftSide = new PipedConnection(new Object[]{rightSide});
// test that we really get a new bridge
XBridge xBridge_new = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null);
passed = !UnoRuntime.areSame(xBridge, xBridge_new) && passed;
for(int i = 0; i <10000; ++ i) {
Object x[] = new Object[100];
}