Commit 9d125bb6 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia
Browse files

[OPENBUS-2368] O registro de uma mesma entidade em categorias diferentes deixa...

[OPENBUS-2368] O registro de uma mesma entidade em categorias diferentes deixa o núcleo do barramento instável, gerando erros inesperados

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/core/branches/02_00_00@144875 ae0415b3-e90b-0410-900d-d0be9363c56b
parent 276e079e
......@@ -468,7 +468,6 @@ function OfferRegistry:__init(data)
end
local observerLogins = self.observerLogins
do -- recover observers
local offers = self.offers
local offerRegObsDB = self.offerRegObsDB
local toberemoved = {}
for id, entry in assert(offerRegObsDB:ientries()) do
......@@ -865,14 +864,13 @@ function Category:registerEntity(id, name)
BAD_PARAM{ completed = "COMPLETED_NO", minor = 0 }
end
local categoryId = self.id
local entities = self.entities
-- check if category already exists
local entity = entities[id]
local registry = self.registry
-- check if entity already exists
local entity = registry.entities[id]
if entity ~= nil then
EntityAlreadyRegistered{ category = categoryId, existing = entity }
end
-- persist the new entity
local registry = self.registry
local database = registry.entityDB
assert(database:setentry(id, {categoryId=categoryId, name=name}))
-- create object for the new entity
......
......@@ -292,6 +292,15 @@ function Case.testCreateTwice(self)
Check.assertEquals(EntityAlreadyRegistered, err._repid)
end
function Case.testRegisterEntityInTwoCategories(self)
local entities = OpenBusContext:getEntityRegistry()
local category = entities:createEntityCategory("Fake", "Fake Category")
ok, err = pcall(category.registerEntity, category, self.entId, self.entDesc)
Check.assertTrue(not ok)
Check.assertEquals(EntityAlreadyRegistered, err._repid)
category:remove()
end
function Case.testCategoryInUse(self)
local ok, err = pcall(self.category.remove, self.category)
Check.assertTrue(not ok)
......
Supports Markdown
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