client.lua 1.26 KB
Newer Older
1
local openbus = require "openbus"
2
local log = require "openbus.util.logger"
3

4
require "openbus.test.util"
5

6 7 8
-- customize test configuration for this case
settestcfg(...)

9
-- setup the ORB
10
local orb = openbus.initORB(orbcfg)
11 12

-- load interface definition
13
orb:loadidlfile("idl/hello.idl")
14 15
local iface = orb.types:lookup("tecgraf::openbus::interop::simple::Hello")

16 17 18
-- get bus context manager
local OpenBusContext = orb.OpenBusContext

19
-- connect to the bus
20 21
local conn = OpenBusContext:createConnection(bushost, busport)
OpenBusContext:setDefaultConnection(conn)
22

23 24 25
-- login to the bus
conn:loginByPassword(user, password)

26
-- define service properties
27 28
properties[#properties+1] =
  {name="openbus.component.interface",value=iface.repID}
29

30
-- find the offered service
31
log:TEST("retrieve hello service")
32
local OfferRegistry = OpenBusContext:getOfferRegistry()
33
for _, offer in ipairs(findoffers(OfferRegistry, properties)) do
34 35 36 37 38 39
  local entity = getprop(offer.properties, "openbus.offer.entity")
  log:TEST("found service of ",entity,"!")
  local hello = offer.service_ref:getFacetByName(iface.name):__narrow(iface)
  local result = hello:sayHello()
  assert(result == "Hello "..user.."!", result)
  log:TEST("test successful for service of ",entity)
40
end
41

42
-- logout from the bus
43
conn:logout()
44
orb:shutdown()