mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
App: Release v4.5.15.1709
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.dbs.engines.sqlite.*; import gplx.dbs.engines.mysql.*; import gplx.dbs.engines.postgres.*; import gplx.core.gfo_ndes.*;
|
||||
public class Db_conn_fxt implements Rls_able {
|
||||
public Db_conn Conn() {return conn;} public Db_conn_fxt Conn_(Db_conn v) {conn = v; return this;} Db_conn conn;
|
||||
public void DmlAffectedAvailable_(boolean v) {dmlAffectedAvailable = v;} private boolean dmlAffectedAvailable = true;
|
||||
public void ini_DeleteAll(String tbl) {conn.Exec_qry(Db_qry_.delete_tbl_(tbl));}
|
||||
public void tst_ExecDml(int expd, Db_qry qry) {
|
||||
int actl = conn.Exec_qry(qry);
|
||||
if (dmlAffectedAvailable)
|
||||
Tfds.Eq(expd, actl, "Exec_qry failed: sql={0}", qry.To_sql__exec(conn.Engine().Sql_wtr()));
|
||||
}
|
||||
public void tst_ExecRdrTbl(int expd, String tblName) {tst_ExecRdr(expd, Db_qry_.select_tbl_(tblName));}
|
||||
public void tst_ExecRdr(int expd, Db_qry qry) {
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
try {
|
||||
rdr = conn.Exec_qry_as_old_rdr(qry);
|
||||
tbl = GfoNde_.rdr_(rdr);
|
||||
}
|
||||
catch (Exception e) {Err_.Noop(e); rdr.Rls();}
|
||||
Tfds.Eq(expd, tbl.Subs().Count(), "Exec_qry_as_rdr failed: sql={0}", qry.To_sql__exec(conn.Engine().Sql_wtr()));
|
||||
} GfoNde tbl;
|
||||
public GfoNde tst_RowAry(int index, Object... expdValAry) {
|
||||
GfoNde record = tbl.Subs().FetchAt_asGfoNde(index);
|
||||
Object[] actlValAry = new Object[expdValAry.length];
|
||||
for (int i = 0; i < actlValAry.length; i++)
|
||||
actlValAry[i] = record.ReadAt(i);
|
||||
Tfds.Eq_ary(actlValAry, expdValAry);
|
||||
return record;
|
||||
}
|
||||
public void Rls() {conn.Rls_conn();}
|
||||
|
||||
public static Db_conn Mysql() {return Db_conn_pool.Instance.Get_or_new(Mysql_conn_info.new_("127.0.0.1", "unit_tests", "gplx_user", "gplx_password"));}
|
||||
public static Db_conn Tdb(String fileName) {return Db_conn_pool.Instance.Get_or_new(Db_conn_info_.tdb_(Tfds.RscDir.GenSubDir_nest("140_dbs", "tdbs").GenSubFil(fileName)));}
|
||||
public static Db_conn Postgres() {return Db_conn_pool.Instance.Get_or_new(Postgres_conn_info.new_("127.0.0.1", "unit_tests", "gplx_user", "gplx_password"));}
|
||||
public static Db_conn Sqlite() {return Db_conn_pool.Instance.Get_or_new(Sqlite_conn_info.load_(Tfds.RscDir.GenSubFil_nest("140_dbs", "sqlite", "unit_tests.db")));}
|
||||
public static final boolean SkipPostgres = Tfds.SkipDb || true;
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*; import gplx.dbs.qrys.*;
|
||||
public class db_CrudOps_tst {
|
||||
CrudOpsFxt fx = new CrudOpsFxt();
|
||||
@Test public void Mysql() {if (Tfds.SkipDb) return;
|
||||
fx.RunAll(Db_conn_fxt.Mysql());
|
||||
}
|
||||
@Test public void Tdb() {if (Tfds.SkipDb) return;
|
||||
fx.RunAll(Db_conn_fxt.Tdb("100_dbs_crud_ops.dsv"));
|
||||
}
|
||||
@Test public void Postgres() {if (Db_conn_fxt.SkipPostgres) return;
|
||||
fx.RunAll(Db_conn_fxt.Postgres());
|
||||
}
|
||||
@Test public void Sqlite() {if (Tfds.SkipDb) return;
|
||||
fx.Fx().DmlAffectedAvailable_(false);
|
||||
fx.RunAll(Db_conn_fxt.Sqlite());
|
||||
}
|
||||
}
|
||||
class CrudOpsFxt {
|
||||
public Db_conn_fxt Fx() {return fx;} Db_conn_fxt fx = new Db_conn_fxt();
|
||||
void Init() {fx.ini_DeleteAll("dbs_crud_ops");}
|
||||
public void RunAll(Db_conn conn) {
|
||||
fx.Conn_(conn);
|
||||
Insert_hook();
|
||||
UpdateOne_hook();
|
||||
UpdateMany_hook();
|
||||
DeleteOne_hook();
|
||||
DeleteMany_hook();
|
||||
SelectLike_hook();
|
||||
SelectLikeForFileName_hook();
|
||||
InsertUnicode_hook();
|
||||
Backslash_hook();
|
||||
fx.Rls();
|
||||
}
|
||||
public void Insert_hook() {
|
||||
this.Init();
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "John Doe"));
|
||||
fx.tst_ExecRdrTbl(1, "dbs_crud_ops");
|
||||
fx.tst_RowAry(0, 1, "John Doe");
|
||||
}
|
||||
public void UpdateOne_hook() {
|
||||
this.Init();
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "John Doe"));
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 2).Val_str("name", "John Doe"));
|
||||
|
||||
fx.tst_ExecDml(1, Db_qry_.update_common_("dbs_crud_ops", Db_crt_.New_eq("id", 2), Keyval_.new_("name", "Jane Smith")));
|
||||
fx.tst_ExecRdrTbl(2, "dbs_crud_ops");
|
||||
fx.tst_RowAry(0, 1, "John Doe");
|
||||
fx.tst_RowAry(1, 2, "Jane Smith");
|
||||
}
|
||||
public void UpdateMany_hook() {
|
||||
this.Init();
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "John Doe"));
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 2).Val_str("name", "John Doe"));
|
||||
|
||||
fx.tst_ExecDml(2, Db_qry_.update_common_("dbs_crud_ops", Db_crt_.New_eq("name", "John Doe"), Keyval_.new_("name", "Jane Smith")));
|
||||
fx.tst_ExecRdrTbl(2, "dbs_crud_ops");
|
||||
fx.tst_RowAry(0, 1, "Jane Smith");
|
||||
fx.tst_RowAry(1, 2, "Jane Smith");
|
||||
}
|
||||
public void DeleteOne_hook() {
|
||||
this.Init();
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "John Doe"));
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 2).Val_str("name", "Jane Smith"));
|
||||
|
||||
fx.tst_ExecDml(1, Db_qry_.delete_("dbs_crud_ops", Db_crt_.New_eq("id", 2)));
|
||||
fx.tst_ExecRdrTbl(1, "dbs_crud_ops");
|
||||
fx.tst_RowAry(0, 1, "John Doe");
|
||||
}
|
||||
public void DeleteMany_hook() {
|
||||
this.Init();
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "John Doe"));
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 2).Val_str("name", "Jane Smith"));
|
||||
|
||||
fx.tst_ExecDml(2, Db_qry_.delete_tbl_("dbs_crud_ops"));
|
||||
fx.tst_ExecRdrTbl(0, "dbs_crud_ops");
|
||||
}
|
||||
public void SelectLike_hook() {
|
||||
this.Init();
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "John Doe"));
|
||||
|
||||
fx.tst_ExecRdr(1, Db_qry_.select_cols_("dbs_crud_ops", Db_crt_.New_like("name", "John%")));
|
||||
fx.tst_RowAry(0, 1, "John Doe");
|
||||
}
|
||||
public void SelectLikeForFileName_hook() {
|
||||
this.Init();
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "file%"));
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "file|%"));
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 1).Val_str("name", "file test"));
|
||||
|
||||
fx.tst_ExecRdr(1, Db_qry_.select_cols_("dbs_crud_ops", Db_crt_.New_like("name", "file|%")));
|
||||
fx.tst_RowAry(0, 1, "file%");
|
||||
}
|
||||
public void InsertUnicode_hook() {
|
||||
this.Init();
|
||||
String val = "Ω";
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 3).Val_obj_type("name", val, Db_val_type.Tid_nvarchar));
|
||||
Db_qry__select_cmd select = Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.New_eq("id", 3));
|
||||
Tfds.Eq(val, ExecRdr_val(select));
|
||||
|
||||
fx.tst_ExecDml(1, Db_qry_.update_("dbs_crud_ops", Db_crt_.Wildcard).Val_obj_type("name", val + "a", Db_val_type.Tid_nvarchar));
|
||||
Tfds.Eq(val + "a", ExecRdr_val(select));
|
||||
}
|
||||
public void Backslash_hook() {
|
||||
this.Init();
|
||||
String val = "\\";
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Val_int("id", 3).Val_str("name", val));
|
||||
Tfds.Eq(val, ExecRdr_val(Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.New_eq("id", 3))));
|
||||
Tfds.Eq(val, ExecRdr_val(Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.New_eq("name", "\\"))));
|
||||
}
|
||||
String ExecRdr_val(Db_qry__select_cmd select) {return (String)Db_qry_.Exec_as_obj(fx.Conn(), select);}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*; import gplx.core.type_xtns.*; import gplx.core.stores.*;
|
||||
public class db_DataTypes_tst {
|
||||
DataTypes_base_fxt fx = new DataTypes_base_fxt();
|
||||
@Test public void Mysql() {if (Tfds.SkipDb) return;
|
||||
fx.Select_FloatStr_("0.333333");
|
||||
fx.RunAll(Db_conn_fxt.Mysql());
|
||||
}
|
||||
@Test public void Tdb() {if (Tfds.SkipDb) return;
|
||||
fx.Select_FloatStr_(Float_.To_str(Float_.Div(1, 3)));
|
||||
fx.RunAll(Db_conn_fxt.Tdb("110_dbs_multiple_data_types.dsv"));
|
||||
}
|
||||
@Test public void Postgres() {if (Db_conn_fxt.SkipPostgres) return;
|
||||
fx.Select_FloatStr_("0.33333334");
|
||||
fx.RunAll(Db_conn_fxt.Postgres());
|
||||
}
|
||||
@Test public void Sqlite() {if (Tfds.SkipDb) return;
|
||||
fx.Select_FloatStr_("0.33333334");
|
||||
fx.RunAll(Db_conn_fxt.Sqlite());
|
||||
}
|
||||
/*
|
||||
DROP TABLE dbs_multiple_data_types;
|
||||
CREATE TABLE dbs_multiple_data_types (
|
||||
unique_id int
|
||||
, full_name varchar(255)
|
||||
, is_active bit
|
||||
, last_update timestamp
|
||||
, quantity float(24)
|
||||
, amount decimal(12, 3)
|
||||
);
|
||||
INSERT INTO dbs_multiple_data_types VALUES (1, 'John Doe', B'1', '3/30/2006 10:22 PM', 0.333333343, 12.345);
|
||||
*/
|
||||
}
|
||||
class DataTypes_base_fxt {
|
||||
public Db_conn Conn() {return conn;} Db_conn conn;
|
||||
public DataTypes_base_fxt() {}
|
||||
public void Rls() {conn.Rls_conn();}
|
||||
public String Select_FloatStr() {return select_FloatStr;} public DataTypes_base_fxt Select_FloatStr_(String v) {select_FloatStr = v; return this;} private String select_FloatStr;
|
||||
public void RunAll(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.Select_hook(select_FloatStr);
|
||||
conn.Rls_conn();
|
||||
}
|
||||
public void Select_hook(String floatStr) {
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr(Db_qry_.select_tbl_("dbs_multiple_data_types"));
|
||||
|
||||
rdr.MoveNextPeer();
|
||||
Tfds.Eq(rdr.ReadInt("unique_id"), 1);
|
||||
Tfds.Eq(rdr.ReadStr("full_name"), "John Doe");
|
||||
Tfds.Eq(rdr.ReadBool("is_active"), true);
|
||||
Tfds.Eq_date(rdr.ReadDate("last_update"), DateAdp_.parse_gplx("2006-03-30 22:22:00.000"));
|
||||
Tfds.Eq(floatStr, Object_.Xto_str_strict_or_empty(rdr.ReadFloat("quantity")));
|
||||
Tfds.Eq_decimal(rdr.ReadDecimal("amount"), Decimal_adp_.parts_(12, 345));
|
||||
}
|
||||
public void UpdateDate_hook() {
|
||||
conn.Exec_qry(Db_qry_.update_("dbs_multiple_data_types", Db_crt_.New_eq("unique_id", 1)).Val_obj("last_update", DateAdpClassXtn.Instance.XtoDb(DateAdp_.parse_gplx("20091115 220000.000"))));
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr(Db_qry_.select_tbl_("dbs_multiple_data_types"));
|
||||
rdr.MoveNextPeer();
|
||||
Tfds.Eq_date(rdr.ReadDate("last_update"), DateAdp_.parse_gplx("20091115 220000.000"));
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.groupBys; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*; import gplx.dbs.qrys.*; import gplx.core.gfo_ndes.*; import gplx.core.stores.*;
|
||||
public abstract class GroupBys_base_tst {
|
||||
protected abstract Db_conn provider_();
|
||||
protected Db_conn conn;
|
||||
@Before public void setup() {
|
||||
conn = provider_();
|
||||
Db_qry_.delete_tbl_("dbs_group_bys").Exec_qry(conn);
|
||||
}
|
||||
@After public void teardown() {
|
||||
conn.Rls_conn();
|
||||
}
|
||||
protected void GroupBy_1fld_hook() {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 1));
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 2));
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr
|
||||
(Db_qry_.select_().From_("dbs_group_bys")
|
||||
.Cols_("key1")
|
||||
.GroupBy_("key1"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key1", "a");
|
||||
}
|
||||
protected void GroupBy_2fld_hook() {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_str("key2", "b").Val_int("val_int", 1));
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_str("key2", "b").Val_int("val_int", 2));
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr
|
||||
(Db_qry_.select_().From_("dbs_group_bys")
|
||||
.Cols_("key1", "key2")
|
||||
.GroupBy_("key1", "key2"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key1", "a");
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key2", "b");
|
||||
}
|
||||
protected void MinMax_hook(boolean min) {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 1));
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 2));
|
||||
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().From_("dbs_group_bys")
|
||||
.Cols_("key1")
|
||||
.GroupBy_("key1");
|
||||
int expd = min ? 1 : 2;
|
||||
if (min)
|
||||
qry.Cols_groupBy_min("val_int", "val_int_func");
|
||||
else
|
||||
qry.Cols_groupBy_max("val_int", "val_int_func");
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr(qry);
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key1", "a");
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "val_int_func", expd);
|
||||
}
|
||||
protected void Count_hook() {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 10));
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 20));
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr
|
||||
(Db_qry_.select_().From_("dbs_group_bys")
|
||||
.Cols_("key1").Cols_groupBy_count("val_int", "val_int_func")
|
||||
.GroupBy_("key1"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key1", "a");
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "val_int_func", 2);
|
||||
}
|
||||
protected void Sum_hook() {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 10));
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 20));
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr
|
||||
(Db_qry_.select_().From_("dbs_group_bys")
|
||||
.Cols_("key1").Cols_groupBy_sum("val_int", "val_int_func")
|
||||
.GroupBy_("key1"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key1", "a");
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "val_int_func", 30);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.groupBys; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*;
|
||||
public class GroupBys_mysql_tst extends GroupBys_base_tst {
|
||||
@Override protected Db_conn provider_() {return Db_conn_fxt.Mysql();}
|
||||
@Test public void GroupBy_1fld() {super.GroupBy_1fld_hook();}
|
||||
@Test public void GroupBy_2fld() {super.GroupBy_2fld_hook();}
|
||||
@Test public void Min() {super.MinMax_hook(true);}
|
||||
@Test public void Max() {super.MinMax_hook(false);}
|
||||
@Test public void Count() {super.Count_hook();}
|
||||
@Test public void Sum() {super.Sum_hook();}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.groupBys; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*;
|
||||
public class GroupBys_tdb_tst extends GroupBys_base_tst {
|
||||
@Override protected Db_conn provider_() {return Db_conn_fxt.Tdb("130_dbs_group_bys.dsv");}
|
||||
@Test public void GroupBy_1fld() {super.GroupBy_1fld_hook();}
|
||||
@Test public void GroupBy_2fld() {super.GroupBy_2fld_hook();}
|
||||
@Test public void Min() {super.MinMax_hook(true);}
|
||||
@Test public void Max() {super.MinMax_hook(false);}
|
||||
@Test public void Count() {super.Count_hook();}
|
||||
@Test public void Sum() {super.Sum_hook();}
|
||||
// Avg, CountDistinct
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.insertIntos; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*; import gplx.core.gfo_ndes.*; import gplx.dbs.qrys.*; import gplx.core.stores.*;
|
||||
public abstract class InsertIntos_base_tst {
|
||||
protected abstract Db_conn provider_();
|
||||
protected Db_conn conn;
|
||||
@Before public void setup() {
|
||||
conn = provider_();
|
||||
conn.Exec_qry(Db_qry_delete.new_("dbs_group_bys"));
|
||||
conn.Exec_qry(Db_qry_delete.new_("dbs_insert_intos"));
|
||||
}
|
||||
@After public void teardown() {
|
||||
conn.Rls_conn();
|
||||
}
|
||||
protected void Select_hook() {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 1));
|
||||
|
||||
conn.Exec_qry
|
||||
(Db_qry_.insert_("dbs_insert_intos")
|
||||
.Cols_("key1", "val_int")
|
||||
.Select_
|
||||
( new Db_qry__select_cmd().Cols_("key1", "val_int").From_("dbs_group_bys")
|
||||
)
|
||||
);
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr(new Db_qry__select_cmd().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key1", "a");
|
||||
}
|
||||
protected void GroupBy_hook() {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 1));
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Val_str("key1", "a").Val_int("val_int", 2));
|
||||
|
||||
conn.Exec_qry
|
||||
(Db_qry_.insert_("dbs_insert_intos")
|
||||
.Cols_("key1", "val_int")
|
||||
.Select_
|
||||
( new Db_qry__select_cmd().Cols_("key1").Cols_groupBy_sum("val_int", "val_int_func")
|
||||
.From_("dbs_group_bys").GroupBy_("key1")
|
||||
));
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr(new Db_qry__select_cmd().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "val_int", 3);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.insertIntos; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*;
|
||||
public class InsertIntos_mysql_tst extends InsertIntos_base_tst {
|
||||
@Override protected Db_conn provider_() {return Db_conn_fxt.Mysql();}
|
||||
@Test public void Select() {super.Select_hook();}
|
||||
@Test public void GroupBy() {super.GroupBy_hook();}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.insertIntos; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*;
|
||||
public class InsertIntos_tdb_tst extends InsertIntos_base_tst {
|
||||
@Override protected Db_conn provider_() {return Db_conn_fxt.Tdb("140_dbs_insert_intos.dsv");}
|
||||
@Test public void Select() {super.Select_hook();}
|
||||
@Test public void GroupBy() {super.GroupBy_hook();}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.joins; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*; import gplx.core.gfo_ndes.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*; import gplx.core.stores.*;
|
||||
public abstract class Joins_base_tst {
|
||||
protected Db_conn conn;
|
||||
@Before public void setup() {
|
||||
conn = provider_();
|
||||
Db_qry_delete.new_("dbs_crud_ops").Exec_qry(conn);
|
||||
Db_qry_delete.new_("dbs_join1").Exec_qry(conn);
|
||||
}
|
||||
@After public void teardown() {
|
||||
conn.Rls_conn();
|
||||
}
|
||||
protected void InnerJoin_hook() {
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_crud_ops").Val_int("id", 0).Val_str("name", "me"));
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_crud_ops").Val_int("id", 1).Val_str("name", "you"));
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_join1").Val_int("join_id", 0).Val_str("join_data", "data0"));
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_join1").Val_int("join_id", 1).Val_str("join_data", "data1"));
|
||||
Db_qry__select_cmd select = new Db_qry__select_cmd().From_("dbs_crud_ops").Join_("dbs_join1", "j1", Db_qry_.New_join__join("join_id", "dbs_crud_ops", "id")).Cols_("id", "name", "join_data");
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_old_rdr(select);
|
||||
GfoNde table = GfoNde_.rdr_(rdr);
|
||||
Tfds.Eq(table.Subs().Count(), 2);
|
||||
Tfds.Eq(table.Subs().FetchAt_asGfoNde(0).Read("join_data"), "data0");
|
||||
Tfds.Eq(table.Subs().FetchAt_asGfoNde(1).Read("join_data"), "data1");
|
||||
}
|
||||
protected abstract Db_conn provider_();
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.joins; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*;
|
||||
public class Joins_tdb_tst extends Joins_base_tst {
|
||||
@Override protected Db_conn provider_() {return Db_conn_fxt.Tdb("120_dbs_joins.dsv");}
|
||||
@Test public void InnerJoin() {
|
||||
try {
|
||||
InnerJoin_hook();
|
||||
}
|
||||
catch (Exception exc) {
|
||||
if (String_.Has(Err_.Message_lang(exc), "joins not supported for tdbs")) return;
|
||||
}
|
||||
Tfds.Fail("'joins not supported for tdbs' error not thrown");
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.orderBys; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*; import gplx.dbs.qrys.*;
|
||||
public abstract class OrderBys_base_tst {
|
||||
@Before public void setup() {
|
||||
conn = provider_();
|
||||
fx.Conn_(conn);
|
||||
Db_qry_delete.new_("dbs_crud_ops").Exec_qry(conn);
|
||||
} protected Db_conn_fxt fx = new Db_conn_fxt();
|
||||
@After public void teardown() {conn.Rls_conn();}
|
||||
protected abstract Db_conn provider_(); protected Db_conn conn;
|
||||
protected void Basic_hook() {
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Val_int("id", 1).Val_str("name", "you"));
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Val_int("id", 0).Val_str("name", "me"));
|
||||
|
||||
fx.tst_ExecRdr(2, new Db_qry__select_cmd().From_("dbs_crud_ops").Order_("id", true));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 1, "you");
|
||||
|
||||
fx.tst_ExecRdr(2, new Db_qry__select_cmd().From_("dbs_crud_ops").Order_("id", false));
|
||||
fx.tst_RowAry(0, 1, "you");
|
||||
fx.tst_RowAry(1, 0, "me");
|
||||
}
|
||||
protected void SameVals_hook() {
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Val_int("id", 0).Val_str("name", "me"));
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Val_int("id", 0).Val_str("name", "you"));
|
||||
|
||||
fx.tst_ExecRdr(2, new Db_qry__select_cmd().From_("dbs_crud_ops").Order_("id", true));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 0, "you");
|
||||
|
||||
fx.tst_ExecRdr(2, new Db_qry__select_cmd().From_("dbs_crud_ops").Order_("id", false));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 0, "you");
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.orderBys; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*;
|
||||
public class OrderBys_tdb_tst extends OrderBys_base_tst {
|
||||
@Override protected Db_conn provider_() {return Db_conn_fxt.Tdb("120_dbs_joins.dsv");}
|
||||
@Test public void Basic() {
|
||||
Basic_hook();
|
||||
}
|
||||
@Test public void SameVals() {
|
||||
SameVals_hook();
|
||||
}
|
||||
}
|
||||
//namespace gplx.dbs.crudOps {
|
||||
// import org.junit.*;
|
||||
// public class CrudOps_tdb_tst {
|
||||
// @Before public void setup() {fx = new CrudOpsFxt(Db_conn_fxt.Tdb("100_dbs_crud_ops.dsv"));} CrudOpsFxt fx;
|
||||
// @Test public void FlushToDisk() {
|
||||
// fx.Fx().tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Arg_("id", 2).Arg_("name", "you"));
|
||||
// Db_qry_flush.new_("dbs_crud_ops").Exec_qry(fx.Fx().Conn());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user