BridgeFactory_Test.java (2be43276) | BridgeFactory_Test.java (9cbd97ce) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 15 unchanged lines hidden (view full) --- 24package com.sun.star.comp.bridgefactory; 25 26import com.sun.star.bridge.BridgeExistsException; 27import com.sun.star.bridge.XBridge; 28import com.sun.star.comp.connections.PipedConnection; 29import com.sun.star.connection.XConnection; 30import com.sun.star.lang.XComponent; 31import com.sun.star.uno.UnoRuntime; | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 15 unchanged lines hidden (view full) --- 24package com.sun.star.comp.bridgefactory; 25 26import com.sun.star.bridge.BridgeExistsException; 27import com.sun.star.bridge.XBridge; 28import com.sun.star.comp.connections.PipedConnection; 29import com.sun.star.connection.XConnection; 30import com.sun.star.lang.XComponent; 31import com.sun.star.uno.UnoRuntime; |
32import complexlib.ComplexTestCase; | |
33 | 32 |
34public final class BridgeFactory_Test extends ComplexTestCase { 35 public String getTestObjectName() { 36 return getClass().getName(); 37 } | 33import org.junit.Test; 34import static org.junit.Assert.*; |
38 | 35 |
39 public String[] getTestMethodNames() { 40 return new String[] { "test" }; 41 } 42 | 36public final class BridgeFactory_Test { 37 @Test |
43 public void test() throws Exception { 44 PipedConnection rightSide = new PipedConnection(new Object[0]); 45 PipedConnection leftSide = new PipedConnection(new Object[]{rightSide}); 46 47 BridgeFactory bridgeFactory = new BridgeFactory(); // create the needed bridgeFactory 48 49 // create a bridge 50 XBridge xBridge = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null); 51 52 // test that we get the same bridge | 38 public void test() throws Exception { 39 PipedConnection rightSide = new PipedConnection(new Object[0]); 40 PipedConnection leftSide = new PipedConnection(new Object[]{rightSide}); 41 42 BridgeFactory bridgeFactory = new BridgeFactory(); // create the needed bridgeFactory 43 44 // create a bridge 45 XBridge xBridge = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null); 46 47 // test that we get the same bridge |
53 assure("", UnoRuntime.areSame(xBridge, | 48 assertTrue("", UnoRuntime.areSame(xBridge, |
54 bridgeFactory.getBridge("testbridge"))); 55 56 // test that we can not create another bridge with same name 57 try { 58 XBridge dummy = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null); 59 | 49 bridgeFactory.getBridge("testbridge"))); 50 51 // test that we can not create another bridge with same name 52 try { 53 XBridge dummy = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null); 54 |
60 failed(""); | 55 fail(""); |
61 } 62 catch(BridgeExistsException bridgeExistsException) { 63 } 64 65 66 // test getExistingBridges 67 XBridge xBridges[] = bridgeFactory.getExistingBridges(); | 56 } 57 catch(BridgeExistsException bridgeExistsException) { 58 } 59 60 61 // test getExistingBridges 62 XBridge xBridges[] = bridgeFactory.getExistingBridges(); |
68 assure("", UnoRuntime.areSame(xBridge, xBridges[0])); | 63 assertTrue("", UnoRuntime.areSame(xBridge, xBridges[0])); |
69 70 // dispose the bridge 71 XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, xBridge); 72 xComponent.dispose(); 73 74 75 // test that the bridge has been removed | 64 65 // dispose the bridge 66 XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, xBridge); 67 xComponent.dispose(); 68 69 70 // test that the bridge has been removed |
76 assure("", bridgeFactory.getBridge("testbridge") == null); | 71 assertTrue("", bridgeFactory.getBridge("testbridge") == null); |
77 78 79 80 rightSide = new PipedConnection(new Object[0]); 81 leftSide = new PipedConnection(new Object[]{rightSide}); 82 83 84 // test that we really get a new bridge 85 XBridge xBridge_new = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null); | 72 73 74 75 rightSide = new PipedConnection(new Object[0]); 76 leftSide = new PipedConnection(new Object[]{rightSide}); 77 78 79 // test that we really get a new bridge 80 XBridge xBridge_new = bridgeFactory.createBridge("testbridge", "urp", (XConnection)leftSide, null); |
86 assure("", !UnoRuntime.areSame(xBridge, xBridge_new)); | 81 assertTrue("", !UnoRuntime.areSame(xBridge, xBridge_new)); |
87 88 for(int i = 0; i <10000; ++ i) { 89 Object x[] = new Object[100]; 90 } 91 92 // test getExistingBridges 93 xBridges = bridgeFactory.getExistingBridges(); | 82 83 for(int i = 0; i <10000; ++ i) { 84 Object x[] = new Object[100]; 85 } 86 87 // test getExistingBridges 88 xBridges = bridgeFactory.getExistingBridges(); |
94 assure("", | 89 assertTrue("", |
95 xBridges.length == 1 96 && UnoRuntime.areSame(xBridge_new, xBridges[0])); 97 98 // dispose the new bridge 99 XComponent xComponent_new = UnoRuntime.queryInterface(XComponent.class, xBridge_new); 100 xComponent_new.dispose(); 101 } 102} | 90 xBridges.length == 1 91 && UnoRuntime.areSame(xBridge_new, xBridges[0])); 92 93 // dispose the new bridge 94 XComponent xComponent_new = UnoRuntime.queryInterface(XComponent.class, xBridge_new); 95 xComponent_new.dispose(); 96 } 97} |