mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Command-line: Fix curid argument not working 2
This commit is contained in:
@@ -1,162 +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.xowa.wikis.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_data_mgr_tst {
|
||||
Xow_data_mgr_fxt fxt = new Xow_data_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear(); Datetime_now.Manual_y_();}
|
||||
@After public void term() {Datetime_now.Manual_n_();}
|
||||
@Test public void Create() {
|
||||
fxt .Create("A1", "A1 data")
|
||||
.Create("B12", "B12 data")
|
||||
.Create("C123", "C123 data")
|
||||
.Tst_regy_title("0|A1|C123|3\n")
|
||||
.Tst_data_title(String_.Concat_lines_nl
|
||||
( "!!!!>|!!!!?|!!!!@|"
|
||||
, "!!!!!|!!!!!|!!!!!|0|!!!!(|A1"
|
||||
, "!!!!\"|!!!!!|!!!!\"|0|!!!!)|B12"
|
||||
, "!!!!#|!!!!!|!!!!#|0|!!!!*|C123"
|
||||
))
|
||||
.Tst_data_page(String_.Concat_lines_nl
|
||||
( "!!!!9|!!!!;|!!!!=|"
|
||||
, "!!!!!\t##PX+\tA1\tA1 data\t"
|
||||
, "!!!!\"\t##PX/\tB12\tB12 data\t"
|
||||
, "!!!!#\t##PX0\tC123\tC123 data\t"
|
||||
))
|
||||
;
|
||||
}
|
||||
@Test public void Update() {
|
||||
fxt .Create("A1", "A1 data")
|
||||
.Create("B12", "B12 data")
|
||||
.Create("C123", "C123 data")
|
||||
.Update("B12", "B12 changed")
|
||||
.Tst_regy_title("0|A1|C123|3\n")
|
||||
.Tst_data_title(String_.Concat_lines_nl
|
||||
( "!!!!>|!!!!?|!!!!@|"
|
||||
, "!!!!!|!!!!!|!!!!!|0|!!!!(|A1"
|
||||
, "!!!!\"|!!!!!|!!!!\"|0|!!!!,|B12"
|
||||
, "!!!!#|!!!!!|!!!!#|0|!!!!*|C123"
|
||||
))
|
||||
.Tst_data_page(String_.Concat_lines_nl
|
||||
( "!!!!9|!!!!>|!!!!=|"
|
||||
, "!!!!!\t##PX+\tA1\tA1 data\t"
|
||||
, "!!!!\"\t##PX/\tB12\tB12 changed\t"
|
||||
, "!!!!#\t##PX0\tC123\tC123 data\t"
|
||||
))
|
||||
;
|
||||
}
|
||||
@Test public void Update_zip() {
|
||||
// fxt.Wiki().Fsys_mgr().Dir_regy()[Xow_ns_.Tid__main].Ext_tid_(gplx.core.ios.streams.Io_stream_tid_.Tid__zip);
|
||||
// fxt.Wiki().Data_mgr().Zip_mgr_(new Io_zip_mgr_mok());
|
||||
// fxt .Create("A1", "A1 data")
|
||||
// .Create("B12", "B12 data")
|
||||
// .Create("C123", "C123 data")
|
||||
// .Update("B12", "B12 changed")
|
||||
// .Tst_regy_title("0|A1|C123|3\n")
|
||||
// .Tst_data_title(String_.Concat_lines_nl
|
||||
// ( "!!!!>|!!!!?|!!!!@|"
|
||||
// , "!!!!!|!!!!!|!!!!!|0|!!!!(|A1"
|
||||
// , "!!!!\"|!!!!!|!!!!\"|0|!!!!,|B12"
|
||||
// , "!!!!#|!!!!!|!!!!#|0|!!!!*|C123"
|
||||
// ))
|
||||
// .Tst_data_page(String_.Concat_lines_nl
|
||||
// ( "zipped:!!!!9|!!!!>|!!!!=|"
|
||||
// , "!!!!!\t##PX+\tA1\tA1 data\t"
|
||||
// , "!!!!\"\t##PX/\tB12\tB12 changed\t"
|
||||
// , "!!!!#\t##PX0\tC123\tC123 data\t"
|
||||
// ))
|
||||
// ;
|
||||
}
|
||||
@Test public void Create_out_of_order() {
|
||||
fxt .Create("C123", "C123 data")
|
||||
.Create("B12", "B12 data")
|
||||
.Create("A1", "A1 data")
|
||||
.Tst_regy_title("0|A1|C123|3\n")
|
||||
.Tst_data_title(String_.Concat_lines_nl
|
||||
( "!!!!>|!!!!?|!!!!@|"
|
||||
, "!!!!#|!!!!!|!!!!#|0|!!!!(|A1"
|
||||
, "!!!!\"|!!!!!|!!!!\"|0|!!!!)|B12"
|
||||
, "!!!!!|!!!!!|!!!!!|0|!!!!*|C123"
|
||||
))
|
||||
.Tst_data_page(String_.Concat_lines_nl
|
||||
( "!!!!=|!!!!;|!!!!9|"
|
||||
, "!!!!!\t##PX+\tC123\tC123 data\t"
|
||||
, "!!!!\"\t##PX/\tB12\tB12 data\t"
|
||||
, "!!!!#\t##PX0\tA1\tA1 data\t"
|
||||
))
|
||||
;
|
||||
}
|
||||
@Test public void Rename() {
|
||||
fxt .Create("A1", "A1 data")
|
||||
.Create("B12", "B12 data")
|
||||
.Create("C123", "C123 data")
|
||||
.Rename("C123", "C1234")
|
||||
.Tst_regy_title("0|A1|C123|3\n")
|
||||
.Tst_data_title(String_.Concat_lines_nl
|
||||
( "!!!!>|!!!!?|!!!!@|"
|
||||
, "!!!!!|!!!!!|!!!!!|0|!!!!(|A1"
|
||||
, "!!!!\"|!!!!!|!!!!\"|0|!!!!)|B12"
|
||||
, "!!!!#|!!!!!|!!!!#|0|!!!!*|C123"
|
||||
))
|
||||
.Tst_data_page(String_.Concat_lines_nl
|
||||
( "!!!!9|!!!!;|!!!!=|"
|
||||
, "!!!!!\t##PX+\tA1\tA1 data\t"
|
||||
, "!!!!\"\t##PX/\tB12\tB12 data\t"
|
||||
, "!!!!#\t##PX0\tC123\tC123 data\t"
|
||||
))
|
||||
;
|
||||
}
|
||||
}
|
||||
class Xow_data_mgr_fxt {
|
||||
Xoae_app app;
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
wiki.Db_mgr().Save_mgr().Page_id_next_(0);
|
||||
}
|
||||
public Xow_data_mgr_fxt Create(String ttl_str, String data) {
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
|
||||
wiki.Db_mgr().Save_mgr().Data_create(ttl, Bry_.new_u8(data));
|
||||
return this;
|
||||
}
|
||||
public Xow_data_mgr_fxt Update(String ttl_str, String data) {
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
|
||||
Xoae_page page = Xoae_page.New_test(wiki, ttl);
|
||||
wiki.Db_mgr().Save_mgr().Data_update(page, Bry_.new_u8(data));
|
||||
return this;
|
||||
}
|
||||
public Xow_data_mgr_fxt Rename(String old_ttl, String new_ttl) {
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(old_ttl));
|
||||
Xoae_page page = Xoae_page.New_test(wiki, ttl);
|
||||
wiki.Db_mgr().Save_mgr().Data_rename(page, ttl.Ns().Id(), Bry_.new_u8(new_ttl));
|
||||
return this;
|
||||
}
|
||||
public Xow_data_mgr_fxt Tst_regy_title(String expd) {return Tst_regy(Xotdb_dir_info_.Name_title, expd);}
|
||||
Xow_data_mgr_fxt Tst_regy(String name, String expd) {
|
||||
Io_url file_orig = Io_url_.mem_fil_("mem/xowa/wiki/en.wikipedia.org/ns/000/" + name + "/reg.csv");
|
||||
Tfds.Eq_str_lines(expd, Io_mgr.Instance.LoadFilStr(file_orig));
|
||||
return this;
|
||||
}
|
||||
public Xow_data_mgr_fxt Tst_data_page(String expd) {return Tst_data(Xotdb_dir_info_.Tid_page , Xow_ns_.Tid__main, 0, expd);}
|
||||
public Xow_data_mgr_fxt Tst_data_title(String expd) {return Tst_data(Xotdb_dir_info_.Tid_ttl, Xow_ns_.Tid__main, 0, expd);}
|
||||
public Xow_data_mgr_fxt Tst_data(byte dir_tid, int ns_id, int fil, String expd) {
|
||||
Io_url url = wiki.Tdb_fsys_mgr().Url_ns_fil(dir_tid, ns_id, fil);
|
||||
Tfds.Eq_str_lines(expd, Io_mgr.Instance.LoadFilStr(url));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +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.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xowd_page_itm_tst {
|
||||
@Before public void init() {fxt.Init();} private Xowd_page_itm_fxt fxt = new Xowd_page_itm_fxt();
|
||||
@Test public void Ttl_() {
|
||||
fxt.Test_ttl_("User_talk:A", Xow_ns_.Tid__user_talk, "A");
|
||||
fxt.Test_ttl_("User talk:A", Xow_ns_.Tid__user_talk, "A");
|
||||
}
|
||||
}
|
||||
class Xowd_page_itm_fxt {
|
||||
public void Init() {
|
||||
if (ns_mgr == null) {
|
||||
ns_mgr = new Xow_ns_mgr(gplx.xowa.langs.cases.Xol_case_mgr_.A7());
|
||||
ns_mgr.Add_new(Xow_ns_.Tid__main, "");
|
||||
ns_mgr.Add_new(Xow_ns_.Tid__user_talk, "User talk");
|
||||
ns_mgr.Init_w_defaults();
|
||||
tmp_page = new Xowd_page_itm();
|
||||
}
|
||||
} private Xow_ns_mgr ns_mgr; Xowd_page_itm tmp_page;
|
||||
public void Test_ttl_(String ttl, int expd_ns, String expd_ttl) {
|
||||
tmp_page.Ttl_(Bry_.new_a7(ttl), ns_mgr);
|
||||
Tfds.Eq(expd_ns, tmp_page.Ns_id());
|
||||
Tfds.Eq(expd_ttl, String_.new_a7(tmp_page.Ttl_page_db()));
|
||||
}
|
||||
}
|
||||
@@ -1,33 +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.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import org.junit.*; import gplx.xowa.bldrs.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xowd_page_tbl_tst {
|
||||
private Xowd_page_tbl_fxt fxt = new Xowd_page_tbl_fxt();
|
||||
@Test public void Find_search_end() {
|
||||
fxt.Test_find_search_end("ab", "ac");
|
||||
fxt.Test_find_search_end("ab%", "ac%");
|
||||
}
|
||||
}
|
||||
class Xowd_page_tbl_fxt {
|
||||
public void Test_find_search_end(String val, String expd) {Tfds.Eq(expd, String_.new_u8(Find_search_end(Bry_.new_u8(val))));}
|
||||
private static byte[] Find_search_end(byte[] orig) { // NOTE: moved from old Xowd_page_tbl; is probably obsolete
|
||||
byte[] rv = Bry_.Copy(orig);
|
||||
int rv_len = rv.length;
|
||||
int increment_pos = rv[rv_len - 1] == Byte_ascii.Percent ? rv_len - 2 : rv_len - 1; // increment last char, unless it is %; if %, increment one before it
|
||||
return Bry_.Increment_last(rv, increment_pos);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +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.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import org.junit.*; import gplx.dbs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xowd_wbase_qid_tbl_tst {
|
||||
private final Xowd_wbase_qid_tbl_fxt fxt = new Xowd_wbase_qid_tbl_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Space() {
|
||||
fxt.Exec_insert("enwiki", Xow_ns_.Tid__main, "A B", "q1");
|
||||
fxt.Test_select("enwiki", Xow_ns_.Tid__main, "A B", "q1");
|
||||
fxt.Test_select("enwiki", Xow_ns_.Tid__main, "A_B", "q1");
|
||||
}
|
||||
}
|
||||
class Xowd_wbase_qid_tbl_fxt {
|
||||
private Xowd_wbase_qid_tbl qid_tbl;
|
||||
public void Clear() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
Db_conn_bldr.Instance.Reg_default_mem();
|
||||
Db_conn conn = Db_conn_bldr.Instance.New(Io_url_.mem_fil_("mem/db/wbase.xowa"));
|
||||
this.qid_tbl = new Xowd_wbase_qid_tbl(conn, Bool_.N, Bool_.Y); // simulate v2.4.2 with bad "spaces"
|
||||
qid_tbl.Create_tbl();
|
||||
}
|
||||
public void Exec_insert(String src_wiki, int src_ns, String src_ttl, String trg_ttl) {
|
||||
qid_tbl.Insert_bgn();
|
||||
qid_tbl.Insert_cmd_by_batch(Bry_.new_u8(src_wiki), src_ns, Bry_.new_u8(src_ttl), Bry_.new_u8(trg_ttl));
|
||||
qid_tbl.Insert_end();
|
||||
}
|
||||
public void Test_select(String src_wiki, int src_ns, String src_ttl, String expd) {
|
||||
byte[] actl = qid_tbl.Select_qid(Bry_.new_u8(src_wiki), Bry_.new_a7(Int_.To_str(src_ns)), Bry_.new_u8(src_ttl));
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
}
|
||||
}
|
||||
@@ -1,94 +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.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_wm_tst {
|
||||
private Xow_abrv_wm_fxt fxt = new Xow_abrv_wm_fxt();
|
||||
@Test public void Parse() {
|
||||
fxt.Test_parse("foundationwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__wmfblog);
|
||||
fxt.Test_parse("wikidatawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__wikidata);
|
||||
fxt.Test_parse("mediawikiwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__mediawiki);
|
||||
fxt.Test_parse("commonswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__commons);
|
||||
fxt.Test_parse("specieswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__species);
|
||||
fxt.Test_parse("metawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__meta);
|
||||
fxt.Test_parse("incubatorwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__incubator);
|
||||
fxt.Test_parse("enwiki" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikipedia);
|
||||
fxt.Test_parse("enwiktionary" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wiktionary);
|
||||
fxt.Test_parse("enwikisource" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikisource);
|
||||
fxt.Test_parse("enwikibooks" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikibooks);
|
||||
fxt.Test_parse("enwikiversity" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikiversity);
|
||||
fxt.Test_parse("enwikiquote" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikiquote);
|
||||
fxt.Test_parse("enwikinews" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikinews);
|
||||
fxt.Test_parse("enwikivoyage" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikivoyage);
|
||||
fxt.Test_parse("frwiki" , Xol_lang_stub_.Id_fr , Xow_domain_tid_.Tid__wikipedia);
|
||||
fxt.Test_parse_null("unknown");
|
||||
fxt.Test_parse("plwikimedia" , Xol_lang_stub_.Id_pl , Xow_domain_tid_.Tid__wikimedia);
|
||||
}
|
||||
@Test public void Parse_override() {
|
||||
fxt.Test_parse("arwikimedia" , Xol_lang_stub_.Id_es , Xow_domain_tid_.Tid__wikimedia);
|
||||
fxt.Test_parse("ukwikimedia" , Xol_lang_stub_.Id_uk , Xow_domain_tid_.Tid__wikimedia);
|
||||
}
|
||||
@Test public void To_domain_itm() {
|
||||
fxt.Test_to_domain_itm("enwiki" , "en" , "en.wikipedia.org");
|
||||
fxt.Test_to_domain_itm("zh_yuewiki" , "zh-yue" , "zh-yue.wikipedia.org");
|
||||
}
|
||||
@Test public void To_domain_bry() {
|
||||
fxt.Test_to_domain_bry("enwiki" , "en.wikipedia.org");
|
||||
fxt.Test_to_domain_bry("zh_yuewiki" , "zh-yue.wikipedia.org");
|
||||
fxt.Test_to_domain_bry("arwikimedia", "ar.wikimedia.org");
|
||||
fxt.Test_to_domain_bry("ukwikimedia", "ua.wikimedia.org");
|
||||
}
|
||||
@Test public void To_abrv() {
|
||||
fxt.Test_to_abrv("simple.wikipedia.org" , "simplewiki");
|
||||
fxt.Test_to_abrv("en.wikipedia.org" , "enwiki");
|
||||
fxt.Test_to_abrv("commons.wikimedia.org" , "commonswiki");
|
||||
}
|
||||
@Test public void To_abrv_by_lang() {
|
||||
fxt.Test_to_abrv_by_lang("en", Xow_domain_tid_.Tid__wikipedia, "enwiki");
|
||||
}
|
||||
}
|
||||
class Xow_abrv_wm_fxt {
|
||||
public void Test_parse(String raw, int expd_lang_id, int expd_domain_tid) {
|
||||
byte[] raw_bry = Bry_.new_a7(raw);
|
||||
Xow_abrv_wm abrv = Xow_abrv_wm_.Parse_to_abrv_or_null(raw_bry);
|
||||
Xol_lang_stub actl_lang_itm = abrv.Lang_actl();
|
||||
Tfds.Eq(expd_lang_id , actl_lang_itm == null ? Xol_lang_stub_.Id__unknown : actl_lang_itm.Id());
|
||||
Tfds.Eq(expd_domain_tid , abrv.Domain_type());
|
||||
}
|
||||
public void Test_parse_null(String raw) {
|
||||
byte[] raw_bry = Bry_.new_a7(raw);
|
||||
Xow_abrv_wm abrv = Xow_abrv_wm_.Parse_to_abrv_or_null(raw_bry);
|
||||
Tfds.Eq_true(abrv == null);
|
||||
}
|
||||
public void Test_to_abrv(String domain_str, String expd) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_a7(domain_str));
|
||||
byte[] actl = Xow_abrv_wm_.To_abrv(domain);
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
public void Test_to_abrv_by_lang(String lang_key, int wiki_tid, String expd) {
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
Xow_abrv_wm_.To_abrv(tmp_bfr, Bry_.new_a7(lang_key), gplx.core.primitives.Int_obj_ref.New(wiki_tid));
|
||||
Tfds.Eq_str(expd, tmp_bfr.To_str_and_clear(), "to_abrv");
|
||||
}
|
||||
public void Test_to_domain_bry(String wmf_key, String expd_domain) {
|
||||
Tfds.Eq(expd_domain , String_.new_a7(Xow_abrv_wm_.Parse_to_domain_bry(Bry_.new_a7(wmf_key))));
|
||||
}
|
||||
public void Test_to_domain_itm(String wmf_key, String expd_lang_key, String expd_domain) {
|
||||
Xow_domain_itm domain = Xow_abrv_wm_.Parse_to_domain_itm(Bry_.new_a7(wmf_key));
|
||||
Tfds.Eq(expd_lang_key , String_.new_a7(domain.Lang_actl_key()));
|
||||
Tfds.Eq(expd_domain , String_.new_a7(domain.Domain_bry()));
|
||||
}
|
||||
}
|
||||
@@ -1,41 +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.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_abrv_xo__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_abrv_xo__fxt fxt = new Xow_abrv_xo__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test("en.wikipedia.org" , "en.w"); // multi.enwiki
|
||||
fxt.Test("fr.wiktionary.org" , "fr.d"); // multi.frwiktionary
|
||||
fxt.Test("commons.wikimedia.org" , "c"); // important.unique.commons
|
||||
fxt.Test("species.wikimedia.org" , "species"); // important.unique.species
|
||||
fxt.Test("www.wikidata.org" , "wd"); // important.unique.wikidata
|
||||
fxt.Test("home" , "home"); // important.unique.xowa
|
||||
fxt.Test("meta.wikimedia.org" , "meta"); // wikimedia.unique
|
||||
fxt.Test("pl.wikimedia.org" , "pl.m"); // wikimedia.multi
|
||||
fxt.Test("a.b.c" , "a.b.c"); // unkonwn
|
||||
}
|
||||
}
|
||||
class Xow_abrv_xo__fxt {
|
||||
public void Clear() {}
|
||||
public void Test(String domain_str, String expd_abrv) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
|
||||
byte[] actl_abrv = Xow_abrv_xo_.To_bry(domain.Domain_bry(), domain.Lang_actl_key(), domain.Domain_type());
|
||||
Tfds.Eq(expd_abrv, String_.new_u8(actl_abrv), "To_bry");
|
||||
domain = Xow_abrv_xo_.To_itm(actl_abrv);
|
||||
Tfds.Eq(domain_str, domain.Domain_str(), "To_itm");
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xow_domain_itm_tst {
|
||||
private final Xow_domain_fxt fxt = new Xow_domain_fxt();
|
||||
@Test public void Parse_en_wikipedia() {fxt.Test_parse("en.wikipedia.org" , "en" , "en" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_fr_wikipedia() {fxt.Test_parse("fr.wikipedia.org" , "fr" , "fr" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_en_wiktionary() {fxt.Test_parse("en.wiktionary.org" , "en" , "en" , Xow_domain_tid_.Tid__wiktionary);}
|
||||
@Test public void Parse_zh_classical_wikipedia() {fxt.Test_parse("zh-classical.wikipedia.org" , "zh-classical" , "lzh" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_commons() {fxt.Test_parse("commons.wikimedia.org" , "" , "" , Xow_domain_tid_.Tid__commons);}
|
||||
@Test public void Parse_species() {fxt.Test_parse("species.wikimedia.org" , "" , "" , Xow_domain_tid_.Tid__species);}
|
||||
@Test public void Parse_ru_wikimedia_org() {fxt.Test_parse("ru.wikimedia.org" , "ru" , "ru" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_home() {fxt.Test_parse("home" , "" , "" , Xow_domain_tid_.Tid__home);}
|
||||
@Test public void Parse_other() {fxt.Test_parse("other.wiki" , "" , "" , Xow_domain_tid_.Tid__other);}
|
||||
@Test public void Parse_ua_wikimedia_org() {fxt.Test_parse("ua.wikimedia.org" , "ua" , "uk" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_ar_wikimedia_org() {fxt.Test_parse("ar.wikimedia.org" , "ar" , "es" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_blank() {fxt.Test_parse("" , "" , "" , Xow_domain_tid_.Tid__other);}
|
||||
@Test public void Match_lang() {
|
||||
fxt.Test__match_lang_y("en", "en.wikipedia.org", "en.wiktionary.org", "simple.wikipedia.org", "species.wikimedia.org", "www.wikidata.org", "commons.wikimedia.org");
|
||||
fxt.Test__match_lang_y("fr", "fr.wikipedia.org", "fr.wiktionary.org");
|
||||
fxt.Test__match_lang_y("zh", "zh-classical.wikipedia.org");
|
||||
}
|
||||
}
|
||||
class Xow_domain_fxt {
|
||||
public void Test_parse(String domain, String expd_orig_lang, String expd_actl_lang, int expd_tid) {
|
||||
Xow_domain_itm actl = Xow_domain_itm_.parse(Bry_.new_a7(domain));
|
||||
Tfds.Eq_str(expd_orig_lang, String_.new_a7((actl.Lang_orig_key())));
|
||||
Tfds.Eq_str(expd_actl_lang, String_.new_a7((actl.Lang_actl_key())));
|
||||
Tfds.Eq_int(expd_tid, actl.Domain_type_id());
|
||||
}
|
||||
public void Test__match_lang_y(String lang_code, String... domains) {Test__match_lang(Bool_.Y, lang_code, domains);}
|
||||
public void Test__match_lang(boolean expd, String lang_key_str, String[] domains) {
|
||||
int len = domains.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domains[i]));
|
||||
Gftest.Eq__bool(expd, Xow_domain_itm_.Match_lang(domain, lang_key_str), lang_key_str + "|" + domains[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +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.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_domain_uid__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_domain_uid__fxt fxt = new Xow_domain_uid__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test(Xow_domain_uid_.Tid_commons , "commons.wikimedia.org" , "", Xow_domain_tid_.Tid__commons);
|
||||
fxt.Test(100 , "en.wikipedia.org" , "en", Xow_domain_tid_.Tid__wikipedia);
|
||||
}
|
||||
}
|
||||
class Xow_domain_uid__fxt {
|
||||
public void Clear() {}
|
||||
public void Test(int tid, String domain_str, String expd_lang, int expd_tid) {
|
||||
byte[] domain_bry = Bry_.new_a7(domain_str);
|
||||
Xow_domain_itm actl_domain = Xow_domain_uid_.To_domain(tid);
|
||||
Tfds.Eq_bry(domain_bry , actl_domain.Domain_bry());
|
||||
Tfds.Eq_bry(Bry_.new_a7(expd_lang) , actl_domain.Lang_actl_key());
|
||||
Tfds.Eq(expd_tid , actl_domain.Domain_type_id());
|
||||
Tfds.Eq(tid, Xow_domain_uid_.To_int(actl_domain));
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.nss; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
public class Xow_ns_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_ns_mgr_fxt fxt = new Xow_ns_mgr_fxt();
|
||||
@Test public void Basic() {fxt.ini_ns_(-2, 0, 1).run_Ords_sort().tst_Ords(-2, -100, 0, 1);}
|
||||
@Test public void Talk_skip() {fxt.ini_ns_(-2, 0, 2, 3).run_Ords_sort().tst_Ords(-2, -100, 0, 1, 2, 3);}
|
||||
@Test public void Subj_skip() {fxt.ini_ns_(-2, 1, 2, 3).run_Ords_sort().tst_Ords(-2, -100, 0, 1, 2, 3);}
|
||||
@Test public void Out_of_order() {fxt.ini_ns_(3, 1, 2, -2).run_Ords_sort().tst_Ords(-2, -100, 0, 1, 2, 3);}
|
||||
@Test public void Skip_odd() {fxt.ini_ns_(-2, 1, 3).run_Ords_sort().tst_Ords(-2, -100, 0, 1, 2, 3);}
|
||||
@Test public void Skip_even() {fxt.ini_ns_(-2, 2, 4).run_Ords_sort().tst_Ords(-2, -100, 2, 3, 4, 5);}
|
||||
@Test public void Ns_alias() {
|
||||
fxt.Ns_mgr().Aliases_clear();
|
||||
fxt.Ns_mgr().Add_new(Xow_ns_.Tid__template, "Template");
|
||||
fxt.Ns_mgr().Aliases_add(Xow_ns_.Tid__template, "Templatex");
|
||||
fxt.Ns_mgr().Init();
|
||||
byte[] name = Bry_.new_a7("Templatex:Abc");
|
||||
Tfds.Eq(10, fxt.Ns_mgr().Tmpls_get_w_colon(name, 0, name.length));
|
||||
}
|
||||
@Test public void Utf8() {// PURPOSE: handle different casings for ns_names; PAGE:ru.w:Портрет_итальянского_Ренессанса DATE:2014-07-04
|
||||
Xow_ns_mgr ns_mgr = new Xow_ns_mgr(Xol_case_mgr_.U8());
|
||||
ns_mgr.Add_new(1234, "Test");
|
||||
ns_mgr.Add_new(1235, "файл");
|
||||
fxt.Ns_mgr_(ns_mgr);
|
||||
fxt.Test_ns_name(1234, "Test", "test", "TEST", "tesT");
|
||||
fxt.Test_ns_name(1235, "файл", "Файл");
|
||||
}
|
||||
}
|
||||
class Xow_ns_mgr_fxt {
|
||||
private Xow_ns_mgr ns_mgr = new Xow_ns_mgr(Xol_case_mgr_.A7());
|
||||
public Xow_ns_mgr Ns_mgr() {return ns_mgr;}
|
||||
public void Ns_mgr_(Xow_ns_mgr v) {this.ns_mgr = v;}
|
||||
public void Clear() {ns_mgr.Clear();}
|
||||
public Xow_ns_mgr_fxt ini_ns_(int... ids) {
|
||||
int ids_len = ids.length;
|
||||
for (int i = 0; i < ids_len; i++) {
|
||||
int id = ids[i];
|
||||
ns_mgr.Add_new(id, Int_.To_str(id));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Xow_ns_mgr_fxt run_Ords_sort() {ns_mgr.Init(); return this;}
|
||||
public Xow_ns_mgr_fxt tst_Ords(int... expd) {
|
||||
int actl_len = ns_mgr.Ords_len();
|
||||
int[] actl = new int[actl_len];
|
||||
for (int i = 0; i < actl_len; i++) {
|
||||
Xow_ns ns_itm = ns_mgr.Ords_ary()[i];
|
||||
actl[i] = ns_itm == null ? -100 : ns_itm.Id();
|
||||
}
|
||||
Tfds.Eq_ary(expd, actl);
|
||||
return this;
|
||||
}
|
||||
public void Test_ns_name(int expd_id, String... ns_names) {
|
||||
int ns_names_len = ns_names.length;
|
||||
for (int i = 0; i < ns_names_len; ++i) {
|
||||
String ns_name = ns_names[i];
|
||||
Xow_ns actl_ns = ns_mgr.Names_get_or_null(Bry_.new_u8(ns_name));
|
||||
int actl_id = actl_ns == null ? Int_.Min_value : actl_ns.Id();
|
||||
Tfds.Eq(expd_id, actl_id, ns_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +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.xowa.wikis.nss; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_ns_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_ns_fxt fxt = new Xow_ns_fxt();
|
||||
@Test public void Category() {
|
||||
fxt .Expd_id_subjId_(Xow_ns_.Tid__category)
|
||||
.Expd_id_talkId_(Xow_ns_.Tid__category_talk)
|
||||
.Expd_id_subj_(Bool_.Y)
|
||||
.Expd_id_talk_(Bool_.N)
|
||||
.Test(Xow_ns_.Tid__category)
|
||||
;
|
||||
}
|
||||
@Test public void Category_talk() {
|
||||
fxt .Expd_id_subjId_(Xow_ns_.Tid__category)
|
||||
.Expd_id_talkId_(Xow_ns_.Tid__category_talk)
|
||||
.Expd_id_subj_(Bool_.N)
|
||||
.Expd_id_talk_(Bool_.Y)
|
||||
.Test(Xow_ns_.Tid__category_talk)
|
||||
;
|
||||
}
|
||||
@Test public void Special() {
|
||||
fxt .Expd_id_subjId_(Xow_ns_.Tid__special)
|
||||
.Expd_id_talkId_(Xow_ns_.Tid__special)
|
||||
.Expd_id_subj_(Bool_.Y)
|
||||
.Expd_id_talk_(Bool_.N)
|
||||
.Test(Xow_ns_.Tid__special)
|
||||
;
|
||||
}
|
||||
}
|
||||
class Xow_ns_fxt {
|
||||
public void Clear() {
|
||||
expd_id_subjId = expd_id_talkId = Int_.Max_value;
|
||||
expd_id_subj = expd_id_talk = false;
|
||||
}
|
||||
public Xow_ns_fxt Expd_id_subjId_(int v) {expd_id_subjId = v; return this;} private int expd_id_subjId;
|
||||
public Xow_ns_fxt Expd_id_talkId_(int v) {expd_id_talkId = v; return this;} private int expd_id_talkId;
|
||||
public Xow_ns_fxt Expd_id_subj_(boolean v) {expd_id_subj = v; return this;} private boolean expd_id_subj;
|
||||
public Xow_ns_fxt Expd_id_talk_(boolean v) {expd_id_talk = v; return this;} private boolean expd_id_talk;
|
||||
public void Test(int nsId) {
|
||||
Xow_ns actl = new Xow_ns(nsId, Xow_ns_case_.Tid__1st, Bry_.Empty, false);
|
||||
Tfds.Eq(expd_id_subjId, actl.Id_subj_id());
|
||||
Tfds.Eq(expd_id_talkId, actl.Id_talk_id());
|
||||
Tfds.Eq(expd_id_subj, actl.Id_is_subj());
|
||||
Tfds.Eq(expd_id_talk, actl.Id_is_talk());
|
||||
}
|
||||
}
|
||||
@@ -1,51 +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.xowa.wikis.pages.redirects; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.specials.*;
|
||||
public class Xopg_redirect_mgr__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xopg_redirect_mgr__fxt fxt = new Xopg_redirect_mgr__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__Itms__add__special(fxt.Make_meta("XowaTest"), Keyval_.Ary_empty, fxt.Make__itm("en.wikipedia.org/wiki/Special:XowaTest", "Special:XowaTest", null));
|
||||
}
|
||||
@Test public void Args() {
|
||||
fxt.Test__Itms__add__special
|
||||
( fxt.Make_meta("XowaTest"), Keyval_.Ary(Keyval_.new_("k1", "v1"), Keyval_.new_("k2", "v2"), Keyval_.new_("k3", "v3"))
|
||||
, fxt.Make__itm("en.wikipedia.org/wiki/Special:XowaTest?k1=v1&k2=v2&k3=v3", "Special:XowaTest", null)
|
||||
);
|
||||
}
|
||||
}
|
||||
class Xopg_redirect_mgr__fxt {
|
||||
private Xow_wiki wiki;
|
||||
private final Xopg_redirect_mgr mgr = new Xopg_redirect_mgr();
|
||||
public void Clear() {
|
||||
mgr.Clear();
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
public Xow_special_meta Make_meta(String key) {return Xow_special_meta.New_xo(key, "test display name");}
|
||||
public Xopg_redirect_itm Make__itm(String url_str, String ttl_str, String wikitext) {
|
||||
Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(url_str));
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.new_u8(ttl_str));
|
||||
return new Xopg_redirect_itm(url, ttl, Bry_.new_u8_safe(wikitext));
|
||||
}
|
||||
public void Test__Itms__add__special(Xow_special_meta meta, Keyval[] url_args, Xopg_redirect_itm expd) {
|
||||
mgr.Itms__add__special(wiki, meta, url_args);
|
||||
Xopg_redirect_itm actl = mgr.Itms__get_at(0);
|
||||
Gftest.Eq__bry(expd.Ttl().Raw(), actl.Ttl().Raw(), "ttl");
|
||||
Gftest.Eq__str(expd.Url().To_str(), actl.Url().To_str(), "url");
|
||||
Gftest.Eq__bry(expd.Wikitext(), actl.Wikitext(), "wikitext");
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xotdb_fsys_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_fsys_mgr_fxt fxt = new Xow_fsys_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Zip_(Xotdb_dir_info_.Tid_page, Bool_.N).Url_ns_fil(Xotdb_dir_info_.Tid_page, Xow_ns_.Tid__main, 123, "mem/xowa/wiki/en.wikipedia.org/ns/000/page/00/00/00/01/0000000123.xdat");
|
||||
fxt.Zip_(Xotdb_dir_info_.Tid_page, Bool_.Y).Url_ns_fil(Xotdb_dir_info_.Tid_page, Xow_ns_.Tid__main, 123, "mem/xowa/wiki/en.wikipedia.org/ns/000/page_zip/00/00/00/01/0000000123.zip");
|
||||
}
|
||||
}
|
||||
class Xow_fsys_mgr_fxt {
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
Xoae_app app; Xowe_wiki wiki;
|
||||
public Xow_fsys_mgr_fxt Zip_(byte tid, boolean v) {wiki.Tdb_fsys_mgr().Tdb_dir_regy()[tid].Ext_tid_(v ? gplx.core.ios.streams.Io_stream_tid_.Tid__zip : gplx.core.ios.streams.Io_stream_tid_.Tid__raw); return this;}
|
||||
public void Url_ns_fil(byte tid, int ns_id, int fil_idx, String expd) {
|
||||
Tfds.Eq(expd, wiki.Tdb_fsys_mgr().Url_ns_fil(tid, ns_id, fil_idx).Raw());
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*;
|
||||
public class Xob_hive_mgr_tst {
|
||||
Xow_hive_mgr_fxt fxt = new Xow_hive_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Drilldown() {
|
||||
// fxt.Files_create_range(10, 10);
|
||||
// fxt.Drilldown("A00", "J09", "A00", "B09", "C00", "D09", "E00", "F09", "G00", "H09", "I00", "J09");
|
||||
// fxt.Drilldown("E00", "F09", "E00", "E03", "E04", "E07", "E08", "F01", "F02", "F05", "F06", "F09");
|
||||
// fxt.Drilldown("E08", "F01", "E08", "E09", "F00", "F01");
|
||||
}
|
||||
}
|
||||
@@ -1,111 +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.xowa.wikis.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.encoders.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.tdbs.xdats.*;
|
||||
public class Xow_hive_mgr_fxt {
|
||||
public void Clear() {
|
||||
if (hive_mgr == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
hive_mgr = new Xob_hive_mgr(wiki);
|
||||
}
|
||||
hive_mgr.Clear();
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
} private Xob_hive_mgr hive_mgr; Xoae_app app;
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public void Find_nearby(String key, int count, boolean include_redirects, String... expd) {
|
||||
List_adp list = List_adp_.New();
|
||||
wiki.Hive_mgr().Find_bgn(list, wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), count, include_redirects);
|
||||
int actl_len = list.Count();
|
||||
String[] actl = new String[actl_len];
|
||||
for (int i = 0; i < actl_len; i++) {
|
||||
Xowd_page_itm itm = (Xowd_page_itm)list.Get_at(i);
|
||||
actl[i] = String_.new_a7(itm.Ttl_page_db());
|
||||
}
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
}
|
||||
public static void Ttls_create_rng(Xowe_wiki wiki, int files, int ttls_per_file) {Ttls_create_rng(wiki, wiki.Ns_mgr().Ns_main(), files, ttls_per_file);}
|
||||
public static void Ttls_create_rng(Xowe_wiki wiki, Xow_ns ns, int files, int ttls_per_file) {
|
||||
Xob_reg_wtr reg_wtr = new Xob_reg_wtr();
|
||||
byte dir_tid = Xotdb_dir_info_.Tid_ttl;
|
||||
int id = 0;
|
||||
int ttl_bry_len = Int_.DigitCount(ttls_per_file);
|
||||
Xob_xdat_file_wtr xdat_wtr = Xob_xdat_file_wtr.new_file_(ttls_per_file * 8, wiki.Tdb_fsys_mgr().Url_ns_dir(ns.Num_str(), Xotdb_dir_info_.Tid_ttl));
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
byte ltr = Byte_ascii.Ltr_A; byte[] ttl_0 = Bry_.Empty, ttl_n = Bry_.Empty;
|
||||
for (int fil_idx = 0; fil_idx < files; fil_idx++) {
|
||||
for (int ttl_idx = 0; ttl_idx < ttls_per_file; ttl_idx++) {
|
||||
tmp_bfr.Add_byte(ltr).Add_int_fixed(ttl_idx, ttl_bry_len);
|
||||
byte[] ttl_bry = tmp_bfr.To_bry_and_clear();
|
||||
if (ttl_idx == 0) ttl_0 = ttl_bry;
|
||||
else if (ttl_idx == ttls_per_file - 1) ttl_n = ttl_bry;
|
||||
Xotdb_page_itm_.Txt_ttl_save(xdat_wtr.Bfr(), id++, 0, ttl_idx, ttl_idx % 2 == 1, 1, ttl_bry);
|
||||
xdat_wtr.Add_idx(Byte_ascii.Null);
|
||||
}
|
||||
xdat_wtr.Flush(wiki.Appe().Usr_dlg());
|
||||
reg_wtr.Add(ttl_0, ttl_n, ttls_per_file);
|
||||
++ltr;
|
||||
}
|
||||
reg_wtr.Flush(wiki.Tdb_fsys_mgr().Url_ns_reg(ns.Num_str(), dir_tid));
|
||||
}
|
||||
public Xow_hive_mgr_fxt Create_ctg(String key_str, int... pages) {Create_ctg(app, hive_mgr, key_str, pages); return this;}
|
||||
public static void Create_ctg(Xoae_app app, Xob_hive_mgr hive_mgr, String key_str, int... pages) {
|
||||
byte[] key_bry = Bry_.new_a7(key_str);
|
||||
Bry_bfr bfr = app.Utl__bfr_mkr().Get_b512();
|
||||
bfr.Add(key_bry);
|
||||
int pages_len = pages.length;
|
||||
for (int i = 0; i < pages_len; i++)
|
||||
bfr.Add_byte_pipe().Add_base85_len_5(pages[i]);
|
||||
bfr.Add_byte_nl();
|
||||
byte[] row = bfr.To_bry_and_rls();
|
||||
hive_mgr.Create(Xotdb_dir_info_.Tid_category, key_bry, row);
|
||||
}
|
||||
public Xow_hive_mgr_fxt Create_id(int id, int fil_idx, int row_idx, boolean type_redirect, int itm_len, int ns_id, String ttl) {Create_id(app, hive_mgr, id, fil_idx, row_idx, type_redirect, itm_len, ns_id, ttl); return this;}
|
||||
public static void Create_id(Xoae_app app, Xob_hive_mgr hive_mgr, int id, int fil_idx, int row_idx, boolean type_redirect, int itm_len, int ns_id, String ttl) {
|
||||
Bry_bfr bfr = app.Utl__bfr_mkr().Get_b512();
|
||||
byte[] key_bry = Base85_.To_bry(id, 5);
|
||||
bfr .Add(key_bry) .Add_byte_pipe()
|
||||
.Add_base85_len_5(fil_idx) .Add_byte_pipe()
|
||||
.Add_base85_len_5(row_idx) .Add_byte_pipe()
|
||||
.Add_byte(type_redirect ? Byte_ascii.Num_1 : Byte_ascii.Num_0).Add_byte_pipe()
|
||||
.Add_base85_len_5(itm_len) .Add_byte_pipe()
|
||||
.Add_base85_len_5(ns_id) .Add_byte_pipe()
|
||||
.Add_str_u8(ttl) .Add_byte_nl();
|
||||
byte[] row = bfr.To_bry_and_clear();
|
||||
bfr.Mkr_rls();
|
||||
hive_mgr.Create(Xotdb_dir_info_.Tid_id, key_bry, row);
|
||||
}
|
||||
public Xow_hive_mgr_fxt Load(String url, String... expd) {
|
||||
String actl = Io_mgr.Instance.LoadFilStr(url);
|
||||
Tfds.Eq_ary_str(expd, String_.SplitLines_nl(actl));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class Xob_reg_wtr {
|
||||
Bry_bfr bfr = Bry_bfr_.New(); int fil_count = 0;
|
||||
public void Add(byte[] bgn, byte[] end, int itm_count) {
|
||||
bfr
|
||||
.Add_int_variable(fil_count++).Add_byte(Byte_ascii.Pipe)
|
||||
.Add(bgn).Add_byte(Byte_ascii.Pipe)
|
||||
.Add(end).Add_byte(Byte_ascii.Pipe)
|
||||
.Add_int_variable(itm_count).Add_byte(Byte_ascii.Nl);
|
||||
}
|
||||
public void Flush(Io_url url) {
|
||||
Io_mgr.Instance.SaveFilBfr(url, bfr);
|
||||
// Tfds.Dbg(url.Raw() + "\n" + Io_mgr.Instance.LoadFilStr(url));
|
||||
}
|
||||
}
|
||||
@@ -1,97 +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.xowa.wikis.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xowd_hive_mgr_tst {
|
||||
Xowd_hive_mgr_fxt fxt = new Xowd_hive_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Create() {
|
||||
fxt.Create("A", "A|A data\n")
|
||||
.Tst_reg(String_.Concat_lines_nl("0|A|A|1"))
|
||||
.Tst_fil(0, String_.Concat("!!!!*|\n", "A|A data\n"))
|
||||
;
|
||||
}
|
||||
@Test public void Create_2() {
|
||||
fxt .Create("A", "A|1\n")
|
||||
.Create("B", "B|12\n")
|
||||
.Tst_reg(String_.Concat_lines_nl("0|A|B|2"))
|
||||
.Tst_fil(0, String_.Concat("!!!!%|!!!!&|\n", "A|1\n", "B|12\n"))
|
||||
;
|
||||
}
|
||||
@Test public void Create_3() {
|
||||
fxt .Create("A", "A|1\n")
|
||||
.Create("B", "B|12\n")
|
||||
.Create("C", "C|123\n")
|
||||
.Tst_reg(String_.Concat_lines_nl("0|A|C|3"))
|
||||
.Tst_fil(0, String_.Concat("!!!!%|!!!!&|!!!!'|\n", "A|1\n", "B|12\n", "C|123\n"))
|
||||
;
|
||||
}
|
||||
@Test public void Create_sort() {
|
||||
fxt .Create_and_sort("C", "C|1\n")
|
||||
.Create_and_sort("A", "A|12\n")
|
||||
.Create_and_sort("B", "B|123\n")
|
||||
.Tst_reg(String_.Concat_lines_nl("0|A|C|3"))
|
||||
.Tst_fil(0, String_.Concat("!!!!&|!!!!'|!!!!%|\n", "A|12\n", "B|123\n", "C|1\n"))
|
||||
;
|
||||
}
|
||||
@Test public void Update() {
|
||||
fxt .Create("A", "A|A data\n")
|
||||
.Create("B", "B|B data\n")
|
||||
.Create("C", "C|C data\n")
|
||||
.Tst_reg(String_.Concat_lines_nl("0|A|C|3"))
|
||||
.Tst_fil(0, String_.Concat("!!!!*|!!!!*|!!!!*|\n", "A|A data\n", "B|B data\n", "C|C data\n"))
|
||||
.Update("B", "B|changed\n")
|
||||
.Tst_reg(String_.Concat_lines_nl("0|A|C|3"))
|
||||
.Tst_fil(0, String_.Concat("!!!!*|!!!!+|!!!!*|\n", "A|A data\n", "B|changed\n", "C|C data\n"))
|
||||
;
|
||||
}
|
||||
}
|
||||
class Xowd_hive_mgr_fxt {
|
||||
Xoae_app app; Xowe_wiki wiki; Xowd_hive_mgr mgr;
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
mgr = new Xowd_hive_mgr(wiki, Xotdb_dir_info_.Tid_page);
|
||||
}
|
||||
public Xowd_hive_mgr_fxt Tst_reg(String expd) {
|
||||
Io_url file_orig = Io_url_.mem_fil_("mem/xowa/wiki/en.wikipedia.org/ns/000/title/reg.csv");
|
||||
Tfds.Eq_str_lines(expd, Io_mgr.Instance.LoadFilStr(file_orig));
|
||||
return this;
|
||||
}
|
||||
public Xowd_hive_mgr_fxt Tst_fil(int fil, String expd) {
|
||||
Io_url url = wiki.Tdb_fsys_mgr().Url_ns_fil(Xotdb_dir_info_.Tid_page, Xow_ns_.Tid__main, fil);
|
||||
Tfds.Eq_str_lines(expd, Io_mgr.Instance.LoadFilStr(url));
|
||||
return this;
|
||||
}
|
||||
public Xowd_hive_mgr_fxt Update(String key, String data) {
|
||||
mgr.Update(wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), null, Bry_.new_a7(data), 0, Byte_ascii.Pipe, true, true);
|
||||
return this;
|
||||
}
|
||||
public Xowd_hive_mgr_fxt Create(String key, String data) {
|
||||
mgr.Create(wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), Bry_.new_a7(data), null);
|
||||
return this;
|
||||
}
|
||||
public Xowd_hive_mgr_fxt Create_and_sort(String key, String data) {
|
||||
mgr.Create(wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), Bry_.new_a7(data), new Bry_comparer_bgn_eos(0));
|
||||
return this;
|
||||
}
|
||||
// public void Get(String ttl_str, boolean exists) {
|
||||
// Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
|
||||
// Xowd_page_itm row = mgr.Get(ttl.Ns(), ttl.Full_txt());
|
||||
// Tfds.Eq(exists, row != null);
|
||||
// }
|
||||
}
|
||||
@@ -1,35 +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.xowa.wikis.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*; import gplx.core.lists.*;
|
||||
public class Xowd_regy_mgr__tst implements ComparerAble {
|
||||
@Test public void Basic() {
|
||||
String[] slotAry = new String[] {"b", "e", "h"}; // 0=b 1=e 2=h
|
||||
tst_FindSlot(slotAry, "f", "h"); // f -> 1 2 -> 2
|
||||
tst_FindSlot(slotAry, "c", "e"); // c -> -1 1 -> 0 -> 0 1 -> 1
|
||||
tst_FindSlot(slotAry, "a", "b"); // a -> -1 1 -> 0 -> -1 0 -> 0
|
||||
}
|
||||
@Test public void Null() {
|
||||
String[] slotAry = new String[] {"b", "g", "l", "q", "v", null};
|
||||
tst_FindSlot(slotAry, "a", "b");
|
||||
tst_FindSlot(slotAry, "b", "b");
|
||||
tst_FindSlot(slotAry, "c", "g");
|
||||
tst_FindSlot(slotAry, "v", "v");
|
||||
tst_FindSlot(slotAry, "w", null);
|
||||
}
|
||||
public int compare(Object lhsObj, Object rhsObj) {return CompareAble_.Compare_obj(lhsObj, rhsObj);}
|
||||
void tst_FindSlot(String[] slotAry, String s, String expd) {Tfds.Eq(expd, slotAry[gplx.xowa.wikis.tdbs.hives.Xowd_regy_mgr_.FindSlot(this, slotAry, s)]);}
|
||||
}
|
||||
@@ -1,86 +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.xowa.wikis.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*;
|
||||
public class Xowd_regy_mgr_tst {
|
||||
Xowd_regy_mgr_fxt fxt = new Xowd_regy_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Create_cur_is_empty() {fxt.Create("A").Save().Tst_file(String_.Concat_lines_nl("0|A|A|1"));}
|
||||
@Test public void Create_cur_has_one() {fxt.Load(String_.Concat_lines_nl("0|A|A|1")).Create("B").Save().Tst_file(String_.Concat_lines_nl("0|A|A|1", "1|B|B|1"));}
|
||||
@Test public void Update_1st_end() {fxt.Load(String_.Concat_lines_nl("0|B|B|1")).Update_add(0, "C").Save().Tst_file(String_.Concat_lines_nl("0|B|C|2"));}
|
||||
@Test public void Update_1st_bgn() {fxt.Load(String_.Concat_lines_nl("0|B|B|1")).Update_add(0, "A").Save().Tst_file(String_.Concat_lines_nl("0|A|B|2"));}
|
||||
@Test public void Update_mid() {fxt.Load(String_.Concat_lines_nl("0|B|D|2")).Update_add(0, "C").Save().Tst_file(String_.Concat_lines_nl("0|B|D|3"));}
|
||||
@Test public void Update_bgn() {fxt.Load(String_.Concat_lines_nl("0|B|D|2")).Update_add(0, "A").Save().Tst_file(String_.Concat_lines_nl("0|A|D|3"));}
|
||||
@Test public void Update_end() {fxt.Load(String_.Concat_lines_nl("0|B|D|2")).Update_add(0, "E").Save().Tst_file(String_.Concat_lines_nl("0|B|E|3"));}
|
||||
@Test public void Update_change_bgn() {fxt.Load(String_.Concat_lines_nl("0|B|D|2")).Update_change(0, "B", "A").Save().Tst_file(String_.Concat_lines_nl("0|A|D|2"));}
|
||||
@Test public void Update_change_end() {fxt.Load(String_.Concat_lines_nl("0|B|D|2")).Update_change(0, "D", "E").Save().Tst_file(String_.Concat_lines_nl("0|B|E|2"));}
|
||||
@Test public void Update_change_mid() {fxt.Load(String_.Concat_lines_nl("0|B|D|2")).Update_change(0, "C1", "C2").Save().Tst_file(String_.Concat_lines_nl("0|B|D|2"));}
|
||||
@Test public void Find_none() {fxt.Tst_find("A", Xowd_regy_mgr.Regy_null);}
|
||||
@Test public void Find_existing() {
|
||||
fxt.Load(String_.Concat_lines_nl
|
||||
( "0|B|D|3"
|
||||
, "1|E|G|3"
|
||||
, "2|H|J|3"
|
||||
))
|
||||
.Tst_find("B", 0).Tst_find("C", 0).Tst_find("D", 0)
|
||||
.Tst_find("A", 0)
|
||||
.Tst_find("Z", 2)
|
||||
.Tst_find("Da", 1)
|
||||
;
|
||||
}
|
||||
@Test public void Find_existing_null() {
|
||||
fxt.Load(String_.Concat_lines_nl
|
||||
( "0|B|D|3"
|
||||
, "1|D|H|0"
|
||||
, "2|H|J|3"
|
||||
))
|
||||
.Tst_find("B", 0).Tst_find("C", 0).Tst_find("D", 0)
|
||||
.Tst_find("A", 0)
|
||||
.Tst_find("Z", 2)
|
||||
.Tst_find("Da", 1) // rely on
|
||||
;
|
||||
}
|
||||
}
|
||||
class Xowd_regy_mgr_fxt {
|
||||
Xowd_regy_mgr mgr; Io_url mgr_url;
|
||||
public void Clear() {
|
||||
if (mgr == null) {
|
||||
mgr_url = Io_url_.mem_fil_("mem/hive_regy.csv");
|
||||
Io_mgr.Instance.DeleteFil(mgr_url);
|
||||
mgr = new Xowd_regy_mgr(mgr_url);
|
||||
}
|
||||
else {
|
||||
mgr.Clear();
|
||||
}
|
||||
}
|
||||
public Xowd_regy_mgr_fxt Create(String key) {mgr.Create(Bry_.new_a7(key)); return this;}
|
||||
public Xowd_regy_mgr_fxt Update_add(int fil_idx, String key) {mgr.Update_add(fil_idx, Bry_.new_a7(key)); return this;}
|
||||
public Xowd_regy_mgr_fxt Update_change(int fil_idx, String old_key, String new_key) {mgr.Update_change(fil_idx, Bry_.new_a7(old_key), Bry_.new_a7(new_key)); return this;}
|
||||
public Xowd_regy_mgr_fxt Load(String lines) {
|
||||
Io_mgr.Instance.SaveFilStr(mgr_url, lines);
|
||||
mgr = new Xowd_regy_mgr(mgr_url);
|
||||
return this;
|
||||
}
|
||||
public Xowd_regy_mgr_fxt Save() {mgr.Save(); return this;}
|
||||
public Xowd_regy_mgr_fxt Tst_file(String expd) {
|
||||
Tfds.Eq_str_lines(expd, Io_mgr.Instance.LoadFilStr(mgr_url));
|
||||
return this;
|
||||
}
|
||||
public Xowd_regy_mgr_fxt Tst_find(String find, int expd) {
|
||||
Tfds.Eq(expd, mgr.Files_find(Bry_.new_a7(find)));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xof_meta_fil_tst {
|
||||
Xof_meta_fil_fxt fxt = new Xof_meta_fil_fxt();
|
||||
@Before public void init() {fxt.Ini();}
|
||||
@Test public void Bld_url() {fxt.Bld_url("mem/root/", "abcdef", 3, "mem/root/a/b/abc.csv");}
|
||||
}
|
||||
class Xof_meta_fil_fxt {
|
||||
byte[] md5_(byte[] name) {return Xof_file_wkr_.Md5(name);}
|
||||
public void Ini() {}
|
||||
public void Bld_url(String root, String md5, int depth, String expd) {Tfds.Eq(expd, Xof_meta_fil.Bld_url(Io_url_.new_dir_(root), Bry_.new_a7(md5), depth).Raw());}
|
||||
}
|
||||
@@ -1,94 +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.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.gfui.*; import gplx.xowa.files.*;
|
||||
public class Xof_meta_mgr_tst {
|
||||
Xof_file_regy_fxt fxt = new Xof_file_regy_fxt();
|
||||
@Before public void init() {fxt.Ini();}
|
||||
@Test public void Set_one() {
|
||||
fxt .Set("A.png", 440, 400, true, "440,400", "220,200")
|
||||
.tst_Save("mem/xowa/file/#meta/en.wikipedia.org/7/70.csv", "A.png|y||1?440,400|1?440,400;1?220,200");
|
||||
}
|
||||
@Test public void Set_many() {
|
||||
fxt .Set("A.png" , 440, 400, true, "440,400", "220,200")
|
||||
.Set("Cabbage.jpg" , 640, 456, false, "220,200", "200,180")
|
||||
.tst_Save("mem/xowa/file/#meta/en.wikipedia.org/7/70.csv"
|
||||
, "A.png|y||1?440,400|1?440,400;1?220,200"
|
||||
, "Cabbage.jpg|y||2?640,456|1?220,200;1?200,180"
|
||||
);
|
||||
}
|
||||
@Test public void Load_and_add() {
|
||||
fxt.Save_fil("mem/xowa/file/#meta/en.wikipedia.org/7/70.csv"
|
||||
, "A.png|y||1?440,400|"
|
||||
, "Cabbage.jpg|y||2?640,456|1?440,220;1?220,200"
|
||||
)
|
||||
.Set("Wooden_hourglass_3.jpg", 967, 1959, false, "220,200")
|
||||
.tst_Save("mem/xowa/file/#meta/en.wikipedia.org/7/70.csv"
|
||||
, "A.png|y||1?440,400|"
|
||||
, "Cabbage.jpg|y||2?640,456|1?440,220;1?220,200"
|
||||
, "Wooden_hourglass_3.jpg|y||2?967,1959|1?220,200"
|
||||
);
|
||||
}
|
||||
@Test public void Load_and_update() {
|
||||
fxt.Save_fil("mem/xowa/file/#meta/en.wikipedia.org/7/70.csv"
|
||||
, "A.png|y||0?440,400|"
|
||||
, "Cabbage.jpg|y||2?640,456|1?440,400;1?220,200"
|
||||
)
|
||||
.Set("A.png", 550, 500, false, "220,200")
|
||||
.tst_Save("mem/xowa/file/#meta/en.wikipedia.org/7/70.csv"
|
||||
, "A.png|y||2?550,500|1?220,200"
|
||||
, "Cabbage.jpg|y||2?640,456|1?440,400;1?220,200"
|
||||
);
|
||||
}
|
||||
}
|
||||
class Xof_file_regy_fxt {
|
||||
Xof_meta_mgr regy_mgr;
|
||||
byte[] md5_(byte[] name) {return Xof_file_wkr_.Md5(name);}
|
||||
public void Ini() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
regy_mgr = new Xof_meta_mgr(wiki);
|
||||
regy_mgr.Clear();
|
||||
regy_mgr.Depth_(2);
|
||||
}
|
||||
public Xof_file_regy_fxt Save_fil(String url, String... data) {Io_mgr.Instance.SaveFilStr(Io_url_.mem_fil_(url), String_.Concat_lines_nl(data)); return this;}
|
||||
public Xof_file_regy_fxt Set(String name_str, int w, int h, boolean orig_exists, String... thumbs) {
|
||||
byte[] name = Bry_.new_u8(name_str);
|
||||
byte[] md5 = md5_(name);
|
||||
Xof_meta_itm itm = regy_mgr.Get_itm_or_new(name, md5);
|
||||
itm.Vrtl_repo_(Xof_meta_itm.Repo_same); // all tests above assume this is main
|
||||
itm.Update_all(Bry_.Empty, w, h, orig_exists ? Xof_meta_itm.Exists_y : Xof_meta_itm.Exists_unknown, To_ary(thumbs));
|
||||
return this;
|
||||
}
|
||||
Xof_meta_thumb[] To_ary(String[] ary) {
|
||||
int len = ary.length;
|
||||
Xof_meta_thumb[] rv = new Xof_meta_thumb[len];
|
||||
Int_ary_parser parser = new Int_ary_parser();
|
||||
for (int i = 0; i < len; i++) {
|
||||
int[] size = parser.Parse_ary(ary[i], Byte_ascii.Comma);
|
||||
rv[i] = new Xof_meta_thumb().Width_(size[0]).Height_(size[1]).Exists_y_();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Xof_file_regy_fxt tst_Save(String url_str, String... expd_ary) {
|
||||
regy_mgr.Save();
|
||||
Tfds.Eq_ary_str(expd_ary, Io_mgr.Instance.LoadFilStr_args(Io_url_.new_fil_(url_str)).ExecAsStrAryLnx());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +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.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
public class Xof_meta_thumb_parser_tst {
|
||||
Xof_meta_thumb_parser parser = new Xof_meta_thumb_parser();
|
||||
@Test public void Exists_y() {Tst_parse("1?45,40", itm_y_(45, 40));}
|
||||
@Test public void Exists_n() {Tst_parse("0?45,40", itm_n_(45, 40));}
|
||||
@Test public void Many() {Tst_parse("1?45,40;0?90,80", itm_y_(45, 40), itm_n_(90, 80));}
|
||||
@Test public void Seek() {Tst_parse("1?45,40@2,3,4", itm_y_(45, 40, 2, 3, 4));}
|
||||
private void Tst_parse(String raw_str, Xof_meta_thumb... expd) {
|
||||
byte[] raw = Bry_.new_a7(raw_str);
|
||||
parser.Parse_ary(raw, 0, raw.length);
|
||||
Tfds.Eq_str_lines(Xto_str(expd, 0, expd.length), Xto_str(parser.Ary(), 0, parser.Len()));
|
||||
}
|
||||
String Xto_str(Xof_meta_thumb[] ary, int bgn, int end) {
|
||||
for (int i = bgn; i < end; i++) {
|
||||
Xof_meta_thumb itm = ary[i];
|
||||
sb .Add(itm.Exists()).Add(":")
|
||||
.Add(itm.Width()).Add(",")
|
||||
.Add(itm.Height());
|
||||
int seeks_len = itm.Seeks().length;
|
||||
for (int j = 0; j < seeks_len; j++) {
|
||||
int seek = itm.Seeks()[j];
|
||||
sb.Add(i == 0 ? "@" : ",");
|
||||
sb.Add(seek);
|
||||
}
|
||||
sb.Add_char_nl();
|
||||
}
|
||||
return sb.To_str_and_clear();
|
||||
} String_bldr sb = String_bldr_.new_();
|
||||
// Xof_meta_img_chkr img_(int w, int h, params int[] seeks) {return new Xof_meta_img_chkr().Width_(w).Height_(h).Seeks_(seeks);}
|
||||
Xof_meta_thumb itm_y_(int w, int h, int... seeks) {return new Xof_meta_thumb(Xof_meta_itm.Exists_y, w, h, seeks);}
|
||||
Xof_meta_thumb itm_n_(int w, int h, int... seeks) {return new Xof_meta_thumb(Xof_meta_itm.Exists_n, w, h, seeks);}
|
||||
}
|
||||
@@ -1,30 +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.xowa.wikis.tdbs.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Xos_url_gen_tst {
|
||||
@Test public void Url_gen() {
|
||||
tst_url_gen("mem/root/", 0, "mem/root/00/00/00/00/0000000000.csv");
|
||||
tst_url_gen("mem/root/", 99, "mem/root/00/00/00/00/0000000099.csv");
|
||||
tst_url_gen("mem/root/", 1234567890, "mem/root/12/34/56/78/1234567890.csv");
|
||||
}
|
||||
private void tst_url_gen(String root_str, int idx, String expd) {
|
||||
Io_url root = Io_url_.mem_fil_(root_str);
|
||||
Io_url actl_url = Xos_url_gen.bld_fil_(root, idx, Bry_.new_a7(".csv"));
|
||||
Tfds.Eq(expd, actl_url.Xto_api());
|
||||
}
|
||||
}
|
||||
@@ -1,116 +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.xowa.wikis.tdbs.xdats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*; import gplx.core.strings.*; import gplx.xowa.wikis.tdbs.hives.*;
|
||||
public class Xob_xdat_file_tst {
|
||||
@Test public void Find() {
|
||||
Xob_xdat_file rdr = rdr_("!!!!%|!!!!%|!!!!%|!!!!%|!!!!%|", "0|b", "1|d", "2|f", "3|h", "4|j");
|
||||
tst_ReadAt(rdr, 0, "0|b");
|
||||
tst_ReadAt(rdr, 1, "1|d");
|
||||
tst_ReadAt(rdr, 2, "2|f");
|
||||
tst_ReadAt(rdr, 3, "3|h");
|
||||
tst_ReadAt(rdr, 4, "4|j");
|
||||
tst_Find(rdr, "b", 0, false);
|
||||
tst_Find(rdr, "j", 4, false);
|
||||
tst_Find(rdr, "a", 0, false);
|
||||
tst_Find(rdr, "c", 1, false);
|
||||
tst_Find(rdr, "k", 4, false);
|
||||
}
|
||||
@Test public void Update() {
|
||||
Xob_xdat_file rdr = rdr_("!!!!%|!!!!%|!!!!%|!!!!%|!!!!%|", "0|b", "1|d", "2|f", "3|h", "4|j");
|
||||
tst_Update(rdr, 3, "3|h1\n", String_.Concat_lines_nl_skip_last
|
||||
( "!!!!%|!!!!%|!!!!%|!!!!&|!!!!%|"
|
||||
, "0|b"
|
||||
, "1|d"
|
||||
, "2|f"
|
||||
, "3|h1"
|
||||
, "4|j"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Insert() {
|
||||
Xob_xdat_file rdr = rdr_("!!!!%|!!!!%|!!!!%|!!!!%|!!!!%|", "0|b", "1|d", "2|f", "3|h", "4|j");
|
||||
tst_Insert(rdr, "5|k\n", String_.Concat_lines_nl_skip_last
|
||||
( "!!!!%|!!!!%|!!!!%|!!!!%|!!!!%|!!!!%|"
|
||||
, "0|b"
|
||||
, "1|d"
|
||||
, "2|f"
|
||||
, "3|h"
|
||||
, "4|j"
|
||||
, "5|k"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Sort() {
|
||||
Xob_xdat_file rdr = rdr_("!!!!%|!!!!%|!!!!%|!!!!%|!!!!%|", "4|j", "2|f", "0|b", "1|d", "3|h");
|
||||
Bry_comparer_bgn_eos comparer = new Bry_comparer_bgn_eos(2);
|
||||
tst_Sort(rdr, comparer, String_.Concat_lines_nl_skip_last
|
||||
( "!!!!%|!!!!%|!!!!%|!!!!%|!!!!%|"
|
||||
, "0|b"
|
||||
, "1|d"
|
||||
, "2|f"
|
||||
, "3|h"
|
||||
, "4|j"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Rebuild_header() {
|
||||
String orig = String_.Concat_lines_nl("" , "4|j", "2|f", "0|b", "1|d", "3|h");
|
||||
String expd = String_.Concat_lines_nl("!!!!%|!!!!%|!!!!%|!!!!%|!!!!%|" , "4|j", "2|f", "0|b", "1|d", "3|h");
|
||||
Rebuild_header_tst(orig, expd);
|
||||
}
|
||||
private void Rebuild_header_tst(String orig, String expd) {
|
||||
Tfds.Eq_str_lines(expd, String_.new_a7(Xob_xdat_file.Rebuid_header(Bry_.new_a7(orig), Bry_.new_a7("\n"))));
|
||||
}
|
||||
Bry_bfr tmp = Bry_bfr_.New();
|
||||
private void tst_Sort(Xob_xdat_file rdr, gplx.core.lists.ComparerAble comparer, String expd) {
|
||||
rdr.Sort(tmp, comparer);
|
||||
Chk_file(rdr, expd);
|
||||
}
|
||||
private void tst_Insert(Xob_xdat_file rdr, String new_val, String expd) {
|
||||
rdr.Insert(tmp, Bry_.new_u8(new_val));
|
||||
Chk_file(rdr, expd);
|
||||
}
|
||||
private void tst_Update(Xob_xdat_file rdr, int idx, String new_val, String expd) {
|
||||
Xob_xdat_itm itm = new Xob_xdat_itm();
|
||||
rdr.GetAt(itm, idx);
|
||||
rdr.Update(tmp, itm, Bry_.new_u8(new_val));
|
||||
Chk_file(rdr, expd);
|
||||
}
|
||||
private void Chk_file(Xob_xdat_file rdr, String expd) {
|
||||
Io_url url = Io_url_.new_fil_("mem/test.xdat");
|
||||
rdr.Save(url);
|
||||
String actl = Io_mgr.Instance.LoadFilStr(url);
|
||||
Tfds.Eq_str_lines(expd, actl);
|
||||
}
|
||||
private void tst_Find(Xob_xdat_file rdr, String find, int expd, boolean exact) {
|
||||
rdr.Find(itm, Bry_.new_u8(find), 2, Byte_ascii.Nl, exact);
|
||||
int id = Bry_.To_int_or(Bry_.Mid(itm.Itm_bry(), 0, 1), -1);
|
||||
Tfds.Eq(expd, id);
|
||||
}
|
||||
private void tst_ReadAt(Xob_xdat_file rdr, int i, String expd) {rdr.GetAt(itm, i); Tfds.Eq(expd, String_.new_u8(itm.Itm_bry()));}
|
||||
Xob_xdat_itm itm = new Xob_xdat_itm();
|
||||
Xob_xdat_file rdr_(String... lines) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
int len = lines.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String line = lines[i];
|
||||
sb.Add(line).Add_char_nl();
|
||||
}
|
||||
byte[] bry = Bry_.new_u8(sb.To_str());
|
||||
return new Xob_xdat_file().Parse(bry, bry.length, Io_url_.Empty);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +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.xowa.wikis.tdbs.xdats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*;
|
||||
public class Xob_xdat_file_wtr_tst {
|
||||
@Test public void Write() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
Io_url dir = Io_url_.mem_dir_("mem/dir");
|
||||
Xob_xdat_file_wtr wtr = Xob_xdat_file_wtr.new_file_(1000, dir);
|
||||
tst_Write(wtr, "<1", "<1");
|
||||
tst_Write(wtr, ">a", "<1>a");
|
||||
tst_Write(wtr, ">b", "<1>a>b");
|
||||
tst_Add_idx(wtr, 7);
|
||||
wtr.Bfr().Add(Bry_.new_a7("<2>b>cc"));
|
||||
tst_Add_idx(wtr, 15);
|
||||
wtr.Bfr().Add(Bry_.new_a7("<3>c>dd"));
|
||||
tst_Add_idx(wtr, 23);
|
||||
tst_Flush(wtr, String_.Concat
|
||||
( "!!!!(|!!!!)|!!!!)|\n"
|
||||
, "<1>a>b\n"
|
||||
, "<2>b>cc\n"
|
||||
, "<3>c>dd\n"
|
||||
));
|
||||
}
|
||||
private void tst_Write(Xob_xdat_file_wtr wtr, String val, String expd) {
|
||||
wtr.Bfr().Add(Bry_.new_u8(val));
|
||||
Tfds.Eq(expd, String_.new_u8(wtr.Bfr().Bfr(), 0, wtr.Bfr().Len()));
|
||||
}
|
||||
private void tst_Add_idx(Xob_xdat_file_wtr wtr, int expd) {
|
||||
wtr.Add_idx(Byte_ascii.Nl);
|
||||
Tfds.Eq(expd, wtr.Idx()[wtr.Idx_pos() - 1]);
|
||||
}
|
||||
private void tst_Flush(Xob_xdat_file_wtr wtr, String expd) {
|
||||
Io_url url = wtr.Fil_url();
|
||||
wtr.Flush(Gfo_usr_dlg_.Test());
|
||||
String actl = Io_mgr.Instance.LoadFilStr(url);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xoa_ttl__err_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xoa_ttl_fxt fxt = new Xoa_ttl_fxt();
|
||||
@Test public void Invalid__angle() {fxt.Parse("<!--a").Test__null();}
|
||||
@Test public void Invalid__brace() {fxt.Parse("[[a]]").Test__null();}
|
||||
@Test public void Invalid__curly() {fxt.Parse("{{a}}").Test__null();}
|
||||
@Test public void Colon_is_last() {fxt.Parse("Help:").Test__null();}
|
||||
@Test public void Len_max() {fxt.Parse(String_.Repeat("A", 512)).Test__page_txt(String_.Repeat("A", 512));}
|
||||
@Test public void Len_0() {
|
||||
fxt.Parse("").Test__null();
|
||||
fxt.Parse(" ").Test__null();
|
||||
fxt.Parse("_").Test__null();
|
||||
fxt.Parse("_ _").Test__null();
|
||||
}
|
||||
}
|
||||
@@ -1,33 +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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.tests.*;
|
||||
public class Xoa_ttl_fxt {
|
||||
private Xowe_wiki wiki;
|
||||
private String raw;
|
||||
private Xoa_ttl ttl;
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
public Xoa_ttl_fxt Parse(String raw) {
|
||||
this.raw = raw;
|
||||
this.ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(raw));
|
||||
return this;
|
||||
}
|
||||
public void Test__null() {Gftest.Eq__bool_y(ttl == null, "ttl is not null", "raw", raw);}
|
||||
public void Test__page_txt(String expd) {Gftest.Eq__str(expd, String_.new_u8(ttl.Page_txt()), "page_txt", "raw", raw);}
|
||||
}
|
||||
@@ -1,41 +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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_ttl__anchor_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Page__main() {fxt.Init_ttl("a#b") .Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();}
|
||||
@Test public void Page__ns() {fxt.Init_ttl("Help:A#B") .Expd_full_txt("Help:A").Expd_ns_id(Xow_ns_.Tid__help).Expd_page_txt("A").Expd_anch_txt("B").Test();}
|
||||
@Test public void Pageless__main() {fxt.Init_ttl("#a") .Expd_full_txt("").Expd_page_txt("").Expd_anch_txt("a").Test();}
|
||||
@Test public void Xwiki() { // PURPOSE: :#batch:Main Page causes ttl to fail b/c # is treated as anchor; DATE:2013-01-02
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("#batch"), Bry_.new_a7("none"));
|
||||
fxt.Init_ttl(":#batch:Main Page").Expd_full_txt("Main Page").Test();
|
||||
}
|
||||
@Test public void Anch_has_angles() {// PURPOSE: angles in anchor should be encoded; DATE: 2013-01-23
|
||||
fxt.Init_ttl("A#b<c>d").Expd_full_txt("A").Expd_anch_txt("b.3Cc.3Ed").Test();
|
||||
}
|
||||
@Test public void Anch_has_slash() { // PURPOSE: slash in anchor was being treated as a subpage; DATE:2014-01-14
|
||||
fxt.Init_ttl("A#b/c").Expd_full_txt("A").Expd_anch_txt("b/c").Expd_leaf_txt("A").Test(); // NOTE: Leaf_txt should be Page_txt; used to fail
|
||||
}
|
||||
@Test public void Decode_ncr() { // PURPOSE: convert # to #; PAGE:en.s:The_English_Constitution_(1894) DATE:2014-09-07
|
||||
fxt.Init_ttl("A#b").Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();
|
||||
fxt.Init_ttl("A#b").Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();
|
||||
fxt.Init_ttl("A$b").Expd_full_txt("A$b").Expd_page_txt("A$b").Expd_anch_txt("").Test();
|
||||
}
|
||||
@Test public void Multiple() {// PURPOSE: handle multiple anchors; en.w:Grand_Central_Terminal; DATE:2015-12-31
|
||||
fxt.Init_ttl("A#b#c").Expd_page_txt("A").Expd_anch_txt("b#c").Test();
|
||||
}
|
||||
}
|
||||
@@ -1,59 +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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_ttl__basic_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Ns() {fxt.Init_ttl("Help:Test") .Expd_ns_id(Xow_ns_.Tid__help).Expd_page_txt("Test").Test();}
|
||||
@Test public void Ns_false() {fxt.Init_ttl("Helpx:Test") .Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Helpx:Test").Test();}
|
||||
@Test public void Ns_multiple() {fxt.Init_ttl("Help:Talk:test") .Expd_page_txt("Talk:test").Test();}
|
||||
@Test public void Full_txt() {fxt.Init_ttl("Help:a & b") .Expd_full_txt("Help:A & b").Test();} // preserve
|
||||
@Test public void Full_url() {fxt.Init_ttl("Help:a & b") .Expd_full_url("Help:A_%26_b").Test();} // escape
|
||||
@Test public void Page_txt() {fxt.Init_ttl("a & b") .Expd_page_txt("A & b").Test();} // preserve;
|
||||
@Test public void Page_txt_underline() {fxt.Init_ttl("a_b") .Expd_page_txt("A b").Expd_page_url("A_b").Test();} // NOTE: raw is "a_b" but txt is "a b"
|
||||
@Test public void Page_url() {fxt.Init_ttl("a & b") .Expd_page_url("A_%26_b").Test();} // escape
|
||||
@Test public void Page_url_w_ns() {fxt.Init_ttl("Help:a & b") .Expd_page_url("A_%26_b").Test();} // remove ns
|
||||
@Test public void Page_url_symbols() {fxt.Init_ttl(";:@&=$ -_.+!*'(),/").Expd_page_url(";:@%26%3D$_-_.%2B!*%27(),/").Test();}// symbols + space
|
||||
@Test public void Leaf_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_leaf_txt("leaf").Test();}
|
||||
@Test public void Leaf_txt_slash_is_last() {fxt.Init_ttl("root/mid/leaf/") .Expd_leaf_txt("").Test();}
|
||||
@Test public void Leaf_txt_no_slash() {fxt.Init_ttl("root") .Expd_leaf_txt("Root").Test();}
|
||||
@Test public void Leaf_url() {fxt.Init_ttl("root/mid/a & b") .Expd_leaf_url("a_%26_b").Test();} // NOTE: a not capitalized ("root" would be)
|
||||
@Test public void Base_txt() {fxt.Init_ttl("a & b/mid/leaf") .Expd_base_txt("A & b/mid").Test();}
|
||||
@Test public void Base_url() {fxt.Init_ttl("a & b/mid/leaf") .Expd_base_url("A_%26_b/mid").Test();}
|
||||
@Test public void Root_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_root_txt("Root").Test();}
|
||||
@Test public void Rest_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_rest_txt("mid/leaf").Test();}
|
||||
@Test public void Talk_txt() {fxt.Init_ttl("Help:test") .Expd_talk_txt("Help talk:Test").Test();}
|
||||
@Test public void Talk_txt_identity() {fxt.Init_ttl("Help talk:test") .Expd_talk_txt("Help talk:Test").Test();}
|
||||
@Test public void Talk_url() {fxt.Init_ttl("Help:a & b") .Expd_talk_url("Help_talk:A_%26_b").Test();}
|
||||
@Test public void Talk_txt_main() {fxt.Init_ttl("test") .Expd_talk_txt("Talk:Test").Test();}
|
||||
@Test public void Subj_txt() {fxt.Init_ttl("Help talk:test") .Expd_subj_txt("Help:Test").Test();}
|
||||
@Test public void Subj_txt_identity() {fxt.Init_ttl("Help:test") .Expd_subj_txt("Help:Test").Test();}
|
||||
@Test public void Subj_url() {fxt.Init_ttl("Help talk:a & b").Expd_subj_url("Help:A_%26_b").Test();}
|
||||
@Test public void Subj_txt_main() {fxt.Init_ttl("Talk:test") .Expd_subj_txt("Test").Test();}
|
||||
@Test public void Force_literal_link_y() {fxt.Init_ttl(":Help:test") .Expd_force_literal_link(1).Expd_page_txt("Test").Test();}
|
||||
@Test public void Force_literal_link_n() {fxt.Init_ttl( "Help:test") .Expd_force_literal_link(0).Expd_page_txt("Test").Test();}
|
||||
@Test public void Force_literal_link_y_2() {fxt.Init_ttl("::Help:test") .Expd_force_literal_link(1).Expd_page_txt("Test").Test();} // PURPOSE: 2nd initial colon should be ignored; EX:mw:MediaWiki; [[::MediaWiki]]; DATE:2013-12-14
|
||||
@Test public void All_page() {fxt.Init_ttl("test") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Test").Expd_leaf_txt("Test").Expd_anch_txt("").Test();}
|
||||
@Test public void All_ns() {fxt.Init_ttl("Help:test") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Tid__help).Expd_page_txt("Test").Expd_leaf_txt("Test").Expd_anch_txt("").Test();}
|
||||
@Test public void Special() {fxt.Init_ttl("Special:Random").Expd_ns_id(Xow_ns_.Tid__special).Expd_page_txt("Random").Test();}
|
||||
@Test public void Special_xowa() {fxt.Init_ttl("Special:xowa/Search/Ttl").Expd_ns_id(Xow_ns_.Tid__special).Expd_page_txt("Xowa/Search/Ttl").Test();}
|
||||
@Test public void Comment() {fxt.Init_ttl("Ab<!--b-->").Expd_page_txt("Ab").Test();}
|
||||
@Test public void Comment_eos() {fxt.Init_ttl("Ab<!--b--").Expd_page_txt(null).Test();}
|
||||
@Test public void Ns_case() {// PURPOSE: lowercase ns should be converted to proper case; EX: fr.w:Project:Sandbox (redirect link); en.w:Periclimenes imperator; [[commons:category:Periclimenes imperator|''Periclimenes imperator'']]; DATE: 2013-01-27
|
||||
fxt.Init_ttl("help:A").Expd_full_txt("Help:A").Test();
|
||||
fxt.Init_ttl("help talk:A").Expd_full_txt("Help talk:A").Test();
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_ttl__html_entity_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Eacute() {fxt.Init_ttl("é").Expd_page_txt("é").Test();} //É
|
||||
@Test public void Amp_at_end() {fxt.Init_ttl("Bisc &").Expd_page_txt("Bisc &").Test();}
|
||||
@Test public void Ncr_dec() {fxt.Init_ttl("Ab").Expd_page_txt("Ab").Test();}
|
||||
@Test public void Ncr_hex() {fxt.Init_ttl("Ab").Expd_page_txt("Ab").Test();}
|
||||
// @Test public void Ncr_hex_ns() {fxt.Init_ttl("Help:A").Expd_ns_id(Xow_ns_.Tid__help).Expd_page_txt("A").Test();}
|
||||
@Test public void Nbsp() {fxt.Init_ttl("A b").Expd_page_txt("A b").Test();} // NOTE:   must convert to space; EX:w:United States [[Image:Dust Bowl - Dallas, South Dakota 1936.jpg|220px|alt=]]
|
||||
@Test public void Amp() {fxt.Init_ttl("A&b").Expd_page_txt("A&b").Test();} // PURPOSE: A&B -> A&B; PAGE:en.w:Amadou Bagayoko?redirect=n; DATE:2014-09-23
|
||||
}
|
||||
@@ -1,52 +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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
public class Xow_ttl__i18n_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Bidi() { // PURPOSE: handle bidirectional characters; DATE:2015-07-28; DATE:2015-08-24
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0x8E)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0x8F)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAA)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAB)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAC)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAD)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAE)) + "B").Expd_page_txt("AB").Test();
|
||||
}
|
||||
@Test public void Multi_byte_char2() { // PURPOSE: multi-byte HTML entity causes array out of index error; EX: w:List_of_Unicode_characters; DATE:2013-12-25
|
||||
fxt.Init_ttl("ⱥ").Expd_full_txt("ⱥ").Test();
|
||||
}
|
||||
@Test public void First_char_is_multi_byte() { // PURPOSE: if multi-byte, uppercasing is complicated; EX: µ -> Μ; DATE:2013-11-27
|
||||
fxt.Wiki().Lang().Case_mgr_u8_();
|
||||
fxt.Init_ttl("µ").Expd_full_txt("Μ").Test(); // NOTE: this is not an ASCII "Μ"
|
||||
fxt.Init_ttl("µab").Expd_full_txt("Μab").Test(); // check that rest of title works fine
|
||||
fxt.Init_ttl("Help:µab").Expd_full_txt("Help:Μab").Test(); // check ns
|
||||
fxt.Init_ttl("Ι").Expd_full_txt("Ι").Test(); // check that Ι is not upper-cased to COMBINING GREEK YPOGEGRAMMENI; DATE:2014-02-24
|
||||
}
|
||||
@Test public void First_char_is_multi_byte_assymetrical() { // PURPOSE: test multi-byte asymmetry (lc is 3 bytes; uc is 2 bytes)
|
||||
fxt.Wiki().Lang().Case_mgr_u8_();
|
||||
fxt.Init_ttl("ⱥ").Expd_full_txt("Ⱥ").Test();
|
||||
fxt.Init_ttl("ⱥab").Expd_full_txt("Ⱥab").Test(); // check that rest of title works fine
|
||||
fxt.Init_ttl("Help:ⱥab").Expd_full_txt("Help:Ⱥab").Test(); // check ns
|
||||
}
|
||||
@Test public void Ws__basic() { // PURPOSE: replace other whitespace with underscore; PAGE:ja.w:Template:Location_map_USA New_York; DATE:2015-07-28
|
||||
fxt.Init_ttl("A B").Expd_full_txt("A B").Test();
|
||||
}
|
||||
@Test public void Ws__many() { // PURPOSE: replace other whitespace with underscore; PAGE:ja.w:Template:Location_map_USA New_York; DATE:2015-07-28
|
||||
fxt.Init_ttl("A\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000B").Expd_full_txt("A B").Test();
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_ttl__qarg_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Base_txt_wo_qarg() {
|
||||
fxt.Init_ttl("Special:Search/A?b=c").Expd_base_txt_wo_qarg("Search").Expd_qarg_txt("b=c").Test();
|
||||
}
|
||||
@Test public void Leaf_txt_wo_qarg() {
|
||||
fxt.Init_ttl("Special:Search/A?b=c").Expd_leaf_txt_wo_qarg("A").Expd_qarg_txt("b=c").Test();
|
||||
}
|
||||
@Test public void Ttl_has_question_mark() { // PURPOSE: handle titles that have both question mark and leaf; PAGE:en.w:Portal:Organized_Labour/Did_You_Know?/1 DATE:2014-06-08
|
||||
fxt.Init_ttl("A/B?/1").Expd_page_txt("A/B?/1").Expd_base_txt("A/B?").Expd_leaf_txt("1").Expd_leaf_txt_wo_qarg("1").Expd_qarg_txt(null).Test();
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_ttl__ws_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Space() {fxt.Init_ttl(" a b ") .Expd_page_url("A_b").Expd_page_txt("A b").Test();}
|
||||
@Test public void Space_w_ns() {fxt.Init_ttl(" Help : a b ") .Expd_page_url("A_b").Expd_page_txt("A b").Test();}
|
||||
@Test public void Nl() {fxt.Init_ttl("\n\na\n\n") .Expd_page_txt("A").Test();}
|
||||
@Test public void Nl_end() {fxt.Init_ttl("a\nb") .Expd_page_txt("A b").Test();}
|
||||
@Test public void Tab() {fxt.Init_ttl("\ta\t") .Expd_page_txt("A").Test();}
|
||||
@Test public void Nbsp() {fxt.Init_ttl("A bc") .Expd_page_url("A_bc").Expd_page_txt("A bc").Test();} // PURPOSE:convert " " to " "; DATE:2014-09-25
|
||||
@Test public void Nbsp_mix() {fxt.Init_ttl("A bc") .Expd_page_url("A_bc").Expd_page_txt("A bc").Test();} // PURPOSE:convert multiple " " to " "; PAGE:en.w:Greek_government-debt_crisis; DATE:2014-09-25
|
||||
}
|
||||
@@ -1,40 +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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_ttl__xwik_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Known() {fxt.Init_ttl("fr:a") .Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("a").Test();}
|
||||
@Test public void Known_ns() {fxt.Init_ttl("fr:Help:a") .Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Tid__main).Expd_full_txt("Help:a").Expd_page_txt("Help:a").Test();} // NOTE: Page is "Help:a" b/c ns are unknowable in foreign wiki
|
||||
@Test public void Unknown() {fxt.Init_ttl("frx:a") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Frx:a").Test();}
|
||||
@Test public void Unknown_ns() {fxt.Init_ttl("frx:Help:a") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Frx:Help:a").Test();}
|
||||
@Test public void Known_ns_leaf_anch() {fxt.Init_ttl("fr:Help:a/b/c#d").Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Help:a/b/c").Expd_leaf_txt("c").Expd_anch_txt("d").Expd_full_txt("Help:a/b/c").Test();}
|
||||
@Test public void Colon_is_last() {
|
||||
fxt.Init_ttl("fr:Help:").Expd_xwik_txt("fr").Expd_page_txt("Help:").Test();
|
||||
fxt.Init_ttl("fr:_ _").Expd_xwik_txt("fr").Expd_page_txt("").Test(); // NOTE: fr:_ _ is invalid (resolves to "fr:");
|
||||
fxt.Init_ttl("fr:Help:_ _").Expd_xwik_txt("fr").Expd_page_txt("Help:").Test();
|
||||
}
|
||||
@Test public void Colon_multiple() {
|
||||
fxt.Init_ttl("fr::Help:Test").Expd_xwik_txt("fr").Expd_page_txt(":Help:Test").Test();
|
||||
fxt.Init_ttl("fr::Test").Expd_xwik_txt("fr").Expd_page_txt(":Test").Test();
|
||||
fxt.Init_ttl(":fr:Test").Expd_xwik_txt("fr").Expd_page_txt("Test").Expd_force_literal_link(1).Test();
|
||||
fxt.Init_ttl(":::fr:Test").Expd_xwik_txt("").Expd_page_txt(":fr:Test").Expd_force_literal_link(1).Test();
|
||||
}
|
||||
@Test public void Ns_should_precede_xwiki() {// PURPOSE: the "Wikipedia" in "Wikipedia:Main page" should be interpreted as Srch_rslt_cbk, not an alias
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("Wikipedia"), Bry_.new_a7("en.wikipedia.org"));
|
||||
fxt.Init_ttl("Wikipedia:Test").Expd_xwik_txt("").Expd_full_txt("Wikipedia:Test").Test();
|
||||
}
|
||||
}
|
||||
@@ -1,87 +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.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.log_msgs.*;
|
||||
class Xow_ttl_fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
public Xow_ttl_fxt Init_ttl(String raw) {test_raw = raw; return this;} private String test_raw = "";
|
||||
public Xow_ttl_fxt Expd_ns_id(int v) {expd_ns_id = v; return this;} private int expd_ns_id = Int_.Min_value;
|
||||
public Xow_ttl_fxt Expd_page_txt(String v) {expd_page_txt = v; return this;} private String expd_page_txt;
|
||||
public Xow_ttl_fxt Expd_page_url(String v) {expd_page_url = v; return this;} private String expd_page_url;
|
||||
public Xow_ttl_fxt Expd_page_db (String v) {expd_page_db = v; return this;} private String expd_page_db;
|
||||
public Xow_ttl_fxt Expd_full_txt(String v) {expd_full_txt = v; return this;} private String expd_full_txt;
|
||||
public Xow_ttl_fxt Expd_full_url(String v) {expd_full_url = v; return this;} private String expd_full_url;
|
||||
public Xow_ttl_fxt Expd_leaf_txt(String v) {expd_leaf_txt = v; return this;} private String expd_leaf_txt;
|
||||
public Xow_ttl_fxt Expd_leaf_url(String v) {expd_leaf_url = v; return this;} private String expd_leaf_url;
|
||||
public Xow_ttl_fxt Expd_base_txt(String v) {expd_base_txt = v; return this;} private String expd_base_txt;
|
||||
public Xow_ttl_fxt Expd_base_url(String v) {expd_base_url = v; return this;} private String expd_base_url;
|
||||
public Xow_ttl_fxt Expd_root_txt(String v) {expd_root_txt = v; return this;} private String expd_root_txt;
|
||||
public Xow_ttl_fxt Expd_rest_txt(String v) {expd_rest_txt = v; return this;} private String expd_rest_txt;
|
||||
public Xow_ttl_fxt Expd_talk_txt(String v) {expd_talk_txt = v; return this;} private String expd_talk_txt;
|
||||
public Xow_ttl_fxt Expd_talk_url(String v) {expd_talk_url = v; return this;} private String expd_talk_url;
|
||||
public Xow_ttl_fxt Expd_subj_txt(String v) {expd_subj_txt = v; return this;} private String expd_subj_txt;
|
||||
public Xow_ttl_fxt Expd_subj_url(String v) {expd_subj_url = v; return this;} private String expd_subj_url;
|
||||
public Xow_ttl_fxt Expd_qarg_txt(String v) {expd_qarg_txt = v; return this;} private String expd_qarg_txt;
|
||||
public Xow_ttl_fxt Expd_xwik_txt(String v) {expd_xwik_txt = v; return this;} private String expd_xwik_txt;
|
||||
public Xow_ttl_fxt Expd_anch_txt(String v) {expd_anch_txt = v; return this;} private String expd_anch_txt;
|
||||
public Xow_ttl_fxt Expd_base_txt_wo_qarg(String v) {expd_base_txt_wo_qarg = v; return this;} private String expd_base_txt_wo_qarg;
|
||||
public Xow_ttl_fxt Expd_leaf_txt_wo_qarg(String v) {expd_leaf_txt_wo_qarg = v; return this;} private String expd_leaf_txt_wo_qarg;
|
||||
public Xow_ttl_fxt Expd_force_literal_link(int v) {expd_force_literal_link = v; return this;} private int expd_force_literal_link = -1;
|
||||
public Xow_ttl_fxt Expd_err(Gfo_msg_itm v) {expd_err = v; return this;} private Gfo_msg_itm expd_err;
|
||||
public Xowe_wiki Wiki() {return fxt.Wiki();}
|
||||
public void Reset() {
|
||||
fxt.Reset();
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("fr"), Bry_.new_a7("fr.wikipedia.org"));
|
||||
test_raw = "Test page";
|
||||
expd_ns_id = Int_.Min_value;
|
||||
expd_xwik_txt = expd_full_txt = expd_full_url = expd_page_txt = expd_page_url = expd_leaf_txt = expd_leaf_url = expd_base_txt = expd_base_url
|
||||
= expd_root_txt = expd_rest_txt = expd_talk_txt = expd_talk_url = expd_subj_txt = expd_subj_url = expd_anch_txt
|
||||
= expd_base_txt_wo_qarg = expd_leaf_txt_wo_qarg = expd_qarg_txt = null;
|
||||
expd_err = null;
|
||||
expd_force_literal_link = -1;
|
||||
fxt.Log_clear();
|
||||
}
|
||||
public void Test() {
|
||||
Xoa_ttl actl = Xoa_ttl.Parse(fxt.Wiki(), Bry_.new_u8(test_raw));
|
||||
if (expd_err == null) {
|
||||
if (expd_ns_id != Int_.Min_value) Tfds.Eq(expd_ns_id, actl.Ns().Id(), "ns");
|
||||
if (expd_xwik_txt != null) Tfds.Eq(expd_xwik_txt, String_.new_u8(actl.Wik_txt()), "Wiki");
|
||||
if (expd_page_txt != null) Tfds.Eq(expd_page_txt, String_.new_u8(actl.Page_txt()), "Page_txt");
|
||||
if (expd_page_url != null) Tfds.Eq(expd_page_url, String_.new_u8(actl.Page_url()), "Page_url");
|
||||
if (expd_page_db != null) Tfds.Eq(expd_page_db , String_.new_u8(actl.Page_db()) , "Page_db");
|
||||
if (expd_full_txt != null) Tfds.Eq(expd_full_txt, String_.new_u8(actl.Full_txt_w_ttl_case()), "Full_txt");
|
||||
if (expd_full_url != null) Tfds.Eq(expd_full_url, String_.new_u8(actl.Full_url()), "Full_url");
|
||||
if (expd_leaf_txt != null) Tfds.Eq(expd_leaf_txt, String_.new_u8(actl.Leaf_txt()), "Leaf_txt");
|
||||
if (expd_leaf_url != null) Tfds.Eq(expd_leaf_url, String_.new_u8(actl.Leaf_url()), "Leaf_url");
|
||||
if (expd_base_txt != null) Tfds.Eq(expd_base_txt, String_.new_u8(actl.Base_txt()), "Base_txt");
|
||||
if (expd_base_url != null) Tfds.Eq(expd_base_url, String_.new_u8(actl.Base_url()), "Base_url");
|
||||
if (expd_root_txt != null) Tfds.Eq(expd_root_txt, String_.new_u8(actl.Root_txt()), "Root_txt");
|
||||
if (expd_rest_txt != null) Tfds.Eq(expd_rest_txt, String_.new_u8(actl.Rest_txt()), "Rest_txt");
|
||||
if (expd_talk_txt != null) Tfds.Eq(expd_talk_txt, String_.new_u8(actl.Talk_txt()), "Talk_txt");
|
||||
if (expd_talk_url != null) Tfds.Eq(expd_talk_url, String_.new_u8(actl.Talk_url()), "Talk_url");
|
||||
if (expd_subj_txt != null) Tfds.Eq(expd_subj_txt, String_.new_u8(actl.Subj_txt()), "Subj_txt");
|
||||
if (expd_subj_url != null) Tfds.Eq(expd_subj_url, String_.new_u8(actl.Subj_url()), "Subj_url");
|
||||
if (expd_anch_txt != null) Tfds.Eq(expd_anch_txt, String_.new_u8(actl.Anch_txt()), "Anch_txt");
|
||||
if (expd_qarg_txt != null) Tfds.Eq(expd_qarg_txt, String_.new_u8(actl.Qarg_txt()), "Qarg_txt");
|
||||
if (expd_base_txt_wo_qarg != null) Tfds.Eq(expd_base_txt_wo_qarg, String_.new_u8(actl.Base_txt_wo_qarg()), "Expd_base_txt_wo_qarg");
|
||||
if (expd_leaf_txt_wo_qarg != null) Tfds.Eq(expd_leaf_txt_wo_qarg, String_.new_u8(actl.Leaf_txt_wo_qarg()), "Expd_leaf_txt_wo_qarg");
|
||||
if (expd_force_literal_link != -1) Tfds.Eq(expd_force_literal_link == 1, actl.ForceLiteralLink(), "ForceLiteralLink");
|
||||
}
|
||||
else {
|
||||
Tfds.Eq_ary(String_.Ary(String_.new_u8(expd_err.Owner().Path()) + "." + String_.new_u8(expd_err.Key_bry())), fxt.Log_xtoAry());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +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.xowa.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_tst {
|
||||
private final Xow_xwiki_itm_fxt fxt = new Xow_xwiki_itm_fxt();
|
||||
@Test public void Show_in_sitelangs__basic() { // PURPOSE: basic test for show in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("en", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__lang_like() { // PURPOSE: only consider xwikis with key similar to domain; EX: [[w:A]] in simplewiki; PAGE:Main_Page; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("w", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__same() { // PURPOSE: same wiki should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("en", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia, "en.wikipedia.org", "enwiki"), "en");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__no_url_fmt() { // PURPOSE: xwikis with no format should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("en", "", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__commons() { // PURPOSE: commons should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("c", "commons.wikimedia.org/wiki/{0}", Xol_lang_stub_.Id__intl, Xow_domain_tid_.Tid__commons, "commons.wikimedia.org", "commonswiki"), "en");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__nb() { // PURPOSE: handle special wikis like nb, lzh, simple; EX: [[nb:]] -> no.w; PAGE:nn.w:; DATE:2015-12-04
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("nb", "no.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_no, Xow_domain_tid_.Tid__wikipedia, "no.wikipedia.org", "nbwiki"), "nn");
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("lzh", "zh-classical.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_zh, Xow_domain_tid_.Tid__wikipedia, "zh-classical.wikipedia.org", "lzwwiki"), "zh");
|
||||
}
|
||||
}
|
||||
class Xow_xwiki_itm_fxt {
|
||||
public Xow_xwiki_itm Make__xwiki(String key_bry, String url_fmt, int lang_id, int domain_tid, String domain_bry, String abrv_wm) {
|
||||
return Xow_xwiki_itm.new_(Bry_.new_u8(key_bry), Bry_.new_u8(url_fmt), lang_id, domain_tid, Bry_.new_u8(domain_bry), Bry_.new_u8(abrv_wm));
|
||||
}
|
||||
public void Test__type_is_xwiki_lang(boolean expd, Xow_xwiki_itm xwiki_itm, String cur_lang_key) {
|
||||
Tfds.Eq_bool(expd, xwiki_itm.Show_in_sitelangs(Bry_.new_u8(cur_lang_key)));
|
||||
}
|
||||
}
|
||||
@@ -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.xowa.wikis.xwikis.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_bldr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_xwiki_itm_bldr_fxt fxt = new Xow_xwiki_itm_bldr_fxt();
|
||||
@Test public void Commons() {fxt.Test_bld("commons.wikimedia.org/wiki/$1" , "commons.wikimedia.org" , "commons.wikimedia.org/wiki/~{0}" , Xow_domain_tid_.Tid__commons , Xol_lang_stub_.Id__unknown);}
|
||||
@Test public void Wiktionary() {fxt.Test_bld("fr.wiktionary.org/wiki/$1" , "fr.wiktionary.org" , "fr.wiktionary.org/wiki/~{0}" , Xow_domain_tid_.Tid__wiktionary , Xol_lang_stub_.Id_fr);}
|
||||
@Test public void Lang() {fxt.Test_bld("fr.wikipedia.org/wiki/$1" , "fr.wikipedia.org" , "fr.wikipedia.org/wiki/~{0}" , Xow_domain_tid_.Tid__wikipedia , Xol_lang_stub_.Id_fr);}
|
||||
}
|
||||
class Xow_xwiki_itm_bldr_fxt {
|
||||
private Xow_domain_itm domain_itm;
|
||||
public void Clear() {
|
||||
domain_itm = Xow_domain_itm.new_(Bry_.new_a7("en.wikivoyage.org"), Xow_domain_tid_.Tid__wikivoyage, Xol_lang_itm_.Key_en); // NOTE: use "en.wikivoyage.org" to domain_name; needed for "Related sites"
|
||||
}
|
||||
public void Test_bld(String url, String expd_domain, String expd_url_fmt, int expd_wiki_tid, int expd_lang_tid) {
|
||||
Xow_xwiki_itm itm = Xow_xwiki_itm_bldr.Instance.Bld_mw(domain_itm, domain_itm.Domain_bry(), Bry_.new_u8(url), null);
|
||||
Tfds.Eq(expd_domain , String_.new_u8(itm.Domain_bry()));
|
||||
Tfds.Eq(expd_url_fmt , String_.new_u8(itm.Url_fmt()));
|
||||
Tfds.Eq(expd_wiki_tid , itm.Domain_tid(), "wiki");
|
||||
Tfds.Eq(expd_lang_tid , itm.Lang_id(), "lang");
|
||||
}
|
||||
}
|
||||
@@ -1,95 +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.xowa.wikis.xwikis.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_parser_tst {
|
||||
private final Xow_xwiki_itm_parser_fxt fxt = new Xow_xwiki_itm_parser_fxt();
|
||||
@Test public void Manual() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "0|a|https://a.org/~{0}|A"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a|https://a.org/~{0}|A"
|
||||
));
|
||||
}
|
||||
@Test public void Mw_domain() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "1|w|en.wikipedia.org|Wikipedia"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "w|https://en.wikipedia.org/wiki/~{0}|Wikipedia"
|
||||
));
|
||||
}
|
||||
@Test public void Wm_peer() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt|wiktionary|Wiktionary"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
));
|
||||
}
|
||||
@Test public void Wm_lang() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "3|fr|fr|French"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "fr|https://fr.wikipedia.org/wiki/~{0}|French"
|
||||
));
|
||||
}
|
||||
@Test public void Multiple() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt;wiktionary|wiktionary|Wiktionary"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
, "wiktionary|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
));
|
||||
}
|
||||
@Test public void Default_name() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt|wiktionary|"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|English Wiktionary"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xow_xwiki_itm_parser_fxt {
|
||||
private final Xow_xwiki_itm_parser parser = new Xow_xwiki_itm_parser();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
public Xow_xwiki_itm_parser_fxt() {
|
||||
parser.Init_by_wiki(Xow_domain_itm_.parse(Bry_.new_a7("en.wikipedia.org")));
|
||||
}
|
||||
public void Exec_parse(String raw) {
|
||||
byte[] src = Bry_.new_u8(raw);
|
||||
parser.Load_by_bry(src);
|
||||
}
|
||||
public void Test_parse(String expd) {
|
||||
Tfds.Eq_str_lines(expd, To_str());
|
||||
}
|
||||
private String To_str() {
|
||||
Ordered_hash list = parser.Xwiki_list();
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_xwiki_itm itm = (Xow_xwiki_itm)list.Get_at(i);
|
||||
tmp_bfr.Add(itm.Key_bry()).Add_byte_pipe();
|
||||
tmp_bfr.Add(itm.Url_fmt()).Add_byte_pipe();
|
||||
tmp_bfr.Add(itm.Domain_name()).Add_byte_nl();
|
||||
}
|
||||
list.Clear();
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -1,145 +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.xowa.wikis.xwikis.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.langs.*;
|
||||
public class Xow_xwiki_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_xwiki_mgr_fxt fxt = new Xow_xwiki_mgr_fxt();
|
||||
@Test public void Add_bulk_langs_wiki() {
|
||||
fxt.Init_langs();
|
||||
fxt.Test_add_bulk_langs
|
||||
( fxt.xwiki_("en", "en.wikipedia.org", "https://en.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("de", "de.wikipedia.org", "https://de.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("fr", "fr.wikipedia.org", "https://fr.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("ja", "ja.wikipedia.org", "https://ja.wikipedia.org/wiki/~{0}")
|
||||
);
|
||||
}
|
||||
@Test public void Add_bulk_langs_grp_commons() {
|
||||
fxt.Init_langs();
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_sitelink_mgr(Xow_domain_tid_.Tid__wikipedia);
|
||||
fxt.Tst_itms(fxt.xwiki_("de", "de.wikipedia.org", "https://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "https://fr.wikipedia.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers() {
|
||||
fxt.Init_peers();
|
||||
fxt.Test_add_bulk_peers
|
||||
( fxt.xwiki_("wikt", "en.wiktionary.org"
|
||||
, "https://en.wiktionary.org/wiki/~{0}")
|
||||
, fxt.xwiki_("wiktionary", "en.wiktionary.org"
|
||||
, "https://en.wiktionary.org/wiki/~{0}")
|
||||
, fxt.xwiki_("s", "en.wikisource.org", "https://en.wikisource.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers_skip_self() { // PURPOSE: skip "wikipedia" as alias since "Wikipedia" is Srch_rslt_cbk; needed for titles of "Wikipedia:Main page" (which would otherwise try to go to page "Main Page" in the main names of xwiki "Wikipedia"
|
||||
fxt.Init_peers();
|
||||
fxt.Test_add_bulk_peers
|
||||
( fxt.xwiki_null_("wikipedia")
|
||||
, fxt.xwiki_("w", "en.wikipedia.org", "https://en.wikipedia.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers_tid() { // PURPOSE:wikt should generate wiki_tid of wiktionary, not wikipedia; PAGE:en.s:Main_Page DATE:2014-09-14
|
||||
fxt.Init_wikt ().Test_add_bulk_peers(fxt.xwiki_("wikt", "en.wiktionary.org", "https://en.wiktionary.org/wiki/~{0}"));
|
||||
}
|
||||
// @Test public void Duplicate() { // PURPOSE.FIX: multiple aliases for same domain should only be added once to Get_at's list; DATE:2014-11-07
|
||||
// fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
// ( "0|a1|a.org"
|
||||
// , "0|a2|a.org"
|
||||
// ));
|
||||
// fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
// ( "a1|https://a.org//~{0}"
|
||||
// ));
|
||||
// }
|
||||
}
|
||||
class Xow_xwiki_mgr_fxt {
|
||||
Xow_xwiki_mgr xwiki_mgr; Xoa_lang_mgr lang_mgr; String_bldr sb = String_bldr_.new_(); Xoae_app app; Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
if (xwiki_mgr == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
xwiki_mgr = wiki.Xwiki_mgr();
|
||||
lang_mgr = app.Lang_mgr();
|
||||
}
|
||||
xwiki_mgr.Clear();
|
||||
lang_mgr.Clear();
|
||||
}
|
||||
public Xowe_wiki Wiki() {return wiki;}
|
||||
public Xow_xwiki_itm xwiki_null_(String key) {return Xow_xwiki_itm.new_(Bry_.new_u8(key), Bry_.Empty, Xol_lang_stub_.Id__unknown, Xow_domain_tid_.Tid__other, Bry_.Empty, Bry_.Empty);}
|
||||
public Xow_xwiki_itm xwiki_(String key, String domain_str, String url_fmt) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
|
||||
return Xow_xwiki_itm.new_(Bry_.new_u8(key), Bry_.new_u8(url_fmt), domain.Lang_actl_itm().Id(), domain.Domain_type_id(), domain.Domain_bry(), domain.Abrv_wm());
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_langs() {
|
||||
app.Xwiki_mgr__sitelink_mgr().Parse(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "0|english"
|
||||
, "1|en|English"
|
||||
, "0|europe_west"
|
||||
, "1|fr|French"
|
||||
, "1|de|German"
|
||||
, "0|asia_east"
|
||||
, "1|ja|Japanese"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_peers() {
|
||||
wiki.Xwiki_mgr().Add_by_csv(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "1|d|www.wikidata.org"
|
||||
, "2|wikt;wiktionary|wiktionary"
|
||||
, "2|s|wikisource"
|
||||
, "2|w;wikipedia|wikipedia"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_wikt() {
|
||||
wiki.Xwiki_mgr().Add_by_csv(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "2|wikt;wiktionary|wiktionary"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk_langs(Xow_xwiki_itm... itms) {
|
||||
xwiki_mgr.Add_by_sitelink_mgr();
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk_peers(Xow_xwiki_itm... itms) {
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Tst_itms(Xow_xwiki_itm... itms) {
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_len(int expd) {Tfds.Eq(expd, xwiki_mgr.Len()); return this;}
|
||||
Xow_xwiki_itm[] To_ary(Xow_xwiki_itm[] itms) {
|
||||
int len = itms.length;
|
||||
List_adp rv = List_adp_.New();
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] alias = itms[i].Key_bry();
|
||||
Xow_xwiki_itm itm = xwiki_mgr.Get_by_key(alias);
|
||||
if (itm == null) itm = xwiki_null_(String_.new_u8(alias)); // "null", ignore
|
||||
rv.Add(itm);
|
||||
}
|
||||
return (Xow_xwiki_itm[])rv.To_ary(Xow_xwiki_itm.class);
|
||||
}
|
||||
String Xto_str(Xow_xwiki_itm[] itms) {
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xow_xwiki_itm itm = itms[i];
|
||||
if (Bry_.Len_eq_0(itm.Domain_bry())) // "null", ignore
|
||||
sb.Add(itm.Key_bry()).Add_char_nl();
|
||||
else {
|
||||
sb.Add(itm.Key_bry()).Add_char_pipe().Add(itm.Domain_bry()).Add_char_pipe().Add(itm.Url_fmt()).Add_char_pipe().Add(itm.Domain_tid()).Add_char_nl();
|
||||
}
|
||||
}
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -1,67 +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.xowa.wikis.xwikis.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*;
|
||||
public class Xoa_sitelink_mgr_parser_tst {
|
||||
private final Xoa_sitelink_mgr_parser_fxt fxt = new Xoa_sitelink_mgr_parser_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
String raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|de|German"
|
||||
, "1|en|English"
|
||||
, "0|Tier 1"
|
||||
, "1|ar|Arabic"
|
||||
, "1|ca|Catalan"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
fxt.Test_parse(raw);
|
||||
}
|
||||
@Test public void Move() {
|
||||
String raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|de|German"
|
||||
, "0|Tier 1"
|
||||
, "1|ar|Arabic"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|ar|Arabic"
|
||||
, "0|Tier 1"
|
||||
, "1|de|German"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
fxt.Test_parse(raw);
|
||||
}
|
||||
}
|
||||
class Xoa_sitelink_mgr_parser_fxt {
|
||||
private final Xoa_sitelink_mgr mgr = new Xoa_sitelink_mgr();
|
||||
private final Xoa_sitelink_mgr_parser parser;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
public void Clear() {mgr.Grp_mgr().Clear();}
|
||||
public Xoa_sitelink_mgr_parser_fxt() {
|
||||
this.parser = new Xoa_sitelink_mgr_parser(mgr);
|
||||
}
|
||||
public void Exec_parse(String raw) {
|
||||
byte[] src = Bry_.new_u8(raw);
|
||||
parser.Load_by_bry(src);
|
||||
}
|
||||
public void Test_parse(String expd) {
|
||||
mgr.Grp_mgr().To_bfr(tmp_bfr);
|
||||
Tfds.Eq_str_lines(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -1,60 +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.xowa.wikis.xwikis.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.parsers.*;
|
||||
class Xoa_sitelink_div_wtr_fxt {
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
Init_langs(wiki);
|
||||
}
|
||||
public static void Init_langs(Xowe_wiki wiki) {
|
||||
Xoae_app app = wiki.Appe();
|
||||
app.Xwiki_mgr__sitelink_mgr().Parse(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "0|grp1"
|
||||
, "1|simple|Simple"
|
||||
, "1|es|Spanish"
|
||||
, "1|it|Italian"
|
||||
, "1|zh|Chinese"
|
||||
, "0|grp2"
|
||||
, "1|fr|French"
|
||||
, "1|de|German"
|
||||
)));
|
||||
wiki.Xwiki_mgr().Add_by_sitelink_mgr();
|
||||
wiki.Appe().Usere().Wiki().Xwiki_mgr().Add_by_csv(Bry_.new_a7(String_.Concat_lines_nl
|
||||
( "1|simple.wikipedia.org|simple.wikipedia.org"
|
||||
, "1|fr.wikipedia.org|fr.wikipedia.org"
|
||||
, "1|es.wikipedia.org|es.wikipedia.org"
|
||||
, "1|de.wikipedia.org|de.wikipedia.org"
|
||||
, "1|it.wikipedia.org|it.wikipedia.org"
|
||||
)));
|
||||
}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
Xoae_app app;
|
||||
public void tst(String raw, String expd) {
|
||||
Xop_ctx ctx = wiki.Parser_mgr().Ctx();
|
||||
ctx.Page().Ttl_(Xoa_ttl.Parse(wiki, Bry_.new_a7("test_page")));
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Xop_root_tkn root = ctx.Tkn_mkr().Root(raw_bry);
|
||||
wiki.Parser_mgr().Main().Parse_page_all_clear(root, ctx, ctx.Tkn_mkr(), raw_bry);
|
||||
wiki.Html_mgr().Html_wtr().Write_doc(bfr, ctx, raw_bry, root);
|
||||
|
||||
Bry_bfr html_bfr = Bry_bfr_.New();
|
||||
wiki.App().Xwiki_mgr__sitelink_mgr().Write_html(html_bfr, wiki, ctx.Page().Slink_list(), gplx.xowa.xtns.wbases.Wdata_xwiki_link_wtr.Qid_null);
|
||||
Tfds.Eq_str_lines(expd, html_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -1,98 +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.xowa.wikis.xwikis.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import org.junit.*;
|
||||
public class Xoa_sitelink_div_wtr_tst {
|
||||
private final Xoa_sitelink_div_wtr_fxt fxt = new Xoa_sitelink_div_wtr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.tst("[[simple:Earth]] [[fr:Terre]] [[es:Tierra]] [[de:Erde]] [[it:Terre]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 5) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"Earth\" href=\"/site/simple.wikipedia.org/wiki/Earth\">Earth</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Spanish</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"es\" title=\"Tierra\" href=\"/site/es.wikipedia.org/wiki/Tierra\">Tierra</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Italian</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"it\" title=\"Terre\" href=\"/site/it.wikipedia.org/wiki/Terre\">Terre</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " <h4>grp2</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>French</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"fr\" title=\"Terre\" href=\"/site/fr.wikipedia.org/wiki/Terre\">Terre</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>German</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"de\" title=\"Erde\" href=\"/site/de.wikipedia.org/wiki/Erde\">Erde</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Empty() {
|
||||
fxt.tst("[[simple:]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"Test page\" href=\"/site/simple.wikipedia.org/wiki/\">Test page</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Unregistered() {
|
||||
// fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("zh"), Bry_.new_a7("zh.wikipedia.org"), Bry_.new_a7("http://zh.wikipedia.org/~{0}"));
|
||||
fxt.tst("[[zh:Earth]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Chinese</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"zh\" title=\"Earth\" href=\"https://zh.wikipedia.org/wiki/Earth\">Earth</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Anchor() {// PURPOSE: A#b was not showing anchor "#b"; DATE:2013-10-23
|
||||
fxt.tst("[[simple:A#b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"A#b\" href=\"/site/simple.wikipedia.org/wiki/A#b\">A#b</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user