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

Refactor: @Test whitespace clean-up and other corelib changes

This commit is contained in:
gnosygnu
2021-11-28 08:16:54 -05:00
parent 2a4abd8f75
commit b0082fd231
1059 changed files with 23816 additions and 21909 deletions

View File

@@ -1,18 +1,18 @@
/*
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
*/
/*
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.core.stores; import gplx.*; import gplx.core.*;
import org.junit.*;
import gplx.dbs.*; /*Db_conn_info*/
@@ -40,13 +40,13 @@ public class DbMaprMgr_tst {
conn = Db_conn_pool.Instance.Get_or_new(Db_conn_info_.Test);
Db_qry_fxt.DeleteAll(conn, "mock_discs", "mock_titles", "mock_chapters", "mock_streams");
} DbMaprMgr mgr; DbMaprWtr wtr; Db_conn conn; MockDisc disc; MockTitle title; MockChapter chapter; MockStream audio, subtitle; SrlMgr rdr;
@Test public void PurgeObjTree() {
@Test public void PurgeObjTree() {
disc = MockDisc.new_().Id_(1);
Db_qry_fxt.Insert_kvo(conn, "mock_discs", Keyval_list.New_with_one("disc_id", 1));
DbMaprWtrUtl.PurgeObjTree(disc, mgr, conn);
Tfds.Eq(0, Db_qry_fxt.SelectAll_count(conn, "mock_discs"));
}
@Test public void PurgeObjTree_deep() {
@Test public void PurgeObjTree_deep() {
disc = MockDisc.new_().Id_(1);
Db_qry_fxt.Insert_kvo(conn, "mock_discs", Keyval_list.New_with_one("disc_id", 1));
Db_qry_fxt.Insert_kvo(conn, "mock_titles", Keyval_list.New_with_one("disc_id", 1).Add("title_id", 1));
@@ -58,13 +58,13 @@ public class DbMaprMgr_tst {
Tfds.Eq(0, Db_qry_fxt.SelectAll_count(conn, "mock_titles"));
Tfds.Eq(1, Db_qry_fxt.SelectAll_count(conn, "mock_chapters")); // ignore chapter with disc_id=2
}
@Test public void Save_root() {
@Test public void Save_root() {
disc = MockDisc.new_().Id_(1).Name_("disc");
wtr.StoreRoot(disc, "mock_discs");
Db_qry_fxt.tst_Select(conn, "mock_discs", Db_mock_row.vals_only_(1, "disc"));
}
@Test public void Save_subs() {
@Test public void Save_subs() {
disc = MockDisc.new_().Id_(1).Name_("disc");
title = MockTitle.new_().Id_(2).Name_("title").Disc_(disc);
@@ -72,7 +72,7 @@ public class DbMaprMgr_tst {
Db_qry_fxt.tst_Select(conn, "mock_discs", Db_mock_row.vals_only_(1, "disc"));
Db_qry_fxt.tst_Select(conn, "mock_titles", Db_mock_row.vals_only_(1, 2, "title"));
}
@Test public void Save_deep() {
@Test public void Save_deep() {
disc = MockDisc.new_().Id_(1).Name_("disc");
title = MockTitle.new_().Id_(2).Name_("title").Disc_(disc);
chapter = MockChapter.new_().Id_(3).Name_("chap").Title_(title);
@@ -88,7 +88,7 @@ public class DbMaprMgr_tst {
, Db_mock_row.vals_only_(1, 2, null, 5, "subtitle")
);
}
@Test public void Load_root() {
@Test public void Load_root() {
rdr = rdr_();
Db_qry_fxt.Insert_kvo(conn, "mock_discs", Keyval_list.New_with_one("disc_id", 1).Add("disc_name", "name"));
disc = (MockDisc)rdr.StoreRoot(MockDisc.Instance, null);
@@ -97,7 +97,7 @@ public class DbMaprMgr_tst {
Tfds.Eq("name", disc.Name());
Tfds.Eq(0, disc.Titles().Count());
}
@Test public void Load_subs() {
@Test public void Load_subs() {
rdr = rdr_();
Db_qry_fxt.Insert_kvo(conn, "mock_discs", Keyval_list.New_with_one("disc_id", 1).Add("disc_name", "name"));
Db_qry_fxt.Insert_kvo(conn, "mock_titles", Keyval_list.New_with_one("disc_id", 1).Add("title_id", 1).Add("title_name", "title1"));
@@ -110,7 +110,7 @@ public class DbMaprMgr_tst {
Tfds.Eq("title1", ((MockTitle)disc.Titles().Get_at(0)).Name());
Tfds.Eq("title2", ((MockTitle)disc.Titles().Get_at(1)).Name());
}
@Test public void Load_deep() {
@Test public void Load_deep() {
rdr = rdr_();
Db_qry_fxt.Insert_kvo(conn, "mock_discs", Keyval_list.New_with_one("disc_id", 1).Add("disc_name", "name"));
Db_qry_fxt.Insert_kvo(conn, "mock_titles", Keyval_list.New_with_one("disc_id", 1).Add("title_id", 1).Add("title_name", "title1"));

View File

@@ -1,32 +1,32 @@
/*
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
*/
/*
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;
@Test public void Mysql() {if (Tfds.SkipDb) return;
fx.RunAll(Db_conn_fxt.Mysql());
}
@Test public void Tdb() {if (Tfds.SkipDb) return;
@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;
@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 (Tfds.SkipDb) return;
fx.Fx().DmlAffectedAvailable_(false);
fx.RunAll(Db_conn_fxt.Sqlite());
}

View File

@@ -1,35 +1,35 @@
/*
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
*/
/*
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;
@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;
@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;
@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 (Tfds.SkipDb) return;
fx.Select_FloatStr_("0.33333334");
fx.RunAll(Db_conn_fxt.Sqlite());
}

View File

@@ -13,14 +13,14 @@ 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();}
}
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();}
}

View File

@@ -13,15 +13,15 @@ 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
}
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
}

View File

@@ -13,10 +13,10 @@ 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();}
}
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();}
}

View File

@@ -13,10 +13,10 @@ 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();}
}
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();}
}

View File

@@ -13,17 +13,17 @@ 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");
}
}
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");
}
}

View File

@@ -1,26 +1,26 @@
/*
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
*/
/*
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() {
@Test public void Basic() {
Basic_hook();
}
@Test public void SameVals() {
@Test public void SameVals() {
SameVals_hook();
}
}
@@ -28,7 +28,7 @@ public class OrderBys_tdb_tst extends OrderBys_base_tst {
// 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() {
// @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());
// }

View File

@@ -0,0 +1,29 @@
package gplx.dbs.qrys;
import gplx.Byte_;
import gplx.DateAdp_;
import gplx.Decimal_adp_;
import gplx.core.tests.Gftest;
import gplx.objects.lists.GfoListBase;
import org.junit.Test;
public class Db_val_typeTest {
@Test public void Numbers() {
TestToSqlStr
("ABC true 1 2 3 4.0 5 6 XYZ"
,"ABC ? ? ? ? ? ? ? XYZ"
, true, Byte_.By_int(1), 2, (long)3, (float)4, (double)5, Decimal_adp_.int_(6)
);
}
@Test public void Strings() {
TestToSqlStr
("ABC 'abc' 'a\\'\"c' 'xyz' 'x\\'\"z' '2021-01-02 03:04:05.006' XYZ"
,"ABC ? ? ? ? ? XYZ"
, "abc", "a'\"c", "xyz", "x'\"z", DateAdp_.new_(2021, 1, 2, 3, 4, 5, 6)
);
}
private void TestToSqlStr(String expd, String sql, Object... paramArray) {
String actl = Db_val_type.ToSqlStr(sql, new GfoListBase<>().AddMany(paramArray));
Gftest.Eq__str(expd, actl);
}
}

View File

@@ -1,18 +1,18 @@
/*
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
*/
/*
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.utls; import gplx.*; import gplx.dbs.*;
import org.junit.*;
public class PoolIds_tst {
@@ -21,21 +21,21 @@ public class PoolIds_tst {
Db_qry_fxt.DeleteAll(conn, PoolIds.Tbl_Name);
mgr = PoolIds.Instance;
}
@Test public void FetchNextId() {
@Test public void FetchNextId() {
tst_Fetch("/test0", 0);
}
@Test public void ChangeNextId_Insert() {
@Test public void ChangeNextId_Insert() {
run_Change("/test0", 1);
tst_Fetch("/test0", 1);
}
@Test public void ChangeNextId_Update() {
@Test public void ChangeNextId_Update() {
run_Change("/test0", 0);
run_Change("/test0", 1);
tst_Fetch("/test0", 1);
}
@Test public void FetchNextId_Multiple() {
@Test public void FetchNextId_Multiple() {
run_Change("/test0", 0);
run_Change("/test1", 1);