From 73e0098c4d8e0dcb9f79a89564f0325dc6e79215 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 18 Jun 2015 14:23:30 +0200 Subject: [PATCH] Removed persistence sqlite folder which is now obsolete. --- .../sqlite/persistence_sqlite-safe.ecf | 31 -- .../persistence/sqlite/persistence_sqlite.ecf | 31 -- library/persistence/sqlite/scripts/Readme.txt | 1 - library/persistence/sqlite/scripts/schema.sql | 36 --- .../sqlite/src/cms_storage_sqlite.e | 29 -- .../sqlite/src/cms_storage_sqlite_builder.e | 68 ----- library/persistence/sqlite/tests/Readme.md | 26 -- .../persistence/sqlite/tests/application.e | 29 -- library/persistence/sqlite/tests/cms_lite.db | Bin 18432 -> 0 bytes .../sqlite/tests/nodes/node_test_set.e | 205 ------------- .../sqlite/tests/storage/storage_test_set.e | 273 ------------------ .../persistence/sqlite/tests/tests-safe.ecf | 26 -- .../sqlite/tests/users/user_test_set.e | 72 ----- .../sqlite/tests/util/abstract_db_test.e | 55 ---- .../persistence/sqlite/tests/util/clean_db.e | 66 ----- 15 files changed, 948 deletions(-) delete mode 100644 library/persistence/sqlite/persistence_sqlite-safe.ecf delete mode 100644 library/persistence/sqlite/persistence_sqlite.ecf delete mode 100644 library/persistence/sqlite/scripts/Readme.txt delete mode 100644 library/persistence/sqlite/scripts/schema.sql delete mode 100644 library/persistence/sqlite/src/cms_storage_sqlite.e delete mode 100644 library/persistence/sqlite/src/cms_storage_sqlite_builder.e delete mode 100644 library/persistence/sqlite/tests/Readme.md delete mode 100644 library/persistence/sqlite/tests/application.e delete mode 100644 library/persistence/sqlite/tests/cms_lite.db delete mode 100644 library/persistence/sqlite/tests/nodes/node_test_set.e delete mode 100644 library/persistence/sqlite/tests/storage/storage_test_set.e delete mode 100644 library/persistence/sqlite/tests/tests-safe.ecf delete mode 100644 library/persistence/sqlite/tests/users/user_test_set.e delete mode 100644 library/persistence/sqlite/tests/util/abstract_db_test.e delete mode 100644 library/persistence/sqlite/tests/util/clean_db.e diff --git a/library/persistence/sqlite/persistence_sqlite-safe.ecf b/library/persistence/sqlite/persistence_sqlite-safe.ecf deleted file mode 100644 index ea2d754..0000000 --- a/library/persistence/sqlite/persistence_sqlite-safe.ecf +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - /EIFGENs$ - /CVS$ - /.svn$ - - - - diff --git a/library/persistence/sqlite/persistence_sqlite.ecf b/library/persistence/sqlite/persistence_sqlite.ecf deleted file mode 100644 index 365295e..0000000 --- a/library/persistence/sqlite/persistence_sqlite.ecf +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - /EIFGENs$ - /CVS$ - /.svn$ - - - - diff --git a/library/persistence/sqlite/scripts/Readme.txt b/library/persistence/sqlite/scripts/Readme.txt deleted file mode 100644 index 04064dc..0000000 --- a/library/persistence/sqlite/scripts/Readme.txt +++ /dev/null @@ -1 +0,0 @@ -Added Stored Procedures \ No newline at end of file diff --git a/library/persistence/sqlite/scripts/schema.sql b/library/persistence/sqlite/scripts/schema.sql deleted file mode 100644 index 0dffacb..0000000 --- a/library/persistence/sqlite/scripts/schema.sql +++ /dev/null @@ -1,36 +0,0 @@ -PRAGMA foreign_keys = OFF; - -BEGIN; -CREATE TABLE "users"( - "uid" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("uid">=0), - "name" VARCHAR(100) NOT NULL, - "password" VARCHAR(100) NOT NULL, - "salt" VARCHAR(100) NOT NULL, - "email" VARCHAR(250) NOT NULL, - "status" INTEGER, - "created" DATETIME NOT NULL, - "signed" DATETIME, - CONSTRAINT "name" - UNIQUE("name") -); - -CREATE TABLE "users_roles"( - "rid" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("rid">=0), - "role" VARCHAR(100) NOT NULL, - CONSTRAINT "role" - UNIQUE("role") -); - -CREATE TABLE "nodes"( - "nid" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("nid">=0), - "version" INTEGER, - "type" INTEGER, - "title" VARCHAR(255) NOT NULL, - "summary" TEXT NOT NULL, - "content" MEDIUMTEXT NOT NULL, - "author" INTEGER, - "publish" DATETIME, - "created" DATETIME NOT NULL, - "changed" DATETIME NOT NULL -); -COMMIT; diff --git a/library/persistence/sqlite/src/cms_storage_sqlite.e b/library/persistence/sqlite/src/cms_storage_sqlite.e deleted file mode 100644 index 218b09e..0000000 --- a/library/persistence/sqlite/src/cms_storage_sqlite.e +++ /dev/null @@ -1,29 +0,0 @@ -note - description: "Summary description for {CMS_STORAGE_SQLITE}." - date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $" - revision: "$Revision: 96596 $" - -class - CMS_STORAGE_SQLITE - -inherit - CMS_STORAGE_STORE_SQL - - CMS_CORE_STORAGE_SQL_I - - CMS_USER_STORAGE_SQL_I - - REFACTORING_HELPER - -create - make - -feature -- Status report - - is_initialized: BOOLEAN - -- Is storage initialized? - do - Result := has_user - end - -end diff --git a/library/persistence/sqlite/src/cms_storage_sqlite_builder.e b/library/persistence/sqlite/src/cms_storage_sqlite_builder.e deleted file mode 100644 index f48a77f..0000000 --- a/library/persistence/sqlite/src/cms_storage_sqlite_builder.e +++ /dev/null @@ -1,68 +0,0 @@ -note - description: "[ - Interface responsible to instantiate CMS_STORAGE_SQLITE object. - ]" - author: "$Author: jfiat $" - date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $" - revision: "$Revision: 96616 $" - -class - CMS_STORAGE_SQLITE_BUILDER - -inherit - CMS_STORAGE_STORE_SQL_BUILDER - - GLOBAL_SETTINGS - -create - make - -feature {NONE} -- Initialization - - make - -- Initialize `Current'. - do - end - -feature -- Factory - - storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_SQLITE - local - s: STRING - conn: detachable DATABASE_CONNECTION - do - if - attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.environment.application_config_path) as l_database_config - then - s := "Driver=SQLite3 ODBC Driver;Database=" - if attached l_database_config.database_name as db_name then - s.append (db_name) - end - s.append (";LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;") - if attached reuseable_connection.item as d then - if s.same_string (d.name) then - conn := d.connection - end - end - if conn = Void or else not conn.is_connected then - create {DATABASE_CONNECTION_ODBC} conn.login_with_connection_string (s) - reuseable_connection.replace ([s, conn]) - end - if conn.is_connected then - create Result.make (conn) - set_map_zero_null_value (False) --| This way we map 0 to 0, instead of Null as default. - if Result.is_available then - if not Result.is_initialized then - initialize (a_setup, Result) - end - end - end - end - end - - reuseable_connection: CELL [detachable TUPLE [name: STRING; connection: DATABASE_CONNECTION]] - once - create Result.put (Void) - end - -end diff --git a/library/persistence/sqlite/tests/Readme.md b/library/persistence/sqlite/tests/Readme.md deleted file mode 100644 index b81d64f..0000000 --- a/library/persistence/sqlite/tests/Readme.md +++ /dev/null @@ -1,26 +0,0 @@ -SQLite ODBC. - -Install the odbc driver from http://www.ch-werner.de/sqliteodbc/ - -Current version - sqliteodbc.exe -- Win32 - sqliteodbc_w64.exe -- Win64 - - -Test the ODBC driver using Firefox SQLite DBManager https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/ - -1. Open the odbc manger from Windows, create a new database using the SQLite3 ODBC driver and then open it from Firefox. - - -EiffelStore + SQLiteODBC. - -Connection String: https://www.connectionstrings.com/sqlite3-odbc-driver/ - - "Driver=SQLite3 ODBC Driver;Database=./cms_lite.db;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;" - -Edit the database location based on your system. - - - - - diff --git a/library/persistence/sqlite/tests/application.e b/library/persistence/sqlite/tests/application.e deleted file mode 100644 index 9b3ede1..0000000 --- a/library/persistence/sqlite/tests/application.e +++ /dev/null @@ -1,29 +0,0 @@ -note - description : "tests application root class" - date : "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $" - revision : "$Revision: 96542 $" - -class - APPLICATION - -inherit - ARGUMENTS - -create - make - -feature {NONE} -- Initialization - - make - -- Run application. - local - storage: CMS_STORAGE_SQLITE - do - -- Change the path. - create connection.login_with_connection_string ("Driver=SQLite3 ODBC Driver;Database=./cms_lite.db;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;") - create storage.make (connection) - end - - connection: DATABASE_CONNECTION_ODBC - -end diff --git a/library/persistence/sqlite/tests/cms_lite.db b/library/persistence/sqlite/tests/cms_lite.db deleted file mode 100644 index 208c3a4ea00239f0563f5ea7751e0b9d0f3594fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18432 zcmeHO%}*Og6yNn48QDF}>%4WIP3RJuPz&NT&HtTh;0tSo;!4+~GyrgdY5!iJ@ zrAn1a+jCR(FX*wS{t>49hZi1c70gPr&CY_>jv79^B*we6zOa^B(KW{O{f|Q0wAO zpv>FcKimnMWwYls7=`kH$HT{YmMK+>`jK%^1_b8|b+d-v^L0Z%H1aa~@-{x;ygbjd z$J=J%aaljCm30H%+-gQsvYL=p?yhKph{{C&|m5g7Oq(D<138-u7 z&1^;iz2L4z*h&z#(y5It&5yJZ1CtYhfV-QeNa?(czTg~iue&__&715FvehES&=2Z* zbx%L_%C*^ls?uLARP;H}GH|@aBL2Sk5MfqpMcqI*S6h1#l{v@Xv-;z5X|G_GYSnzP zU;-`^aIgsHnB=`fy@y1lRxIuJ#4$^zeYAp+$f?m1je4b0IQ&!;vf9Je$Xi;}s-|8w zMPXG-q_$SE1Q?73I)oi1*inKV&E0hfdx2mt5bTAV;t+O(U`GgcBzMOl>@dL&6YOyA zwnNw(Lrc=oaJ~QI)Re?e^ia8c2Nc>1Lrd^0junP)t@g)YbXPhfe~YX z?El;kBW4&ihcYmN45V2PGqoF^GIhgLrGzTW$zW2|7Q#w08ViOZ(P%6o$!anYT8JpI z1aKB6mFMPiRNYP=9USbfm!DQY-cBgVjVJLq#31`W_tyxLMNOg%PzE|O;N_-#aQ(ym ze~ejYn059g`p)1&`54*7i7_5aV>lXk z8$|<=gA3g}?a@F~=G^3ia4;g-EutzuD;UP}+98PDo*#AbeN%l|rf9k_bk+ zMQ)pVwMTE8#V~?P&j0omPoF6Rl!1%E06G6(3~Q;ClmW_sodLN2yV-q)-Dh8N68D7p zh4~iz4E2g!_VB6M?)h_8ZW%hs<Cq;*tGr4!miLA2F$MG%Fxbepv3x7vclyTAY$fiK?kdimK|_RG&(XIQMR zO%-2<^DGv!PPJIpo+(Ij(?~vGQ=*j>h)Lz=;^BuxFo`mj{}dEr?Dt6Ke>0qx=6*f7Q{> zDFZ`gfUf_c(oZ|53=EY4>i-)m{j_t+z)%^W`~Ohsr=3#D5k-k3Jymjt?Z>=8|hnPY$3MYJXa>cLq|d z1<^?{REzv&|5F#{i))vVU-B!~=9ffTWA7Pyywb@piE3WQFWKa#`ESpsotaIEo_@)u zWDk!amP7ZBe#sWjS(hQI1Cy<{UlOC>S^v6@$^Ygwr~ALNzwam-W#CO>fUf^HX|$-W JlmTZM_!mP!L_q)m diff --git a/library/persistence/sqlite/tests/nodes/node_test_set.e b/library/persistence/sqlite/tests/nodes/node_test_set.e deleted file mode 100644 index e80f720..0000000 --- a/library/persistence/sqlite/tests/nodes/node_test_set.e +++ /dev/null @@ -1,205 +0,0 @@ -note - description: "[ - Eiffel tests that can be executed by testing tool. - ]" - author: "EiffelStudio test wizard" - date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $" - revision: "$Revision: 96542 $" - testing: "type/manual" - -class - NODE_TEST_SET - -inherit - EQA_TEST_SET - redefine - on_prepare, - on_clean - select - default_create - end - ABSTRACT_DB_TEST - rename - default_create as default_db_test - end - - -feature {NONE} -- Events - - on_prepare - -- - do - (create {CLEAN_DB}).clean_db(connection) - assert ("Empty Nodes", storage.nodes.after) - end - - on_clean - -- - do - end - -feature -- Test routines - - test_new_node - do - 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 storage.node_by_id (1)) - -- Not exist node with id 2 - assert ("Not exist node with id 2", storage.node_by_id (2) = Void) - end - - - test_update_node - local - l_node: CMS_NODE - do - assert ("Empty Nodes", storage.nodes.after) - l_node := custom_node ("

test node udpate

", "Update node", "Test case update") - 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} 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} storage.node_by_id (1) as l_un then - l_un.set_content ("

Updating test node udpate

") - l_un.set_summary ("updating summary") - 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} storage.node_by_id (1) as l_un then - l_un.set_content ("

Updating test node udpate

") - l_un.set_summary ("updating summary") - l_un.set_title ("Updating Test case") - 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 - - test_update_title - local - l_node: CMS_NODE - do - assert ("Empty Nodes", storage.nodes.after) - l_node := custom_node ("

test node udpate

", "Update node", "Test case update") - 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} 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} 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 - - test_update_summary - local - l_node: CMS_NODE - do - assert ("Empty Nodes", storage.nodes.after) - l_node := custom_node ("

test node udpate

", "Update node", "Test case update") - 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} 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} 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 - - test_update_content - local - l_node: CMS_NODE - do - assert ("Empty Nodes", storage.nodes.after) - l_node := custom_node ("

test node udpate

", "Update node", "Test case update") - 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} 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} 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 - - - test_delete_node - local - l_node: CMS_NODE - do - assert ("Empty Nodes", storage.nodes.after) - l_node := custom_node ("

test node udpate

", "Update node", "Test case update") - 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} 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 - - storage.delete_node_by_id (1) - assert ("Node does not exist", storage.node_by_id (1) = Void) - end - - test_recent_nodes - -- Content_10, Summary_10, Title_10 - -- Content_9, Summary_9, Title_9 - -- .. - -- Content_1, Summary_1, Title_1 - local - i : INTEGER - do - assert ("Empty Nodes", storage.nodes.after) - across 1 |..| 10 as c loop - 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 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 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 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", storage.recent_nodes (10, 10).after) - - end - - -end - - - diff --git a/library/persistence/sqlite/tests/storage/storage_test_set.e b/library/persistence/sqlite/tests/storage/storage_test_set.e deleted file mode 100644 index 0189001..0000000 --- a/library/persistence/sqlite/tests/storage/storage_test_set.e +++ /dev/null @@ -1,273 +0,0 @@ -note - description: "Summary description for {STORAGE_TEST_SET}." - author: "" - date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $" - revision: "$Revision: 96542 $" - -class - STORAGE_TEST_SET - -inherit - EQA_TEST_SET - redefine - on_prepare, - on_clean - select - default_create - end - ABSTRACT_DB_TEST - rename - default_create as default_db_test - end - - -feature {NONE} -- Events - - on_prepare - -- - do - (create {CLEAN_DB}).clean_db(connection) - end - - on_clean - -- - do - end - -feature -- Test routines - - test_has_user - do - assert ("Not has user", not storage.has_user) - end - - test_all_users - do - assert ("to implement all_users", False) - end - - test_user_by_id_not_exist - do - assert ("User does not exist", storage.user_by_id (1) = Void) - end - - test_user_by_name_not_exist - do - assert ("User does not exist", storage.user_by_name ("test") = Void) - end - - test_user_by_email_not_exist - do - assert ("User does not exist", storage.user_by_name ("test@test.com") = Void) - end - - test_user_with_bad_id - local - l_retry: BOOLEAN - l_user: detachable CMS_USER - do - if not l_retry then - l_user := storage.user_by_id (0) - assert ("Precondition does not get the wrong value", False) - else - assert ("Expected precondition violation", True) - end - rescue - l_retry := True - retry - end - - test_user_with_bad_name_empty - local - l_retry: BOOLEAN - l_user: detachable CMS_USER - do - if not l_retry then - l_user := storage.user_by_name ("") - assert ("Precondition does not get the wrong value", False) - else - assert ("Expected precondition violation", True) - end - rescue - l_retry := True - retry - end - - test_user_with_bad_email_empty - local - l_retry: BOOLEAN - l_user: detachable CMS_USER - do - if not l_retry then - l_user := storage.user_by_email ("") - assert ("Precondition does not get the wrong value", False) - else - assert ("Expected precondition violation", True) - end - rescue - l_retry := True - retry - end - - test_save_user - do - storage.save_user (default_user) - assert ("Has user", storage.has_user) - end - - test_user_by_id - do - storage.save_user (default_user) - assert ("Has user", storage.has_user) - if attached {CMS_USER} storage.user_by_id (1) as l_user then - assert ("Exist", True) - assert ("User test", l_user.name ~ "test") - assert ("User id = 1", l_user.id = 1) - else - assert ("Wrong Implementation", False) - end - end - - test_user_by_name - do - storage.save_user (default_user) - assert ("Has user", storage.has_user) - if attached {CMS_USER} storage.user_by_name ("test") as l_user then - assert ("Exist", True) - assert ("User nane: test", l_user.name ~ "test") - else - assert ("Wrong Implementation", False) - end - end - - test_user_by_email - do - storage.save_user (default_user) - assert ("Has user", storage.has_user) - if attached {CMS_USER} storage.user_by_email ("test@test.com") as l_user then - assert ("Exist", True) - assert ("User email: test@test.com", l_user.email ~ "test@test.com") - else - assert ("Wrong Implementation", False) - end - end - - test_invalid_credential - do - storage.save_user (default_user) - assert ("Has user test", attached storage.user_by_name ("test")) - assert ("Wrong password", not storage.is_valid_credential ("test", "test")) - assert ("Wrong user", not storage.is_valid_credential ("test1", "test")) - end - - test_valid_credential - do - storage.save_user (default_user) - assert ("Has user test", attached storage.user_by_name ("test")) - assert ("Valid password", storage.is_valid_credential ("test", "password")) - end - --- test_recent_nodes_empty --- do --- assert ("No recent nodes", storage.recent_nodes (0, 10).is_empty) --- end - --- test_recent_nodes --- local --- l_nodes: LIST[CMS_NODE] --- do --- across 1 |..| 10 as c loop --- storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)) --- end --- l_nodes := storage.recent_nodes (0, 10) --- assert ("10 recent nodes", l_nodes.count = 10) --- assert ("First node id=10", l_nodes.first.id = 10) --- assert ("Last node id=1", l_nodes.last.id = 1) - - --- l_nodes := storage.recent_nodes (5, 10) --- assert ("5 recent nodes", l_nodes.count = 5) --- assert ("First node id=5", l_nodes.first.id = 5) --- assert ("Last node id=1", l_nodes.last.id = 1) - --- l_nodes := storage.recent_nodes (9, 10) --- assert ("1 recent nodes", l_nodes.count = 1) --- assert ("First node id=1", l_nodes.first.id = 1) --- assert ("Last node id=1", l_nodes.last.id = 1) - --- l_nodes := storage.recent_nodes (10, 10) --- assert ("Is empty", l_nodes.is_empty) --- end - --- test_node_does_not_exist --- do --- across 1 |..| 10 as c loop --- storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)) --- end --- assert ("Not exist node id: 12", storage.node_by_id (12) = Void) --- end - --- test_node --- do --- across 1 |..| 10 as c loop --- storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)) --- end --- assert ("has nodes", storage.nodes.count > 5) --- assert ("Node id: 10", attached storage.node_by_id (10) as l_node and then l_node.title ~ "Title_10" ) --- end - --- test_update_node --- local --- l_node: CMS_NODE --- do --- storage.new_node (custom_node ("Content", "Summary", "Title")) --- if attached {CMS_NODE} storage.node_by_id (1) as ll_node then --- l_node := ll_node.twin --- l_node.set_content ("New Content") --- l_node.set_summary ("New Summary") --- l_node.set_title("New Title") - ----- storage.update_node (l_node) --- assert ("Updated", attached {CMS_NODE} storage.node_by_id (1) as u_node and then not (u_node.title ~ ll_node.title) and then not (u_node.content ~ ll_node.content) and then not (u_node.summary ~ ll_node.summary)) --- end --- end - --- test_update_node_title --- do --- storage.new_node (custom_node ("Content", "Summary", "Title")) --- if attached {CMS_NODE} storage.node_by_id (1) as ll_node then ----- storage.update_node_title (ll_node.id, "New Title") --- assert ("Updated", attached {CMS_NODE} storage.node_by_id (1) as u_node and then not (u_node.title ~ ll_node.title) and then u_node.content ~ ll_node.content and then u_node.summary ~ ll_node.summary) --- end --- end - --- test_update_node_summary --- do --- storage.new_node (custom_node ("Content", "Summary", "Title")) --- if attached {CMS_NODE} storage.node_by_id (1) as ll_node then ----- storage.update_node_summary (ll_node.id, "New Summary") --- assert ("Updated", attached {CMS_NODE} storage.node_by_id (1) as u_node and then u_node.title ~ ll_node.title and then u_node.content ~ ll_node.content and then not (u_node.summary ~ ll_node.summary)) --- end --- end - --- test_update_node_content --- do --- storage.new_node (custom_node ("Content", "Summary", "Title")) --- if attached {CMS_NODE} storage.node_by_id (1) as ll_node then ----- storage.update_node_content (ll_node.id, "New Content") --- assert ("Updated", attached {CMS_NODE} storage.node_by_id (1) as u_node and then u_node.title ~ ll_node.title and then not (u_node.content ~ ll_node.content) and then u_node.summary ~ ll_node.summary) --- end --- end - --- test_delete_node --- do --- across 1 |..| 10 as c loop --- storage.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)) --- end --- assert ("Exist node id: 10", attached storage.node_by_id (10) as l_node and then l_node.title ~ "Title_10" ) --- storage.delete_node_by_id (10) --- assert ("Not exist node id: 10", storage.node_by_id (10) = Void) --- end - - -end diff --git a/library/persistence/sqlite/tests/tests-safe.ecf b/library/persistence/sqlite/tests/tests-safe.ecf deleted file mode 100644 index a8f1365..0000000 --- a/library/persistence/sqlite/tests/tests-safe.ecf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - /EIFGENs$ - /CVS$ - /.svn$ - /nodes$ - - - - diff --git a/library/persistence/sqlite/tests/users/user_test_set.e b/library/persistence/sqlite/tests/users/user_test_set.e deleted file mode 100644 index db5047c..0000000 --- a/library/persistence/sqlite/tests/users/user_test_set.e +++ /dev/null @@ -1,72 +0,0 @@ -note - description: "[ - Eiffel tests that can be executed by testing tool. - ]" - author: "EiffelStudio test wizard" - date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $" - revision: "$Revision: 96542 $" - testing: "type/manual" - -class - USER_TEST_SET - -inherit - EQA_TEST_SET - redefine - on_prepare, - on_clean - select - default_create - end - ABSTRACT_DB_TEST - rename - default_create as default_db_test - end - - -feature {NONE} -- Events - - on_prepare - -- - do - (create {CLEAN_DB}).clean_db(connection) - storage.new_user (custom_user ("admin", "admin","admin@admin.com")) - end - - on_clean - -- - do - end - -feature -- Test routines - - test_user_exist - -- User admin exist - do - assert ("Not void", attached storage.user_by_email ("admin@admin.com")) - assert ("Not void", attached storage.user_by_id (1)) - assert ("Not void", attached storage.user_by_name ("admin")) - end - - test_user_not_exist - -- Uset test does not exist. - do - assert ("Void", storage.user_by_email ("test@admin.com") = Void) - assert ("Void", storage.user_by_id (2) = Void ) - assert ("Void", storage.user_by_name ("test") = Void) - end - - test_new_user - do - storage.new_user (custom_user ("test", "test","test@admin.com")) - assert ("Not void", attached storage.user_by_email ("test@admin.com")) - assert ("Not void", attached storage.user_by_id (2)) - assert ("Not void", attached storage.user_by_id (2) as l_user and then l_user.id = 2 and then l_user.name ~ "test") - assert ("Not void", attached storage.user_by_name ("test")) - end - - - -end - - diff --git a/library/persistence/sqlite/tests/util/abstract_db_test.e b/library/persistence/sqlite/tests/util/abstract_db_test.e deleted file mode 100644 index 3ce95e3..0000000 --- a/library/persistence/sqlite/tests/util/abstract_db_test.e +++ /dev/null @@ -1,55 +0,0 @@ -note - description: "Summary description for {ABSTRACT_DB_TEST}." - date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $" - revision: "$Revision: 96542 $" - -class - ABSTRACT_DB_TEST - - -feature -- Database connection - - connection: DATABASE_CONNECTION_ODBC - -- odbc database connection - once - create Result.login_with_connection_string ("Driver=SQLite3 ODBC Driver;Database=cms_lite.db;LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;") --- create Result.make_basic ("cms_lite.db") - end - -feature {NONE} -- Implementation - - storage: CMS_STORAGE - -- node provider. - once - create {CMS_STORAGE_SQLITE} Result.make (connection) - end - -feature {NONE} -- Fixture Factory: Users - - default_user: CMS_USER - do - Result := custom_user ("test", "password", "test@test.com") - end - - custom_user (a_name, a_password, a_email: READABLE_STRING_32): CMS_USER - do - create Result.make (a_name) - Result.set_password (a_password) - Result.set_email (a_email) - end - ---feature {NONE} -- Fixture Factories: Nodes - --- 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_PAGE --- do --- create Result.make (a_title) --- Result.set_content (a_content, a_summary, Void) --- end - - -end diff --git a/library/persistence/sqlite/tests/util/clean_db.e b/library/persistence/sqlite/tests/util/clean_db.e deleted file mode 100644 index d381540..0000000 --- a/library/persistence/sqlite/tests/util/clean_db.e +++ /dev/null @@ -1,66 +0,0 @@ -note - description: "[ - Setting up database tests - 1. Put the database in a known state before running your test suite. - 2. Data reinitialization. For testing in developer sandboxes, something that you should do every time you rebuild the system, you may want to forgo dropping and rebuilding the database in favor of simply reinitializing the source data. - You can do this either by erasing all existing data and then inserting the initial data vales back into the database, or you can simple run updates to reset the data values. - The first approach is less risky and may even be faster for large amounts of data. - See more at: http://www.agiledata.org/essays/databaseTesting.html#sthash.6yVp35g8.dpuf - ]" - - date: "$Date$" - revision: "$Revision$" - EIS: "name=Database Testing", "src=http://www.agiledata.org/essays/databaseTesting.html", "protocol=uri" - -class - CLEAN_DB - -feature - - clean_db (a_connection: DATABASE_CONNECTION) - -- Clean db test. - local - l_parameters: STRING_TABLE[STRING] - do - create l_parameters.make (0) - - db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_nodes, l_parameters)) - db_handler(a_connection).execute_change - - -- Clean Users - db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_users, l_parameters)) - db_handler(a_connection).execute_change - --- -- Reset Autoincremente --- db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_users_autoincrement, l_parameters)) --- db_handler(a_connection).execute_change - --- db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_nodes_autoincrement, l_parameters)) --- db_handler(a_connection).execute_change - end - - - -feature -- Database Hanlder - - db_handler (a_connection: DATABASE_CONNECTION): DATABASE_HANDLER - -- Db handler - once - create {DATABASE_HANDLER_IMPL} Result.make (a_connection) - end - - -feature -- Sql delete queries - - Sql_delete_users: STRING = "delete from Users" - -- Clean Users. - - Sql_delete_nodes: STRING = "delete from Nodes" - -- Clean Nodes. - - Rest_users_autoincrement: STRING = "ALTER TABLE Users AUTO_INCREMENT = 1" - -- reset autoincrement - - Rest_nodes_autoincrement: STRING = "ALTER TABLE Nodes AUTO_INCREMENT = 1" - -- reset autoincrement. - -end