svx: prefix members of SdrUnoObj
[LibreOffice.git] / qadevOOo / tests / java / mod / _acceptor / Acceptor.java
blob0985a6afffea2d3185a04dd6f504cedc70d55bdf
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._acceptor;
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 * Here <code>com.sun.star.connection.Acceptor</code> service is tested.<p>
32 * Test allows to run object tests in several threads concurrently.
33 * @see com.sun.star.connection.Acceptor
34 * @see com.sun.star.connection.XAcceptor
35 * @see com.sun.star.connection.XConnector
36 * @see ifc.connection._XAcceptor
38 public class Acceptor 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 String sOfficeHost = null ;
49 /**
50 * Retrieves host name where StarOffice is started from test
51 * parameter <code>'CONNECTION_STRING'</code>.
53 @Override
54 public void initialize( TestParameters tParam, PrintWriter log ) {
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 * Creating a TestEnvironment for the interfaces to be tested. <p>
62 * Creates <code>Acceptor</code> service and passed as relation
63 * connection string where port for accepting is unique among
64 * different object test threads. <p>
65 * The following object relations are created :
66 * <ul>
67 * <li> <code>'XAcceptor.connectStr'</code> : String variable for
68 * <code>XAcceptor</code> interface test. Has the following format :
69 * <code>'socket,host=<SOHost>,port=<UniquePort>' where <SOHost> is
70 * the host where StarOffice is started. </li>
71 * <li> <code>'Acceptor.Port'</code> : Integer value which specifies
72 * port on which Acceptor must listen, and which is required
73 * when disposing environment, to free this port number. </li>
74 * <ul>
76 @Override
77 public TestEnvironment createTestEnvironment(
78 TestParameters Param, PrintWriter log ) throws Exception {
80 XInterface oObj = null;
81 XInterface acceptor = null;
83 acceptor = (XInterface)
84 Param.getMSF().createInstance
85 ("com.sun.star.connection.Acceptor");
87 // select the port
88 curPort = utils.getNextFreePort(basePort);
89 log.println("Choose Port nr: " + curPort);
90 oObj = acceptor;
92 TestEnvironment tEnv = new TestEnvironment(oObj) ;
94 // adding connection string as relation
95 tEnv.addObjRelation("XAcceptor.connectStr",
96 "socket,host=" + sOfficeHost + ",port=" + curPort) ;
98 // adding port number for freeing it.
99 tEnv.addObjRelation("Acceptor.Port", Integer.valueOf(curPort)) ;
101 return tEnv ;
105 * Just clears flag which indicates that port is free now.
107 @Override
108 public synchronized void disposeTestEnvironment( TestEnvironment tEnv,
109 TestParameters tParam) {
111 curPort = ((Integer)tEnv.getObjRelation("Acceptor.Port")).intValue();