Improved error library by refactorying the sync as two way propagation.
Now one can setup error handler propagation in one way, or two way (sync). The "reset" applies in both way, even if this is a one way propagation to fit current existing usage. Added optional id for the error handlers. Feature renaming according to design changes. Added related autotest cases.
This commit is contained in:
@@ -38,6 +38,30 @@ feature -- Test routines
|
||||
|
||||
end
|
||||
|
||||
test_propagation_2
|
||||
note
|
||||
testing: "error"
|
||||
local
|
||||
h1, h2: ERROR_HANDLER
|
||||
-- cl: CELL [INTEGER]
|
||||
do
|
||||
create h1.make_with_id ("h1")
|
||||
create h2.make_with_id ("h2")
|
||||
|
||||
h1.add_propagation (h2)
|
||||
|
||||
h1.add_custom_error (123, "abc", "abc error occurred")
|
||||
h1.add_custom_error (456, "def", "def error occurred")
|
||||
|
||||
assert ("has 2 errors", h1.count = 2 and h2.count = h1.count)
|
||||
|
||||
h2.add_custom_error (789, "ghi", "error occurred only for h2")
|
||||
assert ("h1 has 2 errors, h2 has 3 errors", h1.count = 2 and h2.count = h1.count + 1)
|
||||
|
||||
h1.remove_all_errors
|
||||
assert ("remove all error from h1, and one remaining on h2", h1.count = 0 and h2.count = 1)
|
||||
end
|
||||
|
||||
test_sync_2
|
||||
note
|
||||
testing: "error"
|
||||
@@ -50,7 +74,7 @@ feature -- Test routines
|
||||
h1.add_synchronization (h2)
|
||||
|
||||
h1.add_custom_error (123, "abc", "abc error occurred")
|
||||
h1.add_custom_error (456, "abc", "abc error occurred")
|
||||
h1.add_custom_error (456, "def", "def error occurred")
|
||||
|
||||
assert ("has 2 errors", h1.count = 2 and h2.count = h1.count)
|
||||
|
||||
@@ -108,6 +132,62 @@ feature -- Test routines
|
||||
|
||||
end
|
||||
|
||||
test_tree_propag
|
||||
--| Testing tree propagation
|
||||
--|
|
||||
--| |-----> batch ..........
|
||||
--| | :
|
||||
--| db ---> core ---> app ----> ui :
|
||||
--| : : : : :
|
||||
--| :.......:.........:........:...:.....> logger
|
||||
--|
|
||||
note
|
||||
testing: "error"
|
||||
local
|
||||
hdb, hcore, happ, hui, hlog, hbat: ERROR_HANDLER
|
||||
do
|
||||
create hdb.make_with_id ("db")
|
||||
create hcore.make_with_id ("core")
|
||||
create happ.make_with_id ("app")
|
||||
create hui.make_with_id ("ui")
|
||||
create hlog.make_with_id ("logger")
|
||||
create hbat.make_with_id ("batch")
|
||||
|
||||
hdb.add_propagation (hcore)
|
||||
hcore.add_propagation (happ)
|
||||
hcore.add_propagation (hbat)
|
||||
happ.add_propagation (hui)
|
||||
|
||||
hdb.add_propagation (hlog)
|
||||
hcore.add_propagation (hlog)
|
||||
happ.add_propagation (hlog)
|
||||
hui.add_propagation (hlog)
|
||||
hbat.add_propagation (hlog)
|
||||
|
||||
hdb.add_custom_error (1, "db", "database connection error")
|
||||
hdb.add_custom_error (2, "db", "database query error")
|
||||
assert ("2 errors", hdb.count = 2 and hcore.count = 2 and happ.count = 2 and hui.count = 2 and hlog.count = 2)
|
||||
hcore.add_custom_error (11, "core", "core error")
|
||||
assert ("3 errors", hdb.count = 2 and hcore.count = 3 and happ.count = 3 and hui.count = 3 and hlog.count = 3)
|
||||
happ.add_custom_error (101, "app", "app issue")
|
||||
assert ("2 errors", hdb.count = 2 and hcore.count = 3 and happ.count = 4 and hui.count = 4 and hlog.count = 4)
|
||||
hui.add_custom_error (1001, "ui", "user interface trouble")
|
||||
assert ("2 errors", hdb.count = 2 and hcore.count = 3 and happ.count = 4 and hui.count = 5 and hlog.count = 5)
|
||||
|
||||
assert ("hbat", hbat.count = 3 and hlog.count = 5)
|
||||
hbat.add_custom_error (10001, "bat", "Batch issue")
|
||||
assert ("2 errors", hdb.count = 2 and hcore.count = 3 and happ.count = 4 and hui.count = 5 and hbat.count = 4 and hlog.count = 6)
|
||||
hbat.remove_all_errors
|
||||
assert ("2 errors", hdb.count = 2 and hcore.count = 3 and happ.count = 4 and hui.count = 5 and hbat.count = 0 and hlog.count = 2)
|
||||
|
||||
hui.remove_all_errors
|
||||
assert ("2 errors", hdb.count = 2 and hcore.count = 3 and happ.count = 4 and hui.count = 0 and hlog.count = 0)
|
||||
|
||||
hdb.reset
|
||||
assert ("no more errors", hdb.count = 0 and hcore.count = 3 and happ.count = 4 and hui.count = 0 and hlog.count = 0)
|
||||
|
||||
end
|
||||
|
||||
test_remove_sync
|
||||
note
|
||||
testing: "error"
|
||||
@@ -145,9 +225,9 @@ feature -- Test routines
|
||||
h1, h2, h3: ERROR_HANDLER
|
||||
-- cl: CELL [INTEGER]
|
||||
do
|
||||
create h1.make
|
||||
create h2.make
|
||||
create h3.make
|
||||
create h1.make_with_id ("h1")
|
||||
create h2.make_with_id ("h2")
|
||||
create h3.make_with_id ("h3")
|
||||
|
||||
h1.add_synchronization (h2)
|
||||
h2.add_synchronization (h3)
|
||||
|
||||
Reference in New Issue
Block a user