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,55 +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;
|
||||
import org.junit.*;
|
||||
public class GfoMsg_rdr_tst {
|
||||
@Before public void setup() {
|
||||
msg = msg_().Add("a", "1").Add("b", "2").Add("c", "3");
|
||||
ctx.Match("init", "init");
|
||||
} GfoMsg msg; GfsCtx ctx = GfsCtx.new_();
|
||||
@Test public void Key() {
|
||||
tst_Msg(msg, "a", "1");
|
||||
tst_Msg(msg, "b", "2");
|
||||
tst_Msg(msg, "c", "3");
|
||||
tst_Msg(msg, "d", null);
|
||||
}
|
||||
@Test public void Pos() {
|
||||
msg = msg_().Add("", "1").Add("", "2").Add("", "3");
|
||||
tst_Msg(msg, "", "1");
|
||||
tst_Msg(msg, "", "2");
|
||||
tst_Msg(msg, "", "3");
|
||||
tst_Msg(msg, "", null);
|
||||
}
|
||||
@Test public void OutOfOrder() {
|
||||
tst_Msg(msg, "c", "3");
|
||||
tst_Msg(msg, "b", "2");
|
||||
tst_Msg(msg, "a", "1");
|
||||
}
|
||||
@Test public void Key3_Pos1_Pos2() {
|
||||
msg = msg_().Add("", "1").Add("", "2").Add("c", "3");
|
||||
tst_Msg(msg, "c", "3");
|
||||
tst_Msg(msg, "", "1");
|
||||
tst_Msg(msg, "", "2");
|
||||
}
|
||||
@Test public void MultipleEmpty() {
|
||||
msg = msg_().Add("", "1").Add("", "2").Add("", "3");
|
||||
tst_Msg(msg, "", "1");
|
||||
tst_Msg(msg, "", "2");
|
||||
tst_Msg(msg, "", "3");
|
||||
}
|
||||
GfoMsg msg_() {return GfoMsg_.new_parse_("test");}
|
||||
void tst_Msg(GfoMsg m, String k, String expd) {Tfds.Eq(expd, m.ReadStrOr(k, null));}
|
||||
}
|
||||
@@ -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;
|
||||
public class GfoTreeBldr_fxt {
|
||||
public List_adp Atrs() {return atrs;} List_adp atrs = List_adp_.New();
|
||||
public List_adp Subs() {return subs;} List_adp subs = List_adp_.New();
|
||||
public GfoTreeBldr_fxt atr_(Object key, Object val) {
|
||||
atrs.Add(new Object[] {key, val});
|
||||
return this;
|
||||
}
|
||||
public GfoTreeBldr_fxt sub_(GfoTreeBldr_fxt... ary) {
|
||||
for (GfoTreeBldr_fxt sub : ary)
|
||||
subs.Add(sub);
|
||||
return this;
|
||||
}
|
||||
public static GfoTreeBldr_fxt new_() {return new GfoTreeBldr_fxt();} GfoTreeBldr_fxt() {}
|
||||
}
|
||||
@@ -1,22 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_dir_basic_memory_tst extends IoEngine_dir_basic_base {
|
||||
@Override protected void setup_hook() {
|
||||
root = Io_url_.mem_dir_("mem");
|
||||
} @Override protected IoEngine engine_() {return IoEngine_.Mem_init_();}
|
||||
}
|
||||
@@ -1,26 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_dir_basic_system_tst extends IoEngine_dir_basic_base {
|
||||
@Override protected void setup_hook() {
|
||||
root = Tfds.RscDir.GenSubDir_nest("100_core", "ioEngineTest", "_temp");
|
||||
IoEngine_xrg_deleteDir.new_(root).Recur_().ReadOnlyFails_off().Exec();
|
||||
} @Override protected IoEngine engine_() {return IoEngine_system.new_();}
|
||||
@Test @Override public void ScanDir() {
|
||||
super.ScanDir();
|
||||
}
|
||||
}
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_dir_deep_memory_tst extends IoEngine_dir_deep_base {
|
||||
@Override protected void setup_hook() {
|
||||
root = Io_url_.mem_dir_("mem/root");
|
||||
} @Override protected IoEngine engine_() {return IoEngine_.Mem_init_();}
|
||||
@Test @Override public void SearchDir() {
|
||||
super.SearchDir();
|
||||
}
|
||||
@Test @Override public void MoveDirDeep() {
|
||||
super.MoveDirDeep();
|
||||
}
|
||||
@Test @Override public void CopyDir() {
|
||||
super.CopyDir();
|
||||
}
|
||||
@Test @Override public void DeleteDir() {
|
||||
super.DeleteDir();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_dir_deep_system_tst extends IoEngine_dir_deep_base {
|
||||
@Override protected void setup_hook() {
|
||||
root = Tfds.RscDir.GenSubDir_nest("100_core", "ioEngineTest", "_temp");
|
||||
IoEngine_xrg_deleteDir.new_(root).Recur_().ReadOnlyFails_off().Exec();
|
||||
} @Override protected IoEngine engine_() {return IoEngine_.Sys;}
|
||||
}
|
||||
@@ -1,55 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_fil_basic_memory_tst extends IoEngine_fil_basic_base {
|
||||
@Override protected IoEngine engine_() {return IoEngine_.Mem_init_();}
|
||||
@Override protected void setup_hook() {
|
||||
root = Io_url_.mem_dir_("mem");
|
||||
fil = root.GenSubFil_nest("root", "fil.txt");
|
||||
}
|
||||
@Test @Override public void OpenStreamRead() {
|
||||
super.OpenStreamRead ();
|
||||
}
|
||||
@Test @Override public void SaveFilText_overwrite() {
|
||||
super.SaveFilText_overwrite();
|
||||
|
||||
// bugfix: verify changed file in ownerDir's hash
|
||||
IoItmDir dirItm = fx.tst_ScanDir(fil.OwnerDir(), fil);
|
||||
IoItmFil_mem filItm = (IoItmFil_mem)dirItm.SubFils().Get_at(0);
|
||||
Tfds.Eq(filItm.Text(), "changed");
|
||||
}
|
||||
@Test public void RecycleFil() {
|
||||
fx.run_SaveFilText(fil, "text");
|
||||
fx.tst_ExistsPaths(true, fil);
|
||||
|
||||
IoRecycleBin bin = IoRecycleBin.Instance;
|
||||
List_adp list = Tfds.RscDir.XtoNames();
|
||||
// foreach (String s in list)
|
||||
// Tfds.Write(s);
|
||||
list.Del_at(0); // remove drive
|
||||
IoEngine_xrg_recycleFil recycleXrg = bin.Send_xrg(fil)
|
||||
.RootDirNames_(list)
|
||||
.AppName_("gplx.test").Time_(DateAdp_.parse_gplx("20100102_115559123")).Uuid_(Guid_adp_.Parse("467ffb41-cdfe-402f-b22b-be855425784b"));
|
||||
recycleXrg.Exec();
|
||||
fx.tst_ExistsPaths(false, fil);
|
||||
fx.tst_ExistsPaths(true, recycleXrg.RecycleUrl());
|
||||
|
||||
bin.Recover(recycleXrg.RecycleUrl());
|
||||
fx.tst_ExistsPaths(true, fil);
|
||||
fx.tst_ExistsPaths(false, recycleXrg.RecycleUrl());
|
||||
}
|
||||
}
|
||||
@@ -1,56 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_fil_basic_system_tst extends IoEngine_fil_basic_base {
|
||||
@Override protected void setup_hook() {
|
||||
root = Tfds.RscDir.GenSubDir_nest("100_core", "ioEngineTest", "_temp");
|
||||
fil = root.GenSubFil("fil.txt");
|
||||
IoEngine_xrg_deleteDir.new_(fil.OwnerDir()).Recur_().ReadOnlyFails_off().Exec();
|
||||
} @Override protected IoEngine engine_() {return IoEngine_system.new_();}
|
||||
@Test public void ExistsFil_IgnoreDifferentCasing() {
|
||||
if (root.Info().CaseSensitive()) return;
|
||||
fx.run_SaveFilText(fil, "text");
|
||||
fx.tst_ExistsPaths(true, fil);
|
||||
fx.tst_ExistsPaths(true, fil.OwnerDir().GenSubFil("FIL.txt"));
|
||||
}
|
||||
@Test @gplx.Virtual public void RecycleFil() {
|
||||
fx.run_SaveFilText(fil, "text");
|
||||
fx.tst_ExistsPaths(true, fil);
|
||||
|
||||
IoRecycleBin bin = IoRecycleBin.Instance;
|
||||
List_adp list = root.XtoNames(); list.Del_at(0); // remove drive
|
||||
IoEngine_xrg_recycleFil recycleXrg = bin.Send_xrg(fil)
|
||||
.RootDirNames_(list)
|
||||
.AppName_("gplx.test").Time_(DateAdp_.parse_gplx("20100102_115559123")).Uuid_(Guid_adp_.Parse("467ffb41-cdfe-402f-b22b-be855425784b"));
|
||||
recycleXrg.Exec();
|
||||
fx.tst_ExistsPaths(false, fil);
|
||||
fx.tst_ExistsPaths(true, recycleXrg.RecycleUrl());
|
||||
|
||||
bin.Recover(recycleXrg.RecycleUrl());
|
||||
fx.tst_ExistsPaths(true, fil);
|
||||
fx.tst_ExistsPaths(false, recycleXrg.RecycleUrl());
|
||||
}
|
||||
@Test @Override public void DeleteFil_missing_pass() {
|
||||
super.DeleteFil_missing_pass();
|
||||
}
|
||||
@Test @Override public void DeleteFil_readOnly_pass() {
|
||||
super.DeleteFil_readOnly_pass ();
|
||||
}
|
||||
@Test @Override public void SaveFilText_readOnlyFails() {
|
||||
super.SaveFilText_readOnlyFails();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_fil_xfer_memory_tst extends IoEngine_fil_xfer_base {
|
||||
@Override protected void setup_hook() {
|
||||
root = Io_url_.mem_dir_("mem");
|
||||
} @Override protected IoEngine engine_() {return IoEngine_.Mem_init_();}
|
||||
@Override protected Io_url AltRoot() {
|
||||
Io_mgr.Instance.InitEngine_mem_("mem2");
|
||||
return Io_url_.mem_dir_("mem2");
|
||||
}
|
||||
}
|
||||
@@ -1,26 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_fil_xfer_system_tst extends IoEngine_fil_xfer_base {
|
||||
@Override protected void setup_hook() {
|
||||
root = Tfds.RscDir.GenSubDir_nest("100_core", "ioEngineTest", "_temp");
|
||||
IoEngine_xrg_deleteDir.new_(root.OwnerDir()).Recur_().ReadOnlyFails_off().Exec();
|
||||
} @Override protected IoEngine engine_() {return IoEngine_system.new_();}
|
||||
@Override protected Io_url AltRoot() {
|
||||
return Tfds.RscDir.GenSubDir_nest("100_core", "ioEngineTest", "_temp");
|
||||
}
|
||||
}
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_stream_xfer_tst {
|
||||
@Before public void setup() {
|
||||
srcEngine = IoEngine_memory.new_("mock1");
|
||||
trgEngine = IoEngine_memory.new_("mock2");
|
||||
IoEnginePool.Instance.Add_if_dupe_use_nth(srcEngine); IoEnginePool.Instance.Add_if_dupe_use_nth(trgEngine);
|
||||
IoUrlInfoRegy.Instance.Reg(IoUrlInfo_.mem_("mem1/", srcEngine.Key()));
|
||||
IoUrlInfoRegy.Instance.Reg(IoUrlInfo_.mem_("mem2/", trgEngine.Key()));
|
||||
srcDir = Io_url_.mem_dir_("mem1/dir"); trgDir = Io_url_.mem_dir_("mem2/dir");
|
||||
}
|
||||
@Test public void TransferBetween() {
|
||||
Io_url srcPath = srcDir.GenSubFil("fil.txt");
|
||||
Io_url trgPath = trgDir.GenSubFil("fil.txt");
|
||||
tst_TransferStreams(srcEngine, srcPath, trgEngine, trgPath);
|
||||
}
|
||||
void tst_TransferStreams(IoEngine srcEngine, Io_url srcPath, IoEngine trgEngine, Io_url trgPath) {
|
||||
srcEngine.SaveFilText_api(IoEngine_xrg_saveFilStr.new_(srcPath, "test1"));
|
||||
trgEngine.DeleteFil_api(IoEngine_xrg_deleteFil.new_(trgPath)); // make sure file is deleted
|
||||
fx.tst_ExistsPaths(true, srcPath);
|
||||
fx.tst_ExistsPaths(false, trgPath);
|
||||
|
||||
IoEngineUtl utl = IoEngineUtl.new_();
|
||||
utl.BufferLength_set(4);
|
||||
utl.XferFil(srcEngine, IoEngine_xrg_xferFil.copy_(srcPath, trgPath));
|
||||
fx.tst_ExistsPaths(true, srcPath, trgPath);
|
||||
fx.tst_LoadFilStr(trgPath, "test1");
|
||||
}
|
||||
IoEngineFxt fx = IoEngineFxt.new_();
|
||||
Io_url srcDir, trgDir;
|
||||
IoEngine srcEngine, trgEngine;
|
||||
}
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_xrg_queryDir_tst {
|
||||
@Before public void setup() {
|
||||
engine = IoEngine_.Mem_init_();
|
||||
} IoEngine engine; Io_url[] ary;
|
||||
@Test public void Basic() {
|
||||
ary = save_text_(fil_("fil1.txt"));
|
||||
|
||||
tst_ExecPathAry(finder_(), ary);
|
||||
}
|
||||
@Test public void FilPath() {
|
||||
ary = save_text_(fil_("fil1.txt"), fil_("fil2.jpg"), fil_("fil3.txt"));
|
||||
|
||||
tst_ExecPathAry(finder_(), ary); // default: all files
|
||||
tst_ExecPathAry(finder_().FilPath_("*.txt") // findPattern of *.txt
|
||||
, fil_("fil1.txt"), fil_("fil3.txt"));
|
||||
}
|
||||
@Test public void Recur() {
|
||||
ary = save_text_(fil_("fil1.txt"), fil_("dirA", "fil1A.jpg"));
|
||||
|
||||
tst_ExecPathAry(finder_(), fil_("fil1.txt")); // default: no recursion
|
||||
tst_ExecPathAry(finder_().Recur_(), ary); // recurse
|
||||
}
|
||||
@Test public void DirPattern() {
|
||||
save_text_(fil_("fil1.txt"), fil_("dirA", "fil1A.jpg"));
|
||||
|
||||
tst_ExecPathAry(finder_(), fil_("fil1.txt")); // default: files only
|
||||
tst_ExecPathAry(finder_().DirInclude_() // include dirs; NOTE: fil1A not returned b/c Recur_ is not true
|
||||
, dir_("dirA"), fil_("fil1.txt"));
|
||||
}
|
||||
@Test public void Sort_by() {
|
||||
save_text_(fil_("fil2a.txt"), fil_("fil1.txt"));
|
||||
|
||||
tst_ExecPathAry(finder_() // default: sortByAscOrder
|
||||
, fil_("fil1.txt"), fil_("fil2a.txt"));
|
||||
}
|
||||
IoEngine_xrg_queryDir finder_() {return IoEngine_xrg_queryDir.new_(Io_url_.mem_dir_("mem/root"));}// NOTE: not in setup b/c finder must be newed several times inside test method
|
||||
Io_url fil_(String... ary) {return Io_url_.mem_dir_("mem/root").GenSubFil_nest(ary);}
|
||||
Io_url dir_(String... ary) {return Io_url_.mem_dir_("mem/root").GenSubDir_nest(ary);}
|
||||
|
||||
Io_url[] save_text_(Io_url... ary) {
|
||||
for (Io_url url : ary)
|
||||
Io_mgr.Instance.SaveFilStr(url, url.Raw());
|
||||
return ary;
|
||||
}
|
||||
void tst_ExecPathAry(IoEngine_xrg_queryDir finder, Io_url... expd) {Tfds.Eq_ary(expd, finder.ExecAsUrlAry());}
|
||||
}
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoEngine_xrg_recycleFil_tst {
|
||||
@Before public void setup() {
|
||||
IoEngine_.Mem_init_();
|
||||
}
|
||||
@Test public void GenRecycleUrl() {
|
||||
tst_GenRecycleUrl(recycle_(), Io_url_.mem_fil_("mem/z_trash/20100102/gplx.images;115559123;;fil.txt"));
|
||||
tst_GenRecycleUrl(recycle_().Uuid_include_(), Io_url_.mem_fil_("mem/z_trash/20100102/gplx.images;115559123;467ffb41-cdfe-402f-b22b-be855425784b;fil.txt"));
|
||||
}
|
||||
IoEngine_xrg_recycleFil recycle_() {return IoEngine_xrg_recycleFil.gplx_(Io_url_.mem_fil_("mem/dir/fil.txt")).AppName_("gplx.images").Uuid_(Guid_adp_.Parse("467ffb41-cdfe-402f-b22b-be855425784b")).Time_(DateAdp_.parse_gplx("20100102_115559123"));}
|
||||
void tst_GenRecycleUrl(IoEngine_xrg_recycleFil xrg, Io_url expd) {
|
||||
Tfds.Eq(expd, xrg.RecycleUrl());
|
||||
}
|
||||
}
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoItmDir_FetchDeepOrNull_tst {
|
||||
@Before public void setup() {
|
||||
drive = Io_url_.mem_dir_("mem");
|
||||
rootDir = bldr.dir_(drive, bldr.dir_(drive.GenSubDir("sub1")));
|
||||
} IoItm_fxt bldr = IoItm_fxt.new_(); Io_url drive; IoItmDir rootDir;
|
||||
@Test public void FetchDeepOrNull() {
|
||||
tst_FetchDeepOrNull(rootDir, drive.GenSubDir("sub1"), true);
|
||||
tst_FetchDeepOrNull(rootDir, drive.GenSubDir("sub2"), false);
|
||||
tst_FetchDeepOrNull(rootDir.SubDirs().Get_at(0), drive.GenSubDir("sub1"), true);
|
||||
tst_FetchDeepOrNull(rootDir.SubDirs().Get_at(0), drive.GenSubDir("sub2"), false);
|
||||
}
|
||||
void tst_FetchDeepOrNull(Object rootDirObj, Io_url find, boolean expdFound) {
|
||||
IoItmDir rootDir = IoItmDir_.as_(rootDirObj);
|
||||
IoItmDir actlDir = rootDir.FetchDeepOrNull(find);
|
||||
if (actlDir == null) {
|
||||
if (expdFound) Tfds.Fail("actlDir is null, but expd dir to be found");
|
||||
else return; // actlDir is null but expdFound was false; return;
|
||||
}
|
||||
Tfds.Eq(find.Raw(), actlDir.Url().Raw());
|
||||
}
|
||||
}
|
||||
@@ -1,56 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoUrlInfo_alias_tst {
|
||||
IoUrlInfo_alias alias;
|
||||
@Test public void MapWntToWnt() {
|
||||
Make("usr:\\", "D:\\usr\\");
|
||||
tst_Xto_api("usr:\\dir\\fil.txt", "D:\\usr\\dir\\fil.txt");
|
||||
tst_OwnerDir("usr:\\dir\\", "usr:\\");
|
||||
tst_OwnerDir("usr:\\", "");
|
||||
tst_NameOnly("usr:\\", "usr");
|
||||
}
|
||||
@Test public void MapToLnx() {
|
||||
Make("usr:\\", "/home/");
|
||||
tst_Xto_api("usr:\\dir\\fil.txt", "/home/dir/fil.txt");
|
||||
}
|
||||
@Test public void MapLnxToWnt() {
|
||||
Make("usr:/", "C:\\usr\\");
|
||||
tst_Xto_api("usr:/dir/fil.txt", "C:\\usr\\dir\\fil.txt");
|
||||
}
|
||||
@Test public void WntToWnt() {
|
||||
Make("C:\\", "X:\\");
|
||||
tst_Xto_api("C:\\dir\\fil.txt", "X:\\dir\\fil.txt");
|
||||
tst_NameOnly("C:\\", "C");
|
||||
}
|
||||
@Test public void WntToLnx() {
|
||||
Make("C:\\", "/home/");
|
||||
tst_Xto_api("C:\\dir\\fil.txt", "/home/dir/fil.txt");
|
||||
}
|
||||
@Test public void LnxToWnt() {
|
||||
Make("/home/", "C:\\");
|
||||
tst_Xto_api("/home/dir/fil.txt", "C:\\dir\\fil.txt");
|
||||
tst_NameOnly("/home/", "home");
|
||||
tst_NameOnly("/", "root");
|
||||
}
|
||||
void tst_Xto_api(String raw, String expd) {Tfds.Eq(expd, alias.Xto_api(raw));}
|
||||
void tst_OwnerDir(String raw, String expd) {Tfds.Eq(expd, alias.OwnerDir(raw));}
|
||||
void tst_NameOnly(String raw, String expd) {Tfds.Eq(expd, alias.NameOnly(raw));}
|
||||
void Make(String srcDir, String trgDir) {
|
||||
alias = IoUrlInfo_alias.new_(srcDir, trgDir, IoEngine_.SysKey);
|
||||
}
|
||||
}
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoUrl_lnx_tst {
|
||||
IoUrlFxt fx = IoUrlFxt.new_();
|
||||
@Test public void Raw() {
|
||||
fx.tst_Xto_gplx(Io_url_.lnx_dir_("/home/"), "/home/");
|
||||
fx.tst_Xto_gplx(Io_url_.lnx_dir_("/home"), "/home/"); // add /
|
||||
fx.tst_Xto_gplx(Io_url_.lnx_dir_("/"), "/");
|
||||
fx.tst_Xto_gplx(Io_url_.lnx_fil_("/home/fil.txt"), "/home/fil.txt");
|
||||
}
|
||||
@Test public void Xto_api() {
|
||||
fx.tst_Xto_api(Io_url_.lnx_fil_("/home/fil.txt"), "/home/fil.txt");
|
||||
fx.tst_Xto_api(Io_url_.lnx_dir_("/home/"), "/home"); // del /
|
||||
fx.tst_Xto_api(Io_url_.lnx_dir_("/"), "/");
|
||||
}
|
||||
@Test public void OwnerRoot() {
|
||||
fx.tst_OwnerRoot(Io_url_.lnx_dir_("/home/fil.txt"), "/");
|
||||
fx.tst_OwnerRoot(Io_url_.lnx_dir_("/home"), "/");
|
||||
fx.tst_OwnerRoot(Io_url_.lnx_dir_("root"), "/");
|
||||
}
|
||||
@Test public void XtoNames() {
|
||||
fx.tst_XtoNames(Io_url_.lnx_dir_("/home/fil.txt"), fx.ary_("root", "home", "fil.txt"));
|
||||
fx.tst_XtoNames(Io_url_.lnx_dir_("/home"), fx.ary_("root", "home"));
|
||||
}
|
||||
@Test public void IsDir() {
|
||||
fx.tst_IsDir(Io_url_.lnx_dir_("/home"), true);
|
||||
fx.tst_IsDir(Io_url_.lnx_fil_("/home/file.txt"), false);
|
||||
}
|
||||
@Test public void OwnerDir() {
|
||||
fx.tst_OwnerDir(Io_url_.lnx_dir_("/home/lnxusr"), Io_url_.lnx_dir_("/home"));
|
||||
fx.tst_OwnerDir(Io_url_.lnx_dir_("/fil.txt"), Io_url_.lnx_dir_("/"));
|
||||
fx.tst_OwnerDir(Io_url_.lnx_dir_("/"), Io_url_.Empty);
|
||||
}
|
||||
@Test public void NameAndExt() {
|
||||
fx.tst_NameAndExt(Io_url_.lnx_fil_("/fil.txt"), "fil.txt");
|
||||
fx.tst_NameAndExt(Io_url_.lnx_dir_("/dir"), "dir/");
|
||||
}
|
||||
}
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoUrl_map_tst {
|
||||
IoUrlFxt fx = IoUrlFxt.new_();
|
||||
@Test public void Xto_api() {
|
||||
IoUrlInfo inf = IoUrlInfo_.alias_("tst:\\", "C:\\tst\\", IoEngine_.SysKey);
|
||||
fx.tst_Xto_api(Io_url_.new_inf_("tst:\\dir\\fil.txt", inf), "C:\\tst\\dir\\fil.txt");
|
||||
fx.tst_Xto_api(Io_url_.new_inf_("tst:\\dir\\", inf), "C:\\tst\\dir"); // no trailing \
|
||||
}
|
||||
@Test public void Xto_api_wce() {
|
||||
IoUrlInfo inf = IoUrlInfo_.alias_("wce:\\", "\\SD Card\\", IoEngine_.SysKey);
|
||||
fx.tst_Xto_api(Io_url_.new_inf_("wce:\\dir\\", inf), "\\SD Card\\dir");
|
||||
}
|
||||
}
|
||||
@@ -1,96 +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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class IoUrl_wnt_tst {
|
||||
IoUrlFxt fx = IoUrlFxt.new_();
|
||||
@Test public void Raw() {
|
||||
fx.tst_Xto_gplx(Io_url_.wnt_fil_("C:\\dir\\fil.txt"), "C:\\dir\\fil.txt");
|
||||
fx.tst_Xto_gplx(Io_url_.wnt_dir_("C:\\dir\\"), "C:\\dir\\");
|
||||
fx.tst_Xto_gplx(Io_url_.wnt_dir_("C:\\dir") , "C:\\dir\\"); // add \
|
||||
}
|
||||
@Test public void Xto_api() {
|
||||
fx.tst_Xto_api(Io_url_.wnt_fil_("C:\\fil.txt"), "C:\\fil.txt");
|
||||
fx.tst_Xto_api(Io_url_.wnt_dir_("C:\\dir\\"), "C:\\dir"); // del \
|
||||
fx.tst_Xto_api(Io_url_.wnt_dir_("C:"), "C:");
|
||||
}
|
||||
@Test public void OwnerRoot() {
|
||||
fx.tst_OwnerRoot(Io_url_.wnt_dir_("C:\\dir") , "C:\\");
|
||||
fx.tst_OwnerRoot(Io_url_.wnt_dir_("C:\\fil.png") , "C:\\");
|
||||
fx.tst_OwnerRoot(Io_url_.wnt_dir_("C:") , "C:\\");
|
||||
}
|
||||
@Test public void IsDir() {
|
||||
fx.tst_IsDir(Io_url_.wnt_dir_("C:\\dir\\"), true);
|
||||
fx.tst_IsDir(Io_url_.wnt_fil_("C:\\dir"), false);
|
||||
fx.tst_IsDir(Io_url_.wnt_fil_("C:\\fil.txt"), false);
|
||||
}
|
||||
@Test public void OwnerDir() {
|
||||
fx.tst_OwnerDir(Io_url_.wnt_dir_("C:\\dir\\sub1"), Io_url_.wnt_dir_("C:\\dir"));
|
||||
fx.tst_OwnerDir(Io_url_.wnt_fil_("C:\\fil.txt"), Io_url_.wnt_dir_("C:"));
|
||||
fx.tst_OwnerDir(Io_url_.wnt_dir_("C:"), Io_url_.Empty);
|
||||
// fx.tst_OwnerDir(Io_url_.wnt_fil_("press enter to select this folder"), Io_url_.Empty);
|
||||
}
|
||||
@Test public void NameAndExt() {
|
||||
fx.tst_NameAndExt(Io_url_.wnt_fil_("C:\\fil.txt"), "fil.txt");
|
||||
fx.tst_NameAndExt(Io_url_.wnt_dir_("C:\\dir"), "dir\\");
|
||||
}
|
||||
@Test public void NameOnly() {
|
||||
fx.tst_NameOnly(Io_url_.wnt_fil_("C:\\fil.txt"), "fil");
|
||||
fx.tst_NameOnly(Io_url_.wnt_dir_("C:\\dir"), "dir");
|
||||
fx.tst_NameOnly(Io_url_.wnt_dir_("C:"), "C");
|
||||
}
|
||||
@Test public void Ext() {
|
||||
fx.tst_Ext(Io_url_.wnt_fil_("C:\\fil.txt"), ".txt"); // fil
|
||||
fx.tst_Ext(Io_url_.wnt_fil_("C:\\fil.multiple.txt"), ".txt"); // multiple ext
|
||||
fx.tst_Ext(Io_url_.wnt_fil_("C:\\fil"), ""); // no ext
|
||||
fx.tst_Ext(Io_url_.wnt_dir_("C:\\dir"), "\\"); // dir
|
||||
}
|
||||
@Test public void GenSubDir_nest() {
|
||||
fx.tst_GenSubDir_nest(Io_url_.wnt_dir_("C:"), fx.ary_("dir1", "sub1"), Io_url_.wnt_dir_("C:\\dir1\\sub1"));
|
||||
}
|
||||
@Test public void GenNewExt() {
|
||||
fx.tst_GenNewExt(Io_url_.wnt_fil_("C:\\fil.gif"), ".png", Io_url_.wnt_fil_("C:\\fil.png")); // basic
|
||||
fx.tst_GenNewExt(Io_url_.wnt_fil_("C:\\fil.tst.gif"), ".png", Io_url_.wnt_fil_("C:\\fil.tst.png")); // last in multiple dotted
|
||||
}
|
||||
@Test public void GenRelUrl_orEmpty() {
|
||||
fx.tst_GenRelUrl_orEmpty(Io_url_.wnt_fil_("C:\\root\\fil.txt") , Io_url_.wnt_dir_("C:\\root") , "fil.txt"); // fil
|
||||
fx.tst_GenRelUrl_orEmpty(Io_url_.wnt_dir_("C:\\root\\dir") , Io_url_.wnt_dir_("C:\\root") , "dir\\"); // dir
|
||||
fx.tst_GenRelUrl_orEmpty(Io_url_.wnt_fil_("C:\\root\\dir\\fil.txt") , Io_url_.wnt_dir_("C:\\root") , "dir\\fil.txt"); // fil: nested1
|
||||
fx.tst_GenRelUrl_orEmpty(Io_url_.wnt_fil_("C:\\root\\dir\\fil.txt") , Io_url_.wnt_dir_("C:") , "root\\dir\\fil.txt"); // fil: nested2
|
||||
}
|
||||
@Test public void GenParallel() {
|
||||
fx.tst_GenParallel(Io_url_.wnt_fil_("C:\\root1\\fil.txt"), Io_url_.wnt_dir_("C:\\root1"), Io_url_.wnt_dir_("D:\\root2"), Io_url_.wnt_fil_("D:\\root2\\fil.txt"));
|
||||
fx.tst_GenParallel(Io_url_.wnt_dir_("C:\\root1\\dir") , Io_url_.wnt_dir_("C:\\root1"), Io_url_.wnt_dir_("D:\\root2"), Io_url_.wnt_dir_("D:\\root2\\dir"));
|
||||
}
|
||||
}
|
||||
class IoUrlFxt {
|
||||
public void tst_Xto_api(Io_url url, String expd) {Tfds.Eq(expd, url.Xto_api());}
|
||||
public void tst_OwnerRoot(Io_url url, String expd) {Tfds.Eq(expd, url.OwnerRoot().Raw());}
|
||||
public void tst_XtoNames(Io_url url, String... expdAry) {Tfds.Eq_ary(expdAry, url.XtoNames().To_str_ary());}
|
||||
public void tst_NameAndExt(Io_url url, String expd) {Tfds.Eq(expd, url.NameAndExt());}
|
||||
public void tst_Xto_gplx(Io_url url, String expd) {Tfds.Eq(expd, url.Raw());}
|
||||
public void tst_IsDir(Io_url url, boolean expd) {Tfds.Eq(expd, url.Type_dir());}
|
||||
public void tst_OwnerDir(Io_url url, Io_url expd) {Tfds.Eq_url(expd, url.OwnerDir());}
|
||||
public void tst_NameOnly(Io_url url, String expd) {Tfds.Eq(expd, url.NameOnly());}
|
||||
public void tst_Ext(Io_url url, String expd) {Tfds.Eq(expd, url.Ext());}
|
||||
public void tst_GenSubDir_nest(Io_url rootDir, String[] parts, Io_url expd) {Tfds.Eq(expd, rootDir.GenSubDir_nest(parts));}
|
||||
public void tst_GenNewExt(Io_url url, String ext, Io_url expd) {Tfds.Eq_url(expd, url.GenNewExt(ext));}
|
||||
public void tst_GenRelUrl_orEmpty(Io_url url, Io_url rootDir, String expd) {Tfds.Eq(expd, url.GenRelUrl_orEmpty(rootDir));}
|
||||
public void tst_GenParallel(Io_url url, Io_url oldRoot, Io_url newRoot, Io_url expd) {Tfds.Eq_url(expd, url.GenParallel(oldRoot, newRoot));}
|
||||
|
||||
public String[] ary_(String... ary) {return String_.Ary(ary);}
|
||||
public static IoUrlFxt new_() {return new IoUrlFxt();} IoUrlFxt() {}
|
||||
}
|
||||
@@ -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.core.stores; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*; import gplx.core.gfo_ndes.*; import gplx.core.type_xtns.*;
|
||||
public class GfoNdeRdr_read_tst {
|
||||
@Test public void ReadInt() {
|
||||
rdr = rdr_(IntClassXtn.Instance, "id", 1);
|
||||
Tfds.Eq(rdr.ReadInt("id"), 1);
|
||||
}
|
||||
@Test public void ReadIntOr() {
|
||||
rdr = rdr_(IntClassXtn.Instance, "id", 1);
|
||||
Tfds.Eq(rdr.ReadIntOr("id", -1), 1);
|
||||
}
|
||||
@Test public void ReadIntElse_minus1() {
|
||||
rdr = rdr_(IntClassXtn.Instance, "id", null);
|
||||
Tfds.Eq(rdr.ReadIntOr("id", -1), -1);
|
||||
}
|
||||
@Test public void ReadInt_parse() {
|
||||
rdr = rdr_(StringClassXtn.Instance, "id", "1");
|
||||
Tfds.Eq(rdr.ReadInt("id"), 1);
|
||||
}
|
||||
@Test public void ReadIntElse_parse() {
|
||||
rdr = rdr_(StringClassXtn.Instance, "id", "2");
|
||||
Tfds.Eq(rdr.ReadIntOr("id", -1), 2);
|
||||
}
|
||||
GfoNdeRdr rdr_(ClassXtn type, String key, Object val) { // makes rdr with one row and one val
|
||||
GfoFldList flds = GfoFldList_.new_().Add(key, type);
|
||||
GfoNde row = GfoNde_.vals_(flds, new Object[] {val});
|
||||
boolean parse = type == StringClassXtn.Instance; // assumes type is either StringClassXtn or IntClassXtn
|
||||
return GfoNdeRdr_.leaf_(row, parse);
|
||||
}
|
||||
GfoNdeRdr rdr;
|
||||
}
|
||||
@@ -1,187 +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.core.stores; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*; import gplx.core.gfo_ndes.*;
|
||||
public class GfoNdeRdr_tst {
|
||||
@Test public void Subs_leafs() {
|
||||
root =
|
||||
fx.root_
|
||||
( fx.row_vals_(0)
|
||||
, fx.row_vals_(1)
|
||||
, fx.row_vals_(2)
|
||||
);
|
||||
tst_NdeVals(root, 0, 1, 2);
|
||||
}
|
||||
@Test public void Subs_ndes() {
|
||||
root =
|
||||
fx.root_
|
||||
( leaf_("", 0)
|
||||
, leaf_("", 1)
|
||||
, leaf_("", 2)
|
||||
);
|
||||
tst_NdeVals(root, 0, 1, 2);
|
||||
}
|
||||
@Test public void Subs_mix() {
|
||||
root =
|
||||
fx.root_
|
||||
( leaf_("", 0)
|
||||
, fx.row_vals_(1)
|
||||
, fx.row_vals_(2)
|
||||
);
|
||||
tst_NdeVals(root, 0, 1, 2);
|
||||
}
|
||||
@Test public void Subs_rdr() {
|
||||
root =
|
||||
fx.root_
|
||||
( fx.row_vals_(0)
|
||||
);
|
||||
rootRdr = GfoNdeRdr_.root_parseNot_(root);
|
||||
DataRdr rdr = rootRdr.Subs();
|
||||
Tfds.Eq_true(rdr.MoveNextPeer());
|
||||
Tfds.Eq(0, rdr.ReadAt(0));
|
||||
Tfds.Eq_false(rdr.MoveNextPeer());
|
||||
}
|
||||
@Test public void MoveNextPeer_implicit() {
|
||||
root =
|
||||
fx.root_
|
||||
( fx.csv_dat_
|
||||
( fx.row_vals_(0)
|
||||
, fx.row_vals_(1)
|
||||
, fx.row_vals_(2)
|
||||
)
|
||||
);
|
||||
GfoNdeRdr rootRdr = GfoNdeRdr_.root_parseNot_(root);
|
||||
DataRdr subsRdr = rootRdr.Subs(); // pos=-1; bof
|
||||
DataRdr subRdr = subsRdr.Subs(); // MoveNextPeer not needed; implicitly moves to pos=0
|
||||
tst_RdrVals(subRdr, Object_.Ary(0, 1, 2));
|
||||
}
|
||||
@Test public void MoveNextPeer_explicit() {
|
||||
root =
|
||||
fx.root_
|
||||
( fx.csv_dat_
|
||||
( fx.row_vals_(0)
|
||||
, fx.row_vals_(1)
|
||||
, fx.row_vals_(2)
|
||||
)
|
||||
);
|
||||
GfoNdeRdr rootRdr = GfoNdeRdr_.root_parseNot_(root);
|
||||
DataRdr subsRdr = rootRdr.Subs(); // pos=-1; bof
|
||||
Tfds.Eq_true(subsRdr.MoveNextPeer()); // explicitly moves to pos=0
|
||||
DataRdr subRdr = subsRdr.Subs();
|
||||
tst_RdrVals(subRdr, Object_.Ary(0, 1, 2));
|
||||
}
|
||||
@Test public void Xpath_basic() {
|
||||
root = fx.root_
|
||||
( leaf_("root", 0)
|
||||
, leaf_("root", 1)
|
||||
, leaf_("root", 2)
|
||||
);
|
||||
tst_Xpath_all(root, "root", 0, 1, 2);
|
||||
}
|
||||
@Test public void Xpath_nested() {
|
||||
root = fx.root_
|
||||
( fx.tbl_("owner"
|
||||
, leaf_("root", 0)
|
||||
, leaf_("root", 1)
|
||||
, leaf_("root", 2)
|
||||
));
|
||||
tst_Xpath_all(root, "owner/root", 0, 1, 2);
|
||||
}
|
||||
@Test public void Xpath_null() {
|
||||
root = fx.root_
|
||||
( leaf_("match", 0)
|
||||
);
|
||||
rootRdr = GfoNdeRdr_.root_parseNot_(root);
|
||||
DataRdr sub = rootRdr.Subs_byName("no_match");
|
||||
Tfds.Eq_false(sub.MoveNextPeer());
|
||||
}
|
||||
@Test public void Xpath_moveFirst_basic() {
|
||||
root = fx.root_
|
||||
( leaf_("nde0", 0)
|
||||
);
|
||||
tst_Xpath_first(root, "nde0", 0);
|
||||
}
|
||||
@Test public void Xpath_moveFirst_shallow() {
|
||||
root = fx.root_
|
||||
( leaf_("nde0", 0)
|
||||
, leaf_("nde1", 1)
|
||||
, leaf_("nde2", 2)
|
||||
);
|
||||
tst_Xpath_first(root, "nde2", 2);
|
||||
}
|
||||
@Test public void Xpath_moveFirst_nested() {
|
||||
root = fx.root_
|
||||
( node_("nde0", Object_.Ary("0")
|
||||
, leaf_("nde00", "00")
|
||||
));
|
||||
tst_Xpath_first(root, "nde0", "0");
|
||||
tst_Xpath_first(root, "nde0/nde00", "00");
|
||||
}
|
||||
@Test public void Xpath_moveFirst_nested_similarName() {
|
||||
root = fx.root_
|
||||
( node_("nde0", Object_.Ary("0")
|
||||
, leaf_("nde00", "00")
|
||||
)
|
||||
, node_("nde1", Object_.Ary("1")
|
||||
, leaf_("nde00", "10")
|
||||
));
|
||||
tst_Xpath_first(root, "nde1/nde00", "10");
|
||||
}
|
||||
@Test public void Xpath_moveFirst_many() {
|
||||
root = fx.root_
|
||||
( leaf_("root", 0)
|
||||
, leaf_("root", 1)
|
||||
, leaf_("root", 2)
|
||||
);
|
||||
tst_Xpath_first(root, "root", 0); // returns first
|
||||
}
|
||||
@Test public void Xpath_moveFirst_null() {
|
||||
root = fx.root_
|
||||
( leaf_("nde0", 0)
|
||||
, leaf_("nde1", 1)
|
||||
, leaf_("nde2", 2)
|
||||
);
|
||||
rootRdr = GfoNdeRdr_.root_parseNot_(root);
|
||||
DataRdr rdr = rootRdr.Subs_byName("nde3");
|
||||
Tfds.Eq_false(rdr.MoveNextPeer());
|
||||
}
|
||||
|
||||
GfoNde leaf_(String name, Object... vals) {return GfoNde_.nde_(name, vals, GfoNde_.Ary_empty);}
|
||||
GfoNde node_(String name, Object[] vals, GfoNde... subs) {return GfoNde_.nde_(name, vals, subs);}
|
||||
void tst_NdeVals(GfoNde nde, Object... exptVals) {
|
||||
DataRdr rdr = GfoNdeRdr_.root_parseNot_(nde);
|
||||
tst_RdrVals(rdr.Subs(), exptVals);
|
||||
}
|
||||
void tst_RdrVals(DataRdr rdr, Object[] exptVals) {
|
||||
int count = 0;
|
||||
while (rdr.MoveNextPeer()) {
|
||||
Object actl = rdr.ReadAt(0);
|
||||
Tfds.Eq(actl, exptVals[count++]);
|
||||
}
|
||||
Tfds.Eq(count, exptVals.length);
|
||||
}
|
||||
void tst_Xpath_first(GfoNde root, String xpath, Object expt) {
|
||||
DataRdr rdr = GfoNdeRdr_.root_parseNot_(root);
|
||||
DataRdr sel = rdr.Subs_byName_moveFirst(xpath);
|
||||
Object actl = sel.ReadAt(0);
|
||||
Tfds.Eq(actl, expt);
|
||||
}
|
||||
void tst_Xpath_all(GfoNde root, String xpath, Object... exptVals) {
|
||||
DataRdr rdr = GfoNdeRdr_.root_parseNot_(root);
|
||||
tst_RdrVals(rdr.Subs_byName(xpath), exptVals);
|
||||
}
|
||||
GfoNde root; DataRdr rootRdr; GfoNdeFxt fx = GfoNdeFxt.new_();
|
||||
}
|
||||
@@ -1,100 +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.core.stores.xmls; import gplx.*; import gplx.core.*; import gplx.core.stores.*;
|
||||
import org.junit.*;
|
||||
public class XmlDataRdr_tst {
|
||||
@Test public void Read() {
|
||||
DataRdr rdr = fx.rdr_("<title id=\"1\" name=\"first\" profiled=\"false\" />");
|
||||
Tfds.Eq(rdr.NameOfNode(), "title");
|
||||
Tfds.Eq(rdr.ReadStr("name"), "first");
|
||||
Tfds.Eq(rdr.ReadInt("id"), 1);
|
||||
Tfds.Eq(rdr.ReadBool("profiled"), false);
|
||||
}
|
||||
@Test public void None() {
|
||||
DataRdr rdr = fx.rdr_
|
||||
( "<root>"
|
||||
, "<find/>"
|
||||
, "</root>"
|
||||
);
|
||||
fx.tst_Subs_ByName(rdr, "no_nde", "no_atr");
|
||||
}
|
||||
@Test public void One() {
|
||||
DataRdr rdr = fx.rdr_
|
||||
( "<root>"
|
||||
, "<find id=\"f0\" />"
|
||||
, "</root>"
|
||||
);
|
||||
fx.tst_Subs_ByName(rdr, "find", "id", "f0");
|
||||
}
|
||||
@Test public void One_IgnoreOthers() {
|
||||
DataRdr rdr = fx.rdr_
|
||||
( "<root>"
|
||||
, "<find id=\"f0\" />"
|
||||
, "<skip id=\"s0\" />"
|
||||
, "</root>"
|
||||
);
|
||||
fx.tst_Subs_ByName(rdr, "find", "id", "f0");
|
||||
}
|
||||
@Test public void Many() {
|
||||
DataRdr rdr = fx.rdr_
|
||||
( "<root>"
|
||||
, "<find id=\"f0\" />"
|
||||
, "<find id=\"f1\" />"
|
||||
, "</root>"
|
||||
);
|
||||
fx.tst_Subs_ByName(rdr, "find", "id", "f0", "f1");
|
||||
}
|
||||
@Test public void Nested() {
|
||||
DataRdr rdr = fx.rdr_
|
||||
( "<root>"
|
||||
, "<sub1>"
|
||||
, "<find id=\"f0\" />"
|
||||
, "<find id=\"f1\" />"
|
||||
, "</sub1>"
|
||||
, "</root>"
|
||||
);
|
||||
fx.tst_Subs_ByName(rdr, "sub1/find", "id", "f0", "f1");
|
||||
}
|
||||
@Test public void Nested_IgnoreOthers() {
|
||||
DataRdr rdr = fx.rdr_
|
||||
( "<root>"
|
||||
, "<sub1>"
|
||||
, "<find id=\"f0\" />"
|
||||
, "<skip id=\"s0\" />"
|
||||
, "</sub1>"
|
||||
, "<sub1>"
|
||||
, "<find id=\"f1\" />" // NOTE: find across ndes
|
||||
, "<skip id=\"s1\" />"
|
||||
, "</sub1>"
|
||||
, "</root>"
|
||||
);
|
||||
fx.tst_Subs_ByName(rdr, "sub1/find", "id", "f0", "f1");
|
||||
}
|
||||
XmlDataRdr_fxt fx = XmlDataRdr_fxt.new_();
|
||||
}
|
||||
class XmlDataRdr_fxt {
|
||||
public DataRdr rdr_(String... ary) {return XmlDataRdr_.text_(String_.Concat(ary));}
|
||||
public void tst_Subs_ByName(DataRdr rdr, String xpath, String key, String... expdAry) {
|
||||
DataRdr subRdr = rdr.Subs_byName(xpath);
|
||||
List_adp list = List_adp_.New();
|
||||
while (subRdr.MoveNextPeer())
|
||||
list.Add(subRdr.Read(key));
|
||||
|
||||
String[] actlAry = list.To_str_ary();
|
||||
Tfds.Eq_ary(actlAry, expdAry);
|
||||
}
|
||||
public static XmlDataRdr_fxt new_() {return new XmlDataRdr_fxt();} XmlDataRdr_fxt() {}
|
||||
}
|
||||
@@ -1,93 +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.core.stores.xmls; import gplx.*; import gplx.core.*; import gplx.core.stores.*;
|
||||
import org.junit.*;
|
||||
public class XmlDataWtr_tst {
|
||||
@Before public void setup() {
|
||||
wtr = XmlDataWtr.new_();
|
||||
}
|
||||
@Test public void WriteNodeBgn() {
|
||||
wtr.WriteNodeBgn("chapter");
|
||||
tst_XStr(wtr, "<chapter />", String_.CrLf);
|
||||
}
|
||||
@Test public void Attributes() {
|
||||
wtr.WriteNodeBgn("chapter");
|
||||
wtr.WriteData("id", 1);
|
||||
wtr.WriteData("name", "first");
|
||||
tst_XStr(wtr, "<chapter id=\"1\" name=\"first\" />", String_.CrLf);
|
||||
}
|
||||
@Test public void Subs() {
|
||||
wtr.WriteNodeBgn("title");
|
||||
wtr.WriteNodeBgn("chapters");
|
||||
wtr.WriteNodeBgn("chapter");
|
||||
tst_XStr(wtr
|
||||
, "<title>", String_.CrLf
|
||||
, "<chapters>", String_.CrLf
|
||||
, "<chapter />", String_.CrLf
|
||||
, "</chapters>", String_.CrLf
|
||||
, "</title>", String_.CrLf
|
||||
);
|
||||
}
|
||||
@Test public void Subs_Iterate() {
|
||||
wtr.WriteNodeBgn("titles");
|
||||
for (int title = 1; title <= 2; title++) {
|
||||
wtr.WriteNodeBgn("title");
|
||||
wtr.WriteData("id", title);
|
||||
wtr.WriteNodeBgn("chapters");
|
||||
wtr.WriteNodeEnd(); // chapters
|
||||
wtr.WriteNodeEnd(); // title
|
||||
}
|
||||
wtr.WriteNodeEnd(); //titles
|
||||
tst_XStr(wtr
|
||||
, "<titles>", String_.CrLf
|
||||
, "<title id=\"1\">", String_.CrLf
|
||||
, "<chapters />", String_.CrLf
|
||||
, "</title>", String_.CrLf
|
||||
, "<title id=\"2\">", String_.CrLf
|
||||
, "<chapters />", String_.CrLf
|
||||
, "</title>", String_.CrLf
|
||||
, "</titles>", String_.CrLf
|
||||
);
|
||||
}
|
||||
@Test public void Peers() {
|
||||
wtr.WriteNodeBgn("title");
|
||||
wtr.WriteNodeBgn("chapters");
|
||||
wtr.WriteNodeEnd();
|
||||
wtr.WriteNodeBgn("audioStreams");
|
||||
tst_XStr(wtr
|
||||
, "<title>", String_.CrLf
|
||||
, "<chapters />", String_.CrLf
|
||||
, "<audioStreams />", String_.CrLf
|
||||
, "</title>", String_.CrLf
|
||||
);
|
||||
}
|
||||
@Test public void AtrsWithNesting() {
|
||||
wtr.WriteNodeBgn("title");
|
||||
wtr.WriteData("id", 1);
|
||||
wtr.WriteData("name", "first");
|
||||
wtr.WriteNodeBgn("chapters");
|
||||
tst_XStr(wtr
|
||||
, "<title id=\"1\" name=\"first\">", String_.CrLf
|
||||
, "<chapters />", String_.CrLf
|
||||
, "</title>", String_.CrLf
|
||||
);
|
||||
}
|
||||
void tst_XStr(XmlDataWtr wtr, String... parts) {
|
||||
String expd = String_.Concat(parts);
|
||||
Tfds.Eq(expd, wtr.To_str());
|
||||
}
|
||||
XmlDataWtr wtr;
|
||||
}
|
||||
Reference in New Issue
Block a user