tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _connectr / Connector.java
blob3128ef468c267eea0ca1f53c17ac1621841104d4
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._connectr;
21 import java.io.PrintWriter;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.utils;
28 import com.sun.star.uno.XInterface;
30 /**
31 * Test for object which is represented by service
32 * <code>com.sun.star.connection.Connector</code>. <p>
33 * Object implements the following interfaces :
34 * <ul>
35 * <li> <code>com::sun::star::connection::XConnector</code></li>
36 * </ul>
37 * Can be run in several threads.
38 * @see com.sun.star.connection.XConnector
39 * @see ifc.connection._XConnector
41 public class Connector extends TestCase {
43 /**
44 * Acceptor chooses the first port after <code>basePort</code>
45 * which is free.
47 protected static final int basePort = 10000 ;
48 private int curPort ;
49 private static String sOfficeHost = null ;
51 /**
52 * Retrieves host name where StarOffice is started from test
53 * parameter <code>'CONNECTION_STRING'</code>.
55 @Override
56 protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
57 String cncstr = (String) tParam.get("CONNECTION_STRING") ;
58 int idx = cncstr.indexOf("host=") + 5 ;
59 sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ;
62 /**
63 * Does nothing.
65 @Override
66 protected void cleanup( TestParameters tParam, PrintWriter log ) {
70 /**
71 * Creating a TestEnvironment for the interfaces to be tested.
72 * Just creates service <code>com.sun.star.connection.Connector</code>
74 @Override
75 public TestEnvironment createTestEnvironment(
76 TestParameters Param, PrintWriter log) throws Exception {
77 XInterface connector = (XInterface)
78 Param.getMSF().createInstance
79 ("com.sun.star.connection.Connector") ;
81 TestEnvironment tEnv = new TestEnvironment(connector) ;
83 // select the port
84 curPort = utils.getNextFreePort(basePort);
85 log.println("Choose Port nr: " + curPort);
87 // adding connection string as relation
88 tEnv.addObjRelation("XConnector.connectStr",
89 "socket,host=" + sOfficeHost + ",port=" + curPort) ;
91 // adding port number for freeing it.
92 tEnv.addObjRelation("Connector.Port", Integer.valueOf(curPort)) ;
94 return tEnv ;
97 /**
98 * Just clears flag which indicates that port is free now.
100 @Override
101 public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
102 TestParameters tParam) {
104 curPort = ((Integer)tEnv.getObjRelation("Connector.Port")).intValue();