Added weight into to the CMS_LINK and provide a `sort' feature for CMS_MENU and related.
Protected cms service from registering many time the same module type.
Moved library/persistence/implementation/* under library/persistence/.
Moved site/www/themes to site/themes
For SQLite storage driver, auto create sqlite db file using associated sql script (to be completed).
Added code in demo module to reuse storage for module purpose.
Always call sql_post_execution in sql_query and sql_change, and not anymore by the callers.
Removed is_web and is_html from {CMS_SETUP}, it was not used.
Reused SHARED_*_ENCODER in CMS_ENCODERS
Added CMS_API.logger rather than using directly the SHARED_LOGGER.log ...
Centralize the implementation of current_user in CMS_REQUEST_UTIL
Removed the inheritance on WSF_FILTER for node handlers, since it is useless and unused.
Added CMS_NODE_API and CMS_USER_API
Prefix html id for block generated html items with "block-", to avoid css name conflict on "main", "content" or similar.
Code cleaning
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="persistence_mysql" uuid="DC757CBD-D8C4-44D6-A07F-C1148D8D233E" library_target="persistence_mysql">
|
||||
<target name="persistence_mysql">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="all">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\..\layout\layout-safe.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="mysql" location="$ISE_LIBRARY\library\store\dbms\rdbms\mysql\mysql-safe.ecf"/>
|
||||
<library name="store" location="$ISE_LIBRARY\library\store\store-safe.ecf" readonly="false"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<cluster name="common" location="..\common\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/database/database_connection_odbc.e</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
<cluster name="persistence_mysql" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="persistence_mysql" uuid="DC757CBD-D8C4-44D6-A07F-C1148D8D233E" library_target="persistence_mysql">
|
||||
<target name="persistence_mysql">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="none">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\cms.ecf" readonly="false"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\..\layout\layout.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model.ecf"/>
|
||||
<library name="mysql" location="$ISE_LIBRARY\library\store\dbms\rdbms\mysql\mysql.ecf"/>
|
||||
<library name="store" location="$ISE_LIBRARY\library\store\store.ecf" readonly="false"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||
<cluster name="common" location="..\common\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/database/database_connection_odbc.e</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
<cluster name="persistence_mysql" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,3 +0,0 @@
|
||||
To build the MySQL schema use the schema.sql script.
|
||||
The other script will be deleted soon.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Added Stored Procedures
|
||||
@@ -1,163 +0,0 @@
|
||||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Schema mydb
|
||||
-- -----------------------------------------------------
|
||||
-- -----------------------------------------------------
|
||||
-- Schema cms_dev
|
||||
-- -----------------------------------------------------
|
||||
CREATE SCHEMA IF NOT EXISTS `cms_dev` DEFAULT CHARACTER SET latin1 ;
|
||||
USE `cms_dev` ;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `cms_dev`.`users`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `cms_dev`.`users` (
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`username` VARCHAR(100) NOT NULL,
|
||||
`password` VARCHAR(100) NOT NULL,
|
||||
`salt` VARCHAR(100) NOT NULL,
|
||||
`email` VARCHAR(250) NOT NULL,
|
||||
`creation_date` DATETIME NULL DEFAULT NULL,
|
||||
`last_login_date` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `username` (`username` ASC))
|
||||
ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 2
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `cms_dev`.`nodes`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `cms_dev`.`nodes` (
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`publication_date` DATE NOT NULL,
|
||||
`creation_date` DATE NOT NULL,
|
||||
`modification_date` DATE NOT NULL,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`summary` TEXT NOT NULL,
|
||||
`content` MEDIUMTEXT NOT NULL,
|
||||
`author_id` INT(10) UNSIGNED NULL DEFAULT NULL,
|
||||
`version` INT(10) UNSIGNED ZEROFILL NULL DEFAULT NULL,
|
||||
`editor_id` INT(10) UNSIGNED NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fk_nodes_users1_idx` (`author_id` ASC),
|
||||
INDEX `fk_nodes_users2_idx` (`editor_id` ASC),
|
||||
CONSTRAINT `fk_nodes_users1`
|
||||
FOREIGN KEY (`author_id`)
|
||||
REFERENCES `cms_dev`.`users` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_nodes_users2`
|
||||
FOREIGN KEY (`editor_id`)
|
||||
REFERENCES `cms_dev`.`users` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 11
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `cms_dev`.`roles`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `cms_dev`.`roles` (
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`role` VARCHAR(100) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `role` (`role` ASC))
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `cms_dev`.`permissions`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `cms_dev`.`permissions` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(45) NOT NULL,
|
||||
`roles_id` INT(10) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `name_UNIQUE` (`name` ASC),
|
||||
INDEX `fk_permissions_roles1_idx` (`roles_id` ASC),
|
||||
CONSTRAINT `fk_permissions_roles1`
|
||||
FOREIGN KEY (`roles_id`)
|
||||
REFERENCES `cms_dev`.`roles` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `cms_dev`.`profiles`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `cms_dev`.`profiles` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`key` VARCHAR(45) NOT NULL,
|
||||
`value` VARCHAR(100) NULL DEFAULT NULL,
|
||||
`users_id` INT(10) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `key_UNIQUE` (`key` ASC),
|
||||
INDEX `fk_profiles_users1_idx` (`users_id` ASC),
|
||||
CONSTRAINT `fk_profiles_users1`
|
||||
FOREIGN KEY (`users_id`)
|
||||
REFERENCES `cms_dev`.`users` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `cms_dev`.`users_nodes`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `cms_dev`.`users_nodes` (
|
||||
`users_id` INT(10) UNSIGNED NOT NULL,
|
||||
`nodes_id` INT(10) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`users_id`, `nodes_id`),
|
||||
INDEX `fk_users_has_nodes_nodes1_idx` (`nodes_id` ASC),
|
||||
INDEX `fk_users_has_nodes_users_idx` (`users_id` ASC),
|
||||
CONSTRAINT `fk_users_has_nodes_nodes1`
|
||||
FOREIGN KEY (`nodes_id`)
|
||||
REFERENCES `cms_dev`.`nodes` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_users_has_nodes_users`
|
||||
FOREIGN KEY (`users_id`)
|
||||
REFERENCES `cms_dev`.`users` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `cms_dev`.`users_roles`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `cms_dev`.`users_roles` (
|
||||
`users_id` INT(10) UNSIGNED NOT NULL,
|
||||
`roles_id` INT(10) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`users_id`, `roles_id`),
|
||||
INDEX `fk_users_has_roles_roles1_idx` (`roles_id` ASC),
|
||||
INDEX `fk_users_has_roles_users1_idx` (`users_id` ASC),
|
||||
CONSTRAINT `fk_users_has_roles_roles1`
|
||||
FOREIGN KEY (`roles_id`)
|
||||
REFERENCES `cms_dev`.`roles` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_users_has_roles_users1`
|
||||
FOREIGN KEY (`users_id`)
|
||||
REFERENCES `cms_dev`.`users` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
SET SQL_MODE=@OLD_SQL_MODE;
|
||||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
||||
@@ -1,72 +0,0 @@
|
||||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Schema mydb
|
||||
-- -----------------------------------------------------
|
||||
-- -----------------------------------------------------
|
||||
-- Schema roc_cms
|
||||
-- -----------------------------------------------------
|
||||
DROP SCHEMA IF EXISTS `roc_cms` ;
|
||||
CREATE SCHEMA IF NOT EXISTS `roc_cms` DEFAULT CHARACTER SET latin1 ;
|
||||
USE `roc_cms` ;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `roc_cms`.`nodes`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `roc_cms`.`nodes` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `roc_cms`.`nodes` (
|
||||
`nid` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`version` INT(11) NULL DEFAULT NULL,
|
||||
`type` INT(11) NULL DEFAULT NULL,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`summary` TEXT NOT NULL,
|
||||
`content` MEDIUMTEXT NOT NULL,
|
||||
`author` INT(11) NULL DEFAULT NULL,
|
||||
`publish` DATETIME NULL DEFAULT NULL,
|
||||
`created` DATETIME NOT NULL,
|
||||
`changed` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`nid`))
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `roc_cms`.`users`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `roc_cms`.`users` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `roc_cms`.`users` (
|
||||
`uid` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(100) NOT NULL,
|
||||
`password` VARCHAR(100) NOT NULL,
|
||||
`salt` VARCHAR(100) NOT NULL,
|
||||
`email` VARCHAR(250) NOT NULL,
|
||||
`status` INT(11) NULL DEFAULT NULL,
|
||||
`created` DATETIME NOT NULL,
|
||||
`signed` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`uid`),
|
||||
UNIQUE INDEX `name` (`name` ASC))
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `roc_cms`.`users_roles`
|
||||
-- -----------------------------------------------------
|
||||
DROP TABLE IF EXISTS `roc_cms`.`users_roles` ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `roc_cms`.`users_roles` (
|
||||
`rid` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`role` VARCHAR(100) NOT NULL,
|
||||
PRIMARY KEY (`rid`),
|
||||
UNIQUE INDEX `role` (`role` ASC))
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
SET SQL_MODE=@OLD_SQL_MODE;
|
||||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
||||
@@ -1,14 +0,0 @@
|
||||
DROP TABLE IF EXISTS nodes;
|
||||
|
||||
CREATE TABLE nodes
|
||||
(
|
||||
id smallint unsigned NOT NULL auto_increment,
|
||||
publication_date date NOT NULL, #When the article was published
|
||||
creation_date date NOT NULL, #When the article was created
|
||||
modification_date date NOT NULL, #When the article was updated
|
||||
title varchar(255) NOT NULL, #Full title of the article
|
||||
summary text NOT NULL, #A short summary of the articule
|
||||
content mediumtext NOT NULL, #The HTML content of the article
|
||||
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
@@ -1,8 +0,0 @@
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER update_editor
|
||||
AFTER INSERT ON `users_nodes` FOR EACH ROW
|
||||
UPDATE Nodes
|
||||
SET editor_id = NEW.users_id
|
||||
WHERE id = NEW.nodes_id;
|
||||
$$
|
||||
DELIMITER ;
|
||||
@@ -1,75 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_NODE_STORAGE_MYSQL}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
deferred class
|
||||
CMS_NODE_STORAGE_MYSQL
|
||||
|
||||
inherit
|
||||
CMS_NODE_STORAGE_SQL
|
||||
redefine
|
||||
nodes, recent_nodes
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
nodes: LIST [CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||
across nodes_iterator as ic loop
|
||||
Result.force (ic.item)
|
||||
end
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
-- List of recent `a_count' nodes with an offset of `lower'.
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (a_count)
|
||||
across recent_nodes_iterator (a_lower, a_count) as c loop
|
||||
Result.force (c.item)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access: iterator
|
||||
|
||||
nodes_iterator: DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- List of nodes.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".nodes_iterator")
|
||||
create l_parameters.make (0)
|
||||
sql_query (select_nodes, l_parameters)
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
recent_nodes_iterator (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- The most recent `a_rows'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
l_query: STRING
|
||||
do
|
||||
-- FIXME: check implementation...
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".recent_nodes_iterator")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_rows, "rows")
|
||||
l_parameters.put (a_lower, "offset")
|
||||
create l_query.make_from_string (select_recent_nodes)
|
||||
sql_query (l_query, l_parameters)
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,112 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_STORAGE_MYSQL}."
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
CMS_STORAGE_MYSQL
|
||||
|
||||
inherit
|
||||
CMS_STORAGE
|
||||
|
||||
CMS_STORAGE_STORE_SQL
|
||||
|
||||
CMS_USER_STORAGE_MYSQL
|
||||
|
||||
CMS_NODE_STORAGE_MYSQL
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
--feature {NONE} -- Initialization
|
||||
|
||||
-- make (a_connection: DATABASE_CONNECTION)
|
||||
-- --
|
||||
-- require
|
||||
-- is_connected: a_connection.is_connected
|
||||
-- do
|
||||
-- connection := a_connection
|
||||
-- log.write_information (generator + ".make - is database connected? "+ a_connection.is_connected.out )
|
||||
|
||||
-- create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
|
||||
-- create error_handler.make
|
||||
---- error_handler.add_synchronization (db_handler.database_error_handler)
|
||||
-- end
|
||||
|
||||
-- db_handler: DATABASE_HANDLER
|
||||
|
||||
-- connection: DATABASE_CONNECTION
|
||||
-- -- Current database connection.
|
||||
|
||||
--feature -- Query
|
||||
|
||||
-- sql_post_execution
|
||||
-- -- Post database execution.
|
||||
-- do
|
||||
-- error_handler.append (db_handler.database_error_handler)
|
||||
-- if error_handler.has_error then
|
||||
-- log.write_critical (generator + ".post_execution " + error_handler.as_string_representation)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- sql_begin_transaction
|
||||
-- do
|
||||
-- connection.begin_transaction
|
||||
-- end
|
||||
|
||||
-- sql_commit_transaction
|
||||
-- do
|
||||
-- connection.commit
|
||||
-- end
|
||||
|
||||
-- sql_query (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
|
||||
-- do
|
||||
-- check_sql_query_validity (a_sql_statement, a_params)
|
||||
-- db_handler.set_query (create {DATABASE_QUERY}.data_reader (a_sql_statement, a_params))
|
||||
-- db_handler.execute_query
|
||||
-- end
|
||||
|
||||
-- sql_change (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
|
||||
-- do
|
||||
-- check_sql_query_validity (a_sql_statement, a_params)
|
||||
-- db_handler.set_query (create {DATABASE_QUERY}.data_reader (a_sql_statement, a_params))
|
||||
-- db_handler.execute_change
|
||||
-- end
|
||||
|
||||
-- sql_rows_count: INTEGER
|
||||
-- -- Number of rows for last sql execution.
|
||||
-- do
|
||||
-- Result := db_handler.count
|
||||
-- end
|
||||
|
||||
-- sql_start
|
||||
-- -- Set the cursor on first element.
|
||||
-- do
|
||||
-- db_handler.start
|
||||
-- end
|
||||
|
||||
-- sql_after: BOOLEAN
|
||||
-- -- Are there no more items to iterate over?
|
||||
-- do
|
||||
-- Result := db_handler.after
|
||||
-- end
|
||||
|
||||
-- sql_forth
|
||||
-- -- Fetch next row from last sql execution, if any.
|
||||
-- do
|
||||
-- db_handler.forth
|
||||
-- end
|
||||
|
||||
-- sql_item (a_index: INTEGER): detachable ANY
|
||||
-- do
|
||||
-- if attached {DB_TUPLE} db_handler.item as l_item and then l_item.count >= a_index then
|
||||
-- Result := l_item.item (a_index)
|
||||
-- else
|
||||
-- check has_item_at_index: False end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
end
|
||||
@@ -1,40 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that ...
|
||||
]"
|
||||
author: "$Author: jfiat $"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
CMS_STORAGE_MYSQL_BUILDER
|
||||
|
||||
inherit
|
||||
CMS_STORAGE_BUILDER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_MYSQL
|
||||
local
|
||||
conn: DATABASE_CONNECTION
|
||||
do
|
||||
if attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.layout.application_config_path) as l_database_config then
|
||||
create {DATABASE_CONNECTION_MYSQL} conn.login_with_connection_string (l_database_config.connection_string)
|
||||
if conn.is_connected then
|
||||
create Result.make (conn)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_STORAGE_MYSQL}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
deferred class
|
||||
CMS_USER_STORAGE_MYSQL
|
||||
|
||||
inherit
|
||||
CMS_USER_STORAGE_SQL
|
||||
|
||||
|
||||
end
|
||||
@@ -1,140 +0,0 @@
|
||||
note
|
||||
description: "Object that handle a database connection for ODBC"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
DATABASE_CONNECTION_MYSQL
|
||||
|
||||
inherit
|
||||
|
||||
DATABASE_CONNECTION
|
||||
redefine
|
||||
db_application
|
||||
end
|
||||
|
||||
create
|
||||
make, make_common, make_basic, login_with_connection_string, login_with_schema
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make_common
|
||||
-- Create a database handler for MYSQL with common settings.
|
||||
local
|
||||
l_retried: BOOLEAN
|
||||
do
|
||||
create database_error_handler.make
|
||||
create db_application.login (username, password)
|
||||
|
||||
if not l_retried then
|
||||
db_application.set_hostname (hostname)
|
||||
db_application.set_data_source (database_name)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := is_keep_connection
|
||||
if keep_connection then
|
||||
connect
|
||||
end
|
||||
else
|
||||
create db_control.make
|
||||
end
|
||||
rescue
|
||||
create database_error_handler.make
|
||||
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||
l_retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
make_basic (a_database_name: STRING)
|
||||
-- Create a database handler and
|
||||
-- set database_name to `a_database_name'.
|
||||
local
|
||||
l_retried: BOOLEAN
|
||||
do
|
||||
create database_error_handler.make
|
||||
create db_application.login (username, password)
|
||||
|
||||
if not l_retried then
|
||||
db_application.set_hostname (hostname)
|
||||
db_application.set_data_source (a_database_name)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := is_keep_connection
|
||||
if keep_connection then
|
||||
connect
|
||||
end
|
||||
else
|
||||
create db_control.make
|
||||
end
|
||||
rescue
|
||||
create database_error_handler.make
|
||||
exception_as_error ((create {EXCEPTION_MANAGER}).last_exception)
|
||||
l_retried := True
|
||||
retry
|
||||
end
|
||||
|
||||
make (a_username: STRING; a_password: STRING; a_hostname: STRING; a_database_name: STRING; connection: BOOLEAN)
|
||||
|
||||
-- Create a database handler for ODBC and set `username' to `a_username',
|
||||
-- `password' to `a_password'
|
||||
-- `database_name' to `a_database_name'
|
||||
-- `connection' to `a_connection'
|
||||
do
|
||||
create database_error_handler.make
|
||||
create db_application.login (a_username, a_password)
|
||||
db_application.set_hostname (a_hostname)
|
||||
db_application.set_data_source (a_database_name)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := connection
|
||||
if keep_connection then
|
||||
connect
|
||||
end
|
||||
end
|
||||
|
||||
login_with_connection_string (a_string: STRING)
|
||||
-- Login with `a_connection_string'and immediately connect to database.
|
||||
local
|
||||
l_string: LIST[STRING]
|
||||
l_server: STRING
|
||||
l_port: STRING
|
||||
l_schema: STRING
|
||||
l_user: STRING
|
||||
l_password: STRING
|
||||
do
|
||||
create database_error_handler.make
|
||||
|
||||
l_string := a_string.split (';')
|
||||
l_server := l_string.at (2).split ('=').at (2)
|
||||
l_port := l_string.at (3).split ('=').at (2)
|
||||
l_schema := l_string.at (4).split ('=').at (2)
|
||||
l_user := l_string.at (5).split ('=').at (2)
|
||||
l_password := l_string.at (6).split ('=').at (2)
|
||||
|
||||
create db_application
|
||||
db_application.set_application (l_schema)
|
||||
db_application.set_hostname (l_server + ":" + l_port)
|
||||
db_application.login_and_connect (l_user, l_password)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := is_keep_connection
|
||||
end
|
||||
|
||||
login_with_schema (a_schema: STRING; a_username: STRING; a_password: STRING)
|
||||
-- Login with `a_connection_string'and immediately connect to database.
|
||||
do
|
||||
create database_error_handler.make
|
||||
create db_application
|
||||
db_application.set_application (a_schema)
|
||||
db_application.login_and_connect (a_username, a_password)
|
||||
db_application.set_base
|
||||
create db_control.make
|
||||
keep_connection := is_keep_connection
|
||||
end
|
||||
|
||||
feature -- Databse Connection
|
||||
|
||||
db_application: DATABASE_APPL [MYSQL]
|
||||
-- Database application.
|
||||
|
||||
end
|
||||
@@ -1,72 +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
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
create connection.login_with_schema ("cms_dev", "root", "")
|
||||
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
|
||||
create {CMS_STORAGE_MYSQL} storage.make (connection)
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.new_user (default_user)
|
||||
storage.new_user (custom_user ("u2", "p2", "e2"))
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
storage.update_node_title (2,ll_node.id, "New Title")
|
||||
check
|
||||
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
|
||||
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} -- Implementation
|
||||
|
||||
|
||||
connection: DATABASE_CONNECTION_MYSQL
|
||||
|
||||
|
||||
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
|
||||
@@ -1,81 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
DATABASE_HANDLER_TEST
|
||||
|
||||
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
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_wrong_database_query
|
||||
-- New test routine
|
||||
local
|
||||
l_parameters: STRING_TABLE[detachable ANY]
|
||||
do
|
||||
create l_parameters.make (0)
|
||||
handler.set_query (create {DATABASE_QUERY}.data_reader ("Sellect from users", l_parameters))
|
||||
handler.execute_query
|
||||
assert ("Has error:", handler.has_error)
|
||||
end
|
||||
|
||||
|
||||
|
||||
test_sequences_of_wrong_and_correct_queries
|
||||
-- New test routine
|
||||
local
|
||||
l_parameters: STRING_TABLE[detachable ANY]
|
||||
do
|
||||
create l_parameters.make (0)
|
||||
handler.set_query (create {DATABASE_QUERY}.data_reader ("Sellect from users;", l_parameters))
|
||||
handler.execute_query
|
||||
assert ("Has error:", handler.has_error)
|
||||
|
||||
handler.set_query (create {DATABASE_QUERY}.data_reader ("Select * from users;", l_parameters))
|
||||
handler.execute_query
|
||||
assert ("Not Has error:",not handler.has_error)
|
||||
end
|
||||
|
||||
|
||||
feature -- Handler
|
||||
|
||||
handler: DATABASE_HANDLER
|
||||
once
|
||||
create {DATABASE_HANDLER_IMPL} Result.make (connection )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,242 +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:"execution/isolated"
|
||||
|
||||
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
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db (connection)
|
||||
assert ("Empty Nodes", storage.nodes_count = 0)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_new_node
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
do
|
||||
assert ("Empty Nodes", storage.nodes_count = 0)
|
||||
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
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "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 ("<h1>Updating test node udpate </h1>")
|
||||
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 ("<h1>Updating test node udpate </h1>")
|
||||
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
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
u: CMS_USER
|
||||
do
|
||||
u := default_user
|
||||
storage.new_user (u)
|
||||
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "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 (u.id, 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
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
u: CMS_USER
|
||||
do
|
||||
u := default_user
|
||||
storage.new_user (u)
|
||||
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "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 (u.id, 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
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
u: CMS_USER
|
||||
do
|
||||
u := default_user
|
||||
storage.new_user (u)
|
||||
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
storage.sql_begin_transaction
|
||||
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 (u.id, 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
|
||||
storage.sql_commit_transaction
|
||||
end
|
||||
|
||||
|
||||
test_delete_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "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
|
||||
|
||||
test_new_node_add_author
|
||||
do
|
||||
storage.new_node (default_node)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} storage.node_by_id (1))
|
||||
storage.new_user (custom_user ("u1", "u1", "email"))
|
||||
if attached storage.user_by_name ("u1") as l_user then
|
||||
if attached storage.node_by_id (1) as l_node then
|
||||
l_node.set_author (l_user)
|
||||
storage.update_node (l_node)
|
||||
assert ("Author not void for node 1", attached storage.node_author (1))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,358 +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
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
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_new_user
|
||||
do
|
||||
storage.new_user (default_user)
|
||||
assert ("Has user", storage.has_user)
|
||||
end
|
||||
|
||||
test_user_by_id
|
||||
do
|
||||
storage.new_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.new_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.new_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.new_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.new_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]
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.new_user (default_user)
|
||||
across 1 |..| 10 as c loop
|
||||
l_node := custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
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
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.new_user (default_user)
|
||||
across 1 |..| 10 as c loop
|
||||
l_node := custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
end
|
||||
assert ("Not exist node id: 12", storage.node_by_id (12) = Void)
|
||||
end
|
||||
|
||||
test_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
storage.new_user (default_user)
|
||||
across 1 |..| 10 as c loop
|
||||
l_node := custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
end
|
||||
assert ("Node id: 10", attached storage.node_by_id (10) as ll_node and then ll_node.title ~ "Title_10" )
|
||||
end
|
||||
|
||||
test_update_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.new_user (default_user)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
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")
|
||||
if attached storage.user_by_email (default_user.email) as l_user then
|
||||
l_node.set_author (l_user)
|
||||
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
|
||||
end
|
||||
|
||||
test_update_node_title
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.new_user (default_user)
|
||||
storage.new_user (custom_user ("u2", "p2", "e2"))
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
storage.update_node_title (2,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
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.new_user (default_user)
|
||||
storage.new_user (custom_user ("u2", "p2", "e2"))
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
storage.update_node_summary (2,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
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.new_user (default_user)
|
||||
storage.new_user (custom_user ("u2", "p2", "e2"))
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
storage.update_node_content (2,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_update_node_title_by_author
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.new_user (default_user)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
storage.update_node_title (1,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_by_author
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.new_user (default_user)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
storage.update_node_summary (1,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_by_author
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.new_user (default_user)
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.new_node (l_node)
|
||||
if attached {CMS_NODE} storage.node_by_id (1) as ll_node then
|
||||
storage.update_node_content (1,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
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
l_user: like {CMS_NODE}.author
|
||||
do
|
||||
storage.new_user (custom_user ("test_delete", "testu", "email"))
|
||||
l_user := storage.user_by_name ("test_delete")
|
||||
across 1 |..| 10 as c loop
|
||||
l_node := custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out)
|
||||
l_node.set_author (l_user)
|
||||
storage.new_node (l_node)
|
||||
end
|
||||
assert ("Exist node id: 10", attached storage.node_by_id (10) as ll_node and then ll_node.title ~ "Title_10" )
|
||||
storage.delete_node_by_id (10)
|
||||
assert ("Not exist node id: 10", storage.node_by_id (10) = Void)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="tests" uuid="FCC2264E-784F-4ACF-9262-E348904FDBA5">
|
||||
<target name="tests">
|
||||
<root class="APPLICATION" feature="make"/>
|
||||
<option warning="true" void_safety="conformance">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="concurrency" value="thread"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="persitence_mysql" location="..\persistence_mysql-safe.ecf" readonly="false"/>
|
||||
<library name="process" location="$ISE_LIBRARY\library\process\process-safe.ecf"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<cluster name="tests" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,87 +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
|
||||
TRANSACTION_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
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db (connection)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_user_rollback
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
u: detachable CMS_USER
|
||||
do
|
||||
u := storage.user_by_name ("test")
|
||||
if u = Void then
|
||||
u := custom_user ("test", "test","test@admin.com")
|
||||
storage.new_user (u)
|
||||
end
|
||||
assert ("Has user:", storage.has_user)
|
||||
u.set_email ("test@example.com")
|
||||
storage.sql_begin_transaction
|
||||
storage.update_user (u)
|
||||
assert ("Has user:", storage.user_by_email ("test@example.com") /= Void)
|
||||
storage.sql_rollback_transaction
|
||||
assert ("Not has user:", storage.user_by_email ("test@example.com") = Void)
|
||||
end
|
||||
|
||||
test_user_node_rollback
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
u: detachable CMS_USER
|
||||
do
|
||||
u := storage.user_by_name ("test")
|
||||
if u = Void then
|
||||
u := custom_user ("test", "test","test@admin.com")
|
||||
storage.new_user (u)
|
||||
end
|
||||
|
||||
connection.begin_transaction
|
||||
u.set_email ("test@example.com")
|
||||
assert ("Has user:", storage.user_by_email ("test@example.com") /= Void)
|
||||
storage.new_node (default_node)
|
||||
assert ("Has one node:", storage.nodes_count = 1)
|
||||
connection.rollback
|
||||
assert ("Not has user:", storage.user_by_email ("test@example.com") = Void)
|
||||
assert ("Has no node:", storage.nodes_count = 0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,111 +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:"execution/isolated"
|
||||
|
||||
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
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
storage.new_user (custom_user ("admin", "admin","admin@admin.com"))
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
-- (create {CLEAN_DB}).clean_db(connection)
|
||||
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 ("User by email: Void", storage.user_by_email ("test1@test.com") = Void)
|
||||
assert ("User by id: Void", storage.user_by_id (5) = Void )
|
||||
assert ("User by name: Void", storage.user_by_name ("test1") = Void)
|
||||
end
|
||||
|
||||
test_new_user
|
||||
local
|
||||
u: CMS_USER
|
||||
do
|
||||
u := default_user
|
||||
storage.new_user (u)
|
||||
assert ("Not void", attached storage.user_by_email (u.email))
|
||||
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 ~ u.name)
|
||||
assert ("Not void", attached storage.user_by_name (u.name))
|
||||
end
|
||||
|
||||
-- test_new_user_with_roles
|
||||
-- do
|
||||
-- storage.new_user (default_user)
|
||||
-- storage.new_role ("Admin")
|
||||
-- assert ("Empty roles for given user", storage.user_roles (1).after)
|
||||
-- storage.add_role (1, 1)
|
||||
-- assert ("Not empty roles for given user", not storage.user_roles (1).after)
|
||||
-- end
|
||||
|
||||
-- test_new_user_without_profile
|
||||
-- do
|
||||
-- storage.new_user ("test", "test","test@admin.com")
|
||||
-- assert ("Empty", storage.user_profile (1).new_cursor.after)
|
||||
-- end
|
||||
|
||||
-- test_new_user_with_profile
|
||||
-- local
|
||||
-- l_profile: CMS_USER_PROFILE
|
||||
-- l_db_profile: CMS_USER_PROFILE
|
||||
-- do
|
||||
-- storage.new_user (default_user)
|
||||
-- if attached {CMS_USER} storage.user_by_name ("test") as l_user then
|
||||
-- assert ("Empty", storage.user_profile (l_user.id).new_cursor.after)
|
||||
-- create l_profile.make
|
||||
-- l_profile.force ("Eiffel", "language")
|
||||
-- l_profile.force ("Argentina", "country")
|
||||
-- l_profile.force ("GMT-3", "time zone")
|
||||
-- storage.save_profile (l_user.id, l_profile)
|
||||
-- l_db_profile := storage.user_profile (l_user.id)
|
||||
-- assert ("Not Empty", not l_db_profile.new_cursor.after)
|
||||
|
||||
-- assert ("Expected language Eiffel", attached l_db_profile.item ("language") as l_language and then l_language ~ "Eiffel")
|
||||
-- assert ("Expected time zone GMT-3", attached l_db_profile.item ("time zone") as l_language and then l_language ~ "GMT-3")
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,48 +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_MYSQL
|
||||
-- MYSQL database connection
|
||||
once
|
||||
create Result.login_with_schema ("cms_dev", "root", "")
|
||||
end
|
||||
|
||||
storage: CMS_STORAGE_MYSQL
|
||||
once
|
||||
create 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: READABLE_STRING_32; a_email: READABLE_STRING_8): 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_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
end
|
||||
@@ -1,129 +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"
|
||||
testing:"execution/serial"
|
||||
|
||||
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)
|
||||
|
||||
a_connection.begin_transaction
|
||||
|
||||
-- Clean Profiles
|
||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_user_profiles, l_parameters))
|
||||
db_handler(a_connection).execute_change
|
||||
|
||||
-- Clean Permissions
|
||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_permissions, l_parameters))
|
||||
db_handler(a_connection).execute_change
|
||||
|
||||
|
||||
-- Clean Users Nodes
|
||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_users_nodes, l_parameters))
|
||||
db_handler(a_connection).execute_change
|
||||
|
||||
|
||||
-- Clean Users Roles
|
||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_users_roles, l_parameters))
|
||||
db_handler(a_connection).execute_change
|
||||
|
||||
-- Clean Roles
|
||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_roles, l_parameters))
|
||||
db_handler(a_connection).execute_change
|
||||
|
||||
-- Clean Nodes
|
||||
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
|
||||
|
||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_roles_autoincrement, l_parameters))
|
||||
db_handler(a_connection).execute_change
|
||||
|
||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_permissions_autoincrement, l_parameters))
|
||||
db_handler(a_connection).execute_change
|
||||
|
||||
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_profiles_autoincrement, l_parameters))
|
||||
db_handler(a_connection).execute_change
|
||||
|
||||
a_connection.commit
|
||||
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.
|
||||
|
||||
Sql_delete_roles: STRING = "delete from Roles"
|
||||
-- Clean Roles.
|
||||
|
||||
Sql_delete_permissions: STRING = "delete from Permissions"
|
||||
-- Clean Permissions.
|
||||
|
||||
Sql_delete_users_roles: STRING = "delete from Users_roles"
|
||||
-- Clean User roles.
|
||||
|
||||
Sql_delete_user_profiles: STRING = "delete from profiles"
|
||||
-- Clean profiles.
|
||||
|
||||
Sql_delete_users_nodes: STRING = "delete from users_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.
|
||||
|
||||
Rest_roles_autoincrement: STRING = "ALTER TABLE Roles AUTO_INCREMENT = 1"
|
||||
-- reset autoincrement.
|
||||
|
||||
Rest_permissions_autoincrement: STRING = "ALTER TABLE Permissions AUTO_INCREMENT = 1"
|
||||
-- reset autoincrement.
|
||||
|
||||
Rest_profiles_autoincrement: STRING = "ALTER TABLE Profiles AUTO_INCREMENT = 1"
|
||||
-- reset autoincrement.
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="persistence_sqlite" uuid="8FD9D3B3-5FC1-495F-A05D-0205EC966841" library_target="persistence_sqlite">
|
||||
<target name="persistence_sqlite">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="all">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\cms-safe.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\..\layout\layout-safe.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="odbc" location="$ISE_LIBRARY\library\store\dbms\rdbms\odbc\odbc-safe.ecf"/>
|
||||
<library name="store" location="$ISE_LIBRARY\library\store\store-safe.ecf" readonly="false"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<cluster name="common" location="..\common\" recursive="true"/>
|
||||
<cluster name="persistence_sqlite" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="persistence_sqlite" uuid="8FD9D3B3-5FC1-495F-A05D-0205EC966841" library_target="persistence_sqlite">
|
||||
<target name="persistence_sqlite">
|
||||
<root all_classes="true"/>
|
||||
<option warning="true" void_safety="none">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\cms.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\..\layout\layout.ecf"/>
|
||||
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging.ecf"/>
|
||||
<library name="model" location="..\..\..\model\cms_model.ecf"/>
|
||||
<library name="odbc" location="$ISE_LIBRARY\library\store\dbms\rdbms\odbc\odbc.ecf"/>
|
||||
<library name="store" location="$ISE_LIBRARY\library\store\store.ecf" readonly="false"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||
<cluster name="common" location="..\common\" recursive="true"/>
|
||||
<cluster name="persistence_sqlite" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -1 +0,0 @@
|
||||
Added Stored Procedures
|
||||
@@ -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;
|
||||
@@ -1,75 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_NODE_STORAGE_SQLITE}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
deferred class
|
||||
CMS_NODE_STORAGE_SQLITE
|
||||
|
||||
inherit
|
||||
CMS_NODE_STORAGE_SQL
|
||||
redefine
|
||||
nodes, recent_nodes
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
nodes: LIST [CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
||||
across nodes_iterator as ic loop
|
||||
Result.force (ic.item)
|
||||
end
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
-- List of recent `a_count' nodes with an offset of `lower'.
|
||||
do
|
||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (a_count)
|
||||
across recent_nodes_iterator (a_lower, a_count) as c loop
|
||||
Result.force (c.item)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access: iterator
|
||||
|
||||
nodes_iterator: DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- List of nodes.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".nodes_iterator")
|
||||
create l_parameters.make (0)
|
||||
sql_query (select_nodes, l_parameters)
|
||||
sql_post_execution
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
end
|
||||
|
||||
recent_nodes_iterator (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- The most recent `a_rows'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
l_query: STRING
|
||||
do
|
||||
-- FIXME: check implementation...
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".recent_nodes_iterator")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_rows, "rows")
|
||||
l_parameters.put (a_lower, "offset")
|
||||
create l_query.make_from_string (select_recent_nodes)
|
||||
sql_query (l_query, l_parameters)
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,112 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_STORAGE_MYSQL}."
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
CMS_STORAGE_SQLITE
|
||||
|
||||
inherit
|
||||
CMS_STORAGE
|
||||
|
||||
CMS_STORAGE_STORE_SQL
|
||||
|
||||
CMS_USER_STORAGE_SQLITE
|
||||
|
||||
CMS_NODE_STORAGE_SQLITE
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
--feature {NONE} -- Initialization
|
||||
|
||||
-- make (a_connection: DATABASE_CONNECTION)
|
||||
-- --
|
||||
-- require
|
||||
-- is_connected: a_connection.is_connected
|
||||
-- do
|
||||
-- connection := a_connection
|
||||
-- log.write_information (generator + ".make_with_database is database connected? "+ a_connection.is_connected.out )
|
||||
|
||||
-- create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
|
||||
-- create error_handler.make
|
||||
---- error_handler.add_synchronization (db_handler.database_error_handler)
|
||||
-- end
|
||||
|
||||
-- db_handler: DATABASE_HANDLER
|
||||
|
||||
-- connection: DATABASE_CONNECTION
|
||||
-- -- Current database connection.
|
||||
|
||||
--feature -- Access: user
|
||||
|
||||
-- sql_post_execution
|
||||
-- -- Post database execution.
|
||||
-- do
|
||||
-- error_handler.append (db_handler.database_error_handler)
|
||||
-- if error_handler.has_error then
|
||||
-- log.write_critical (generator + ".post_execution " + error_handler.as_string_representation)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- sql_begin_transaction
|
||||
-- do
|
||||
-- connection.begin_transaction
|
||||
-- end
|
||||
|
||||
-- sql_commit_transaction
|
||||
-- do
|
||||
-- connection.commit
|
||||
-- end
|
||||
|
||||
-- sql_query (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
|
||||
-- do
|
||||
-- check_sql_query_validity (a_sql_statement, a_params)
|
||||
-- db_handler.set_query (create {DATABASE_QUERY}.data_reader (a_sql_statement, a_params))
|
||||
-- db_handler.execute_query
|
||||
-- end
|
||||
|
||||
-- sql_change (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
|
||||
-- do
|
||||
-- check_sql_query_validity (a_sql_statement, a_params)
|
||||
-- db_handler.set_query (create {DATABASE_QUERY}.data_reader (a_sql_statement, a_params))
|
||||
-- db_handler.execute_change
|
||||
-- end
|
||||
|
||||
-- sql_rows_count: INTEGER
|
||||
-- -- Number of rows for last sql execution.
|
||||
-- do
|
||||
-- Result := db_handler.count
|
||||
-- end
|
||||
|
||||
-- sql_start
|
||||
-- -- Set the cursor on first element.
|
||||
-- do
|
||||
-- db_handler.start
|
||||
-- end
|
||||
|
||||
-- sql_after: BOOLEAN
|
||||
-- -- Are there no more items to iterate over?
|
||||
-- do
|
||||
-- Result := db_handler.after
|
||||
-- end
|
||||
|
||||
-- sql_forth
|
||||
-- -- Fetch next row from last sql execution, if any.
|
||||
-- do
|
||||
-- db_handler.forth
|
||||
-- end
|
||||
|
||||
-- sql_item (a_index: INTEGER): detachable ANY
|
||||
-- do
|
||||
-- if attached {DB_TUPLE} db_handler.item as l_item and then l_item.count >= a_index then
|
||||
-- Result := l_item.item (a_index)
|
||||
-- else
|
||||
-- check has_item_at_index: False end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
end
|
||||
@@ -1,43 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Objects that ...
|
||||
]"
|
||||
author: "$Author: jfiat $"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
CMS_STORAGE_SQLITE_BUILDER
|
||||
|
||||
inherit
|
||||
CMS_STORAGE_BUILDER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Factory
|
||||
|
||||
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_SQLITE
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
if attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (a_setup.layout.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;")
|
||||
create Result.make (create {DATABASE_CONNECTION_ODBC}.login_with_connection_string (s))
|
||||
--create Result.make (create {DATABASE_CONNECTION_ODBC}.login_with_connection_string (l_database_config.connection_string))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_USER_STORAGE_SQLITE}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
deferred class
|
||||
CMS_USER_STORAGE_SQLITE
|
||||
|
||||
inherit
|
||||
CMS_USER_STORAGE_SQL
|
||||
|
||||
|
||||
end
|
||||
@@ -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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
Binary file not shown.
@@ -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
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
assert ("Empty Nodes", storage.nodes.after)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
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 ("<h1> test node udpate </h1>", "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 ("<h1>Updating test node udpate </h1>")
|
||||
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 ("<h1>Updating test node udpate </h1>")
|
||||
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 ("<h1> test node udpate </h1>", "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 ("<h1> test node udpate </h1>", "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 ("<h1> test node udpate </h1>", "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 ("<h1> test node udpate </h1>", "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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
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
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="tests" uuid="FE27C81D-3F7D-4E46-992B-55F4BBDA4F8B">
|
||||
<target name="tests">
|
||||
<root class="APPLICATION" feature="make"/>
|
||||
<option warning="true" void_safety="conformance">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="concurrency" value="thread"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="model" location="..\..\..\..\model\cms_model-safe.ecf"/>
|
||||
<library name="persitence_sqlite" location="..\persistence_sqlite-safe.ecf" readonly="false"/>
|
||||
<library name="process" location="$ISE_LIBRARY\library\process\process-safe.ecf"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<cluster name="tests" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -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
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
storage.new_user (custom_user ("admin", "admin","admin@admin.com"))
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
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
|
||||
|
||||
|
||||
@@ -1,54 +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_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -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
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {CMS_STORAGE_STORE_SQL}."
|
||||
author: ""
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
deferred class
|
||||
CMS_STORAGE_STORE_SQL
|
||||
@@ -28,6 +28,14 @@ feature {NONE} -- Initialization
|
||||
-- error_handler.add_synchronization (db_handler.database_error_handler)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_available: BOOLEAN
|
||||
-- Is storage available?
|
||||
do
|
||||
Result := connection.is_connected
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
@@ -66,6 +74,7 @@ feature -- Query
|
||||
check_sql_query_validity (a_sql_statement, a_params)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (a_sql_statement, a_params))
|
||||
db_handler.execute_query
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
sql_change (a_sql_statement: STRING; a_params: detachable STRING_TABLE [detachable ANY])
|
||||
@@ -73,6 +82,7 @@ feature -- Query
|
||||
check_sql_query_validity (a_sql_statement, a_params)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (a_sql_statement, a_params))
|
||||
db_handler.execute_change
|
||||
sql_post_execution
|
||||
end
|
||||
|
||||
sql_rows_count: INTEGER
|
||||
Reference in New Issue
Block a user