mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
App: Release v4.5.15.1709
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.users; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.xwikis.*;
|
||||
public class Xou_user_tst {
|
||||
private final Xou_user_fxt fxt = new Xou_user_fxt();
|
||||
@Test public void Available_from_fsys() {
|
||||
Io_mgr.Instance.CreateDir(fxt.App().Fsys_mgr().Wiki_dir().GenSubDir("en.wikipedia.org"));
|
||||
fxt.App().Usere().Available_from_fsys();
|
||||
fxt.Test_xwikis
|
||||
( fxt.Make_xwiki(Bool_.N, "home")
|
||||
, fxt.Make_xwiki(Bool_.Y, "en.wikipedia.org") // available_from_fsys should mark as offline=y
|
||||
);
|
||||
}
|
||||
}
|
||||
class Xou_user_fxt {
|
||||
public Xoae_app App() {return app;} private Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
public String Make_xwiki(boolean offline, String name) {return String_.Concat_with_str("|", Yn.To_str(offline), name);}
|
||||
public void Test_xwikis(String... expd) {
|
||||
Xow_xwiki_mgr xwiki_mgr = app.Usere().Wiki().Xwiki_mgr();
|
||||
int len = xwiki_mgr.Len();
|
||||
String[] actl = new String[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_xwiki_itm xwiki_itm = xwiki_mgr.Get_at(i);
|
||||
actl[i] = Make_xwiki(xwiki_itm.Offline(), String_.new_u8(xwiki_itm.Domain_name()));
|
||||
}
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoud_opt_scope_tst {
|
||||
private Xoud_opt_scope_fxt fxt = new Xoud_opt_scope_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.Test_parse("en.w" , fxt.Make(Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia));
|
||||
fxt.Test_parse("en.*" , fxt.Make(Xol_lang_stub_.Id_en, Xoud_opt_scope.Type_id_wildcard));
|
||||
fxt.Test_parse("*.w" , fxt.Make(Xoud_opt_scope.Lang_id_wildcard, Xow_domain_tid_.Tid__wikipedia));
|
||||
fxt.Test_parse("<any>" , Xoud_opt_scope.App);
|
||||
fxt.Test_parse("en.w,fr.d" , fxt.Make(Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia), fxt.Make(Xol_lang_stub_.Id_fr, Xow_domain_tid_.Tid__wiktionary));
|
||||
}
|
||||
}
|
||||
class Xoud_opt_scope_fxt {
|
||||
private final Xoud_opt_scope_parser parser = new Xoud_opt_scope_parser();
|
||||
public void Clear() {
|
||||
// Gfo_usr_dlg_.I = Xoa_app_.New__usr_dlg__console();
|
||||
}
|
||||
public Xoud_opt_scope Make(int lang_id, int type_id) {return new Xoud_opt_scope(lang_id, type_id);}
|
||||
public void Test_parse(String raw, Xoud_opt_scope... expd) {
|
||||
Xoud_opt_scope[] actl = parser.Parse(Bry_.new_u8(raw));
|
||||
Tfds.Eq(To_str(expd), To_str(actl));
|
||||
}
|
||||
private static String To_str(Xoud_opt_scope[] ary) {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoud_opt_scope itm = ary[i];
|
||||
if (i != 0) bfr.Add_str_a7(",");
|
||||
bfr.Add_str_a7(itm.To_str());
|
||||
}
|
||||
return 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.users.history; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import org.junit.*;
|
||||
public class Xou_history_mgr_tst {
|
||||
private Xou_history_mgr_fxt fxt = new Xou_history_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Archive() {
|
||||
Datetime_now.Manual_y_(); // NOTE: each DateTime_.Now() advances clock by 1 min; adding a new Datetime_now.Get() anywhere will throw off times on this test; DATE:2014-04-01
|
||||
fxt.Invk(Xou_history_mgr.Invk_current_itms_max_, 4).Invk(Xou_history_mgr.Invk_current_itms_reset_, 2);
|
||||
fxt.Add_many("A", "B", "C", "D", "E");
|
||||
fxt.Save();
|
||||
fxt.List_tst("E", "D");
|
||||
fxt.Fil_tst("mem/xowa/user/test_user/app/data/history/20010101_001000.000.csv", String_.Concat_lines_nl
|
||||
( "20010101 000500.000|20010101 000500.000|1|en.wikipedia.org|C"
|
||||
, "20010101 000300.000|20010101 000300.000|1|en.wikipedia.org|B"
|
||||
, "20010101 000100.000|20010101 000100.000|1|en.wikipedia.org|A"
|
||||
));
|
||||
}
|
||||
@Test public void Normalize() {
|
||||
fxt.Clear();
|
||||
fxt.Add_many("Category:A_B", "Category:A B", "Category:a B", "Category:_A B_");
|
||||
fxt.List_tst("Category:A_B");
|
||||
}
|
||||
@Test public void Args() {
|
||||
fxt.Clear();
|
||||
fxt.Add_one("Special:AllPages", "?from=A");
|
||||
fxt.List_tst("Special:AllPages?from=A");
|
||||
}
|
||||
@Test public void Remove_nl() {
|
||||
fxt.Clear();
|
||||
fxt.Add_many("Category:A?pagefrom=B\nB");
|
||||
fxt.List_tst("Category:A?pagefrom=B");
|
||||
}
|
||||
}
|
||||
class Xou_history_mgr_fxt {
|
||||
Xoae_app app; Xowe_wiki wiki;
|
||||
Xou_history_mgr under;
|
||||
public void Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
under = app.Usere().History_mgr();
|
||||
}
|
||||
Io_mgr.Instance.DeleteDirDeep(Io_url_.new_dir_("mem/xowa/user/test_user/app/data/history/"));
|
||||
under.Clear();
|
||||
}
|
||||
public Xou_history_mgr_fxt Add_many(String... ary) {
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
String itm = ary[i];
|
||||
Add_one(itm, null);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Xou_history_mgr_fxt Add_one(String ttl_str, String arg_str) {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
Xoae_page page = Xoae_page.New_test(wiki, ttl);
|
||||
page.Db().Page().Modified_on_(Datetime_now.Get());
|
||||
byte[] url_bry = ttl_bry;
|
||||
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_u8(arg_str));
|
||||
Xoa_url url = wiki.Utl__url_parser().Parse(url_bry);
|
||||
page.Url_(url); // set url b/c history_mgr.Add uses url
|
||||
under.Add(page);
|
||||
return this;
|
||||
}
|
||||
public Xou_history_mgr_fxt List_tst(String... expd) {
|
||||
int actl_len = under.Len();
|
||||
String[] actl = new String[actl_len];
|
||||
for (int i = 0; i < actl_len; i++) {
|
||||
Xou_history_itm itm = under.Get_at(i);
|
||||
actl[i] = String_.new_u8(itm.Page());
|
||||
}
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
return this;
|
||||
}
|
||||
public Xou_history_mgr_fxt Invk(String key, Object v) {Gfo_invk_.Invk_by_val(under, key, v); return this;}
|
||||
public Xou_history_mgr_fxt Save() {under.Save(app); return this;}
|
||||
public Xou_history_mgr_fxt Fil_tst(String expd_url, String expd) {
|
||||
String actl = Io_mgr.Instance.LoadFilStr(expd_url);
|
||||
Tfds.Eq_str_lines(expd, actl);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -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.users.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import org.junit.*; import gplx.core.envs.*;
|
||||
public class Xofs_url_itm_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xofs_url_itm_parser_fxt fxt = new Xofs_url_itm_parser_fxt();
|
||||
@Test public void Custom() {fxt.Test_parse_custom("/xowa/wiki/en.wikipedia.org/");}
|
||||
@Test public void Lnx() {fxt.Init_dir_spr_lnx().Init_name("xowa", "/xowa") .Test_parse("xowa-fs://~{xowa}/bin/any/", "/xowa/bin/any/");}
|
||||
@Test public void Wnt() {fxt.Init_dir_spr_wnt().Init_name("xowa", "C:\\xowa") .Test_parse("xowa-fs://~{xowa}/bin/any/", "C:\\xowa\\bin\\any\\");}
|
||||
@Test public void Outliers() {
|
||||
fxt.Init_name("xowa", "/xowa");
|
||||
fxt.Test_parse("xowa-fs://ab" , "ab"); // no subst
|
||||
fxt.Test_parse("xowa-fs://a~b" , "a~b"); // tilde
|
||||
fxt.Test_parse("xowa-fs://a~{~{b" , "a~{b"); // escape
|
||||
fxt.Test_parse("xowa-fs://ab~" , "ab~"); // eos
|
||||
fxt.Test_parse("xowa-fs://ab~{~{" , "ab~{"); // eos
|
||||
}
|
||||
}
|
||||
class Xofs_url_itm_parser_fxt {
|
||||
private Xofs_url_itm_parser parser;
|
||||
private Xofs_url_itm itm = new Xofs_url_itm();
|
||||
public void Clear() {
|
||||
parser = new Xofs_url_itm_parser();
|
||||
}
|
||||
public Xofs_url_itm_parser_fxt Init_name(String key, String val) {parser.Names_add(key, val); return this;}
|
||||
public Xofs_url_itm_parser_fxt Init_dir_spr_lnx() {parser.Dir_spr_(Op_sys.Lnx.Fsys_dir_spr_byte()); return this;}
|
||||
public Xofs_url_itm_parser_fxt Init_dir_spr_wnt() {parser.Dir_spr_(Op_sys.Wnt.Fsys_dir_spr_byte()); return this;}
|
||||
public void Test_parse_custom(String raw) {
|
||||
parser.Parse(itm, raw);
|
||||
Tfds.Eq(Bool_.N, itm.Tid_is_xowa());
|
||||
Tfds.Eq(raw, itm.Url());
|
||||
}
|
||||
public void Test_parse(String raw, String expd) {
|
||||
parser.Parse(itm, raw);
|
||||
Tfds.Eq(Bool_.Y, itm.Tid_is_xowa());
|
||||
Tfds.Eq(expd, itm.Url());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user