svx: prefix members of SdrUnoObj
[LibreOffice.git] / qadevOOo / tests / java / mod / _connector / uno / Connector.java
blob17b0c4e73d364ae6d50cb29455d8d6780e0b4ece
1 /*
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._connector.uno;
21 import com.sun.star.uno.XInterface;
22 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.utils;
28 /**
29 * Test for object which is represented by service
30 * <code>com.sun.star.connection.Connector</code>. <p>
31 * Object implements the following interfaces :
32 * <ul>
33 * <li> <code>com::sun::star::connection::XConnector</code></li>
34 * </ul>
35 * Can be run in several threads.
36 * @see com.sun.star.connection.XConnector
37 * @see ifc.connection._XConnector
39 public class Connector extends TestCase {
41 /**
42 * Acceptor chooses the first port after <code>basePort</code>
43 * which is free.
45 protected static final int basePort = 10000 ;
46 private int curPort ;
47 private static String sOfficeHost = null ;
49 /**
50 * Retrieves host name where StarOffice is started from test
51 * parameter <code>'CONNECTION_STRING'</code>.
53 @Override
54 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
55 String cncstr = (String) tParam.get("CONNECTION_STRING") ;
56 int idx = cncstr.indexOf("host=") + 5 ;
57 sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ;
60 /**
61 * Does nothing.
63 @Override
64 protected void cleanup( TestParameters tParam, PrintWriter log ) {
68 /**
69 * Creating a TestEnvironment for the interfaces to be tested.
70 * Just creates service <code>com.sun.star.connection.Connector</code>
72 @Override
73 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
75 XInterface connector = (XInterface)
76 Param.getMSF().createInstance
77 ("com.sun.star.connection.Connector") ;
79 TestEnvironment tEnv = new TestEnvironment(connector) ;
81 // select the port
82 curPort = utils.getNextFreePort(basePort);
83 log.println("Choose Port nr: " + curPort);
85 // adding connection string as relation
86 tEnv.addObjRelation("XConnector.connectStr",
87 "socket,host=" + sOfficeHost + ",port=" + curPort) ;
89 // adding port number for freeing it.
90 tEnv.addObjRelation("Connector.Port", Integer.valueOf(curPort)) ;
92 return tEnv ;
95 /**
96 * Just clears flag which indicates that port is free now.
98 @Override
99 public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
100 TestParameters tParam) {
102 curPort = ((Integer)tEnv.getObjRelation("Connector.Port")).intValue();