// check no path defaults to current working directory /// <exception cref="System.IO.IOException"/> public virtual void ProcessOptionsNoPath() { Org.Apache.Hadoop.FS.Shell.Find.Find find = new Org.Apache.Hadoop.FS.Shell.Find.Find (); find.SetConf(conf); string args = "-print"; List <string> argsList = GetArgs(args); find.ProcessOptions(argsList); Assert.Equal(Collections.SingletonList(Path.CurDir), argsList ); }
// check print is used as the default expression /// <exception cref="System.IO.IOException"/> public virtual void ProcessOptionsNoExpression() { Org.Apache.Hadoop.FS.Shell.Find.Find find = new Org.Apache.Hadoop.FS.Shell.Find.Find (); find.SetConf(conf); string args = "path"; string expected = "Print(;)"; find.ProcessOptions(GetArgs(args)); Expression expression = find.GetRootExpression(); Assert.Equal(expected, expression.ToString()); }
// check -and is handled correctly /// <exception cref="System.IO.IOException"/> public virtual void ProcessOptionsAnd() { Org.Apache.Hadoop.FS.Shell.Find.Find find = new Org.Apache.Hadoop.FS.Shell.Find.Find (); find.SetConf(conf); string args = "path -name one -and -name two -and -print"; string expected = "And(;And(;Name(one;),Name(two;)),Print(;))"; find.ProcessOptions(GetArgs(args)); Expression expression = find.GetRootExpression(); Assert.Equal(expected, expression.ToString()); }
// check options and expressions are stripped from args leaving paths /// <exception cref="System.IO.IOException"/> public virtual void ProcessOptionsExpression() { Org.Apache.Hadoop.FS.Shell.Find.Find find = new Org.Apache.Hadoop.FS.Shell.Find.Find (); find.SetConf(conf); string paths = "path1 path2 path3"; string args = "-L -H " + paths + " -print -name test"; List <string> argsList = GetArgs(args); find.ProcessOptions(argsList); List <string> pathList = GetArgs(paths); Assert.Equal(pathList, argsList); }
// check unknown options are rejected when mixed with known options /// <exception cref="System.IO.IOException"/> public virtual void ProcessOptionsKnownUnknown() { Org.Apache.Hadoop.FS.Shell.Find.Find find = new Org.Apache.Hadoop.FS.Shell.Find.Find (); find.SetConf(conf); string args = "path -print -unknown -print"; try { find.ProcessOptions(GetArgs(args)); NUnit.Framework.Assert.Fail("Unknown expression not caught"); } catch (IOException) { } }