Commit f07e7b08 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia

[OPENBUS-2553] [Lua] Implementar teste de interoperabilidade da serialização de cadeias

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/sdk/lua/branches/02_00_01@157532 ae0415b3-e90b-0410-900d-d0be9363c56b
parent befefe1c
local log = require "openbus.util.logger"
local openbus = require "openbus"
require "openbus.test.util"
-- setup the ORB
local orb = openbus.initORB()
-- load interface definition
orb:loadidlfile("idl/proxy.idl")
local iface = orb.types:lookup("tecgraf::openbus::interop::chaining::HelloProxy")
-- customize test configuration for this case
settestcfg(iface, ...)
-- get bus context manager
local OpenBusContext = orb.OpenBusContext
-- connect to the bus
local conn = OpenBusContext:createConnection(bushost, busport)
OpenBusContext:setDefaultConnection(conn)
-- login to the bus
conn:loginByPassword(user, password)
-- define service properties
properties[#properties+1] =
{name="openbus.component.interface",value=iface.repID}
-- find the offered service
log:TEST("retrieve hello service")
local OfferRegistry = OpenBusContext:getOfferRegistry()
for _, offer in ipairs(findoffers(OfferRegistry, properties)) do
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 login = getprop(offer.properties, "openbus.offer.login")
local chain = OpenBusContext:makeChainFor(login)
local encoded = OpenBusContext:encodeChain(chain)
local result = hello:fetchHello(encoded)
assert(result == "Hello "..user.."!", result)
log:TEST("test successful for service of ",entity)
end
-- logout from the bus
conn:logout()
orb:shutdown()
local log = require "openbus.util.logger"
local openbus = require "openbus"
local sysex = require "openbus.util.sysex"
local ComponentContext = require "scs.core.ComponentContext"
require "openbus.test.util"
-- setup and start the ORB
local orb = openbus.initORB()
-- load interface definition
orb:loadidlfile("idl/proxy.idl")
orb:loadidlfile("helloidl/hello.idl")
local iface = orb.types:lookup("tecgraf::openbus::interop::chaining::HelloProxy")
local serviface = orb.types:lookup("tecgraf::openbus::interop::simple::Hello")
-- customize test configuration for this case
settestcfg(iface, ...)
-- get bus context manager
local OpenBusContext = orb.OpenBusContext
-- create service implementation
local hello = {}
function hello:fetchHello(encodedChain)
if not pcall(function ()
local chain = OpenBusContext:decodeChain(encodedChain)
OpenBusContext:joinChain(chain)
end) then
sysex.BAD_PARAM()
end
local result
if not pcall(function ()
-- define service properties
properties[#properties+1] =
{name="openbus.component.interface",value=serviface.repID}
properties[#properties+1] =
{name="openbus.component.name",value="RestrictedHello"},
-- find the offered service
log:TEST("retrieve hello service")
local OfferRegistry = OpenBusContext:getOfferRegistry()
for _, offer in ipairs(findoffers(OfferRegistry, properties)) do
local entity = getprop(offer.properties, "openbus.offer.entity")
log:TEST("found service of ",entity,"!")
local hello = offer.service_ref:getFacetByName(serviface.name):__narrow(serviface)
result = hello:sayHello()
log:TEST("got result from service of ",entity)
break
end
end) then
sysex.NO_RESOURCES()
end
return result
end
-- create service SCS component
local component = ComponentContext(orb, {
name = "Hello",
major_version = 1,
minor_version = 0,
patch_version = 0,
platform_spec = "Lua",
})
component:addFacet(iface.name, iface.repID, hello)
-- connect to the bus
local conn = OpenBusContext:createConnection(bushost, busport)
OpenBusContext:setDefaultConnection(conn)
-- login to the bus
conn:loginByCertificate(system, assert(openbus.readKeyFile(syskey)))
-- offer service
local OfferRegistry = OpenBusContext:getOfferRegistry()
OfferRegistry:registerService(component.IComponent, properties)
log:TEST("hello service ready!")
local log = require "openbus.util.logger"
local openbus = require "openbus"
local sysex = require "openbus.util.sysex"
local ComponentContext = require "scs.core.ComponentContext"
require "openbus.test.util"
-- setup and start the ORB
local orb = openbus.initORB()
-- load interface definition
orb:loadidlfile("helloidl/hello.idl")
local iface = orb.types:lookup("tecgraf::openbus::interop::simple::Hello")
-- customize test configuration for this case
settestcfg(iface, ...)
-- get bus context manager
local OpenBusContext = orb.OpenBusContext
-- create service implementation
local hello = {}
local expected = {
cpp = true,
java = true,
lua = true,
csharp = true,
}
function hello:sayHello()
local chain = OpenBusContext:getCallerChain()
local entity = chain.caller.entity
if expected[entity:match("^interop_chaining_(.-)_helloproxy$")] ~= nil then
log:TEST("got call from ",chain2str(chain))
return "Hello "..chain.originators[1].entity.."!"
else
sysex.NO_PERMISSION()
end
end
-- create service SCS component
local component = ComponentContext(orb, {
name = "RestrictedHello",
major_version = 1,
minor_version = 0,
patch_version = 0,
platform_spec = "Lua",
})
component:addFacet(iface.name, iface.repID, hello)
-- connect to the bus
local conn = OpenBusContext:createConnection(bushost, busport)
OpenBusContext:setDefaultConnection(conn)
-- login to the bus
conn:loginByCertificate(system, assert(openbus.readKeyFile(syskey)))
-- offer service
local OfferRegistry = OpenBusContext:getOfferRegistry()
OfferRegistry:registerService(component.IComponent, properties)
log:TEST("hello service ready!")
......@@ -11,6 +11,7 @@ for case, services in pairs{
SharedAuth = { "Hello" },
ReloggedJoin = { "Hello" },
Delegation = { "Messenger","Broadcaster","Forwarder" },
Chaining = { "Hello","HelloProxy" },
} do
for _, iface in ipairs(services) do
local module = case:lower()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment