1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Refactor: Pull more classes into baselib

This commit is contained in:
gnosygnu
2021-12-19 16:19:19 -05:00
parent 48559edffe
commit 0e80d7ef6d
7999 changed files with 1375876 additions and 1365947 deletions

View File

@@ -13,20 +13,23 @@ 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.*;
package gplx.dbs.engines; import gplx.dbs.*;
import gplx.frameworks.tests.GfoDbTstr;
import gplx.frameworks.tests.GfoTstr;
import gplx.types.commons.KeyVal;
import org.junit.*; import gplx.dbs.qrys.*;
public class db_CrudOps_tst {
CrudOpsFxt fx = new CrudOpsFxt();
@Test public void Mysql() {if (Tfds.SkipDb) return;
@Test public void Mysql() {if (GfoDbTstr.SkipDb) return;
fx.RunAll(Db_conn_fxt.Mysql());
}
@Test public void Tdb() {if (Tfds.SkipDb) return;
@Test public void Tdb() {if (GfoDbTstr.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;
@Test public void Sqlite() {if (GfoDbTstr.SkipDb) return;
fx.Fx().DmlAffectedAvailable_(false);
fx.RunAll(Db_conn_fxt.Sqlite());
}
@@ -58,7 +61,7 @@ class CrudOpsFxt {
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_ExecDml(1, Db_qry_.update_common_("dbs_crud_ops", Db_crt_.New_eq("id", 2), KeyVal.NewStr("name", "Jane Smith")));
fx.tst_ExecRdrTbl(2, "dbs_crud_ops");
fx.tst_RowAry(0, 1, "John Doe");
fx.tst_RowAry(1, 2, "Jane Smith");
@@ -68,7 +71,7 @@ class CrudOpsFxt {
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_ExecDml(2, Db_qry_.update_common_("dbs_crud_ops", Db_crt_.New_eq("name", "John Doe"), KeyVal.NewStr("name", "Jane Smith")));
fx.tst_ExecRdrTbl(2, "dbs_crud_ops");
fx.tst_RowAry(0, 1, "Jane Smith");
fx.tst_RowAry(1, 2, "Jane Smith");
@@ -111,17 +114,17 @@ class CrudOpsFxt {
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));
GfoTstr.EqObj(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));
GfoTstr.EqObj(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", "\\"))));
GfoTstr.EqObj(val, ExecRdr_val(Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.New_eq("id", 3))));
GfoTstr.EqObj(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);}
}

View File

@@ -13,23 +13,29 @@ 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.*;
package gplx.dbs.engines; import gplx.dbs.*;
import gplx.frameworks.tests.GfoDbTstr;
import gplx.frameworks.tests.GfoTstr;
import gplx.types.basics.utls.ObjectUtl;
import gplx.types.basics.utls.FloatUtl;
import gplx.types.commons.GfoDateUtl;
import gplx.types.commons.GfoDecimalUtl;
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;
@Test public void Mysql() {if (GfoDbTstr.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)));
@Test public void Tdb() {if (GfoDbTstr.SkipDb) return;
fx.Select_FloatStr_(FloatUtl.ToStr(FloatUtl.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;
@Test public void Sqlite() {if (GfoDbTstr.SkipDb) return;
fx.Select_FloatStr_("0.33333334");
fx.RunAll(Db_conn_fxt.Sqlite());
}
@@ -60,18 +66,18 @@ class DataTypes_base_fxt {
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));
GfoTstr.EqObj(rdr.ReadInt("unique_id"), 1);
GfoTstr.EqObj(rdr.ReadStr("full_name"), "John Doe");
GfoTstr.EqObj(rdr.ReadBool("is_active"), true);
GfoTstr.Eq(rdr.ReadDate("last_update"), GfoDateUtl.ParseGplx("2006-03-30 22:22:00.000"));
GfoTstr.EqObj(floatStr, ObjectUtl.ToStrOrEmpty(rdr.ReadFloat("quantity")));
GfoTstr.Eq(rdr.ReadDecimal("amount"), GfoDecimalUtl.NewByParts(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"))));
conn.Exec_qry(Db_qry_.update_("dbs_multiple_data_types", Db_crt_.New_eq("unique_id", 1)).Val_obj("last_update", DateAdpClassXtn.Instance.XtoDb(GfoDateUtl.ParseGplx("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"));
GfoTstr.Eq(rdr.ReadDate("last_update"), GfoDateUtl.ParseGplx("20091115 220000.000"));
}
}