From 562979c4a8fe47952edf7986d4144624e41630f7 Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 4 Dec 2006 02:42:57 +0000 Subject: add unit tests for active record and sqlmap --- .../simple_unit/SqlMap/scripts/mysql/DataBase.sql | 214 +++++++++++++++++++++ .../SqlMap/scripts/mysql/account-init.sql | 20 ++ .../SqlMap/scripts/mysql/account-procedure.sql | 2 + .../SqlMap/scripts/mysql/category-init.sql | 12 ++ .../SqlMap/scripts/mysql/category-procedure.sql | 2 + .../SqlMap/scripts/mysql/documents-init.sql | 20 ++ .../SqlMap/scripts/mysql/enumeration-init.sql | 18 ++ .../SqlMap/scripts/mysql/line-item-init.sql | 37 ++++ .../SqlMap/scripts/mysql/more-account-records.sql | 7 + .../SqlMap/scripts/mysql/order-init.sql | 30 +++ .../SqlMap/scripts/mysql/other-init.sql | 91 +++++++++ .../SqlMap/scripts/mysql/swap-procedure.sql | 2 + .../simple_unit/SqlMap/scripts/mysql/user-init.sql | 14 ++ 13 files changed, 469 insertions(+) create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/DataBase.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/account-init.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/account-procedure.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/category-init.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/category-procedure.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/documents-init.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/enumeration-init.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/line-item-init.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/more-account-records.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/order-init.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/other-init.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/swap-procedure.sql create mode 100644 tests/simple_unit/SqlMap/scripts/mysql/user-init.sql (limited to 'tests/simple_unit/SqlMap/scripts/mysql') diff --git a/tests/simple_unit/SqlMap/scripts/mysql/DataBase.sql b/tests/simple_unit/SqlMap/scripts/mysql/DataBase.sql new file mode 100644 index 00000000..b6542cdb --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/DataBase.sql @@ -0,0 +1,214 @@ +use mysql; + +drop database IBatisNet; +create database IBatisNet; + +drop database NHibernate; +create database NHibernate; + +grant all privileges on IBatisNet.* to IBatisNet@'%' identified by 'test'; +grant all privileges on IBatisNet.* to IBatisNet@localhost identified by 'test'; +grant all privileges on IBatisNet.* to IBatisNet@localhost.localdomain identified by 'test'; + +grant all privileges on NHibernate.* to NHibernate@'%' identified by 'test'; +grant all privileges on NHibernate.* to NHibernate@localhost identified by 'test'; +grant all privileges on NHibernate.* to NHibernate@localhost.localdomain identified by 'test'; + + +/*==============================================================*/ +/* Nom de la base : MYSQL */ +/* Nom de SGBD : MySQL 3.23 */ +/* Date de cr閍tion : 27/05/2004 20:51:40 */ +/*==============================================================*/ + +use IBatisNet; + +drop table if exists Accounts; + +drop table if exists Categories; + +drop table if exists Enumerations; + +drop table if exists LineItems; + +drop table if exists Orders; + +drop table if exists Others; + +drop table if exists Documents; + +/*==============================================================*/ +/* Table : Accounts */ +/*==============================================================*/ +create table Accounts +( + Account_Id int not null, + Account_FirstName varchar(32) not null, + Account_LastName varchar(32) not null, + Account_Email varchar(128), + Account_Banner_Option varchar(255), + Account_Cart_Option int, + primary key (Account_Id) +) TYPE=INNODB; + +/*==============================================================*/ +/* Table : Categories */ +/*==============================================================*/ +create table Categories +( + Category_Id int not null AUTO_INCREMENT, + Category_Name varchar(32), + Category_Guid varchar(36), + primary key (Category_Id) +) TYPE=INNODB; + +/*==============================================================*/ +/* Table : Enumerations */ +/*==============================================================*/ +create table Enumerations +( + Enum_Id int not null, + Enum_Day int not null, + Enum_Color int not null, + Enum_Month int, + primary key (Enum_Id) +) TYPE=INNODB; + +/*==============================================================*/ +/* Table : LineItems */ +/*==============================================================*/ +create table LineItems +( + LineItem_Id int not null, + Order_Id int not null, + LineItem_Code varchar(32) not null, + LineItem_Quantity int not null, + LineItem_Price decimal(18,2), + LineItem_Picture blob, + primary key (Order_Id, LineItem_Id) +) TYPE=INNODB; + +/*==============================================================*/ +/* Table : Orders */ +/*==============================================================*/ +create table Orders +( + Order_Id int not null, + Account_Id int null, + Order_Date datetime, + Order_CardType varchar(32), + Order_CardNumber varchar(32), + Order_CardExpiry varchar(32), + Order_Street varchar(32), + Order_City varchar(32), + Order_Province varchar(32), + Order_PostalCode varchar(32), + Order_FavouriteLineItem int, + primary key (Order_Id) +) TYPE=INNODB; + +/*==============================================================*/ +/* Table : Others */ +/*==============================================================*/ +create table Others +( + Other_Int int, + Other_Long bigint, + Other_Bit bit not null default 0, + Other_String varchar(32) not null +) TYPE=INNODB; + +CREATE TABLE F ( + ID varchar(50) NOT NULL , + F_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +CREATE TABLE E ( + ID varchar(50) NOT NULL , + E_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +CREATE TABLE D ( + ID varchar(50) NOT NULL , + D_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +CREATE TABLE C ( + ID varchar(50) NOT NULL , + C_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + + +CREATE TABLE B ( + ID varchar(50) NOT NULL , + C_ID varchar(50) NULL , + D_ID varchar(50) NULL , + B_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +ALTER TABLE B ADD CONSTRAINT FK_B_C FOREIGN KEY FK_B_C (C_ID) + REFERENCES C (ID) + ON DELETE RESTRICT + ON UPDATE RESTRICT, + ADD CONSTRAINT FK_B_D FOREIGN KEY FK_B_D (D_ID) + REFERENCES D (ID) + ON DELETE RESTRICT + ON UPDATE RESTRICT; + +CREATE TABLE A ( + ID varchar(50) NOT NULL , + B_ID varchar(50) NULL , + E_ID varchar(50) NULL , + F_ID varchar(50) NULL , + A_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +ALTER TABLE A ADD CONSTRAINT FK_A_B FOREIGN KEY FK_A_B (B_ID) + REFERENCES B (ID) + ON DELETE RESTRICT + ON UPDATE RESTRICT, + ADD CONSTRAINT FK_A_E FOREIGN KEY FK_A_E (E_ID) + REFERENCES E (ID) + ON DELETE RESTRICT + ON UPDATE RESTRICT, + ADD CONSTRAINT FK_A_F FOREIGN KEY FK_A_F (F_ID) + REFERENCES F (ID) + ON DELETE RESTRICT; + +/*==============================================================*/ +/* Table : Documents */ +/*==============================================================*/ +create table Documents +( + Document_Id int not null, + Document_Title varchar(32), + Document_Type varchar(32), + Document_PageNumber int, + Document_City varchar(32), + primary key (DOCUMENT_ID) +) TYPE=INNODB; + + + +use NHibernate; + +drop table if exists Users; + +/*==============================================================*/ +/* Table : Users */ +/*==============================================================*/ +create table Users +( + LogonId varchar(20) not null default '0', + Name varchar(40) default null, + Password varchar(20) default null, + EmailAddress varchar(40) default null, + LastLogon datetime default null, + primary key (LogonId) +) TYPE=INNODB; diff --git a/tests/simple_unit/SqlMap/scripts/mysql/account-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/account-init.sql new file mode 100644 index 00000000..51b315f4 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/account-init.sql @@ -0,0 +1,20 @@ +use IBatisNet; + +drop table if exists Accounts; + +create table Accounts +( + Account_Id int not null, + Account_FirstName varchar(32) not null, + Account_LastName varchar(32) not null, + Account_Email varchar(128), + Account_Banner_Option varchar(255), + Account_Cart_Option int, + primary key (Account_Id) +) TYPE=INNODB; + +INSERT INTO Accounts VALUES(1,'Joe', 'Dalton', 'Joe.Dalton@somewhere.com', 'Oui', 200); +INSERT INTO Accounts VALUES(2,'Averel', 'Dalton', 'Averel.Dalton@somewhere.com', 'Oui', 200); +INSERT INTO Accounts VALUES(3,'William', 'Dalton', null, 'Non', 100); +INSERT INTO Accounts VALUES(4,'Jack', 'Dalton', 'Jack.Dalton@somewhere.com', 'Non', 100); +INSERT INTO Accounts VALUES(5,'Gilles', 'Bayon', null, 'Oui', 100); \ No newline at end of file diff --git a/tests/simple_unit/SqlMap/scripts/mysql/account-procedure.sql b/tests/simple_unit/SqlMap/scripts/mysql/account-procedure.sql new file mode 100644 index 00000000..03b65b13 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/account-procedure.sql @@ -0,0 +1,2 @@ + +use IBatisNet; \ No newline at end of file diff --git a/tests/simple_unit/SqlMap/scripts/mysql/category-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/category-init.sql new file mode 100644 index 00000000..2f50ff24 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/category-init.sql @@ -0,0 +1,12 @@ + +use IBatisNet; + +drop table if exists Categories; + +create table Categories +( + Category_Id int not null AUTO_INCREMENT, + Category_Name varchar(32), + Category_Guid varchar(36), + primary key (Category_Id) +) TYPE=INNODB; diff --git a/tests/simple_unit/SqlMap/scripts/mysql/category-procedure.sql b/tests/simple_unit/SqlMap/scripts/mysql/category-procedure.sql new file mode 100644 index 00000000..03b65b13 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/category-procedure.sql @@ -0,0 +1,2 @@ + +use IBatisNet; \ No newline at end of file diff --git a/tests/simple_unit/SqlMap/scripts/mysql/documents-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/documents-init.sql new file mode 100644 index 00000000..c254ae4d --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/documents-init.sql @@ -0,0 +1,20 @@ +use IBatisNet; + +drop table if exists Documents; + +create table Documents +( + Document_Id int not null, + Document_Title varchar(32), + Document_Type varchar(32), + Document_PageNumber int, + Document_City varchar(32), + primary key (DOCUMENT_ID) +) TYPE=INNODB; + +INSERT INTO Documents VALUES (1, 'The World of Null-A', 'Book', 55, null); +INSERT INTO Documents VALUES (2, 'Le Progres de Lyon', 'Newspaper', null , 'Lyon'); +INSERT INTO Documents VALUES (3, 'Lord of the Rings', 'Book', 3587, null); +INSERT INTO Documents VALUES (4, 'Le Canard enchaine', 'Tabloid', null , 'Paris'); +INSERT INTO Documents VALUES (5, 'Le Monde', 'Broadsheet', null , 'Paris'); +INSERT INTO Documents VALUES (6, 'Foundation', 'Monograph', 557, null); diff --git a/tests/simple_unit/SqlMap/scripts/mysql/enumeration-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/enumeration-init.sql new file mode 100644 index 00000000..a194b636 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/enumeration-init.sql @@ -0,0 +1,18 @@ + +use IBatisNet; + +drop table if exists Enumerations; + +create table Enumerations +( + Enum_Id int not null, + Enum_Day int not null, + Enum_Color int not null, + Enum_Month int, + primary key (Enum_Id) +) TYPE=INNODB; + +INSERT INTO Enumerations VALUES(1, 1, 1, 128); +INSERT INTO Enumerations VALUES(2, 2, 2, 2048); +INSERT INTO Enumerations VALUES(3, 3, 4, 256); +INSERT INTO Enumerations VALUES(4, 4, 8, null); diff --git a/tests/simple_unit/SqlMap/scripts/mysql/line-item-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/line-item-init.sql new file mode 100644 index 00000000..cb800835 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/line-item-init.sql @@ -0,0 +1,37 @@ + +use IBatisNet; + +drop table if exists LineItems; + +create table LineItems +( + LineItem_Id int not null, + Order_Id int not null, + LineItem_Code varchar(32) not null, + LineItem_Quantity int not null, + LineItem_Price decimal(18,2), + LineItem_Picture blob, + primary key (Order_Id, LineItem_Id) +) TYPE=INNODB; + +INSERT INTO LineItems VALUES (1, 10, 'ESM-34', 1, 45.43, null); +INSERT INTO LineItems VALUES (2, 10, 'QSM-98', 8, 8.40, null); +INSERT INTO LineItems VALUES (1, 9, 'DSM-78', 2, 45.40, null); +INSERT INTO LineItems VALUES (2, 9, 'TSM-12', 2, 32.12, null); +INSERT INTO LineItems VALUES (1, 8, 'DSM-16', 4, 41.30, null); +INSERT INTO LineItems VALUES (2, 8, 'GSM-65', 1, 2.20, null); +INSERT INTO LineItems VALUES (1, 7, 'WSM-27', 7, 52.10, null); +INSERT INTO LineItems VALUES (2, 7, 'ESM-23', 2, 123.34, null); +INSERT INTO LineItems VALUES (1, 6, 'QSM-39', 9, 12.12, null); +INSERT INTO LineItems VALUES (2, 6, 'ASM-45', 6, 78.77, null); +INSERT INTO LineItems VALUES (1, 5, 'ESM-48', 3, 43.87, null); +INSERT INTO LineItems VALUES (2, 5, 'WSM-98', 7, 5.40, null); +INSERT INTO LineItems VALUES (1, 4, 'RSM-57', 2, 78.90, null); +INSERT INTO LineItems VALUES (2, 4, 'XSM-78', 9, 2.34, null); +INSERT INTO LineItems VALUES (1, 3, 'DSM-59', 3, 5.70, null); +INSERT INTO LineItems VALUES (2, 3, 'DSM-53', 3, 98.78, null); +INSERT INTO LineItems VALUES (1, 2, 'DSM-37', 4, 7.80, null); +INSERT INTO LineItems VALUES (2, 2, 'FSM-12', 2, 55.78, null); +INSERT INTO LineItems VALUES (1, 1, 'ESM-48', 8, 87.60, null); +INSERT INTO LineItems VALUES (2, 1, 'ESM-23', 1, 55.40, null); + diff --git a/tests/simple_unit/SqlMap/scripts/mysql/more-account-records.sql b/tests/simple_unit/SqlMap/scripts/mysql/more-account-records.sql new file mode 100644 index 00000000..e9fd4ac2 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/more-account-records.sql @@ -0,0 +1,7 @@ + +INSERT INTO Accounts VALUES(6,'Jane', 'Calamity', 'Jane.Calamity@somewhere.com', 'Oui', 200); +INSERT INTO Accounts VALUES(7,'Lucky', 'Luke', 'Lucky.Luke@somewhere.com', 'Oui', 200); +INSERT INTO Accounts VALUES(8,'Ming', 'Li Foo', null, 'Non', 100); +INSERT INTO Accounts VALUES(9,'O''Hara', 'Steve', 'Jack.OHara@somewhere.com', 'Oui', 200); +INSERT INTO Accounts VALUES(10,'Robert', 'O''Timmins', null, 'Non', 100); + diff --git a/tests/simple_unit/SqlMap/scripts/mysql/order-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/order-init.sql new file mode 100644 index 00000000..e83a4be3 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/order-init.sql @@ -0,0 +1,30 @@ +drop table if exists Orders; + +create table Orders +( + Order_Id int not null, + Account_Id int null, + Order_Date datetime, + Order_CardType varchar(32), + Order_CardNumber varchar(32), + Order_CardExpiry varchar(32), + Order_Street varchar(32), + Order_City varchar(32), + Order_Province varchar(32), + Order_PostalCode varchar(32), + Order_FavouriteLineItem int, + primary key (Order_Id) +) TYPE=INNODB; + +INSERT INTO Orders VALUES (1, 1, '2003-02-15 8:15:00', 'VISA', '999999999999', '05/03', '11 This Street', 'Victoria', 'BC', 'C4B 4F4',2); +INSERT INTO Orders VALUES (2, 4, '2003-02-15 8:15:00', 'MC', '888888888888', '06/03', '222 That Street', 'Edmonton', 'AB', 'X4K 5Y4',1); +INSERT INTO Orders VALUES (3, 3, '2003-02-15 8:15:00', 'AMEX', '777777777777', '07/03', '333 Other Street', 'Regina', 'SK', 'Z4U 6Y4',2); +INSERT INTO Orders VALUES (4, 2, '2003-02-15 8:15:00', 'MC', '666666666666', '08/03', '444 His Street', 'Toronto', 'ON', 'K4U 3S4',1); +INSERT INTO Orders VALUES (5, 5, '2003-02-15 8:15:00', 'VISA', '555555555555', '09/03', '555 Her Street', 'Calgary', 'AB', 'J4J 7S4',2); +INSERT INTO Orders VALUES (6, 5, '2003-02-15 8:15:00', 'VISA', '999999999999', '10/03', '6 Their Street', 'Victoria', 'BC', 'T4H 9G4',1); +INSERT INTO Orders VALUES (7, 4, '2003-02-15 8:15:00', 'MC', '888888888888', '11/03', '77 Lucky Street', 'Edmonton', 'AB', 'R4A 0Z4',2); +INSERT INTO Orders VALUES (8, 3, '2003-02-15 8:15:00', 'AMEX', '777777777777', '12/03', '888 Our Street', 'Regina', 'SK', 'S4S 7G4',1); +INSERT INTO Orders VALUES (9, 2, '2003-02-15 8:15:00', 'MC', '666666666666', '01/04', '999 Your Street', 'Toronto', 'ON', 'G4D 9F4',2); +INSERT INTO Orders VALUES (10, 1, '2003-02-15 8:15:00', 'VISA', '555555555555', '02/04', '99 Some Street', 'Calgary', 'AB', 'W4G 7A4',1); +INSERT INTO Orders VALUES (11, null, '2003-02-15 8:15:00', 'VISA', '555555555555', '02/04', 'Null order', 'Calgary', 'ZZ', 'XXX YYY',1); + diff --git a/tests/simple_unit/SqlMap/scripts/mysql/other-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/other-init.sql new file mode 100644 index 00000000..0281527c --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/other-init.sql @@ -0,0 +1,91 @@ + +use IBatisNet; + +drop table if exists Others; +drop table if exists A; +drop table if exists B; +drop table if exists C; +drop table if exists D; +drop table if exists E; +drop table if exists F; + +create table Others +( + Other_Int int, + Other_Long bigint, + Other_Bit bit not null default 0, + Other_String varchar(32) not null +) TYPE=INNODB; + +CREATE TABLE F ( + ID varchar(50) NOT NULL , + F_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +CREATE TABLE E ( + ID varchar(50) NOT NULL , + E_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +CREATE TABLE D ( + ID varchar(50) NOT NULL , + D_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +CREATE TABLE C ( + ID varchar(50) NOT NULL , + C_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + + +CREATE TABLE B ( + ID varchar(50) NOT NULL , + C_ID varchar(50) NULL , + D_ID varchar(50) NULL , + B_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +ALTER TABLE B ADD CONSTRAINT FK_B_C FOREIGN KEY FK_B_C (C_ID) + REFERENCES C (ID) + ON DELETE RESTRICT + ON UPDATE RESTRICT, + ADD CONSTRAINT FK_B_D FOREIGN KEY FK_B_D (D_ID) + REFERENCES D (ID) + ON DELETE RESTRICT + ON UPDATE RESTRICT; + +CREATE TABLE A ( + ID varchar(50) NOT NULL , + B_ID varchar(50) NULL , + E_ID varchar(50) NULL , + F_ID varchar(50) NULL , + A_Libelle varchar(50) NULL , + primary key (ID) +) TYPE=INNODB; + +ALTER TABLE A ADD CONSTRAINT FK_A_B FOREIGN KEY FK_A_B (B_ID) + REFERENCES B (ID) + ON DELETE RESTRICT + ON UPDATE RESTRICT, + ADD CONSTRAINT FK_A_E FOREIGN KEY FK_A_E (E_ID) + REFERENCES E (ID) + ON DELETE RESTRICT + ON UPDATE RESTRICT, + ADD CONSTRAINT FK_A_F FOREIGN KEY FK_A_F (F_ID) + REFERENCES F (ID) + ON DELETE RESTRICT; + +INSERT INTO Others VALUES(1, 8888888, 0, 'Oui'); +INSERT INTO Others VALUES(2, 9999999999, 1, 'Non'); + +INSERT INTO F VALUES('f', 'fff'); +INSERT INTO E VALUES('e', 'eee'); +INSERT INTO D VALUES('d', 'ddd'); +INSERT INTO C VALUES('c', 'ccc'); +INSERT INTO B VALUES('b', 'c', null, 'bbb'); +INSERT INTO A VALUES('a', 'b', 'e', null, 'aaa'); \ No newline at end of file diff --git a/tests/simple_unit/SqlMap/scripts/mysql/swap-procedure.sql b/tests/simple_unit/SqlMap/scripts/mysql/swap-procedure.sql new file mode 100644 index 00000000..03b65b13 --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/swap-procedure.sql @@ -0,0 +1,2 @@ + +use IBatisNet; \ No newline at end of file diff --git a/tests/simple_unit/SqlMap/scripts/mysql/user-init.sql b/tests/simple_unit/SqlMap/scripts/mysql/user-init.sql new file mode 100644 index 00000000..c124fc2b --- /dev/null +++ b/tests/simple_unit/SqlMap/scripts/mysql/user-init.sql @@ -0,0 +1,14 @@ + +use NHibernate; + +drop table if exists Users; + +create table Users +( + LogonId varchar(20) not null default '0', + Name varchar(40) default null, + Password varchar(20) default null, + EmailAddress varchar(40) default null, + LastLogon datetime default null, + primary key (LogonId) +) TYPE=INNODB; -- cgit v1.2.3