Commit 8ef7ff48 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia

[OPENBUS-1708] [LUA] Implementar testes para o SDK 2.0

- Ajustes nos testes de interop. para funcionar com outras implementações.



git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/sdk/lua/branches/openbus_v2_proto@131668 ae0415b3-e90b-0410-900d-d0be9363c56b
parent accafd17
......@@ -24,7 +24,9 @@ local services = {}
for _, name in ipairs{"Messenger", "Broadcaster", "Forwarder"} do
-- define service properties
local iface = orb.types:lookup("tecgraf::openbus::interop::delegation::"..name)
local props = {{name="openbus.component.interface",value=iface.repID}}
local props = { unpack(properties),
{name="openbus.component.interface",value=iface.repID},
}
-- retrieve service
log:TEST("retrieve messenger service")
for _, offer in ipairs(findoffers(conn.offers, props)) do
......
......@@ -17,7 +17,8 @@ settestcfg(iface, ...)
local manager = orb.OpenBusConnectionManager
-- define service properties
local props = {{name="openbus.component.interface",value=iface.repID}}
properties[#properties+1] =
{name="openbus.component.interface",value=iface.repID}
for _, businfo in ipairs{
{host=bushost, port=busport, offers=3},
......@@ -35,7 +36,7 @@ for _, businfo in ipairs{
log:TEST("retrieve hello services from bus ",conn.busid,"!")
local expected = businfo.offers
local services = table.memoize(function() return {} end)
for _, offer in ipairs(findoffers(conn.offers, props, expected)) do
for _, offer in ipairs(findoffers(conn.offers, properties, expected)) do
local entity = getprop(offer.properties, "openbus.offer.entity")
local login = getprop(offer.properties, "openbus.offer.login")
log:TEST("found service of ",entity,"! (",login,")")
......@@ -48,7 +49,7 @@ for _, businfo in ipairs{
for entity, services in pairs(services) do
local count = 0
for login, hello in pairs(services) do
assert(hello:sayHello() == "Hello from "..user.."@"..conn.busid.."!")
assert(hello:sayHello() == "Hello "..user.."@"..conn.busid.."!")
count = count+1
end
assert(count == expected, entity..": found "..count.." of "..expected)
......
#ifndef __TECGRAF_OPENBUS_INTEROP_HELLO_IDL__
#define __TECGRAF_OPENBUS_INTEROP_HELLO_IDL__
/**
* \brief Mdulo dos sistemas e aplicaes do Tecgraf.
*/
module tecgraf {
/**
* \brief Mdulo do \e middleware OpenBus.
*/
module openbus {
module interop {
module simple {
interface Hello {
string sayHello();
};
}; // hello
}; // demo
}; // openbus
}; // tecgraf
#endif
......@@ -31,7 +31,9 @@ function hello:sayHello()
local chain = conn1AtBus1WithOrb1:getCallerChain()
or connAtBus2WithOrb1:getCallerChain()
or connAtBus1WithOrb2:getCallerChain()
return "Hello from "..chain.caller.entity.."@"..chain.busid.."!"
local entity = chain.caller.entity.."@"..chain.busid
log:TEST("got call from ",entity)
return "Hello "..entity.."!"
end
-- create service SCS components
......@@ -73,3 +75,5 @@ openbus.newthread(function()
end)
connAtBus2WithOrb1.offers:registerService(component1.IComponent, properties)
connAtBus1WithOrb2.offers:registerService(component2.IComponent, properties)
log:TEST("hello service ready!")
......@@ -19,7 +19,7 @@ for case, services in pairs{
name = "server"
end
local ifaceId = "IDL:tecgraf/openbus/interop/"..module.."/"..iface..":1.0"
local entity = "interop_"..case:lower().."_"..name.."_lua"
local entity = "interop_"..case:lower().."_lua".."_"..name
Entity { id = entity, category = category, name = "Lua "..case.." "..iface }
Certificate { id = entity, certificate = syscrt }
Interface { id = ifaceId }
......
......@@ -22,7 +22,9 @@ manager:setDefaultConnection(conn)
-- create service implementation
local hello = {}
function hello:sayHello()
return "Hello "..conn:getCallerChain().caller.entity.."!"
local entity = conn:getCallerChain().caller.entity
log:TEST("got call from ",entity)
return "Hello "..entity.."!"
end
-- create service SCS component
......
......@@ -20,11 +20,12 @@ manager:setDefaultConnection(conn)
conn:loginByPassword(user, password)
-- define service properties
local props = {{name="openbus.component.interface",value=iface.repID}}
properties[#properties+1] =
{name="openbus.component.interface",value=iface.repID}
-- find the offered service
log:TEST("retrieve hello service")
for _, offer in ipairs(findoffers(conn.offers, props)) do
for _, offer in ipairs(findoffers(conn.offers, 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)
......
......@@ -22,7 +22,9 @@ manager:setDefaultConnection(conn)
-- create service implementation
local hello = {}
function hello:sayHello()
return "Hello "..conn:getCallerChain().caller.entity.."!"
local entity = conn:getCallerChain().caller.entity
log:TEST("got call from ",entity)
return "Hello "..entity.."!"
end
-- create service SCS component
......
......@@ -31,8 +31,8 @@ leasetime = get("login.lease.time" , 1)
expirationgap = get("login.expiration.gap", leasetime/2)
bushost = get("bus.host.name" , "localhost")
busport = get("bus.host.port" , 2089)
bus2host = get("bus2.host.name" , "localhost")
bus2port = get("bus2.host.port" , 2090)
bus2host = get("bus2.host.name" , bushost)
bus2port = get("bus2.host.port" , busport+1)
admin = get("admin.entity.name" , "admin")
admpsw = get("admin.password" , admin)
user = get("user.entity.name" , "testuser")
......
......@@ -10,13 +10,10 @@ function settestcfg(interface, testname)
if name == "hello" then name = "server" end
local language = "lua"
local domain = "interop_"..testname
system = domain.."_"..name.."_"..language
user = domain.."_client_"..language
system = domain.."_"..language.."_"..name
user = domain.."_"..language.."_client"
password = user
properties = {
{name="offer.domain",value=domain},
{name="implementation.language",value=language},
}
properties = {{name="offer.domain",value="Interoperability Tests"}}
end
function chain2str(chain)
......
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