diff --git a/examples/rest/restbucks_CRUD/support/simple_db/simple_db-safe.ecf b/examples/rest/restbucks_CRUD/support/simple_db/simple_db-safe.ecf
index 1bee0ca7..f0ac5ee5 100644
--- a/examples/rest/restbucks_CRUD/support/simple_db/simple_db-safe.ecf
+++ b/examples/rest/restbucks_CRUD/support/simple_db/simple_db-safe.ecf
@@ -14,6 +14,12 @@
+
+ /basic_memory_database\.e$
+
+
+
+
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/simple_db.ecf b/examples/rest/restbucks_CRUD/support/simple_db/simple_db.ecf
index 24f0f190..f46af389 100644
--- a/examples/rest/restbucks_CRUD/support/simple_db/simple_db.ecf
+++ b/examples/rest/restbucks_CRUD/support/simple_db/simple_db.ecf
@@ -14,6 +14,12 @@
+
+ /basic_memory_database\.e$
+
+
+
+
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_database.e b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_database.e
index 8dc05789..bd6c64c3 100644
--- a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_database.e
+++ b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_database.e
@@ -38,6 +38,12 @@ feature -- Access
ensure
has_not_item: not has (a_entry_type, a_id)
end
+
+ wipe_out
+ -- Remove all items, and delete the database
+ deferred
+ end
+
note
copyright: "2011-2017, Javier Velilla and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_fs_database.e b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_fs_database.e
new file mode 100644
index 00000000..2644af8e
--- /dev/null
+++ b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_fs_database.e
@@ -0,0 +1,177 @@
+note
+ description: "Summary description for {BASIC_FS_DATABASE}."
+ date: "$Date$"
+ revision: "$Revision$"
+
+deferred class
+ BASIC_FS_DATABASE
+
+inherit
+ BASIC_DATABASE
+
+feature {NONE} -- Initialization
+
+ make (a_location: PATH)
+ local
+ d: DIRECTORY
+ do
+ location := a_location
+ ensure_directory_exists (a_location)
+ end
+
+feature -- Access
+
+ location: PATH
+
+feature {NONE} -- Access
+
+ default_extension: detachable STRING_32
+ -- Default file extension, if any.
+ deferred
+ end
+
+feature -- Access
+
+ count_of (a_entry_type: TYPE [detachable ANY]): INTEGER
+ local
+ d: DIRECTORY
+ ext: like default_extension
+ do
+ create d.make_with_path (location.extended (entry_type_name (a_entry_type)))
+ if d.exists then
+ ext := default_extension
+ across
+ d.entries as ic
+ loop
+ if
+ ext = Void or else
+ attached ic.item.extension as e and then e.is_case_insensitive_equal (ext) then
+ Result := Result + 1
+ end
+ end
+ end
+ end
+
+ has (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): BOOLEAN
+ -- Has entry of type `a_entry_type` associated with id `a_id`?
+ local
+ fut: FILE_UTILITIES
+ do
+ Result := fut.file_path_exists (entry_path (a_entry_type, a_id))
+ end
+
+ item (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): detachable ANY
+ do
+ Result := item_from_location (a_entry_type, entry_path (a_entry_type, a_id))
+ end
+
+ save (a_entry_type: TYPE [detachable ANY]; a_entry: detachable ANY; cl_entry_id: CELL [detachable READABLE_STRING_GENERAL])
+ local
+ f: RAW_FILE
+ l_id: detachable READABLE_STRING_GENERAL
+ p: PATH
+ do
+ l_id := cl_entry_id.item
+ if l_id = Void then
+ l_id := next_identifier (a_entry_type)
+ cl_entry_id.replace (l_id)
+ end
+ p := entry_path (a_entry_type, l_id)
+ ensure_directory_exists (p.parent)
+ save_item_to_location (a_entry, p)
+ end
+
+ delete (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL)
+ local
+ f: RAW_FILE
+ do
+ create f.make_with_path (entry_path (a_entry_type, a_id))
+ if f.exists and then f.is_access_writable then
+ f.delete
+ end
+ end
+
+ wipe_out
+ local
+ d: DIRECTORY
+ do
+ create d.make_with_path (location)
+ if d.exists then
+ d.recursive_delete
+ end
+ end
+
+feature {NONE} -- Implementation
+
+ item_from_location (a_entry_type: TYPE [detachable ANY]; p: PATH): like item
+ deferred
+ end
+
+ save_item_to_location (a_entry: detachable ANY; p: PATH)
+ deferred
+ end
+
+ ensure_directory_exists (dn: PATH)
+ local
+ d: DIRECTORY
+ do
+ create d.make_with_path (dn)
+ if not d.exists then
+ d.recursive_create_dir
+ end
+ end
+
+ entry_path (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): PATH
+ do
+ Result := location.extended (entry_type_name (a_entry_type)).extended (a_id).appended_with_extension ("json")
+ end
+
+ entry_type_name (a_entry_type: TYPE [detachable ANY]): STRING
+ do
+ Result := a_entry_type.name.as_lower
+ Result.prune_all ('!')
+ end
+
+ last_id_file_path (a_entry_type: TYPE [detachable ANY]): PATH
+ do
+ Result := location.extended (entry_type_name (a_entry_type)).extended ("last-id")
+ end
+
+ next_identifier (a_entry_type: TYPE [detachable ANY]): STRING_8
+ local
+ i: NATURAL_64
+ f: RAW_FILE
+ s: STRING
+ do
+ create f.make_with_path (last_id_file_path (a_entry_type))
+ ensure_directory_exists (f.path.parent)
+ if f.exists then
+ create s.make (f.count)
+ f.open_read
+ f.read_line
+ s := f.last_string
+ f.close
+ if s.is_natural_64 then
+ i := s.to_natural_64
+ end
+ end
+ from
+ i := i + 1
+ Result := i.out
+ until
+ not has (a_entry_type, Result)
+ loop
+ i := i + 1
+ Result := i.out
+ end
+ f.open_write
+ f.put_string (Result)
+ f.close
+ end
+
+invariant
+
+note
+ copyright: "2011-2017, Javier Velilla and others"
+ license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
+end
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_json_fs_database.e b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_json_fs_database.e
index 3bca11aa..c5e4ed83 100644
--- a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_json_fs_database.e
+++ b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_json_fs_database.e
@@ -11,7 +11,10 @@ class
BASIC_JSON_FS_DATABASE
inherit
- BASIC_DATABASE
+ BASIC_FS_DATABASE
+ redefine
+ make
+ end
create
make
@@ -19,54 +22,28 @@ create
feature {NONE} -- Initialization
make (a_location: PATH)
- local
- d: DIRECTORY
do
- location := a_location
+ Precursor (a_location)
create serialization
- ensure_directory_exists (a_location)
end
feature -- Access serialization
serialization: JSON_SERIALIZATION
-feature -- Access
+feature {NONE} -- Access
- location: PATH
+ default_extension: STRING_32 = "json"
+ -- Default file extension, if any.
-feature -- Access
+feature {NONE} -- Implementation
- count_of (a_entry_type: TYPE [detachable ANY]): INTEGER
- local
- d: DIRECTORY
- do
- create d.make_with_path (location.extended (entry_type_name (a_entry_type)))
- if d.exists then
- across
- d.entries as ic
- loop
- if attached ic.item.extension as e and then e.is_case_insensitive_equal ("json") then
- Result := Result + 1
- end
- end
- end
- end
-
- has (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): BOOLEAN
- -- Has entry of type `a_entry_type` associated with id `a_id`?
- local
- fut: FILE_UTILITIES
- do
- Result := fut.file_path_exists (entry_path (a_entry_type, a_id))
- end
-
- item (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): detachable ANY
+ item_from_location (a_entry_type: TYPE [detachable ANY]; p: PATH): like item
local
f: RAW_FILE
s: STRING
do
- create f.make_with_path (entry_path (a_entry_type, a_id))
+ create f.make_with_path (p)
if f.exists then
create s.make (f.count)
f.open_read
@@ -82,95 +59,16 @@ feature -- Access
end
end
- save (a_entry_type: TYPE [detachable ANY]; a_entry: detachable ANY; cl_entry_id: CELL [detachable READABLE_STRING_GENERAL])
+ save_item_to_location (a_entry: detachable ANY; p: PATH)
local
f: RAW_FILE
- l_id: detachable READABLE_STRING_GENERAL
do
- l_id := cl_entry_id.item
- if l_id = Void then
- l_id := next_identifier (a_entry_type)
- cl_entry_id.replace (l_id)
- end
- create f.make_with_path (entry_path (a_entry_type, l_id))
- ensure_directory_exists (f.path.parent)
+ create f.make_with_path (p)
f.open_write
f.put_string (serialization.to_json (a_entry).representation)
f.close
end
- delete (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL)
- local
- f: RAW_FILE
- do
- create f.make_with_path (entry_path (a_entry_type, a_id))
- if f.exists and then f.is_access_writable then
- f.delete
- end
- end
-
-feature {NONE} -- Implementation
-
- ensure_directory_exists (dn: PATH)
- local
- d: DIRECTORY
- do
- create d.make_with_path (dn)
- if not d.exists then
- d.recursive_create_dir
- end
- end
-
- entry_path (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): PATH
- do
- Result := location.extended (entry_type_name (a_entry_type)).extended (a_id).appended_with_extension ("json")
- end
-
- entry_type_name (a_entry_type: TYPE [detachable ANY]): STRING
- do
- Result := a_entry_type.name.as_lower
- Result.prune_all ('!')
- end
-
- last_id_file_path (a_entry_type: TYPE [detachable ANY]): PATH
- do
- Result := location.extended (entry_type_name (a_entry_type)).extended ("last-id")
- end
-
- next_identifier (a_entry_type: TYPE [detachable ANY]): STRING_8
- local
- i: NATURAL_64
- f: RAW_FILE
- s: STRING
- do
- create f.make_with_path (last_id_file_path (a_entry_type))
- ensure_directory_exists (f.path.parent)
- if f.exists then
- create s.make (f.count)
- f.open_read
- f.read_line
- s := f.last_string
- f.close
- if s.is_natural_64 then
- i := s.to_natural_64
- end
- end
- from
- i := i + 1
- Result := i.out
- until
- not has (a_entry_type, Result)
- loop
- i := i + 1
- Result := i.out
- end
- f.open_write
- f.put_string (Result)
- f.close
- end
-
-invariant
-
note
copyright: "2011-2017, Javier Velilla and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_memory_database.e b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_memory_database.e
index 3003b166..01e1a000 100644
--- a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_memory_database.e
+++ b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_memory_database.e
@@ -2,7 +2,7 @@ note
description: "[
Basic database for simple example based on memory.
- WARNING: for now, not concurrent compliant.
+ WARNING: for now, this is a database per instance, this is not shared memory inside the same process.
]"
date: "$Date$"
revision: "$Revision$"
@@ -19,6 +19,8 @@ create
feature {NONE} -- Initialization
make
+ local
+ b: SED_MEMORY_READER_WRITER
do
create collections.make (0)
end
@@ -74,6 +76,11 @@ feature -- Access
end
end
+ wipe_out
+ do
+ collections.wipe_out
+ end
+
feature {NONE} -- Implementation
next_identifier (a_entry_type: TYPE [detachable ANY]): STRING_8
@@ -81,20 +88,22 @@ feature {NONE} -- Implementation
i: INTEGER
f: RAW_FILE
s: STRING
+ tb: detachable STRING_TABLE [detachable ANY]
do
- if attached collections.item (a_entry_type) as tb then
+ tb := collections.item (a_entry_type)
+ if tb /= Void then
i := tb.count
+ from
+ i := i + 1
+ Result := i.out
+ until
+ not tb.has_key (Result)
+ loop
+ i := i + 1
+ Result := i.out
+ end
else
- i := 0
- end
- from
- i := i + 1
- Result := i.out
- until
- not has (a_entry_type, Result)
- loop
- i := i + 1
- Result := i.out
+ Result := "1"
end
end
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_sed_fs_database.e b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_sed_fs_database.e
index 31d8bc6d..7fda7132 100644
--- a/examples/rest/restbucks_CRUD/support/simple_db/src/basic_sed_fs_database.e
+++ b/examples/rest/restbucks_CRUD/support/simple_db/src/basic_sed_fs_database.e
@@ -11,7 +11,10 @@ class
BASIC_SED_FS_DATABASE
inherit
- BASIC_DATABASE
+ BASIC_FS_DATABASE
+ redefine
+ make
+ end
create
make
@@ -19,53 +22,29 @@ create
feature {NONE} -- Initialization
make (a_location: PATH)
- local
- d: DIRECTORY
do
- location := a_location
+ Precursor (a_location)
create serialization
- ensure_directory_exists (a_location)
end
feature -- Access
- location: PATH
-
serialization: SED_STORABLE_FACILITIES
-feature -- Access
+feature {NONE} -- Access
- count_of (a_entry_type: TYPE [detachable ANY]): INTEGER
- local
- d: DIRECTORY
- do
- create d.make_with_path (location.extended (entry_type_name (a_entry_type)))
- if d.exists then
- across
- d.entries as ic
- loop
- if attached ic.item.extension as e and then e.is_case_insensitive_equal ("sed") then
- Result := Result + 1
- end
- end
- end
- end
+ default_extension: STRING_32 = "sed"
+ -- Default file extension, if any.
- has (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): BOOLEAN
- -- Has entry of type `a_entry_type` associated with id `a_id`?
- local
- fut: FILE_UTILITIES
- do
- Result := fut.file_path_exists (entry_path (a_entry_type, a_id))
- end
+feature {NONE} -- Implementation
- item (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): detachable ANY
+ item_from_location (a_entry_type: TYPE [detachable ANY]; p: PATH): like item
local
f: RAW_FILE
- s: STRING
l_reader: SED_MEDIUM_READER_WRITER
+ s: STRING
do
- create f.make_with_path (entry_path (a_entry_type, a_id))
+ create f.make_with_path (p)
if f.exists then
create s.make (f.count)
f.open_read
@@ -75,19 +54,12 @@ feature -- Access
end
end
- save (a_entry_type: TYPE [detachable ANY]; a_entry: detachable ANY; cl_entry_id: CELL [detachable READABLE_STRING_GENERAL])
+ save_item_to_location (a_entry: detachable ANY; p: PATH)
local
f: RAW_FILE
- l_id: detachable READABLE_STRING_GENERAL
l_writer: SED_MEDIUM_READER_WRITER
do
- l_id := cl_entry_id.item
- if l_id = Void then
- l_id := next_identifier (a_entry_type)
- cl_entry_id.replace (l_id)
- end
- create f.make_with_path (entry_path (a_entry_type, l_id))
- ensure_directory_exists (f.path.parent)
+ create f.make_with_path (p)
f.open_write
if a_entry /= Void then
create l_writer.make_for_writing (f)
@@ -96,78 +68,6 @@ feature -- Access
f.close
end
- delete (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL)
- local
- f: RAW_FILE
- do
- create f.make_with_path (entry_path (a_entry_type, a_id))
- if f.exists and then f.is_access_writable then
- f.delete
- end
- end
-
-feature {NONE} -- Implementation
-
- ensure_directory_exists (dn: PATH)
- local
- d: DIRECTORY
- do
- create d.make_with_path (dn)
- if not d.exists then
- d.recursive_create_dir
- end
- end
-
- entry_path (a_entry_type: TYPE [detachable ANY]; a_id: READABLE_STRING_GENERAL): PATH
- do
- Result := location.extended (entry_type_name (a_entry_type)).extended (a_id).appended_with_extension ("sed")
- end
-
- entry_type_name (a_entry_type: TYPE [detachable ANY]): STRING
- do
- Result := a_entry_type.name.as_lower
- Result.prune_all ('!')
- end
-
- last_id_file_path (a_entry_type: TYPE [detachable ANY]): PATH
- do
- Result := location.extended (entry_type_name (a_entry_type)).extended ("last-id")
- end
-
- next_identifier (a_entry_type: TYPE [detachable ANY]): STRING_8
- local
- i: NATURAL_64
- f: RAW_FILE
- s: STRING
- do
- create f.make_with_path (last_id_file_path (a_entry_type))
- ensure_directory_exists (f.path.parent)
- if f.exists then
- create s.make (f.count)
- f.open_read
- f.read_line
- s := f.last_string
- f.close
- if s.is_natural_64 then
- i := s.to_natural_64
- end
- end
- from
- i := i + 1
- Result := i.out
- until
- not has (a_entry_type, Result)
- loop
- i := i + 1
- Result := i.out
- end
- f.open_write
- f.put_string (Result)
- f.close
- end
-
-invariant
-
note
copyright: "2011-2017, Javier Velilla and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/tests/a.e b/examples/rest/restbucks_CRUD/support/simple_db/tests/a.e
new file mode 100644
index 00000000..51a6c8b6
--- /dev/null
+++ b/examples/rest/restbucks_CRUD/support/simple_db/tests/a.e
@@ -0,0 +1,38 @@
+note
+ description: "Summary description for {A}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ A
+
+create
+ make_with_name
+
+feature {NONE} -- Initialization
+
+ make_with_name (n: STRING)
+ do
+ name := n
+ create items.make (0)
+ end
+
+feature -- Access
+
+ name: STRING
+
+ count: INTEGER
+
+ items: ARRAYED_LIST [B]
+
+feature -- Element change
+
+ extend (b: B)
+ do
+ items.extend (b)
+ count := items.count
+ end
+
+end
+
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/tests/b.e b/examples/rest/restbucks_CRUD/support/simple_db/tests/b.e
new file mode 100644
index 00000000..fd7f7662
--- /dev/null
+++ b/examples/rest/restbucks_CRUD/support/simple_db/tests/b.e
@@ -0,0 +1,30 @@
+note
+ description: "Summary description for {B}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ B
+
+create
+ make
+
+feature
+
+ make (k: STRING; b: BOOLEAN; v: STRING)
+ do
+ key := k
+ value := v
+ state := b
+ end
+
+feature -- Access
+
+ key: STRING
+
+ value: STRING
+
+ state: BOOLEAN
+
+end
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/tests/test_basic_db_i.e b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_basic_db_i.e
new file mode 100644
index 00000000..c396d194
--- /dev/null
+++ b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_basic_db_i.e
@@ -0,0 +1,53 @@
+note
+ description: "Summary description for {TEST_BASIC_DB_I}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+deferred class
+ TEST_BASIC_DB_I
+
+inherit
+ EQA_TEST_SET
+
+feature -- Factory
+
+ new_object: ANY
+ local
+ a: A
+ b: B
+ do
+ create a.make_with_name ("Test")
+ create b.make ("foo", True, "test-foo")
+ a.extend (b)
+ create b.make ("bar", True, "test-bar")
+ a.extend (b)
+ Result := a
+ end
+
+ same_object (a,b: like new_object): BOOLEAN
+ local
+ b1,b2: B
+ do
+ if attached {A} a as l_a1 and attached {A} b as l_a2 then
+ Result := l_a1.name.same_string (l_a2.name) and
+ l_a1.count = l_a2.count
+ if Result then
+ from
+ l_a1.items.start
+ l_a2.items.start
+ until
+ not Result or l_a1.items.after or l_a2.items.after
+ loop
+ b1 := l_a1.items.item
+ b2 := l_a1.items.item
+
+ l_a1.items.forth
+ l_a2.items.forth
+ end
+ Result := Result and l_a1.items.after = l_a2.items.after
+ end
+ end
+ end
+
+end
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/tests/test_json_db.e b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_json_db.e
new file mode 100644
index 00000000..63c1e6fb
--- /dev/null
+++ b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_json_db.e
@@ -0,0 +1,47 @@
+note
+ description: "Summary description for {TEST_JSON_DB}."
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ TEST_JSON_DB
+
+inherit
+ EQA_TEST_SET
+
+ TEST_BASIC_DB_I
+
+feature -- Test routines
+
+ test_json_db
+ -- New test routine
+ local
+ db: BASIC_JSON_FS_DATABASE
+ obj: like new_object
+ cl: CELL [detachable READABLE_STRING_GENERAL]
+ l_type: TYPE [detachable ANY]
+ l_id: detachable READABLE_STRING_GENERAL
+ do
+ create db.make (create {PATH}.make_from_string ("json-db"))
+ db.serialization.set_pretty_printing
+ db.serialization.register_default (create{JSON_REFLECTOR_SERIALIZATION})
+
+ obj := new_object
+ l_type := obj.generating_type
+ create cl.put ("0")
+ db.save (l_type, obj, cl)
+ l_id := cl.item
+ assert ("new id", l_id /= Void and then not l_id.is_whitespace)
+ if l_id /= Void then
+ assert ("has previous entry", db.has (l_type, l_id))
+ if attached db.item (l_type, l_id) as l_stored_obj then
+ assert ("same object", same_object (l_stored_obj, obj))
+ else
+ assert ("found", False)
+ end
+ end
+
+ db.wipe_out
+ end
+
+end
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/tests/test_memory_db.e b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_memory_db.e
new file mode 100644
index 00000000..0a904303
--- /dev/null
+++ b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_memory_db.e
@@ -0,0 +1,47 @@
+note
+ description: "Summary description for {TEST_MEMORY_DB}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ TEST_MEMORY_DB
+
+inherit
+ EQA_TEST_SET
+
+ TEST_BASIC_DB_I
+
+feature -- Test routines
+
+ test_memory_db
+ -- New test routine
+ local
+ db: BASIC_MEMORY_DATABASE
+ obj: like new_object
+ cl: CELL [detachable READABLE_STRING_GENERAL]
+ l_type: TYPE [detachable ANY]
+ l_id: detachable READABLE_STRING_GENERAL
+ do
+ create db.make
+ obj := new_object
+ l_type := obj.generating_type
+ create cl.put ("0")
+ db.save (l_type, obj, cl)
+ l_id := cl.item
+ assert ("new id", l_id /= Void and then not l_id.is_whitespace)
+ if l_id /= Void then
+ assert ("has previous entry", db.has (l_type, l_id))
+ if attached db.item (l_type, l_id) as l_stored_obj then
+ assert ("same object", l_stored_obj.is_deep_equal (obj))
+ else
+ assert ("found", False)
+ end
+ end
+ db.wipe_out
+ end
+
+end
+
+
+
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/tests/test_sed_db.e b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_sed_db.e
new file mode 100644
index 00000000..0f1a0309
--- /dev/null
+++ b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_sed_db.e
@@ -0,0 +1,49 @@
+note
+ description: "[
+ Eiffel tests that can be executed by testing tool.
+ ]"
+ author: "EiffelStudio test wizard"
+ date: "$Date$"
+ revision: "$Revision$"
+ testing: "type/manual"
+
+class
+ TEST_SED_DB
+
+inherit
+ EQA_TEST_SET
+
+ TEST_BASIC_DB_I
+
+feature -- Test routines
+
+ test_sed_db
+ -- New test routine
+ local
+ db: BASIC_SED_FS_DATABASE
+ obj: like new_object
+ cl: CELL [detachable READABLE_STRING_GENERAL]
+ l_type: TYPE [detachable ANY]
+ l_id: detachable READABLE_STRING_GENERAL
+ do
+ create db.make (create {PATH}.make_from_string ("sed-db"))
+ obj := new_object
+ l_type := obj.generating_type
+ create cl.put ("0")
+ db.save (l_type, obj, cl)
+ l_id := cl.item
+ assert ("new id", l_id /= Void and then not l_id.is_whitespace)
+ if l_id /= Void then
+ assert ("has previous entry", db.has (l_type, l_id))
+ if attached db.item (l_type, l_id) as l_stored_obj then
+ assert ("same object", l_stored_obj.is_deep_equal (obj))
+ else
+ assert ("found", False)
+ end
+ end
+ db.wipe_out
+ end
+
+end
+
+
diff --git a/examples/rest/restbucks_CRUD/support/simple_db/tests/test_simple_db.ecf b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_simple_db.ecf
new file mode 100644
index 00000000..029db293
--- /dev/null
+++ b/examples/rest/restbucks_CRUD/support/simple_db/tests/test_simple_db.ecf
@@ -0,0 +1,36 @@
+
+
+
+
+ /\.svn$
+ /\.git$
+ /EIFGENs$
+
+
+
+
+
+
+
+
+
+
+ /.*json.*\.e$
+
+
+
+
+
+ /.*memory.*\.e$
+
+
+
+
+
+
+
+
+
+
+