You're right, I found it. Looks like it should not check "hasOption()"
from CommandLine since it won't be true for defaulted arguments. Fix
incoming to SVN.

On Wed, Jun 16, 2010 at 8:14 PM, Sebastian Schelter
<[email protected]> wrote:
> Please use this unit test code, the former missed ToolRunner.run(...) in
> the second test.
>
> package org.apache.mahout.common;
>
> import java.util.Map;
>
> import org.apache.hadoop.conf.Configuration;
> import org.apache.hadoop.util.ToolRunner;
> import org.apache.mahout.common.AbstractJob;
> import org.apache.mahout.math.MahoutTestCase;
>
> public class AbstractJobTest extends MahoutTestCase {
>
>  private static class TestJob extends AbstractJob {
>    private String valueOfTestOption;
>   �...@override
>    public int run(String[] args) throws Exception {
>      addOption("test", "t", "an option having a default value", "default");
>      Map<String,String> parsedArgs = parseArguments(args);
>      valueOfTestOption = parsedArgs.get("--test");
>      return 0;
>    }
>    public String getValueOfTestOption() {
>      return valueOfTestOption;
>    }
>  }
>
>  private TestJob job;
>  private Configuration conf;
>
> �...@override
>  protected void setUp() throws Exception {
>    super.setUp();
>    job = new TestJob();
>    conf = new Configuration();
>    job.setConf(conf);
>  }
>
>  public void testValueForOption() throws Exception {
>    ToolRunner.run(job, new String[] { "--test", "value" });
>    assertEquals("value", job.getValueOfTestOption());
>  }
>
>  public void testDefaultValueForOption() throws Exception {
>    ToolRunner.run(job, new String[] {});
>    assertEquals("default", job.getValueOfTestOption());
>  }
>
> }
>

Reply via email to