2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod
._brdgfctr
;
21 import java
.io
.PrintWriter
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
28 import com
.sun
.star
.uno
.XInterface
;
31 * Tests <code>com.sun.star.bridge.BridgeFactory</code>
33 * @see com.sun.star.bridge.XBridgeFactory
34 * @see com.sun.star.lang.XComponent
35 * @see ifc.bridge._XBridgeFactory
36 * @see ifc.lang._XComponent
38 public class BridgeFactory
extends TestCase
{
41 * Retrieves host name where StarOffice is started from test
42 * parameter <code>'CONNECTION_STRING'</code>.
45 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
46 String cncstr
= (String
) tParam
.get("CONNECTION_STRING") ;
47 int idx
= cncstr
.indexOf("host=") + 5 ;
48 sOfficeHost
= cncstr
.substring(idx
, cncstr
.indexOf(",", idx
)) ;
52 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
56 * Acceptor chooses the first port after <code>basePort</code>
59 protected static final int basePort
= 50003 ;
61 private static String sOfficeHost
= null ;
64 * Creating a TestEnvironment for the interfaces to be tested.
65 * Just creates <code>com.sun.star.bridge.BridgeFactory</code>
66 * service as object to be tested.
69 public TestEnvironment
createTestEnvironment(
70 TestParameters Param
, PrintWriter log
) throws Exception
{
72 XInterface oObj
= (XInterface
) Param
.getMSF().createInstance
73 ("com.sun.star.bridge.BridgeFactory") ;
75 TestEnvironment tEnv
= new TestEnvironment(oObj
) ;
78 curPort
= utils
.getNextFreePort(basePort
);
79 log
.println("Choose Port nr: " + curPort
);
81 // adding connection string as relation
82 tEnv
.addObjRelation("CNNCTSTR",
83 "socket,host=" + sOfficeHost
+ ",port=" + curPort
) ;
85 // adding port number for freeing it.
86 tEnv
.addObjRelation("Connector.Port", Integer
.valueOf(curPort
)) ;
92 * Just clears flag which indicates that port is free now.
95 public synchronized void disposeTestEnvironment( TestEnvironment tEnv
,
96 TestParameters tParam
) {
97 curPort
= ((Integer
)tEnv
.getObjRelation("Connector.Port")).intValue() ;