1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="bridge_XBridgeFactory" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32*****
33'*************************************************************************
34
35
36
37' Be sure that all variables are dimensioned:
38option explicit
39
40'*************************************************************************
41' This Interface/Service test depends on the following GLOBAL variables,
42' which must be specified in the object creation:
43
44'      Global sProtocol As String
45
46'*************************************************************************
47
48
49
50
51
52
53Sub RunTest()
54
55'*************************************************************************
56' INTERFACE:
57' com.sun.star.bridge.XBridgeFactory
58'*************************************************************************
59On Error Goto ErrHndl
60    Dim bOK As Boolean
61    Dim connectionStr As String
62    Dim oConnector As Object, oAcceptor As Object
63    Dim xConnection As Object
64    Dim oBridge As Object
65    Dim aBridges As Variant, args(1) As Variant
66    oConnector = createUnoService("basichelper.Connector")
67    oAcceptor = createUnoService("com.sun.star.connection.Acceptor")
68
69    Dim iPos1 As Integer, iPos2 As Integer
70
71    iPos1 = inStr(1, CNCSTR, "socket")
72    iPos2 = inStr(iPos1, CNCSTR, "port=")
73
74    connectionStr = mid(CNCSTR, iPos1, iPos2 - iPos1 + 5) + "18888"
75
76    Out.Log("Connection string is '" + connectionStr + "'")
77
78    args(0) = createUnoService("com.sun.star.connection.Connector")
79    args(1) = connectionStr
80
81    ' When call initialize() method, a new thread is created and tries to
82    ' connect to Acceptor after some seconds.
83
84    oConnector.initialize(args())
85
86    xConnection = oAcceptor.accept(connectionStr)
87
88'    wait(5000)
89
90'    xConnection = oConnector.getByName("Connection")
91
92    if (isNull(xConnector)) then
93        Out.Log("Connection was not created !!!")
94    end if
95    Out.Log("State of connector: " + oConnector.getByName("State"))
96
97    Test.StartMethod("createBridge()")
98    bOK = true
99    oBridge = oObj.createBridge("NewBasicBridge", sProtocol, xConnection, NULL_OBJECT)
100    bOK = bOK AND hasUnoInterfaces(oBridge, "com.sun.star.bridge.XBridge")
101    Test.MethodTested("createBridge()", bOK)
102
103    Test.StartMethod("getBridge()")
104    bOK = true
105    oBridge = oObj.getBridge("NewBasicBridge")
106    bOK = bOK AND NOT isNull(oBridge) AND (oBridge.Name = "NewBasicBridge")
107    Test.MethodTested("getBridge()", bOK)
108
109    Test.StartMethod("getExistingBridges()")
110    bOK = true
111    aBridges = oObj.getExistingBridges()
112    bOK = bOK AND NOT isNull(aBridges) AND ubound(aBridges()) > -1
113    Test.MethodTested("getExistingBridges()", bOK)
114
115    Out.Log("Finally the bridge must be disposed ...")
116    xConnection.close()
117
118Exit Sub
119ErrHndl:
120    Test.Exception()
121    bOK = false
122    resume next
123End Sub
124</script:module>
125