1
0
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:
gnosygnu
2017-09-17 22:38:44 -04:00
parent 131c2f696c
commit 4ca98f7333
896 changed files with 0 additions and 69373 deletions

View File

@@ -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.apps; import gplx.*; import gplx.xowa.*;
import org.junit.*;
import gplx.core.brys.fmtrs.*;
import gplx.xowa.apps.gfs.*;
public class Xoa_app_eval_tst {
Xoa_app_eval_fxt fxt = new Xoa_app_eval_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Basic() {
fxt.Eval_test("[~{<>app.sys_cfg.version;<>}]", "[" + Xoa_app_.Version + "]");
}
}
class Xoa_app_eval_fxt {
public void Clear() {
if (app == null) {
app = Xoa_app_fxt.Make__app__edit();
fmtr = Bry_fmtr.new_();
eval = new Xoa_app_eval();
fmtr.Eval_mgr_(eval);
Xoa_gfs_mgr.Msg_parser_init();
}
} private Xoae_app app; Bry_fmtr fmtr; Xoa_app_eval eval;
public void Eval_test(String raw, String expd) {
Tfds.Eq(fmtr.Fmt_(raw).Bld_str_many(), expd);
}
}

View File

@@ -1,28 +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.apps; import gplx.*; import gplx.xowa.*;
import org.junit.*; import gplx.xowa.apps.gfs.*;
public class Xoa_shell_tst {
@Test public void Fetch_page() { // PURPOSE.fix: fetch_page failed with nullRef; DATE:2013-04-12
Xop_fxt parser_fxt = new Xop_fxt();
Xoae_app app = parser_fxt.App(); Xowe_wiki wiki = parser_fxt.Wiki();
parser_fxt.Init_page_create("A", "test"); // need to create page in order for html output to gen
wiki.Html_mgr().Page_wtr_mgr().Html_capable_(true); // need to set html_capable in order for div_home to load
Xoa_gfs_mgr.Msg_parser_init();
wiki.Html_mgr().Portal_mgr().Div_home_fmtr().Fmt_("~{<>app.user.msgs.get('mainpage-description');<>}");
app.Gfs_mgr().Run_str("app.shell.fetch_page('en.wikipedia.org/wiki/A' 'html');"); // this causes a nullRef error b/c app.user.lang is null
}
}

View File

@@ -1,68 +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.apps.apis.xowa.addons.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.addons.*;
import org.junit.*; import gplx.core.tests.*;
public class Xopg_match_mgr__tst {
private final Xopg_match_mgr__fxt fxt = new Xopg_match_mgr__fxt();
@Before public void init() {fxt.Clear();}
@Test public void Specific() {
fxt.Init__set("en.w:A");
fxt.Test__match_y("A");
fxt.Test__match_n("AB");
}
@Test public void Other_wiki() {
fxt.Init__set("fr.w:A");
fxt.Test__match_n("A"); // note that test defaults to "en.w" as primary wiki
}
@Test public void Wildcard__app() {
fxt.Init__set("*");
fxt.Test__match_y("A", "B");
}
@Test public void Wildcard__page() {
fxt.Init__set("en.w:*");
fxt.Test__match_y("A", "B");
}
@Test public void Wildcard__page__other() {
fxt.Init__set("fr.w:*");
fxt.Test__match_n("A", "B");
}
@Test public void Wildcard__wiki() {
fxt.Init__set("*:A");
fxt.Test__match_y("A");
fxt.Test__match_n("B");
}
}
class Xopg_match_mgr__fxt {
private final Xopg_match_mgr match_mgr = new Xopg_match_mgr();
private Xowe_wiki wiki;
public void Clear() {
Xoae_app app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
app.User().Wikii().Xwiki_mgr().Add_by_atrs(wiki.Domain_bry(), wiki.Domain_bry());
}
public void Init__set(String url) {
match_mgr.Set(url);
}
public void Test__match_y(String... urls) {Test__match(Bool_.Y, urls);}
public void Test__match_n(String... urls) {Test__match(Bool_.N, urls);}
private void Test__match(boolean expd, String... urls) {
for (int i = 0; i < urls.length; i++) {
String url = urls[i];
boolean actl = match_mgr.Match(wiki, Bry_.new_u8(url));
Gftest.Eq__bool(expd, actl, "match failed", "expd", expd, "url", url);
}
}
}

View File

@@ -1,70 +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.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.nss.*;
public class Xowc_xtn_pages_tst {
@Before public void init() {fxt.Clear();} private Xowc_xtn_pages_fxt fxt = new Xowc_xtn_pages_fxt();
@Test public void Init() {
fxt.Init_ns(200, "Foreign_page").Init_ns(201, "Foreign_page_talk").Init_ns(202, "Foreign_index").Init_ns(203, "Foreign_index_talk"); // ns set by <siteinfo>
fxt.Init_names("Foreign_page", "Foreign_page_talk", "Foreign_index", "Foreign_index_talk"); // ns set by .gfs files in /user/wiki/#cfg
fxt.Exec_init();
fxt.Test_ns_ids(200, 201, 202, 203);
fxt.Test_ns_canonical("Page", "Page_talk", "Index", "Index_talk");
}
@Test public void Spaces() { // PURPOSE: ensure underlines, not space; EX:"Mục_lục" not "Mục lục"; PAGE:vi.s:Việt_Nam_sử_lược/Quyển_II DATE:2015-10-27
fxt.Init_ns(200, "Foreign_page").Init_ns(201, "Foreign_page_talk").Init_ns(202, "Foreign_index").Init_ns(203, "Foreign_index_talk"); // ns set by <siteinfo>
fxt.Init_names("Foreign page", "Foreign page talk", "Foreign index", "Foreign index talk"); // ns set by .gfs files in /user/wiki/#cfg
fxt.Exec_init();
fxt.Test_ns_ids(200, 201, 202, 203);
fxt.Test_ns_canonical("Page", "Page_talk", "Index", "Index_talk");
}
}
class Xowc_xtn_pages_fxt {
private Xow_ns_mgr ns_mgr;
private Xowc_xtn_pages cfg_pages;
public void Clear() {
ns_mgr = Xow_ns_mgr_.default_(gplx.xowa.langs.cases.Xol_case_mgr_.A7());
cfg_pages = new Xowc_xtn_pages();
}
public Xowc_xtn_pages_fxt Init_ns(int id, String name) {
ns_mgr.Add_new(id, name);
return this;
}
public void Init_names(String page_name, String page_talk_name, String index_name, String index_talk_name) {
cfg_pages.Ns_names_(Bry_.new_a7(page_name), Bry_.new_a7(page_talk_name), Bry_.new_a7(index_name), Bry_.new_a7(index_talk_name));
}
public void Exec_init() {
ns_mgr.Init_w_defaults(); // init ns_msg
cfg_pages.Init(ns_mgr); // init cfg
}
public void Test_ns_ids(int page_id, int page_talk_id, int index_id, int index_talk_id) {
Tfds.Eq(page_id , cfg_pages.Ns_page_id());
Tfds.Eq(page_talk_id , cfg_pages.Ns_page_talk_id());
Tfds.Eq(index_id , cfg_pages.Ns_index_id());
Tfds.Eq(index_talk_id , cfg_pages.Ns_index_talk_id());
}
public void Test_ns_canonical(String page_name, String page_talk_name, String index_name, String index_talk_name) {
Test_ns_canonical_itm(page_name , cfg_pages.Ns_page_id());
Test_ns_canonical_itm(page_talk_name , cfg_pages.Ns_page_talk_id());
Test_ns_canonical_itm(index_name , cfg_pages.Ns_index_id());
Test_ns_canonical_itm(index_talk_name , cfg_pages.Ns_index_talk_id());
}
private void Test_ns_canonical_itm(String name, int expd_ns_id) {
Xow_ns ns = ns_mgr.Names_get_or_null(Bry_.new_a7(name));
int actl_ns_id = ns == null ? Int_.Min_value : ns.Id();
Tfds.Eq(expd_ns_id, actl_ns_id);
}
}

View File

@@ -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.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.langs.gfs.*;
public class Xoa_fmtr_itm_tst {
@Before public void init() {fxt.Clear();} private Xoa_fmtr_itm_fxt fxt = new Xoa_fmtr_itm_fxt();
@Test public void Basic() {
fxt.Init_src("app.wikis;");
fxt.Init_fmt("domain=~{<>domain;<>};");
fxt.Test_run("domain=en.wikipedia.org;");
}
}
class Xoa_fmtr_itm_fxt {
private Xoae_app app; private Xoa_fmtr_itm itm;
public void Clear() {
app = Xoa_app_fxt.Make__app__edit();
Xoa_app_fxt.Make__wiki__edit(app); // create enwiki
itm = new Xoa_fmtr_itm(app);
GfsCore.Instance.MsgParser_(gplx.langs.gfs.Gfs_msg_bldr.Instance);
}
public Xoa_fmtr_itm_fxt Init_src(String v) {itm.Src_(v); return this;}
public Xoa_fmtr_itm_fxt Init_fmt(String v) {itm.Fmt_(Bry_.new_a7(v)); return this;}
public void Test_run(String expd) {
String actl = itm.Run();
Tfds.Eq(expd, actl);
}
}

View File

@@ -1,64 +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.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.xowa.users.*;
public class Xoa_url_finder_tst {
private final Xoa_url_finder_fxt fxt = new Xoa_url_finder_fxt();
@Test public void Find_by_css_or_null() {
// init
String wiki = "en.wikipedia.org";
String file = "logo_night.png";
String[] subs = String_.Ary("bin", "any", "xowa", "html", "css", "nightmode");
String expd = null;
// null case
expd = null;
fxt.Test__Find_by_css_or_null(expd, wiki, file, subs);
// app_bin
expd = "mem/xowa/bin/any/xowa/html/css/nightmode/logo_night.png";
fxt.Init__Fsys__save(expd);
fxt.Test__Find_by_css_or_null(expd, wiki, file, subs);
// usr_bin
expd = "mem/xowa/user/anonymous/app/overrides/bin/any/xowa/html/css/nightmode/logo_night.png";
fxt.Init__Fsys__save(expd);
fxt.Test__Find_by_css_or_null(expd, wiki, file, subs);
// wiki_css
expd = "mem/xowa/user/anonymous/wiki/en.wikipedia.org/html/logo_night.png";
fxt.Init__Fsys__save(expd);
fxt.Test__Find_by_css_or_null(expd, wiki, file, subs);
}
}
class Xoa_url_finder_fxt {
private final Xoa_url_finder finder;
public Xoa_url_finder_fxt() {
Io_url root_dir = Io_url_.mem_dir_("mem/xowa/");
Xoa_fsys_mgr app_fsys_mgr = Xoa_fsys_mgr.New_by_plat("lnx", root_dir);
Xou_fsys_mgr usr_fsys_mgr = new Xou_fsys_mgr(root_dir.GenSubDir_nest("user", "anonymous"));
this.finder = new Xoa_url_finder(app_fsys_mgr);
finder.Init_by_user(usr_fsys_mgr);
}
public void Init__Fsys__save(String url) {
Io_mgr.Instance.SaveFilStr(url, "");
}
public void Test__Find_by_css_or_null(String expd, String wiki, String file, String[] dir_parts) {
Io_url actl = finder.Find_by_css_or(wiki, file, dir_parts, false);
Gftest.Eq__str(expd, actl == null ? null : actl.Raw());
}
}

View File

@@ -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.apps.gfs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Gfs_php_converter__to_gfs__tst {
@Before public void init() {fxt.Clear();} private final Gfs_php_converter_fxt fxt = new Gfs_php_converter_fxt();
@Test public void Escape_sequences() {
fxt.Test__to_gfs("a\\\"b" , "a\"b");
fxt.Test__to_gfs("a\\'b" , "a'b");
fxt.Test__to_gfs("a\\$b" , "a$b");
fxt.Test__to_gfs("a\\\\b" , "a\\b");
fxt.Test__to_gfs("a\\nb" , "a\nb");
fxt.Test__to_gfs("a\\tb" , "a\tb");
fxt.Test__to_gfs("a\\rb" , "a\rb");
fxt.Test__to_gfs("a\\ b" , "a\\ b"); // "\ " seems to be rendered literally; EX:"You do not need to put \ before a /."; PAGE:en.w:MediaWiki:Spam-whitelist; DATE:2016-09-12
fxt.Test__to_gfs("a\\\\b\\'c\\\"d\\$e" , "a\\b'c\"d$e"); // backslash.escape
fxt.Test__to_gfs("\\" , "\\"); // backslash.eos; eos, but nothing to escape; render self but dont fail
}
@Test public void Tilde() {
fxt.Test__to_gfs("a~b" , "a~~b"); // tilde.escape
}
@Test public void Arguments() {
fxt.Test__to_gfs("a$1b" , "a~{0}b"); // dollar
fxt.Test__to_gfs("a $ b" , "a $ b"); // noop
}
}
class Gfs_php_converter_fxt {
private final Bry_bfr bfr = Bry_bfr_.New();
public void Clear() {}
public void Test__to_gfs(String raw, String expd) {
byte[] actl = Gfs_php_converter.To_gfs(bfr, Bry_.new_u8(raw));
Tfds.Eq(expd, String_.new_u8(actl));
}
public void Test_Xto_php_escape_y(String raw, String expd) {Test_Xto_php(raw, Bool_.Y, expd);}
public void Test_Xto_php_escape_n(String raw, String expd) {Test_Xto_php(raw, Bool_.N, expd);}
public void Test_Xto_php(String raw, boolean escape_backslash, String expd) {
byte[] actl = Gfs_php_converter.Xto_php(bfr, escape_backslash, Bry_.new_u8(raw));
Tfds.Eq(expd, String_.new_u8(actl));
}
}

View File

@@ -1,28 +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.apps.gfs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Gfs_php_converter__to_php__tst {
@Before public void init() {fxt.Clear();} private final Gfs_php_converter_fxt fxt = new Gfs_php_converter_fxt();
@Test public void Xto_php() {
fxt.Test_Xto_php_escape_y("a~{0}b" , "a$1b"); // tilde.arg.one
fxt.Test_Xto_php_escape_y("a~{0}b~{1}c~{2}d" , "a$1b$2c$3d"); // tilde.arg.many
fxt.Test_Xto_php_escape_y("a~{9}" , "a$10"); // tilde.arg.9 -> 10
fxt.Test_Xto_php_escape_y("a~~b" , "a~b"); // tilde.escape
fxt.Test_Xto_php_escape_y("a\\b'c\"d$e" , "a\\\\b\\'c\\\"d\\$e"); // backslash.escape_y
fxt.Test_Xto_php_escape_n("a\\b'c\"d$e" , "a\\b'c\"d$e"); // backslash.escape_n
}
}

View File

@@ -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.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
import org.junit.*;
public class Http_server_wkr__tst {
@Before public void init() {fxt.Clear();} private Http_server_wkr__fxt fxt = new Http_server_wkr__fxt();
@Test public void Assert_main_page() {
fxt.Init_wiki_main_page("fr.wikiversity.org", "Accueil");
fxt.Test_assert_main_page("/fr.wikiversity.org/" , "/fr.wikiversity.org/wiki/Accueil");
fxt.Test_assert_main_page("/fr.wikiversity.org/wiki" , "/fr.wikiversity.org/wiki/Accueil");
fxt.Test_assert_main_page("/fr.wikiversity.org/wiki/" , "/fr.wikiversity.org/wiki/Accueil");
fxt.Test_assert_main_page("/fr.wikiversity.org/wiki/A" , "/fr.wikiversity.org/wiki/A");
}
}
class Http_server_wkr__fxt {
private Xoae_app app;
public void Clear() {
this.app = Xoa_app_fxt.Make__app__edit();
}
public void Init_wiki_main_page(String domain, String main_page) {
Xowe_wiki wiki = app.Wiki_mgr().Get_by_or_make(Bry_.new_u8(domain));
wiki.Props().Main_page_(Bry_.new_u8(main_page));
}
public void Test_assert_main_page(String url, String expd) {
Tfds.Eq(expd, Http_server_wkr_.Assert_main_page(app, url));
}
}

View File

@@ -1,63 +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.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
import org.junit.*;
import gplx.core.ios.*; import gplx.core.ios.streams.*;
public class Xosrv_msg_rdr_tst {
@Before public void init() {fxt.Clear();} private Xosrv_msg_rdr_fxt fxt = new Xosrv_msg_rdr_fxt();
@Test public void Parse() {
String raw = "0|0000000045|0000000091|cmd_0|id_0|sender_0|recipient_0|date_0|text_0";
Xosrv_msg msg = fxt.Test_parse_msg(raw, "cmd_0", "id_0", "sender_0", "recipient_0", "date_0", "text_0");
fxt.Test_print(msg, raw);
}
@Test public void Err_header_is_invalid() {fxt.Test_parse_err("abcde", "header is invalid");}
@Test public void Err_checksum_failed() {fxt.Test_parse_err("0|0000000000|0000000000|", "checksum failed");}
@Test public void Err_cmd_missing() {fxt.Test_parse_err("0|0000000001|0000000003|a", "pipe not found for cmd_name");}
}
class Xosrv_msg_rdr_fxt {
public Xosrv_msg_rdr_fxt Clear() {
if (msg_rdr == null) {
msg_rdr_stream = new IoStream_mock();
msg_rdr = new Xosrv_msg_rdr(Bry_.Empty, msg_rdr_stream);
}
msg_rdr_stream.Reset();
return this;
} private Xosrv_msg_rdr msg_rdr; private IoStream_mock msg_rdr_stream;
public Xosrv_msg Test_parse_msg(String raw, String expd_cmd, String expd_id, String expd_sender, String expd_recipient, String expd_date, String expd_text) {
byte[] raw_bry = Bry_.new_a7(raw);
msg_rdr_stream.Data_bry_(raw_bry).Read_limit_(raw_bry.length);
Xosrv_msg msg = msg_rdr.Read();
Tfds.Eq(String_.new_a7(msg.Cmd_name()) , expd_cmd);
Tfds.Eq(String_.new_a7(msg.Msg_id()) , expd_id);
Tfds.Eq(String_.new_a7(msg.Sender()) , expd_sender);
Tfds.Eq(String_.new_a7(msg.Recipient()) , expd_recipient);
Tfds.Eq(String_.new_a7(msg.Msg_date()) , expd_date);
Tfds.Eq(String_.new_a7(msg.Msg_text()) , expd_text);
return msg;
}
public void Test_parse_err(String raw, String expd_err) {
byte[] raw_bry = Bry_.new_a7(raw);
msg_rdr_stream.Data_bry_(raw_bry).Read_limit_(raw_bry.length);
Xosrv_msg msg = msg_rdr.Read();
String msg_text = String_.new_a7(msg.Msg_text());
Tfds.Eq_true(String_.Has_at_bgn(msg_text, expd_err), msg_text);
}
public void Test_print(Xosrv_msg msg, String expd) {
Bry_bfr bfr = Bry_bfr_.New();
msg.Print(bfr);
Tfds.Eq(expd, bfr.To_str_and_clear());
}
}

View File

@@ -1,38 +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.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
import org.junit.*;
import gplx.core.ios.*;
public class Xosrv_server_tst {
@Before public void init() {fxt.Clear();} private Xosrv_server_fxt fxt = new Xosrv_server_fxt();
@Test public void Exec_js() {
fxt.Test_exec_js("{\"args\":[\"xowa_exec_test\",\"a\",\"b\"]}", "{\"xowa_js_result\":\"xowa_exec_test|a|b\"}");
}
@Test public void Exec_js_ary() {
fxt.Test_exec_js("{\"args\":[\"xowa_exec_test_as_array\",\"a\",\"b\"]}", "{\"xowa_js_result\":[\"xowa_exec_test_as_array\",\"a\",\"b\"]}");
}
}
class Xosrv_server_fxt {
public Xosrv_server_fxt Clear() {
app = Xoa_app_fxt.Make__app__edit();
Xoa_app_fxt.Init_gui(app, null); // NOTE: null wiki does not matter for test
return this;
} private Xoae_app app;
public void Test_exec_js(String raw, String expd) {
String actl = app.Tcp_server().Exec_js(null, Bry_.new_a7(raw));
Tfds.Eq(expd, actl);
}
}

View File

@@ -1,34 +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.apps.setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xoa_setup_mgr_tst {
@Before public void init() {fxt.Clear();} private Xoa_setup_mgr_fxt fxt = new Xoa_setup_mgr_fxt();
@Test public void Compare() {
fxt.Test_delete_old_dir("mem/dir/", "1.8.1.1" , "1.8.2.1", Bool_.Y); // version is earlier than checkpoint; delete
fxt.Test_delete_old_dir("mem/dir/", "1.8.2.1" , "1.8.2.1", Bool_.N); // version is not earlier than checkpoint; don't delete
fxt.Test_delete_old_dir("mem/dir/", "" , "1.8.2.1", Bool_.Y); // version is empty; delete;
}
}
class Xoa_setup_mgr_fxt {
public void Clear() {}
public void Test_delete_old_dir(String dir_str, String version_prv, String version_del, boolean expd) {
Io_url dir = Io_url_.new_fil_(dir_str);
Io_mgr.Instance.CreateDirIfAbsent(dir);
Xoa_setup_mgr.Delete_old_dir(Gfo_usr_dlg_.Noop, version_prv, version_del, dir);
Tfds.Eq(expd, !Io_mgr.Instance.ExistsDir(dir), version_prv + "|" + version_del);
}
}

View File

@@ -1,178 +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.apps.site_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
import gplx.core.btries.*;
import gplx.dbs.cfgs.*;
import gplx.langs.jsons.*; import gplx.xowa.wikis.nss.*;
import gplx.xowa.parsers.*; import gplx.xowa.bldrs.wms.*;
public class Xoa_site_cfg_mgr_tst {
private final Xoa_site_cfg_mgr_fxt fxt = new Xoa_site_cfg_mgr_fxt();
@Before public void init() {fxt.Init();}
@After public void term() {fxt.Term();}
@Test public void Extensiontags__cfg() {
fxt.Init_db(Xoa_site_cfg_loader__inet.Qarg__extensiontags, fxt.Make_data(Xoa_site_cfg_loader_.Tid__inet, 1, "math", "source"));
fxt.Exec_load();
fxt.Test_extensiontags_y("math" , "source");
fxt.Test_extensiontags_n("ref" , "graph");
fxt.Test_extensiontags_y("translate", "languages"); // always whitelist <translate>,<languages> DATE:2015-10-13
}
@Test public void Extensiontags__fsys() {
fxt.Init_fsys(Xoa_site_cfg_loader__inet.Qarg__extensiontags, fxt.Make_data(Xoa_site_cfg_loader_.Tid__null, 1, "math", "source"));
fxt.Exec_load();
fxt.Test_extensiontags_y("math", "source");
fxt.Test_extensiontags_n("ref" , "graph");
fxt.Test_db(Xoa_site_cfg_loader__inet.Qarg__extensiontags, fxt.Make_data(Xoa_site_cfg_loader_.Tid__fsys, 1, "math", "source"));
}
@Test public void Extensiontags__inet() {
fxt.Init_inet(fxt.Make_api(fxt.Make_api_extensiontags("math", "source")));
fxt.Exec_load();
fxt.Test_extensiontags_y("math", "source");
fxt.Test_extensiontags_n("ref" , "graph");
fxt.Test_db(Xoa_site_cfg_loader__inet.Qarg__extensiontags, fxt.Make_data(Xoa_site_cfg_loader_.Tid__inet, 1, "math", "source"));
}
@Test public void Extensiontags__fallback() {
fxt.Exec_load();
fxt.Test_db(Xoa_site_cfg_loader__inet.Qarg__extensiontags, fxt.Make_data(Xoa_site_cfg_loader_.Tid__fallback, 1));
fxt.Test_extensiontags_y("math", "source", "ref", "graph");
}
@Test public void Interwikimap__inet() {
fxt.Init_inet(fxt.Make_api(fxt.Make_api_interwikimap("w", "https://en.wikipedia.org", "c", "https://commons.wikimedia.org")));
fxt.Exec_load();
fxt.Test_db(Xoa_site_cfg_loader__inet.Qarg__interwikimap, fxt.Make_data(Xoa_site_cfg_loader_.Tid__inet, 2, "w", "https://en.wikipedia.org", "c", "https://commons.wikimedia.org"));
}
// @Test public void Print() {
// String s = fxt.Make_api(fxt.Make_api_interwikimap("k1", "v1", "k2", "v2"), fxt.Make_api_extensiontags2("k3", "v3", "k4", "v4"));
// Tfds.Dbg(s);
// }
}
class Xoa_site_cfg_mgr_fxt {
private final Xoae_app app; private final Xowe_wiki wiki;
private final Xoa_site_cfg_mgr site_cfg_mgr;
private final Db_cfg_tbl cfg_tbl;
private final Json_printer printer = new Json_printer();
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
public Xoa_site_cfg_mgr_fxt() {
// Xoa_app_.Usr_dlg_(Xoa_app_.New__usr_dlg__console());
gplx.core.ios.IoEngine_system.Web_access_enabled = true; // HACK: must manually enable web_access else above tests will fail due to some other test disabling singleton; DATE:2016-12-15
Xoa_test_.Inet__init();
this.app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
Xoa_test_.Init__db__edit(wiki);
this.cfg_tbl = wiki.Data__core_mgr().Tbl__cfg();
this.site_cfg_mgr = app.Site_cfg_mgr();
}
public void Init() {
Datetime_now.Manual_y_(); Datetime_now.Autoincrement_n_();
Io_mgr.Instance.InitEngine_mem();
cfg_tbl.Delete_grp(Xoa_site_cfg_loader__db.Grp__xowa_wm_api);
site_cfg_mgr.Init_loader_bgn(wiki);
app.Utl__inet_conn().Clear();
}
public void Term() {
Datetime_now.Manual_n_();
}
public void Init_db(String key, String data) {
cfg_tbl.Assert_bry(Xoa_site_cfg_loader__db.Grp__xowa_wm_api, key, Bry_.new_u8(data));
}
public void Test_db(String key, String expd) {
byte[] actl = cfg_tbl.Select_bry_or(Xoa_site_cfg_loader__db.Grp__xowa_wm_api, key, null);
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
}
public void Init_inet(String data) {
String url = Xoa_site_cfg_loader__inet.Bld_url(tmp_bfr, wiki.Domain_str(), site_cfg_mgr.Data_hash(), site_cfg_mgr.Itm_ary());
app.Utl__inet_conn().Upload_by_bytes(url, Bry_.new_u8(data));
}
public void Init_fsys(String key, String data) {
Xoa_site_cfg_loader__fsys loader = Xoa_site_cfg_loader__fsys.new_(app);
Io_url url = loader.Make_load_url(wiki.Domain_str(), key);
Io_mgr.Instance.SaveFilStr(url, data);
}
public Xoa_site_cfg_mgr_fxt Exec_load() {
site_cfg_mgr.Load(wiki);
return this;
}
public void Test_extensiontags_y(String... ary) {Test_extensiontags(Bool_.Y, ary);}
public void Test_extensiontags_n(String... ary) {Test_extensiontags(Bool_.N, ary);}
public void Test_extensiontags(boolean expd_exists, String... ary) {
Btrie_slim_mgr trie = wiki.Mw_parser_mgr().Xnde_tag_regy().Get_trie(Xop_parser_tid_.Tid__defn);
int len = ary.length;
for (int i = 0; i < len; ++i) {
String str = ary[i];
byte[] bry = Bry_.new_u8(str);
boolean actl_exists = trie.Match_exact(bry, 0, bry.length) != null;
Tfds.Eq_bool(expd_exists, actl_exists, str);
}
}
public void Test_inet_qarg(String expd) {
Xoa_site_cfg_loader__inet loader__inet = (Xoa_site_cfg_loader__inet)site_cfg_mgr.Loader_ary()[2];
String api_url = loader__inet.Api_url();
Tfds.Eq(expd, String_.Mid(api_url, String_.FindBwd(api_url, "=") + 1));
}
public String Make_api(byte[]... sections) {
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
bfr.Add_str_a7("{'query':");
int len = sections.length;
bfr.Add_str_a7("{");
for (int i = 0; i < len; ++i) {
if (i != 0) bfr.Add_str_a7(",");
bfr.Add(sections[i]);
}
bfr.Add_str_a7("}");
bfr.Add_str_a7("}");
return printer.Print_by_bry(Bry_.new_u8(Json_doc.Make_str_by_apos(bfr.To_str_and_rls()))).To_str();
}
public byte[] Make_api_interwikimap(String... ary) {
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
bfr.Add_str_a7("'interwikimap':");
int len = ary.length;
bfr.Add_str_a7("[");
for (int i = 0; i < len; i += 2) {
if (i != 0) bfr.Add_str_a7(",");
bfr.Add_str_a7("{'prefix':'" + ary[i] + "'");
bfr.Add_str_a7(",'url':'" + ary[i + 1] + "'");
bfr.Add_str_a7("}");
}
bfr.Add_str_a7("]");
return bfr.To_bry_and_clear();
}
public byte[] Make_api_extensiontags(String... ary) {
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
bfr.Add_str_a7("'extensiontags':");
int len = ary.length;
bfr.Add_str_a7("[");
for (int i = 0; i < len; ++i) {
if (i != 0) bfr.Add_str_a7(",");
bfr.Add_str_a7("'<" + ary[i] + ">'");
}
bfr.Add_str_a7("]");
return bfr.To_bry_and_clear();
}
public String Make_data(int loader_tid, int flds, String... ary) {
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
if (loader_tid != Xoa_site_cfg_loader_.Tid__null) // null when constructing data for fsys
bfr.Add_str_u8(Xoa_site_cfg_loader__db.Bld_meta(loader_tid)).Add_byte_nl();
int len = ary.length;
for (int i = 0; i < len; i += flds) {
if (i != 0) bfr.Add_byte_nl();
for (int j = 0; j < flds; ++j) {
if (j != 0) bfr.Add_byte_pipe();
bfr.Add_str_u8(ary[i + j]);
}
}
return bfr.To_str_and_rls();
}
}

View File

@@ -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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xoa_url__basic__tst {
private final Xoa_url_fxt fxt = new Xoa_url_fxt();
@Test public void Eq_page() {
fxt.Test_eq_page(Bool_.Y, "en.wikipedia.org/wiki/A?redirect=yes", "en.wikipedia.org/wiki/A?redirect=yes");
fxt.Test_eq_page(Bool_.N, "en.wikipedia.org/wiki/A?redirect=no" , "en.wikipedia.org/wiki/A?redirect=yes");
}
}
class Xoa_url_fxt extends Xow_url_parser_fxt { public void Test_eq_page(boolean expd, String lhs_str, String rhs_str) {
Xoa_url lhs_url = parser.Parse(Bry_.new_u8(lhs_str));
Xoa_url rhs_url = parser.Parse(Bry_.new_u8(rhs_str));
Tfds.Eq_bool(expd, lhs_url.Eq_page(rhs_url), "Eq_page");
}
}

View File

@@ -1,54 +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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.xowa.htmls.hrefs.*;
import gplx.xowa.wikis.nss.*;
public class Xoa_url__to_str__tst {
private final Xoa_url__to_str__fxt fxt = new Xoa_url__to_str__fxt();
@Test public void Http() {fxt.Chk_to_str_href(Bool_.N, "http://a.org/b" , "http://a.org/b");}
@Test public void File() {fxt.Chk_to_str_href(Bool_.N, "file:///C/xowa/file/a.png" , "file:///C/xowa/file/a.png");}
@Test public void Abrv__page() {fxt.Chk_to_str_href(Bool_.N, "/wiki/A" , "A");}
@Test public void Abrv__anch() {fxt.Chk_to_str_href(Bool_.N, "#b" , "#b");}
@Test public void Full__page() {fxt.Chk_to_str_href(Bool_.Y, "/wiki/A" , "en.wikipedia.org/wiki/A");}
@Test public void Full__anch() {fxt.Chk_to_str_href(Bool_.Y, "#b" , "en.wikipedia.org/wiki/Page_1#b");}
@Test public void Vnt() {
Xowe_wiki zh_wiki = fxt.Prep_create_wiki("zh.wikipedia.org");
gplx.xowa.langs.vnts.Xol_vnt_regy_fxt.Init__vnt_mgr(zh_wiki.Lang().Vnt_mgr(), 0, String_.Ary("zh-hans", "zh-hant"));
fxt.Chk_to_str_href(zh_wiki, Bool_.Y, "/site/zh.wikipedia.org/zh-hans/A" , "zh.wikipedia.org/zh-hans/A");
fxt.Chk_to_str_href(zh_wiki, Bool_.Y, "/site/zh.wikipedia.org/zh-hant/A" , "zh.wikipedia.org/zh-hant/A");
fxt.Chk_to_str_href(zh_wiki, Bool_.Y, "/site/zh.wikipedia.org/zh-cn/A" , "zh.wikipedia.org/wiki/A");
fxt.Chk_to_str_href(zh_wiki, Bool_.Y, "/site/zh.wikipedia.org/wiki/A" , "zh.wikipedia.org/wiki/A");
}
@Test public void Xwiki() {
fxt.Prep_add_xwiki_to_user("fr.wikipedia.org");
fxt.Chk_to_str_href(Bool_.N, "/site/fr.wikipedia.org/wiki/Page", "fr.wikipedia.org/wiki/Page");
}
@Test public void Alias() {
fxt.Prep_add_xwiki_to_wiki("wikt", "en.wiktionary.org");
Xow_wiki en_d = fxt.Prep_create_wiki("en.wiktionary.org");
en_d.Ns_mgr().Ns_main().Case_match_(Xow_ns_case_.Tid__all);
fxt.Chk_to_str_href(Bool_.N, "/wiki/wikt:a" , "en.wiktionary.org/wiki/a");
}
@Test public void Unknown() {fxt.Chk_to_str_href(Bool_.N, "/wiki/{{{extlink}}}" , "");} // {{{extlink}}} not a valid title; return empty
}
class Xoa_url__to_str__fxt extends Xow_url_parser_fxt { private final Xoh_href_parser href_parser = new Xoh_href_parser();
public void Chk_to_str_href(boolean full, String raw, String expd) {Chk_to_str_href(cur_wiki, full, raw, expd);}
public void Chk_to_str_href(Xowe_wiki wiki, boolean full, String raw, String expd) {
href_parser.Parse_as_url(actl_url, Bry_.new_u8(raw), wiki, Bry__page);
this.Test__to_str(full, expd);
}
private static final byte[] Bry__page = Bry_.new_a7("Page_1");
}

View File

@@ -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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xoav_url_parser_tst {
@Before public void init() {fxt.Clear();} private final Xoav_url_parser_fxt fxt = new Xoav_url_parser_fxt();
@Test public void Page() {
fxt.Exec_parse_xo_href("http:/wiki/Earth").Test_wiki("en.wikipedia.org").Test_page("Earth");
}
@Test public void Site() {
fxt.Exec_parse_xo_href("http:/site/en.wikipedia.org/wiki/Earth").Test_wiki("en.wikipedia.org").Test_page("Earth");
}
}
class Xoav_url_parser_fxt {
private Xoav_url_parser url_parser = new Xoav_url_parser(); private Xoav_url url = new Xoav_url();
public void Clear() {
cur_wiki = Bry_.new_a7("en.wikipedia.org");
url.Clear();
}
public Xoav_url_parser_fxt Init_cur_wiki(String v) {cur_wiki = Bry_.new_u8(v); return this;} private byte[] cur_wiki;
public Xoav_url_parser_fxt Test_wiki(String v) {Tfds.Eq_bry(Bry_.new_u8(v), url.Wiki_bry()); return this;}
public Xoav_url_parser_fxt Test_page(String v) {Tfds.Eq_bry(Bry_.new_u8(v), url.Page_bry()); return this;}
public Xoav_url_parser_fxt Exec_parse_xo_href(String src_str) {
byte[] src_bry = Bry_.new_u8(src_str);
url_parser.Parse_xo_href(url, src_bry, cur_wiki);
return this;
}
}

View File

@@ -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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xow_url_parser__proto_tst {
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
@Test public void Relative() {
tstr.Exec__parse("//en.wikipedia.org/wiki/A").Test__wiki("en.wikipedia.org").Test__page("A");
}
@Test public void Http__basic() {
tstr.Exec__parse("http://en.wikipedia.org/wiki/A").Test__wiki("en.wikipedia.org").Test__page("A");
}
@Test public void Upload__basic() {
tstr.Prep_add_xwiki_to_user("commons.wikimedia.org"); // NOTE: need to add xwiki to be able to resolve "/commons/"
tstr.Exec__parse("http://upload.wikimedia.org/wikipedia/commons/a/ab/C.svg").Test__wiki("commons.wikimedia.org").Test__page("File:C.svg"); // orig
tstr.Exec__parse("http://upload.wikimedia.org/wikipedia/commons/thumb/7/70/A.png/220px-A.png").Test__wiki("commons.wikimedia.org").Test__page("File:A.png"); // thum
}
@Test public void File__basic() {
tstr.Exec__parse("file:///C:/a/b/c").Test__tid(Xoa_url_.Tid_file);
}
@Test public void Ftp__basic() {
tstr.Exec__parse("ftp://en.wikipedia.org/wiki/A").Test__tid(Xoa_url_.Tid_inet);
}
@Test public void Extended() {
tstr.Exec__parse("http://en.wikipedia.org/w/index.php?A=B").Test__wiki("en.wikipedia.org").Test__page("index.php").Test__qargs("?A=B").Test__anch(null);
}
}

View File

@@ -1,62 +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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xow_url_parser__qarg__tst {
private final Xow_url_parser_fxt fxt = new Xow_url_parser_fxt();
@Test public void Redirect() {
fxt.Exec__parse("A?redirect=no").Test__wiki("en.wikipedia.org").Test__page("A").Test__qargs("?redirect=no");
}
@Test public void Action_is_edit() {
fxt.Exec__parse("A?action=edit").Test__wiki("en.wikipedia.org").Test__page("A").Test__action_is_edit_y();
}
@Test public void Assert_state_cleared() { // PURPOSE.fix: action_is_edit (et. al.) was not being cleared on parse even though Xoa_url reused; DATE:20121231
fxt.Exec__parse("A?action=edit") .Test__action_is_edit_y();
fxt.Exec__parse_reuse("B") .Test__action_is_edit_n();
}
@Test public void Query_arg() { // PURPOSE.fix: query args were not printing out
fxt.Exec__parse("en.wikipedia.org/wiki/Special:Search/Earth?fulltext=yes").Test__build_str_is_same();
}
@Test public void Dupe_key() {
fxt.Exec__parse("A?B=C1&B=C2").Test__page("A").Test__qargs("?B=C1&B=C2");
}
@Test public void Question_is_eos() {
fxt.Exec__parse("A?").Test__wiki("en.wikipedia.org").Test__page("A?").Test__qargs("");
}
@Test public void Question_is_page() {
fxt.Exec__parse("A?B").Test__wiki("en.wikipedia.org").Test__page("A?B").Test__qargs("");
}
@Test public void Question_is_anchor() {
fxt.Exec__parse("A#b?c").Test__wiki("en.wikipedia.org").Test__page("A").Test__anch("b.3Fc");
}
@Test public void Title_remove_w() { // PURPOSE: fix /w/ showing up as seg; DATE:2014-05-30
fxt.Exec__parse("http://en.wikipedia.org/w/index.php?title=A").Test__wiki("en.wikipedia.org").Test__page("A");
}
@Test public void Ctg() {
fxt.Exec__parse("Category:A?pagefrom=A#mw-pages").Test__page("Category:A").Test__qargs("?pagefrom=A").Test__anch("mw-pages");
}
@Test public void Anch() {
fxt.Exec__parse("A?k1=v1#anch");
fxt.Test__page("A");
fxt.Test__anch("anch");
fxt.Test__qargs("?k1=v1");
fxt.Test__to_str("en.wikipedia.org/wiki/A?k1=v1#anch");
}
// DELETED: this is wrong as url should not handle html_entities like &#61; instead # should strictly designate anch_href; DATE:2016-10-10
// @Test public void Encoded() {
// fxt.Exec__parse("en.wikipedia.org/wiki/A?action&#61;edit&preload&#61;B").Test__wiki("en.wikipedia.org").Test__page("A").Test__qargs("?action=&#61;edit=&preload=&=").Test__anch("61.3BB"); // NOTE: this is wrong; fix later
// }
}

View File

@@ -1,54 +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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xow_url_parser__ttl_tst {
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
@Test public void Name() {
tstr.Exec__parse("A").Test__wiki("en.wikipedia.org").Test__page("A");
}
@Test public void Sub_1() {
tstr.Exec__parse("A/b").Test__wiki("en.wikipedia.org").Test__page("A/b");
}
@Test public void Sub_2() {
tstr.Exec__parse("A/b/c").Test__wiki("en.wikipedia.org").Test__page("A/b/c");
}
@Test public void Anch() {
tstr.Exec__parse("A#b").Test__wiki("en.wikipedia.org").Test__page("A").Test__anch("b");
}
@Test public void Anch_w_slash() { // PURPOSE: A/b#c/d was not parsing correctly; PAGE:en.w:Enlightenment_Spain#Enlightened_despotism_.281759%E2%80%931788.29
tstr.Exec__parse("A/b#c/d").Test__page("A/b").Test__anch("c.2Fd");
}
@Test public void Ns_category() {
tstr.Exec__parse("Category:A").Test__wiki("en.wikipedia.org").Test__page("Category:A");
}
@Test public void Main_page__basic() {
tstr.Exec__parse("en.wikipedia.org") .Test__wiki("en.wikipedia.org").Test__page_is_main_y();
tstr.Exec__parse("en.wikipedia.org/") .Test__wiki("en.wikipedia.org").Test__page_is_main_y();
tstr.Exec__parse("en.wikipedia.org/wiki") .Test__wiki("en.wikipedia.org").Test__page_is_main_y();
tstr.Exec__parse("en.wikipedia.org/wiki/") .Test__wiki("en.wikipedia.org").Test__page_is_main_y();
tstr.Exec__parse("en.wikipedia.org/wiki/A") .Test__wiki("en.wikipedia.org").Test__page_is_main_n();
}
@Test public void Ns_file__basic() {// PURPOSE: "File:A" should not be mistaken for "file:///" ns
tstr.Exec__parse("File:A").Test__wiki("en.wikipedia.org").Test__page("File:A");
}
@Test public void Ns_file__nested() {// PURPOSE: handle fictitious "File:A/B/C.png"
tstr.Exec__parse("File:A/B/C.png").Test__wiki("en.wikipedia.org").Test__page("File:A/B/C.png"); // should not be C.png b/c of Gfo_url_parser_old
}
@Test public void Anch__basic() {// DATE:2015-07-26
tstr.Exec__parse("#A").Test__tid(Xoa_url_.Tid_anch).Test__wiki_is_missing(true).Test__page("").Test__anch("A");
}
}

View File

@@ -1,66 +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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xow_url_parser__url_bar_tst {
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
@Test public void Basic() {
tstr.Exec__parse_from_url_bar("Page_1").Test__to_str("en.wikipedia.org/wiki/Page_1"); // basic
}
@Test public void Lang() {
tstr.Prep_add_xwiki_to_user("uk", "uk.wikipedia.org");
tstr.Exec__parse_from_url_bar("uk").Test__to_str("en.wikipedia.org/wiki/Uk"); // lang-like page (uk=Ukraine) should not try to open wiki; DATE:2014-02-07
}
@Test public void Lang_like() {
tstr.Prep_add_xwiki_to_user("uk", "uk.wikipedia.org", "http://~{1}.wikipedia.org"); // NOTE: fmt needed for Type_is_lang
tstr.Exec__parse_from_url_bar("uk/A").Test__to_str("en.wikipedia.org/wiki/Uk/A"); // uk/A should not try be interpreted as wiki="uk" page="A"; DATE:2014-04-26
}
@Test public void Macro() {
tstr.Prep_add_xwiki_to_user("fr.wikisource.org");
tstr.Exec__parse_from_url_bar("fr.s:Auteur:Shakespeare").Test__to_str("fr.wikisource.org/wiki/Auteur:Shakespeare"); // url_macros
}
@Test public void Main_page__home() {
tstr.Exec__parse_from_url_bar("home").Test__to_str("en.wikipedia.org/wiki/Home"); // home should go to current wiki's home; DATE:2014-02-09
tstr.Exec__parse_from_url_bar("home/wiki/Main_Page").Test__to_str("home/wiki/Main_Page"); // home Main_Page should go to home; DATE:2014-02-09
}
@Test public void Main_page__zhw() {
Xowe_wiki zh_wiki = tstr.Prep_create_wiki("zh.wikipedia.org");
zh_wiki.Props().Main_page_(Bry_.new_a7("Zh_Main_Page"));
tstr.Exec__parse_from_url_bar("zh.w:Main_Page") .Test__page_is_main_n().Test__to_str("zh.wikipedia.org/wiki/Main_Page");
tstr.Exec__parse_from_url_bar("zh.w:") .Test__page_is_main_y().Test__to_str("zh.wikipedia.org/wiki/Zh_Main_Page");
tstr.Exec__parse_from_url_bar("en.w:") .Test__page_is_main_y().Test__to_str("en.wikipedia.org/wiki/Main_Page"); // old bug: still stuck at zh main page due to reused objects
}
@Test public void Mobile() { // PURPOSE: handle mobile links; DATE:2014-05-03
tstr.Exec__parse_from_url_bar("en.m.wikipedia.org/wiki/A" ).Test__to_str("en.wikipedia.org/wiki/A"); // basic
tstr.Exec__parse_from_url_bar("en.M.wikipedia.org/wiki/A" ).Test__to_str("en.wikipedia.org/wiki/A"); // upper
tstr.Exec__parse_from_url_bar("A" ).Test__to_str("en.wikipedia.org/wiki/A"); // bounds-check: 0
tstr.Exec__parse_from_url_bar("A." ).Test__to_str("en.wikipedia.org/wiki/A."); // bounds-check: 1
tstr.Exec__parse_from_url_bar("A.b" ).Test__to_str("en.wikipedia.org/wiki/A.b"); // bounds-check: 2
tstr.Exec__parse_from_url_bar("A.b.m." ).Test__to_str("en.wikipedia.org/wiki/A.b.m."); // false-match
tstr.Exec__parse_from_url_bar("en.x.wikipedia.org/wiki/A" ).Test__to_str("en.wikipedia.org/wiki/En.x.wikipedia.org/wiki/A"); // fail
}
@Test public void Missing_page() {
tstr.Exec__parse_from_url_bar("http://a.org").Test__is_null(); // unknown wiki; return null;
tstr.Exec__parse_from_url_bar("http://en.wikipedia.org").Test__to_str("en.wikipedia.org/wiki/Main_Page"); // known wiki; return Main_Page
}
@Test public void Invalid_names() {
tstr.Exec__parse_from_url_bar("http://a/b/c").Test__is_null(); // unknown url
tstr.Exec__parse_from_url_bar("war").Test__to_str("en.wikipedia.org/wiki/War"); // word looks like lang, but is actually page; default to current
}
@Test public void Proper_case() {
tstr.Exec__parse_from_url_bar("a" ).Test__to_str("en.wikipedia.org/wiki/A"); // "a" -> "A" x> "a"
}
}

View File

@@ -1,39 +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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xow_url_parser__wiki_tst {
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
@Test public void Basic() {
tstr.Exec__parse("en.wikipedia.org/wiki/A").Test__tid(Xoa_url_.Tid_page).Test__wiki("en.wikipedia.org").Test__page("A");
}
@Test public void No_wiki() { // PURPOSE: no "/wiki/"
tstr.Exec__parse("en.wikipedia.org/A").Test__wiki("en.wikipedia.org").Test__page("A");
}
@Test public void Nested() {
tstr.Exec__parse("en.wikipedia.org/wiki/A/b").Test__wiki("en.wikipedia.org").Test__page("A/b");
}
@Test public void Slash() {
tstr.Exec__parse("en.wikipedia.org/wiki//A").Test__wiki("en.wikipedia.org").Test__page("/A");
tstr.Exec__parse("en.wikipedia.org/wiki/A//b").Test__wiki("en.wikipedia.org").Test__page("A//b");
tstr.Exec__parse("en.wikipedia.org/wiki///A").Test__wiki("en.wikipedia.org").Test__page("//A");
}
@Test public void Vnt() {
Xowe_wiki wiki = tstr.Wiki();
gplx.xowa.langs.vnts.Xol_vnt_regy_fxt.Init__vnt_mgr(wiki.Lang().Vnt_mgr(), 0, String_.Ary("zh-hans", "zh-hant"));
tstr.Exec__parse("en.wikipedia.org/zh-hans/A").Test__wiki("en.wikipedia.org").Test__page("A").Test__vnt("zh-hans");
}
}

View File

@@ -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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xow_url_parser__xcmd_tst {
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
@Test public void Basic() {
tstr.Exec__parse("xowa-cmd:xowa.app.version").Test__tid(Xoa_url_.Tid_xcmd).Test__page("xowa.app.version");
}
@Test public void Encoded() {
tstr.Exec__parse("xowa-cmd:a%22b*c").Test__tid(Xoa_url_.Tid_xcmd).Test__page("a\"b*c");
}
@Test public void Ignore_anchor_and_qargs() {
tstr.Exec__parse("xowa-cmd:a/b/c?d=e#f").Test__tid(Xoa_url_.Tid_xcmd).Test__page("a/b/c?d=e#f");
}
}

View File

@@ -1,78 +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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.xowa.wikis.nss.*;
public class Xow_url_parser__xwiki_tst {
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
@Test public void Commons() { // PURPOSE: "C" was being picked up as an xwiki to commons; PAGE:no.b:C/Variabler; DATE:2014-10-14
tstr.Prep_add_xwiki_to_user("c", "commons.wikimedia.org"); // add alias of "c"
tstr.Exec__parse("C/D").Test__tid(Xoa_url_.Tid_page).Test__wiki("en.wikipedia.org").Test__page("C/D"); // should use current wiki (enwiki), not xwiki to commons; also, page should be "C/D", not "D"
}
@Test public void Parse_lang() {
tstr.Prep_add_xwiki_to_wiki("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/~{0}");
tstr.Exec__parse("http://en.wikipedia.org/wiki/fr:A").Test__tid(Xoa_url_.Tid_page).Test__wiki("fr.wikipedia.org").Test__page("A");
}
@Test public void Alias_wiki() {
tstr.Prep_add_xwiki_to_wiki("s", "en.wikisource.org");
tstr.Exec__parse("s:A/b/c").Test__wiki("en.wikisource.org").Test__page("A/b/c");
}
@Test public void Xwiki_no_segs() { // PURPOSE: handle xwiki without full url; EX: "commons:Commons:Media_of_the_day"; DATE:2014-02-19
tstr.Prep_add_xwiki_to_wiki("s", "en.wikisource.org");
tstr.Exec__parse("s:Project:A").Test__wiki("en.wikisource.org").Test__page("Project:A");
}
@Test public void Domain_only() {
tstr.Prep_add_xwiki_to_user("fr.wikipedia.org");
tstr.Exec__parse("fr.wikipedia.org").Test__wiki("fr.wikipedia.org").Test__page("");
}
@Test public void Domain_and_wiki() {
tstr.Prep_add_xwiki_to_user("fr.wikipedia.org");
tstr.Exec__parse("fr.wikipedia.org/wiki").Test__wiki("fr.wikipedia.org").Test__page("");
}
@Test public void Domain_and_wiki_w_http() {
tstr.Prep_add_xwiki_to_user("fr.wikipedia.org");
tstr.Exec__parse("http://fr.wikipedia.org/wiki").Test__wiki("fr.wikipedia.org").Test__page("");
}
@Test public void Namespace_in_different_wiki() { // PURPOSE.fix: namespaced titles would default to default_wiki instead of current_wiki
Xowe_wiki en_s = tstr.Prep_create_wiki("en.wikisource.org");
tstr.Exec__parse(en_s, "Category:A").Test__wiki("en.wikisource.org").Test__page("Category:A");
}
@Test public void Case_sensitive() {
// tstr.Exec__parse("en.wikipedia.org/wiki/a").Test__wiki("en.wikipedia.org").Test__page("A");
Xowe_wiki en_d = tstr.Prep_create_wiki("en.wiktionary.org");
Xow_ns_mgr ns_mgr = en_d.Ns_mgr();
ns_mgr.Ns_main().Case_match_(Xow_ns_case_.Tid__all);
tstr.Exec__parse("en.wiktionary.org/wiki/a").Test__wiki("en.wiktionary.org").Test__page("a");
ns_mgr.Ns_category().Case_match_(Xow_ns_case_.Tid__all);
tstr.Exec__parse("en.wiktionary.org/wiki/Category:a").Test__wiki("en.wiktionary.org").Test__page("Category:a");
tstr.Exec__parse("en.wiktionary.org/wiki/A/B/C").Test__page("A/B/C");
}
@Test public void Xwiki__to_enwiki() { // PURPOSE: handle alias of "wikipedia" and sv.wikipedia.org/wiki/Wikipedia:Main_Page; DATE:2015-07-31
Xowe_wiki xwiki = tstr.Prep_create_wiki("sv.wikipedia.org");
tstr.Prep_xwiki(xwiki, "wikipedia", "en.wikipedia.org", null);
tstr.Prep_get_ns_mgr_from_meta("sv.wikipedia.org").Add_new(Xow_ns_.Tid__project, "Wikipedia");
tstr.Exec__parse(xwiki, "sv.wikipedia.org/wiki/wikipedia:X").Test__wiki("sv.wikipedia.org").Test__page("wikipedia:X");
tstr.Exec__parse(xwiki, "sv.wikipedia.org/wiki/Wikipedia:X").Test__wiki("sv.wikipedia.org").Test__page("Wikipedia:X");
}
@Test public void Xwiki__to_ns() { // PURPOSE: handle alias of "wikipedia" in current, but no "Wikipedia" ns in other wiki; PAGE:pt.w:Wikipedia:P<>gina_de_testes DATE:2015-09-17
tstr.Prep_create_wiki("pt.wikipedia.org");
tstr.Prep_get_ns_mgr_from_meta("pt.wikipedia.org").Add_new(Xow_ns_.Tid__project, "Project"); // clear ns_mgr and add only "Project" ns, not "Wikipedia" ns
tstr.Prep_xwiki(tstr.Wiki(), "wikipedia", "en.wikipedia.org", null); // add alias of "wikipedia" in current wiki
tstr.Exec__parse(tstr.Wiki(), "pt.wikipedia.org/wiki/Wikipedia:X").Test__wiki("pt.wikipedia.org").Test__page("Wikipedia:X"); // should get "pt.wikipedia.org", not "en.wikipedia.org" (through alias)
}
}

View File

@@ -1,81 +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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.wikis.nss.*;
public class Xow_url_parser_fxt {
protected final Xoae_app app; protected final Xowe_wiki cur_wiki;
protected final Xow_url_parser parser;
protected Xoa_url actl_url;
public Xow_url_parser_fxt() {
this.app = Xoa_app_fxt.Make__app__edit();
this.cur_wiki = Prep_create_wiki("en.wikipedia.org");
this.parser = cur_wiki.Utl__url_parser();
this.actl_url = Xoa_url.blank(); // default to blank for subclasses
}
public Xoae_app App() {return app;}
public Xowe_wiki Wiki() {return cur_wiki;}
public Xowe_wiki Prep_create_wiki(String domain) {
Xowe_wiki rv = Xoa_app_fxt.Make__wiki__edit(app, domain);
Prep_add_xwiki_to_user(domain);
return rv;
}
public Xow_url_parser_fxt Prep_add_xwiki_to_wiki(String alias, String domain) {return Prep_xwiki(cur_wiki, alias, domain, null);}
public Xow_url_parser_fxt Prep_add_xwiki_to_wiki(String alias, String domain, String fmt) {return Prep_xwiki(cur_wiki, alias, domain, fmt);}
public Xow_url_parser_fxt Prep_add_xwiki_to_user(String domain) {return Prep_xwiki(app.Usere().Wiki(), domain, domain, null);}
public Xow_url_parser_fxt Prep_add_xwiki_to_user(String alias, String domain) {return Prep_xwiki(app.Usere().Wiki(), alias, domain, null);}
public Xow_url_parser_fxt Prep_add_xwiki_to_user(String alias, String domain, String fmt) {return Prep_xwiki(app.Usere().Wiki(), alias, domain, fmt);}
public Xow_url_parser_fxt Prep_xwiki(Xow_wiki wiki, String alias, String domain, String fmt) {
wiki.Xwiki_mgr().Add_by_atrs(Bry_.new_u8(alias), Bry_.new_u8(domain), Bry_.new_u8_safe(fmt));
return this;
}
public Xow_ns_mgr Prep_get_ns_mgr_from_meta(String wiki) {
return app.Dbmeta_mgr().Ns__get_or_load(Bry_.new_u8(wiki));
}
public Xow_url_parser_fxt Exec__parse(String actl_str) {return Exec__parse(cur_wiki, actl_str);}
public Xow_url_parser_fxt Exec__parse(Xow_wiki wiki, String actl_str) {
this.actl_url = wiki.Utl__url_parser().Parse(Bry_.new_u8(actl_str));
return this;
}
public Xow_url_parser_fxt Exec__parse_reuse(String actl_str) {
this.actl_url = parser.Parse(Bry_.new_u8(actl_str));
return this;
}
public Xow_url_parser_fxt Exec__parse_from_url_bar(String raw) {
this.actl_url = parser.Parse_by_urlbar_or_null(raw);
return this;
}
public Xow_url_parser_fxt Test__tid(int v) {Tfds.Eq_int(v, actl_url.Tid() , "tid"); return this;}
public Xow_url_parser_fxt Test__is_null() {Tfds.Eq_bool(true, actl_url == null); return this;}
public Xow_url_parser_fxt Test__vnt(String v) {Tfds.Eq_str(v, actl_url.Vnt_bry() , "vnt"); return this;}
public Xow_url_parser_fxt Test__wiki(String v) {Tfds.Eq_str(v, actl_url.Wiki_bry() , "wiki"); return this;}
public Xow_url_parser_fxt Test__wiki_is_missing(boolean v) {Tfds.Eq_bool(v, actl_url.Wiki_is_missing(), "wiki_is_missing"); return this;}
public Xow_url_parser_fxt Test__page(String v) {Tfds.Eq_str(v, actl_url.Page_bry() , "page"); return this;}
public Xow_url_parser_fxt Test__qargs(String v) {Tfds.Eq_str(v, actl_url.Qargs_mgr().To_bry(), "qargs"); return this;}
public Xow_url_parser_fxt Test__page_is_main_y() {return Test__page_is_main(Bool_.Y);}
public Xow_url_parser_fxt Test__page_is_main_n() {return Test__page_is_main(Bool_.N);}
public Xow_url_parser_fxt Test__page_is_main(boolean v) {Tfds.Eq_bool(v, actl_url.Page_is_main() , "page_is_main"); return this;}
public Xow_url_parser_fxt Test__anch(String v) {Tfds.Eq_str(v, actl_url.Anch_bry(), "anch"); return this;}
public Xow_url_parser_fxt Test__action_is_edit_y() {return Test__action_is_edit_(Bool_.Y);}
public Xow_url_parser_fxt Test__action_is_edit_n() {return Test__action_is_edit_(Bool_.N);}
private Xow_url_parser_fxt Test__action_is_edit_(boolean v) {Tfds.Eq_bool(v, actl_url.Qargs_mgr().Match(Xoa_url_.Qarg__action, Xoa_url_.Qarg__action__edit), "action_is_edit"); return this;}
public Xow_url_parser_fxt Test__to_str(String v) {return Test__to_str(Bool_.Y, v);}
public Xow_url_parser_fxt Test__to_str(boolean full, String v) {Tfds.Eq_str(v, actl_url.To_bry(full, Bool_.Y), "To_bry"); return this;}
public Xow_url_parser_fxt Test__build_str_is_same() {
Xow_url_parser parser = new Xow_url_parser(cur_wiki);
Tfds.Eq_str(actl_url.Raw(), parser.Build_str(actl_url), "build_str");
return this;
}
}

View File

@@ -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.apps.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoa_url_encoder__tst {
private final Xoa_url_encoder__fxt fxt = new Xoa_url_encoder__fxt();
@Test public void Syms__diff() {fxt.Test__encode(" &'=+", "_%26%27%3D%2B");}
@Test public void Syms__same() {fxt.Test__encode("!\"#$%()*,-./:;<>?@[\\]^_`{|}~", "!\"#$%()*,-./:;<>?@[\\]^_`{|}~");}
@Test public void Mixed() {fxt.Test__encode("a &'=+b", "a_%26%27%3D%2Bb");} // PURPOSE: make sure dirty flag is set
}
class Xoa_url_encoder__fxt {
private final Xoa_url_encoder encoder = new Xoa_url_encoder();
public void Test__encode(String raw, String expd) {
Gftest.Eq__bry(Bry_.new_u8(expd), encoder.Encode(Bry_.new_u8(raw)));
}
}

View File

@@ -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.apps.versions; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xoa_version_tst {
@Before public void init() {fxt.Clear();} private Xoa_version_fxt fxt = new Xoa_version_fxt();
@Test public void Compare() {
fxt.Test_compare("1.8.1.1", "1.8.2.1" , CompareAble_.Less); // rev:less
fxt.Test_compare("1.8.2.1", "1.8.1.1" , CompareAble_.More); // rev:more
fxt.Test_compare("1.8.1.1", "1.8.1.1" , CompareAble_.Same); // rev:same
fxt.Test_compare("1.7.9.1", "1.8.1.1" , CompareAble_.Less); // min:less
fxt.Test_compare("", "1.8.1.1" , CompareAble_.Less); // empty:less
fxt.Test_compare("1.8.1.1", "" , CompareAble_.More); // empty:more
fxt.Test_compare("", "" , CompareAble_.Same); // empty:more
}
}
class Xoa_version_fxt {
public void Clear() {}
public void Test_compare(String lhs, String rhs, int expd) {
Tfds.Eq(expd, Xoa_version_.Compare(lhs, rhs), lhs + "|" + rhs);
}
}

View File

@@ -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.apps.wms.apis.origs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.wms.*; import gplx.xowa.apps.wms.apis.*;
import org.junit.*;
// https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Main Page&rvprop=timestamp|content
public class Xoapi_orig_base_tst {
Xoapi_orig_base_fxt fxt = new Xoapi_orig_base_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Bld_api_url() {
fxt.Bld_api_url_tst("A.png" , 220, 110, "https://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A.png&iiurlwidth=220&iiurlheight=110");
fxt.Bld_api_url_tst("A.png" , 220, 0, "https://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A.png&iiurlwidth=220");
fxt.Bld_api_url_tst("A.png" , 0, 110, "https://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A.png"); // assert that null width does not write height
fxt.Bld_api_url_tst("A b.png" , 220, 0, "https://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A_b.png&iiurlwidth=220");
fxt.Bld_api_url_tst("A&b.png" , 220, 0, "https://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A%26b.png&iiurlwidth=220");
}
@Test public void Parse_size() {
String raw = "<api><query><pages><page ns=\"6\" title=\"File:A.png\" missing=\"\" imagerepository=\"shared\"><imageinfo><ii size=\"1234\" width=\"220\" height=\"110\" /></imageinfo></page></pages></query></api>";
fxt.Parse_size_tst(raw, 220, 110);
}
@Test public void Parse_reg() {
String raw = "<api><query><pages><page ns=\"6\" title=\"File:A.png\" missing=\"\" imagerepository=\"shared\"><imageinfo><ii descriptionurl=\"http://commons.wikimedia.org/wiki/File:Berkheyde-Haarlem.png\" /></imageinfo></page></pages></query></api>";
fxt.Parse_reg_tst(raw, "commons.wikimedia.org", "Berkheyde-Haarlem.png");
}
}
class Xoapi_orig_base_fxt {
private Xoae_app app; private Xowe_wiki wiki; private Xoapi_orig_rslts rv = new Xoapi_orig_rslts();
public void Clear() {
this.app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
}
public void Bld_api_url_tst(String ttl_str, int w, int h, String expd) {
String actl = Xoapi_orig_wmf.Bld_api_url(wiki.Domain_bry(), Bry_.new_u8(ttl_str), w, h);
Tfds.Eq(expd, actl);
}
public void Parse_size_tst(String xml_str, int expd_w, int expd_h) {
byte[] xml_bry = Bry_.new_u8(xml_str);
Xoapi_orig_wmf.Parse_xml(rv, app.Usr_dlg(), xml_bry);
Tfds.Eq(expd_w, rv.Orig_w());
Tfds.Eq(expd_h, rv.Orig_h());
}
public void Parse_reg_tst(String xml_str, String expd_wiki, String expd_page) {
byte[] xml_bry = Bry_.new_u8(xml_str);
Xoapi_orig_wmf.Parse_xml(rv, app.Usr_dlg(), xml_bry);
Tfds.Eq(expd_wiki, String_.new_u8(rv.Orig_wiki()));
Tfds.Eq(expd_page, String_.new_u8(rv.Orig_page()));
}
}

View File

@@ -1,34 +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.apps.wms.apis.origs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.wms.*; import gplx.xowa.apps.wms.apis.*;
import gplx.xowa.files.downloads.*;
public class Xoapi_orig_mok extends Xoapi_orig_base {
private String wiki_str = "", ttl_str = "", redirect_str = ""; private int orig_w, orig_h; private boolean fail = false;
public Xoapi_orig_mok Ini(String wiki_str, String ttl_str, String redirect_str, int orig_w, int orig_h, boolean pass) {
this.wiki_str = wiki_str; this.ttl_str = ttl_str; this.redirect_str = redirect_str; this.orig_w = orig_w; this.orig_h = orig_h; this.fail = !pass;
return this;
}
public void Clear() {wiki_str = ttl_str = redirect_str = ""; orig_w = orig_h = 0;}
@Override public boolean Api_query_size_exec(Xoapi_orig_rslts rv, Xof_download_wkr download_wkr, byte[] ttl, int width, int height, Gfo_usr_dlg usr_dlg, byte[] repo_wiki_key) {
if (!Bry_.Eq(ttl, Bry_.new_u8(ttl_str))) return false;
if (!String_.Eq(wiki_str, String_.new_a7(repo_wiki_key))) return false;
if (fail) return false;
byte[] orig_page = String_.Eq(redirect_str, "") ? ttl : Bry_.new_u8(redirect_str);
rv.Init_all(repo_wiki_key, orig_page, orig_w, orig_h);
return true;
}
public static final Xoapi_orig_mok Instance = new Xoapi_orig_mok(); Xoapi_orig_mok() {}
}