Revisited the persistence layer.

Simplified schema to focus on user and node.
Now possible to have sqlite via ODBC and/or mysql support, and select using configuration file.
Updated demo example.
This commit is contained in:
2015-01-27 19:48:37 +01:00
parent db9e40cec4
commit 7d5869f3b9
71 changed files with 2665 additions and 3313 deletions

View File

@@ -3,8 +3,8 @@ note
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date$"
revision: "$Revision$"
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
testing: "type/manual"
class
@@ -30,7 +30,7 @@ feature {NONE} -- Events
-- <Precursor>
do
(create {CLEAN_DB}).clean_db(connection)
assert ("Empty Nodes", node_provider.nodes.after)
assert ("Empty Nodes", storage.nodes.after)
end
on_clean
@@ -42,13 +42,13 @@ feature -- Test routines
test_new_node
do
assert ("Empty Nodes", node_provider.nodes.after)
node_provider.new_node (default_node)
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
assert ("Empty Nodes", storage.nodes.after)
storage.new_node (default_node)
assert ("Not empty Nodes after new_node", not storage.nodes.after)
-- Exist node with id 1
assert ("Exist node with id 1", attached node_provider.node (1))
assert ("Exist node with id 1", attached storage.node_by_id (1))
-- Not exist node with id 2
assert ("Not exist node with id 2", node_provider.node (2) = Void)
assert ("Not exist node with id 2", storage.node_by_id (2) = Void)
end
@@ -56,31 +56,31 @@ feature -- Test routines
local
l_node: CMS_NODE
do
assert ("Empty Nodes", node_provider.nodes.after)
assert ("Empty Nodes", storage.nodes.after)
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
node_provider.new_node (l_node)
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
storage.new_node (l_node)
assert ("Not empty Nodes after new_node", not storage.nodes.after)
-- Exist node with id 1
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
-- Update node (content and summary)
if attached {CMS_NODE} node_provider.node (1) as l_un then
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
l_un.set_content ("<h1>Updating test node udpate </h1>")
l_un.set_summary ("updating summary")
node_provider.update_node (l_un)
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then ll_node.title ~ l_node.title )
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
storage.update_node (l_un)
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then ll_node.title ~ l_node.title )
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
end
-- Update node (content and summary and title)
if attached {CMS_NODE} node_provider.node (1) as l_un then
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
l_un.set_content ("<h1>Updating test node udpate </h1>")
l_un.set_summary ("updating summary")
l_un.set_title ("Updating Test case")
node_provider.update_node (l_un)
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then not (ll_node.title ~ l_node.title) )
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
storage.update_node (l_un)
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then not (ll_node.title ~ l_node.title) )
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
end
end
@@ -88,18 +88,18 @@ feature -- Test routines
local
l_node: CMS_NODE
do
assert ("Empty Nodes", node_provider.nodes.after)
assert ("Empty Nodes", storage.nodes.after)
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
node_provider.new_node (l_node)
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
storage.new_node (l_node)
assert ("Not empty Nodes after new_node", not storage.nodes.after)
-- Exist node with id 1
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
-- Update node title
if attached {CMS_NODE} node_provider.node (1) as l_un then
node_provider.update_node_title (l_un.id, "New Title")
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then not ( ll_node.title ~ l_un.title) and then ll_node.title ~ "New Title" )
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
storage.update_node_title (1, l_un.id, "New Title")
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then not ( ll_node.title ~ l_un.title) and then ll_node.title ~ "New Title" )
end
end
@@ -107,18 +107,18 @@ feature -- Test routines
local
l_node: CMS_NODE
do
assert ("Empty Nodes", node_provider.nodes.after)
assert ("Empty Nodes", storage.nodes.after)
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
node_provider.new_node (l_node)
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
storage.new_node (l_node)
assert ("Not empty Nodes after new_node", not storage.nodes.after)
-- Exist node with id 1
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
-- Update node summary
if attached {CMS_NODE} node_provider.node (1) as l_un then
node_provider.update_node_summary (l_un.id,"New Summary")
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then not (ll_node.summary ~ l_un.summary) and then ll_node.summary ~ "New Summary" and then ll_node.title ~ l_un.title)
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
storage.update_node_summary (1, l_un.id,"New Summary")
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_un.content and then not (ll_node.summary ~ l_un.summary) and then ll_node.summary ~ "New Summary" and then ll_node.title ~ l_un.title)
end
end
@@ -126,18 +126,18 @@ feature -- Test routines
local
l_node: CMS_NODE
do
assert ("Empty Nodes", node_provider.nodes.after)
assert ("Empty Nodes", storage.nodes.after)
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
node_provider.new_node (l_node)
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
storage.new_node (l_node)
assert ("Not empty Nodes after new_node", not storage.nodes.after)
-- Exist node with id 1
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
-- Update node content
if attached {CMS_NODE} node_provider.node (1) as l_un then
node_provider.update_node_content (l_un.id,"New Content")
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_un.content) and then ll_node.content ~ "New Content" and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title)
if attached {CMS_NODE} storage.node_by_id (1) as l_un then
storage.update_node_content (1, l_un.id, "New Content")
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then not (ll_node.content ~ l_un.content) and then ll_node.content ~ "New Content" and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title)
end
end
@@ -146,17 +146,17 @@ feature -- Test routines
local
l_node: CMS_NODE
do
assert ("Empty Nodes", node_provider.nodes.after)
assert ("Empty Nodes", storage.nodes.after)
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
node_provider.new_node (l_node)
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
storage.new_node (l_node)
assert ("Not empty Nodes after new_node", not storage.nodes.after)
-- Exist node with id 1
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
-- Delte node 1
node_provider.delete_node (1)
assert ("Node does not exist", node_provider.node (1) = Void)
storage.delete_node_by_id (1)
assert ("Node does not exist", storage.node_by_id (1) = Void)
end
test_recent_nodes
@@ -167,57 +167,37 @@ feature -- Test routines
local
i : INTEGER
do
assert ("Empty Nodes", node_provider.nodes.after)
assert ("Empty Nodes", storage.nodes.after)
across 1 |..| 10 as c loop
node_provider.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
end
-- Scenario (0,10) rows, recents (10 down to 1)
i := 10
across node_provider.recent_nodes (0, 10) as c loop
across storage.recent_nodes (0, 10) as c loop
assert ("Same id:" + i.out, c.item.id = i)
i := i - 1
end
-- Scenario (5, 10) rows, recent nodes (5 down to 1)
i := 5
across node_provider.recent_nodes (5, 10) as c loop
across storage.recent_nodes (5, 10) as c loop
assert ("Same id:" + i.out, c.item.id = i)
i := i - 1
end
-- Scenario (9,10) rows, recent node 1
i := 1
across node_provider.recent_nodes (9, 10) as c loop
across storage.recent_nodes (9, 10) as c loop
assert ("Same id:" + i.out, c.item.id = i)
i := i - 1
end
-- Scenrario 10..10 empty
assert ("Empty", node_provider.recent_nodes (10, 10).after)
assert ("Empty", storage.recent_nodes (10, 10).after)
end
feature {NONE} -- Implementation
node_provider: NODE_DATA_PROVIDER
-- node provider.
once
create Result.make (connection)
end
feature {NONE} -- Implementation Fixture Factories
default_node: CMS_NODE
do
Result := custom_node ("Default content", "default summary", "Default")
end
custom_node (a_content, a_summary, a_title: READABLE_STRING_32): CMS_NODE
do
create Result.make (a_content, a_summary, a_title)
end
end