Author: tpalsulich
Date: Mon Dec 29 18:28:25 2014
New Revision: 1648404

URL: http://svn.apache.org/r1648404
Log:
OODT-762. Migrate cli test resources.

Added:
    oodt/trunk/cli/src/test/java/
    oodt/trunk/cli/src/test/java/org/
    oodt/trunk/cli/src/test/java/org/apache/
    oodt/trunk/cli/src/test/java/org/apache/oodt/
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineArgs.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineUtility.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/action/
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/action/store/
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/action/store/spring/
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/action/store/spring/TestSpringCmdLineActionStore.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToAction.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToActionHandler.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestSetJavaPropertiesHandler.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/require/
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/require/TestActionDependencyRule.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/store/
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/store/spring/
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/store/spring/TestSpringCmdLineOptionStore.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestAllowedArgsCmdLineOptionValidator.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestArgRegExpCmdLineOptionValidator.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestClassExistsCmdLineOptionValidator.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestFileExistCmdLineOptionValidator.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestNoRestrictionsCmdLineOptionValidator.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/parser/
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/parser/TestStdCmdLineOptionParser.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestOutputStream.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestSetContextInjectTypeAction.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestUtils.java
    oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/util/
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/util/TestCmdLineIterable.java
    
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/util/TestCmdLineUtils.java
    oodt/trunk/cli/src/test/resources/
    oodt/trunk/cli/src/test/resources/cmd-line-actions.xml
    oodt/trunk/cli/src/test/resources/cmd-line-options.xml

Added: oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineArgs.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineArgs.java?rev=1648404&view=auto
==============================================================================
--- oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineArgs.java 
(added)
+++ oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineArgs.java 
Mon Dec 29 18:28:25 2014
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli;
+
+//Google static imports
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Sets.newHashSet;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createAction;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createActionOption;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+
+//JDK imports
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.cli.CmdLineArgs;
+import org.apache.oodt.cas.cli.action.CmdLineAction;
+import org.apache.oodt.cas.cli.option.ActionCmdLineOption;
+import org.apache.oodt.cas.cli.option.CmdLineOption;
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import org.apache.oodt.cas.cli.option.HelpCmdLineOption;
+import org.apache.oodt.cas.cli.option.PrintSupportedActionsCmdLineOption;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link CmdLineArgs}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestCmdLineArgs extends TestCase {
+
+   private final static CmdLineAction TEST_ACTION_1 = 
createAction("TestAction1");
+   private final static CmdLineAction TEST_ACTION_2 = 
createAction("TestAction2");
+   private final static CmdLineAction TEST_ACTION_3 = 
createAction("TestAction3");
+
+   private final static ActionCmdLineOption ACTION_OPTION = 
createActionOption("operation");
+   private final static HelpCmdLineOption HELP_OPTION = new 
HelpCmdLineOption();
+   private final static PrintSupportedActionsCmdLineOption PSA_ACTION = new 
PrintSupportedActionsCmdLineOption();
+
+   private final static Set<CmdLineAction> SUPPORTED_ACTIONS = newHashSet(
+         TEST_ACTION_1, TEST_ACTION_2, TEST_ACTION_3);
+   private final static Set<CmdLineOption> SUPPORTED_OPTIONS = newHashSet(
+         (CmdLineOption) ACTION_OPTION, (CmdLineOption) HELP_OPTION,
+         (CmdLineOption) PSA_ACTION);
+
+   public void testBaseCase() {
+      CmdLineOptionInstance specifiedAction = createOptionInstance(
+            ACTION_OPTION, TEST_ACTION_1.getName());
+      Set<CmdLineOptionInstance> specifiedOptions = 
newHashSet(specifiedAction);
+      CmdLineArgs args = new CmdLineArgs(SUPPORTED_ACTIONS, SUPPORTED_OPTIONS,
+            specifiedOptions);
+      assertEquals(TEST_ACTION_1, args.getSpecifiedAction());
+      assertEquals(args.getActionOptionInst(), specifiedAction);
+      assertEquals(ACTION_OPTION, args.getActionOptionInst().getOption());
+      assertNull(args.getHelpOptionInst());
+      assertNull(args.getPrintSupportedActionsOptionInst());
+   }
+
+   public void testCaseActionNotSupported() {
+      CmdLineOptionInstance specifiedAction = createOptionInstance(
+            ACTION_OPTION, "NotSupportedActionName");
+      Set<CmdLineOptionInstance> specifiedOptions = 
newHashSet(specifiedAction);
+      CmdLineArgs args = new CmdLineArgs(SUPPORTED_ACTIONS, SUPPORTED_OPTIONS,
+            specifiedOptions);
+
+      // Verify that CmdLineAction is null since it was not able to be located
+      // in set of supported actions.
+      assertNull(args.getSpecifiedAction());
+      // Verify that if did find the action option.
+      assertEquals(specifiedAction.getOption(), args.getActionOptionInst()
+            .getOption());
+      // Verify that if found the specified action even though it is not
+      // supported.
+      assertEquals(newArrayList("NotSupportedActionName"), args
+            .getActionOptionInst().getValues());
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineUtility.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineUtility.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineUtility.java 
(added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/TestCmdLineUtility.java 
Mon Dec 29 18:28:25 2014
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.CmdLineUtility.validate;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createActionOption;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createAdvancedOption;
+import static 
org.apache.oodt.cas.cli.test.util.TestUtils.createApplyToActionHandler;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+import static 
org.apache.oodt.cas.cli.util.CmdLineUtils.determineFailedValidation;
+import static org.apache.oodt.cas.cli.util.CmdLineUtils.getOptionByName;
+
+//JDK imports
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.cli.CmdLineArgs;
+import org.apache.oodt.cas.cli.CmdLineUtility;
+import org.apache.oodt.cas.cli.action.CmdLineAction;
+import org.apache.oodt.cas.cli.action.PrintMessageAction;
+import org.apache.oodt.cas.cli.option.AdvancedCmdLineOption;
+import org.apache.oodt.cas.cli.option.CmdLineOption;
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import org.apache.oodt.cas.cli.option.HelpCmdLineOption;
+import org.apache.oodt.cas.cli.option.PrintSupportedActionsCmdLineOption;
+import 
org.apache.oodt.cas.cli.option.validator.ArgRegExpCmdLineOptionValidator;
+import org.apache.oodt.cas.cli.option.validator.CmdLineOptionValidator.Result;
+import org.apache.oodt.cas.cli.test.util.TestUtils;
+
+//Google imports
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link CmdLineUtility}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestCmdLineUtility extends TestCase {
+
+   public void testCheck() {
+      CmdLineArgs args = getArgs();
+
+      // Expect pass.
+      assertEquals(0, CmdLineUtility.check(args).size());
+
+      // Expect fail.
+      args.getSupportedOptions().add(
+            TestUtils.createSimpleOption("ReqTestAction", true));
+      assertEquals(1, CmdLineUtility.check(args).size());
+   }
+
+   public void testValidate() {
+      CmdLineArgs args = getArgs();
+
+      // Expect pass.
+      assertEquals(1, CmdLineUtility.validate(args).size());
+      assertEquals(Result.Grade.PASS, CmdLineUtility.validate(args).get(0)
+            .getGrade());
+
+      // Add validator which will cause fail.
+      AdvancedCmdLineOption option = (AdvancedCmdLineOption) 
getOptionByName("message", args.getSupportedOptions());
+      ArgRegExpCmdLineOptionValidator validator = new 
ArgRegExpCmdLineOptionValidator();
+      validator.setAllowedArgs(Lists.newArrayList("\\d{1,2}"));
+      option.addValidator(validator);
+
+      // Expect fail.
+      assertFalse(determineFailedValidation(validate(args)).isEmpty());
+   }
+
+   public void testHandle() {
+      CmdLineArgs args = getArgs();
+
+      // Verify handling works.
+      PrintMessageAction action = (PrintMessageAction) args
+            .getSpecifiedAction();
+      assertNull(action.getMessage());
+      CmdLineUtility.handle(args);
+      assertEquals("Test Message", action.getMessage());
+   }
+
+   private CmdLineArgs getArgs() {
+      // Setup Supported Actions.
+      String actionName = "TestAction";
+      PrintMessageAction action = new PrintMessageAction();
+      action.setName(actionName);
+      Set<CmdLineAction> actions = Sets.newHashSet((CmdLineAction) action);
+
+      // Setup Supported Options.
+      Set<CmdLineOption> options = Sets.newHashSet();
+      options.add(new HelpCmdLineOption());
+      options.add(new PrintSupportedActionsCmdLineOption());
+      options.add(createActionOption("action"));
+      AdvancedCmdLineOption option = createAdvancedOption("message",
+            createApplyToActionHandler(actionName, "setMessage"));
+      ArgRegExpCmdLineOptionValidator validator = new 
ArgRegExpCmdLineOptionValidator();
+      validator.setAllowedArgs(Lists.newArrayList(".*"));
+      option.addValidator(validator);
+      options.add(option);
+
+      // Setup Specified Options.
+      Set<CmdLineOptionInstance> specifiedOptions = Sets.newHashSet();
+      specifiedOptions.add(createOptionInstance(option, "Test Message"));
+      specifiedOptions.add(createOptionInstance(createActionOption("action"),
+            "TestAction"));
+
+      // Setup CmdLineArgs.
+      return new CmdLineArgs(actions, options, specifiedOptions);
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/action/store/spring/TestSpringCmdLineActionStore.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/action/store/spring/TestSpringCmdLineActionStore.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/action/store/spring/TestSpringCmdLineActionStore.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/action/store/spring/TestSpringCmdLineActionStore.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.action.store.spring;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.util.CmdLineUtils.findAction;
+
+//JDK imports
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+//Apache imports
+import org.apache.oodt.cas.cli.action.CmdLineAction;
+import org.apache.oodt.cas.cli.action.CmdLineAction.ActionMessagePrinter;
+import org.apache.oodt.cas.cli.action.PrintMessageAction;
+import org.apache.oodt.cas.cli.action.store.spring.SpringCmdLineActionStore;
+import org.apache.oodt.cas.cli.exception.CmdLineActionStoreException;
+import org.apache.oodt.cas.cli.test.util.TestSetContextInjectTypeAction;
+
+//Spring imports
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Test case for {@link SpringCmdLineActionStore}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestSpringCmdLineActionStore extends TestCase {
+
+   private static final String SPRING_CONFIG = 
"src/test/resources/cmd-line-actions.xml";
+
+   public void testActionNamesAutoSet() {
+      SpringCmdLineActionStore store = new SpringCmdLineActionStore(
+            SPRING_CONFIG);
+      ApplicationContext appContext = store.getApplicationContext();
+      @SuppressWarnings("unchecked")
+      Map<String, CmdLineAction> actionsMap = appContext
+            .getBeansOfType(CmdLineAction.class);
+      for (Entry<String, CmdLineAction> entry : actionsMap.entrySet()) {
+         assertEquals(entry.getKey(), entry.getValue().getName());
+      }
+   }
+
+   public void testApplicationContextAutoSet() throws 
CmdLineActionStoreException {
+      SpringCmdLineActionStore store = new SpringCmdLineActionStore(
+            SPRING_CONFIG);
+      TestSetContextInjectTypeAction action = (TestSetContextInjectTypeAction) 
findAction(
+            "TestSetContextInjectAction", store.loadSupportedActions());
+      assertEquals(action.getContext(), store.getApplicationContext());
+   }
+
+   public void testLoadSupportedActions() throws CmdLineActionStoreException {
+      SpringCmdLineActionStore store = new SpringCmdLineActionStore(
+            SPRING_CONFIG);
+      Set<CmdLineAction> actions = store.loadSupportedActions();
+
+      // Check that all actions were loaded.
+      assertEquals(3, actions.size());
+
+      // Load and verify PrintMessageAction was loaded correctly.
+      CmdLineAction action = findAction("PrintMessageAction", actions);
+      assertTrue(action instanceof PrintMessageAction);
+      PrintMessageAction pma = (PrintMessageAction) action;
+      assertEquals("Prints out a given message", pma.getDescription());
+      ActionMessagePrinter printer = new ActionMessagePrinter();
+      try {
+         pma.execute(printer);
+         fail("Should have thrown IllegalArgumentException");
+      } catch (IllegalArgumentException e) { /* do nothing */ }
+      assertEquals(0, printer.getPrintedMessages().size());
+
+      // Load and verify PrintHelloWorldAction was loaded correctly.
+      action = findAction("PrintHelloWorldAction", actions);
+      assertTrue(action instanceof PrintMessageAction);
+      pma = (PrintMessageAction) action;
+      assertEquals("Prints out 'Hello World'", pma.getDescription());
+      assertEquals("Hello World", pma.getMessage());
+      pma.execute(printer);
+      assertEquals(1, printer.getPrintedMessages().size());
+      assertEquals(pma.getMessage(), printer.getPrintedMessages().get(0));
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToAction.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToAction.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToAction.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToAction.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.handler;
+
+//JUnit imports
+import org.apache.oodt.cas.cli.option.handler.ApplyToAction;
+
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link ApplyToAction}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestApplyToAction extends TestCase {
+
+   public void testVariableSetters() {
+      ApplyToAction applyToAction = new ApplyToAction();
+      assertNull(applyToAction.getActionName());
+      assertNull(applyToAction.getMethodName());
+
+      String actionName = "message";
+      applyToAction.setActionName(actionName);
+      assertEquals(actionName, applyToAction.getActionName());
+
+      String methodName = "setMessage";
+      applyToAction.setMethodName(methodName);
+      assertEquals(methodName, applyToAction.getMethodName());
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToActionHandler.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToActionHandler.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToActionHandler.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestApplyToActionHandler.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.handler;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createAdvancedOption;
+import static 
org.apache.oodt.cas.cli.test.util.TestUtils.createApplyToActionHandler;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+
+//OODT imports
+import org.apache.oodt.cas.cli.action.CmdLineAction;
+import org.apache.oodt.cas.cli.action.PrintMessageAction;
+import org.apache.oodt.cas.cli.option.AdvancedCmdLineOption;
+import org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link ApplyToActionHandler}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestApplyToActionHandler extends TestCase {
+
+   public void testWithoutApplyToActionMappingSet() {
+      ApplyToActionHandler handler = new ApplyToActionHandler();
+      assertNull(handler.getApplyToActions());
+      PrintMessageAction action = new PrintMessageAction();
+      action.setName("PrintMessageAction");
+
+      assertNull(action.getMessage());
+
+      AdvancedCmdLineOption option = new AdvancedCmdLineOption();
+      option.setLongOption("message");
+      option.setHandler(handler);
+      option.getHandler().handleOption(action,
+            createOptionInstance(option, "Howdy"));
+
+      assertEquals("Howdy", action.getMessage());
+   }
+
+   public void testApplyToActionsMapping() {
+      PrintMessageAction action = new PrintMessageAction();
+      action.setName("PrintMessageAction");
+      AdvancedCmdLineOption option = createAdvancedOption("printMessage",
+            createApplyToActionHandler(action.getName(), "setMessage"));
+      option.getHandler().handleOption(action,
+            createOptionInstance(option, "Howdy"));
+
+      assertEquals("Howdy", action.getMessage());
+   }
+
+   public void testSetOrAddInvoke() {
+      TestCmdLineAction action = new TestCmdLineAction();
+      action.setName("TestAction");
+      AdvancedCmdLineOption option = createAdvancedOption("message",
+            createApplyToActionHandler(action.getName(), null));
+
+      // Test that default isRepeating() is false.
+      option.getHandler().handleOption(action,
+            createOptionInstance(option, "Howdy"));
+      assertEquals(TestCmdLineAction.CallType.SET, action.getCallType());
+
+      // Test when isRepeating() is set to false.
+      option.setRepeating(false);
+      option.getHandler().handleOption(action,
+            createOptionInstance(option, "Howdy"));
+      assertEquals(TestCmdLineAction.CallType.SET, action.getCallType());
+
+      // Test when isRepeating() is set to true.
+      option.setRepeating(true);
+      option.getHandler().handleOption(action,
+            createOptionInstance(option, "Howdy"));
+      assertEquals(TestCmdLineAction.CallType.ADD, action.getCallType());
+   }
+
+   public static class TestCmdLineAction extends CmdLineAction {
+      public enum CallType { ADD, SET };
+      private CallType callType;
+
+      @Override
+      public void execute(ActionMessagePrinter printer) {
+      }
+
+      public void addMessage(String message) {
+         callType = CallType.ADD;
+      }
+
+      public void setMessage(String message) {
+         callType = CallType.SET;
+      }
+
+      public CallType getCallType () {
+         return callType;
+      }
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestSetJavaPropertiesHandler.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestSetJavaPropertiesHandler.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestSetJavaPropertiesHandler.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/handler/TestSetJavaPropertiesHandler.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.handler;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createAdvancedOption;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+
+//JDK imports
+import java.util.List;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+//OODT imports
+import org.apache.oodt.cas.cli.option.CmdLineOption;
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import org.apache.oodt.cas.cli.option.handler.SetJavaPropertiesHandler;
+
+//Google imports
+import com.google.common.collect.Lists;
+
+/**
+ * Test class for {@link SetJavaPropertiesHandler}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class TestSetJavaPropertiesHandler extends TestCase {
+
+   public void testSettingOfProperties() {
+      String property = "test.property";
+      SetJavaPropertiesHandler handler = new SetJavaPropertiesHandler();
+      handler.setPropertyNames(Lists.newArrayList(property));
+      CmdLineOption option = createAdvancedOption("testOption", handler);
+      CmdLineOptionInstance optionInstance = createOptionInstance(option, 
"Hello", "World");
+
+      assertNull(System.getProperty(property));
+      
+      handler.handleOption(null, optionInstance);
+      assertEquals("Hello World", System.getProperty(property));
+
+      option.setType(List.class);
+      handler.handleOption(null, optionInstance);
+      assertEquals("Hello,World", System.getProperty(property));
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/require/TestActionDependencyRule.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/require/TestActionDependencyRule.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/require/TestActionDependencyRule.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/require/TestActionDependencyRule.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.require;
+
+//OODT imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createAction;
+
+//OODT imports
+import org.apache.oodt.cas.cli.option.require.ActionDependencyRule;
+import org.apache.oodt.cas.cli.option.require.RequirementRule.Relation;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link ActionDependencyRule}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestActionDependencyRule extends TestCase {
+
+   public void testInitialCase() {
+      ActionDependencyRule actionDependency = new ActionDependencyRule();
+      assertNull(actionDependency.getActionName());
+      assertNull(actionDependency.getRelation());
+   }
+
+   public void testVariableSetting() {
+      String actionName = "operation";
+      Relation relation = Relation.OPTIONAL;
+      ActionDependencyRule actionDependency = new ActionDependencyRule(
+            actionName, relation);
+      assertEquals(actionName, actionDependency.getActionName());
+      assertEquals(relation, actionDependency.getRelation());
+
+      actionName = "action";
+      relation = Relation.REQUIRED;
+      actionDependency.setActionName(actionName);
+      actionDependency.setRelation(relation);
+      assertEquals(actionName, actionDependency.getActionName());
+      assertEquals(relation, actionDependency.getRelation());
+   }
+
+   public void testGetRelation() {
+      String actionName = "operation";
+      Relation relation = Relation.OPTIONAL;
+      ActionDependencyRule actionDependency = new ActionDependencyRule(
+            actionName, relation);
+      assertEquals(relation,
+            actionDependency.getRelation(createAction(actionName)));
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/store/spring/TestSpringCmdLineOptionStore.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/store/spring/TestSpringCmdLineOptionStore.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/store/spring/TestSpringCmdLineOptionStore.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/store/spring/TestSpringCmdLineOptionStore.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.store.spring;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+import static org.apache.oodt.cas.cli.util.CmdLineUtils.findAction;
+import static org.apache.oodt.cas.cli.util.CmdLineUtils.getOptionByName;
+
+//JDK imports
+import java.util.Set;
+
+//OODT imports
+import org.apache.oodt.cas.cli.action.CmdLineAction;
+import org.apache.oodt.cas.cli.action.CmdLineAction.ActionMessagePrinter;
+import org.apache.oodt.cas.cli.action.PrintMessageAction;
+import org.apache.oodt.cas.cli.action.store.spring.SpringCmdLineActionStore;
+import org.apache.oodt.cas.cli.exception.CmdLineActionStoreException;
+import org.apache.oodt.cas.cli.exception.CmdLineOptionStoreException;
+import org.apache.oodt.cas.cli.option.AdvancedCmdLineOption;
+import org.apache.oodt.cas.cli.option.CmdLineOption;
+import org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler;
+import org.apache.oodt.cas.cli.option.require.ActionDependencyRule;
+import org.apache.oodt.cas.cli.option.require.RequirementRule.Relation;
+import org.apache.oodt.cas.cli.option.store.spring.SpringCmdLineOptionStore;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link SpringCmdLineOptionStore}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestSpringCmdLineOptionStore extends TestCase {
+
+   private static final String SPRING_OPTION_CONFIG = 
"src/test/resources/cmd-line-options.xml";
+   private static final String SPRING_ACTION_CONFIG = 
"src/test/resources/cmd-line-actions.xml";
+
+   public void testLoadSupportedOptions() throws CmdLineActionStoreException,
+         CmdLineOptionStoreException {
+      SpringCmdLineOptionStore optionStore = new SpringCmdLineOptionStore(
+            SPRING_OPTION_CONFIG);
+      Set<CmdLineOption> options = optionStore.loadSupportedOptions();
+      SpringCmdLineActionStore actionStore = new SpringCmdLineActionStore(
+            SPRING_ACTION_CONFIG);
+      Set<CmdLineAction> actions = actionStore.loadSupportedActions();
+
+      // Check that all options were loaded.
+      assertEquals(2, options.size());
+
+      // Load and verify printHelloWorld was loaded correctly.
+      CmdLineOption option = getOptionByName("printHelloWorld", options);
+      assertTrue(option instanceof AdvancedCmdLineOption);
+      AdvancedCmdLineOption advancedOption = (AdvancedCmdLineOption) option;
+      assertEquals("phw", advancedOption.getShortOption());
+      assertEquals("printHelloWorld", advancedOption.getLongOption());
+      assertEquals("Print Hello World", advancedOption.getDescription());
+      assertFalse(advancedOption.hasArgs());
+      assertEquals(1, advancedOption.getStaticArgs().size());
+      assertEquals("Hello World!", advancedOption.getStaticArgs().get(0));
+      assertEquals(1, advancedOption.getRequirementRules().size());
+      assertEquals("PrintMessageAction", ((ActionDependencyRule) advancedOption
+            .getRequirementRules().get(0)).getActionName());
+      assertEquals(Relation.OPTIONAL, ((ActionDependencyRule) advancedOption
+            .getRequirementRules().get(0)).getRelation());
+
+      // Load and verify printMessage was loaded correctly.
+      option = getOptionByName("printMessage", options);
+      assertTrue(option instanceof AdvancedCmdLineOption);
+      advancedOption = (AdvancedCmdLineOption) option;
+      assertEquals("pm", advancedOption.getShortOption());
+      assertEquals("printMessage", advancedOption.getLongOption());
+      assertEquals("Message to print out", advancedOption.getDescription());
+      assertEquals(true, advancedOption.hasArgs());
+      assertEquals("message", advancedOption.getArgsDescription());
+      assertEquals(1, advancedOption.getRequirementRules().size());
+      assertEquals("PrintMessageAction", ((ActionDependencyRule) advancedOption
+            .getRequirementRules().get(0)).getActionName());
+      assertEquals(Relation.REQUIRED, ((ActionDependencyRule) advancedOption
+            .getRequirementRules().get(0)).getRelation());
+      assertNotNull(advancedOption.getHandler());
+      assertTrue(advancedOption.getHandler() instanceof ApplyToActionHandler);
+      assertEquals(1, ((ApplyToActionHandler) advancedOption.getHandler())
+            .getApplyToActions().size());
+      assertEquals(findAction("PrintMessageAction", actions).getName(),
+            ((ApplyToActionHandler) advancedOption.getHandler())
+                  .getApplyToActions().get(0).getActionName());
+      assertEquals("setMessage",
+            ((ApplyToActionHandler) advancedOption.getHandler())
+                  .getApplyToActions().get(0).getMethodName());
+   }
+
+   public void testHandlers() throws CmdLineActionStoreException,
+         CmdLineOptionStoreException {
+      SpringCmdLineOptionStore store = new SpringCmdLineOptionStore(
+            SPRING_OPTION_CONFIG);
+      Set<CmdLineOption> options = store.loadSupportedOptions();
+      SpringCmdLineActionStore actionStore = new SpringCmdLineActionStore(
+            SPRING_ACTION_CONFIG);
+      Set<CmdLineAction> actions = actionStore.loadSupportedActions();
+
+      // Load PrintHelloWorldAction
+      PrintMessageAction printHelloWorldAction = (PrintMessageAction) 
findAction(
+            "PrintMessageAction", actions);
+      AdvancedCmdLineOption printHelloWorldOption = (AdvancedCmdLineOption) 
getOptionByName(
+            "printHelloWorld", options);
+      printHelloWorldOption.getHandler().handleOption(printHelloWorldAction,
+            createOptionInstance(printHelloWorldOption));
+      ActionMessagePrinter printer = new ActionMessagePrinter();
+      printHelloWorldAction.execute(printer);
+      assertEquals(1, printer.getPrintedMessages().size());
+      assertEquals("Hello World!", printer.getPrintedMessages().get(0));
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestAllowedArgsCmdLineOptionValidator.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestAllowedArgsCmdLineOptionValidator.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestAllowedArgsCmdLineOptionValidator.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestAllowedArgsCmdLineOptionValidator.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.validator;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createSimpleOption;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+//OODT imports
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import 
org.apache.oodt.cas.cli.option.validator.AllowedArgsCmdLineOptionValidator;
+import org.apache.oodt.cas.cli.option.validator.CmdLineOptionValidator.Result;
+
+//Google imports
+import com.google.common.collect.Lists;
+
+/**
+ * Test class for {@link AllowedArgsCmdLineOptionValidator}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestAllowedArgsCmdLineOptionValidator extends TestCase {
+
+   public void testIntialState() {
+      // Test no null option instance allowed.
+      try {
+         new AllowedArgsCmdLineOptionValidator().validate(null);
+         fail("Should have thrown IllegalArgumentException");
+      } catch (IllegalArgumentException ignore) { /* expect throw */
+      }
+
+      // Test no allowed args set and valid option instance
+      CmdLineOptionInstance instance = createOptionInstance(
+            createSimpleOption("test", false), "value");
+      assertEquals(Result.Grade.FAIL, new AllowedArgsCmdLineOptionValidator()
+            .validate(instance).getGrade());
+   }
+
+   public void testValidate() {
+      AllowedArgsCmdLineOptionValidator validator = new 
AllowedArgsCmdLineOptionValidator();
+      validator.setAllowedArgs(Lists.newArrayList("value1", "value2"));
+
+      // Test no null option instance allowed.
+      try {
+         validator.validate(null);
+         fail("Should have thrown IllegalArgumentException");
+      } catch (IllegalArgumentException ignore) { /* expect throw */
+      }
+
+      // Test should fail case.
+      CmdLineOptionInstance instance = createOptionInstance(
+            createSimpleOption("test", false), "value");
+      assertEquals(Result.Grade.FAIL, validator.validate(instance).getGrade());
+
+      // Test should pass case.
+      instance = createOptionInstance(createSimpleOption("test", false),
+            "value1");
+      assertEquals(Result.Grade.PASS, validator.validate(instance).getGrade());
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestArgRegExpCmdLineOptionValidator.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestArgRegExpCmdLineOptionValidator.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestArgRegExpCmdLineOptionValidator.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestArgRegExpCmdLineOptionValidator.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.validator;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createSimpleOption;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+//OODT imports
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import 
org.apache.oodt.cas.cli.option.validator.AllowedArgsCmdLineOptionValidator;
+import 
org.apache.oodt.cas.cli.option.validator.ArgRegExpCmdLineOptionValidator;
+import org.apache.oodt.cas.cli.option.validator.CmdLineOptionValidator.Result;
+
+//Google imports
+import com.google.common.collect.Lists;
+
+/**
+ * Test class for {@link ArgRegExpCmdLineOptionValidator}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestArgRegExpCmdLineOptionValidator extends TestCase {
+
+   public void testInitialCase() {
+      // Test null option instancd not allowed.
+      try {
+         new ArgRegExpCmdLineOptionValidator().validate(null);
+         fail("Should have thrown IllegalArgumentException");
+      } catch (IllegalArgumentException ignore) { /* expect throw */
+      }
+
+      // Test no allowed args set and valid option instance
+      CmdLineOptionInstance instance = createOptionInstance(
+            createSimpleOption("test", false), "value");
+      assertEquals(Result.Grade.FAIL, new AllowedArgsCmdLineOptionValidator()
+            .validate(instance).getGrade());
+   }
+
+   public void testValidate() {
+      ArgRegExpCmdLineOptionValidator validator = new 
ArgRegExpCmdLineOptionValidator();
+      validator.setAllowedArgs(Lists.newArrayList("v.*?1", "v.*?2"));
+
+      // Test no null option instance allowed.
+      try {
+         validator.validate(null);
+         fail("Should have thrown IllegalArgumentException");
+      } catch (IllegalArgumentException ignore) { /* expect throw */
+      }
+
+      // Test should fail case.
+      CmdLineOptionInstance instance = createOptionInstance(
+            createSimpleOption("test", false), "value");
+      assertEquals(Result.Grade.FAIL, validator.validate(instance).getGrade());
+
+      // Test should pass case.
+      instance = createOptionInstance(createSimpleOption("test", false),
+            "value1");
+      assertEquals(Result.Grade.PASS, validator.validate(instance).getGrade());
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestClassExistsCmdLineOptionValidator.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestClassExistsCmdLineOptionValidator.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestClassExistsCmdLineOptionValidator.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestClassExistsCmdLineOptionValidator.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.validator;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createSimpleOption;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+//OODT imports
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import 
org.apache.oodt.cas.cli.option.validator.ClassExistsCmdLineOptionValidator;
+import org.apache.oodt.cas.cli.option.validator.CmdLineOptionValidator.Result;
+
+/**
+ * Test class for {@link ClassExistsCmdLineOptionValidator}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestClassExistsCmdLineOptionValidator extends TestCase {
+
+   public void testValidate() {
+      // Check null option instance not allowed.
+      try {
+         new ClassExistsCmdLineOptionValidator().validate(null);
+      } catch (IllegalArgumentException ignore) { /* expect throw */
+      }
+
+      // Check fail case.
+      CmdLineOptionInstance instance = createOptionInstance(
+            createSimpleOption("test", false), "bogus");
+      assertEquals(Result.Grade.FAIL, new ClassExistsCmdLineOptionValidator()
+            .validate(instance).getGrade());
+
+      // Check pass case.
+      instance = createOptionInstance(createSimpleOption("test", false),
+            "java.lang.String");
+      assertEquals(Result.Grade.PASS, new ClassExistsCmdLineOptionValidator()
+            .validate(instance).getGrade());
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestFileExistCmdLineOptionValidator.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestFileExistCmdLineOptionValidator.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestFileExistCmdLineOptionValidator.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestFileExistCmdLineOptionValidator.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.validator;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createSimpleOption;
+
+//JDK imports
+import java.io.File;
+import java.io.IOException;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+//OODT imports
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import 
org.apache.oodt.cas.cli.option.validator.FileExistCmdLineOptionValidator;
+import org.apache.oodt.cas.cli.option.validator.CmdLineOptionValidator.Result;
+
+/**
+ * Test class for {@link FileExistCmdLineOptionValidator}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestFileExistCmdLineOptionValidator extends TestCase {
+
+   public void testValidate() throws IOException {
+      // Test null option instance not allowed.
+      try {
+         new FileExistCmdLineOptionValidator().validate(null);
+         fail("Should have thrown IllegalArgumentException");
+      } catch (IllegalArgumentException ignore) { /* expect throw */
+      }
+
+      // Test fail case.
+      CmdLineOptionInstance instance = createOptionInstance(
+            createSimpleOption("test", false), "bogus");
+      assertEquals(Result.Grade.FAIL, new FileExistCmdLineOptionValidator()
+            .validate(instance).getGrade());
+
+      // Test pass case.
+      File tempFile = File.createTempFile("bogus", "bogus");
+      tempFile.deleteOnExit();
+      instance = createOptionInstance(createSimpleOption("test", false),
+            tempFile.getAbsolutePath());
+      assertEquals(Result.Grade.PASS, new FileExistCmdLineOptionValidator()
+            .validate(instance).getGrade());
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestNoRestrictionsCmdLineOptionValidator.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestNoRestrictionsCmdLineOptionValidator.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestNoRestrictionsCmdLineOptionValidator.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/option/validator/TestNoRestrictionsCmdLineOptionValidator.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.option.validator;
+
+//OODT static imports
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createOptionInstance;
+import static org.apache.oodt.cas.cli.test.util.TestUtils.createSimpleOption;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+//OODT imports
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import 
org.apache.oodt.cas.cli.option.validator.NoRestrictionsCmdLineOptionValidator;
+import org.apache.oodt.cas.cli.option.validator.CmdLineOptionValidator.Result;
+
+/**
+ * Test class for {@link NoRestrictionsCmdLineOptionValidator}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestNoRestrictionsCmdLineOptionValidator extends TestCase {
+
+   public void testValidate() {
+      // Test pass for null option instance.
+      assertEquals(Result.Grade.PASS,
+            new NoRestrictionsCmdLineOptionValidator().validate(null)
+                  .getGrade());
+
+      // Test pass for not null option instance.
+      CmdLineOptionInstance instance = createOptionInstance(
+            createSimpleOption("test", false), "bogus");
+      assertEquals(Result.Grade.PASS,
+            new NoRestrictionsCmdLineOptionValidator().validate(instance)
+                  .getGrade());
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/parser/TestStdCmdLineOptionParser.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/parser/TestStdCmdLineOptionParser.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/parser/TestStdCmdLineOptionParser.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/parser/TestStdCmdLineOptionParser.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.parser;
+
+//JDK imports
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.cli.exception.CmdLineParserException;
+import org.apache.oodt.cas.cli.util.ParsedArg;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link StdCmdLineOptionParser}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestStdCmdLineOptionParser extends TestCase {
+
+   public void testParser() throws CmdLineParserException {
+      String[] args =
+            "--group --list one two three four --scalar one --none --group 
--list one --scalar one"
+                  .split(" ");
+
+      // Parse args.
+      StdCmdLineParser parser = new StdCmdLineParser();
+      List<ParsedArg> parsedArgs = parser.parse(args);
+
+      // Check that 14 option instances where returned.
+      assertEquals(14, parsedArgs.size());
+
+      // Check that all args where found and assigned the appropriate type.
+      assertEquals("group", parsedArgs.get(0).getName());
+      assertEquals(ParsedArg.Type.OPTION, parsedArgs.get(0).getType());
+      assertEquals("list", parsedArgs.get(1).getName());
+      assertEquals(ParsedArg.Type.OPTION, parsedArgs.get(1).getType());
+      assertEquals("one", parsedArgs.get(2).getName());
+      assertEquals(ParsedArg.Type.VALUE, parsedArgs.get(2).getType());
+      assertEquals("two", parsedArgs.get(3).getName());
+      assertEquals(ParsedArg.Type.VALUE, parsedArgs.get(3).getType());      
+      assertEquals("three", parsedArgs.get(4).getName());
+      assertEquals(ParsedArg.Type.VALUE, parsedArgs.get(4).getType());
+      assertEquals("four", parsedArgs.get(5).getName());
+      assertEquals(ParsedArg.Type.VALUE, parsedArgs.get(5).getType());
+      assertEquals("scalar", parsedArgs.get(6).getName());
+      assertEquals(ParsedArg.Type.OPTION, parsedArgs.get(6).getType());
+      assertEquals("one", parsedArgs.get(7).getName());
+      assertEquals(ParsedArg.Type.VALUE, parsedArgs.get(7).getType());
+      assertEquals("none", parsedArgs.get(8).getName());
+      assertEquals(ParsedArg.Type.OPTION, parsedArgs.get(8).getType());
+      assertEquals("group", parsedArgs.get(9).getName());
+      assertEquals(ParsedArg.Type.OPTION, parsedArgs.get(9).getType());
+      assertEquals("list", parsedArgs.get(10).getName());
+      assertEquals(ParsedArg.Type.OPTION, parsedArgs.get(10).getType());
+      assertEquals("one", parsedArgs.get(11).getName());
+      assertEquals(ParsedArg.Type.VALUE, parsedArgs.get(11).getType());
+      assertEquals("scalar", parsedArgs.get(12).getName());
+      assertEquals(ParsedArg.Type.OPTION, parsedArgs.get(12).getType());
+      assertEquals("one", parsedArgs.get(13).getName());
+      assertEquals(ParsedArg.Type.VALUE, parsedArgs.get(13).getType());
+   }
+
+   public void testIsOption() {
+      assertTrue(StdCmdLineParser.isOption("--arg"));
+      assertTrue(StdCmdLineParser.isOption("-arg"));
+      assertFalse(StdCmdLineParser.isOption("arg"));
+   }
+
+   public void testGetOptionName() {
+      assertEquals("arg", StdCmdLineParser.getOptionName("--arg"));
+      assertEquals("arg", StdCmdLineParser.getOptionName("-arg"));
+      assertNull(StdCmdLineParser.getOptionName("arg"));
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestOutputStream.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestOutputStream.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestOutputStream.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestOutputStream.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.test.util;
+
+//JDK imports
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Test {@link OutputStream} which writes everything to a {@link StringBuffer}
+ * which can be retrieved to see what was written.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestOutputStream extends OutputStream {
+
+   private StringBuffer sb = new StringBuffer("");
+
+   @Override
+   public void write(int character) throws IOException {
+      sb.append((char) character);
+   }
+
+   public String getText() {
+      return sb.toString();
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestSetContextInjectTypeAction.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestSetContextInjectTypeAction.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestSetContextInjectTypeAction.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestSetContextInjectTypeAction.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.test.util;
+
+//OODT imports
+import org.apache.oodt.cas.cli.action.CmdLineAction;
+import 
org.apache.oodt.cas.cli.action.store.spring.SpringSetContextInjectionType;
+
+//Spring imports
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Test {@link CmdLineAction} for testing {@link SpringSetContextInjectionType}
+ * are injected with the {@link ApplicationContext} correctly.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestSetContextInjectTypeAction extends CmdLineAction implements
+      SpringSetContextInjectionType {
+
+   private ApplicationContext appContext;
+
+   @Override
+   public void execute(ActionMessagePrinter printer) {
+   }
+
+   public void setContext(ApplicationContext appContext) {
+      this.appContext = appContext;
+   }
+
+   public ApplicationContext getContext() {
+      return appContext;
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestUtils.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestUtils.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestUtils.java 
(added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/test/util/TestUtils.java 
Mon Dec 29 18:28:25 2014
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.test.util;
+
+//JDK imports
+import java.util.Collections;
+
+//OODT imports
+import org.apache.oodt.cas.cli.action.CmdLineAction;
+import org.apache.oodt.cas.cli.option.ActionCmdLineOption;
+import org.apache.oodt.cas.cli.option.AdvancedCmdLineOption;
+import org.apache.oodt.cas.cli.option.CmdLineOption;
+import org.apache.oodt.cas.cli.option.CmdLineOptionInstance;
+import org.apache.oodt.cas.cli.option.GroupCmdLineOption;
+import org.apache.oodt.cas.cli.option.SimpleCmdLineOption;
+import org.apache.oodt.cas.cli.option.handler.ApplyToAction;
+import org.apache.oodt.cas.cli.option.handler.ApplyToActionHandler;
+import org.apache.oodt.cas.cli.option.handler.CmdLineOptionHandler;
+import org.apache.oodt.cas.cli.option.require.ActionDependencyRule;
+import org.apache.oodt.cas.cli.option.require.RequirementRule;
+import org.apache.oodt.cas.cli.option.require.RequirementRule.Relation;
+import org.apache.oodt.cas.cli.option.validator.CmdLineOptionValidator;
+
+//Google imports
+import com.google.common.collect.Lists;
+
+/**
+ * Base Test case for CAS-CL unit tests.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestUtils {
+
+   public static CmdLineAction createAction(String name) {
+      return new CmdLineAction(name, "This is an action description") {
+
+         @Override
+         public void execute(ActionMessagePrinter printer) {
+            // do nothing
+         }
+
+      };
+   }
+
+   public static GroupCmdLineOption createGroupOption(String longName,
+         boolean required) {
+      GroupCmdLineOption option = new GroupCmdLineOption();
+      option.setLongOption(longName);
+      option.setShortOption(longName);
+      option.setRequired(required);
+      return option;
+   }
+
+   public static SimpleCmdLineOption createSimpleOption(String longName,
+         boolean required) {
+      return createSimpleOption(longName, longName, required);
+   }
+
+   public static SimpleCmdLineOption createSimpleOption(String shortName,
+         String longName, boolean required) {
+      SimpleCmdLineOption option = new SimpleCmdLineOption();
+      option.setShortOption(shortName);
+      option.setLongOption(longName);
+      option.setRequired(required);
+      return option;
+   }
+
+   public static SimpleCmdLineOption createSimpleOption(String longName,
+         RequirementRule rule) {
+      return createSimpleOption(longName, longName, rule);
+   }
+
+   public static SimpleCmdLineOption createSimpleOption(String shortName,
+         String longName, RequirementRule rule) {
+      SimpleCmdLineOption option = new SimpleCmdLineOption();
+      option.setShortOption(shortName);
+      option.setLongOption(longName);
+      option.setRequirementRules(Collections.singletonList(rule));
+      return option;
+   }
+
+   public static AdvancedCmdLineOption createAdvancedOption(String longName,
+         CmdLineOptionHandler handler) {
+      return createAdvancedOption(longName, longName, handler);
+   }
+
+   public static AdvancedCmdLineOption createAdvancedOption(String shortName,
+         String longName, CmdLineOptionHandler handler) {
+      AdvancedCmdLineOption option = new AdvancedCmdLineOption();
+      option.setShortOption(shortName);
+      option.setLongOption(longName);
+      option.setHandler(handler);
+      return option;
+   }
+
+   public static AdvancedCmdLineOption createValidationOption(String longName,
+         CmdLineOptionValidator... validators) {
+      AdvancedCmdLineOption option = new AdvancedCmdLineOption();
+      option.setLongOption(longName);
+      option.setShortOption(longName);
+      option.setValidators(Lists.newArrayList(validators));
+      return option;
+   }
+
+   public static ActionCmdLineOption createActionOption(String longName) {
+      ActionCmdLineOption option = new ActionCmdLineOption();
+      option.setLongOption(longName);
+      option.setShortOption(longName);
+      return option;
+   }
+
+   public static CmdLineOptionInstance createOptionInstance(
+         CmdLineOption option, String... values) {
+      return new CmdLineOptionInstance(option, Lists.newArrayList(values));
+   }
+
+   public static RequirementRule createRequiredRequirementRule(
+         CmdLineAction action) {
+      ActionDependencyRule rule = new ActionDependencyRule();
+      rule.setActionName(action.getName());
+      rule.setRelation(Relation.REQUIRED);
+      return rule;
+   }
+
+   public static RequirementRule createOptionalRequirementRule(
+         CmdLineAction action) {
+      ActionDependencyRule rule = new ActionDependencyRule();
+      rule.setActionName(action.getName());
+      rule.setRelation(Relation.OPTIONAL);
+      return rule;
+   }
+
+   public static ApplyToActionHandler createApplyToActionHandler(
+         String actionName, String methodName) {
+      ApplyToActionHandler handler = new ApplyToActionHandler();
+      handler.setApplyToActions(Lists.newArrayList(new ApplyToAction(
+            actionName, methodName)));
+      return handler;
+   }
+}

Added: 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/util/TestCmdLineIterable.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/util/TestCmdLineIterable.java?rev=1648404&view=auto
==============================================================================
--- 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/util/TestCmdLineIterable.java
 (added)
+++ 
oodt/trunk/cli/src/test/java/org/apache/oodt/cas/cli/util/TestCmdLineIterable.java
 Mon Dec 29 18:28:25 2014
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.cli.util;
+
+//JDK imports
+import java.util.Arrays;
+
+//OODT imports
+import org.apache.oodt.cas.cli.exception.CmdLineParserException;
+import org.apache.oodt.cas.cli.parser.StdCmdLineParser;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link Args}.
+ * 
+ * @author bfoster (Brian Foster)
+ */
+public class TestCmdLineIterable extends TestCase {
+
+   private static final String ARGS_STRING = "--operation download --url 
http://somewhere.com --user foo --pass bar --toDir /tmp";
+
+   public void testIteration() throws CmdLineParserException {
+      StringBuffer argsString = new StringBuffer("");
+      CmdLineIterable<ParsedArg> args = createArgs();
+      for (ParsedArg arg : args) {
+         if (arg.getType().equals(ParsedArg.Type.OPTION)) {
+            argsString.append("--");
+         }
+         argsString.append(arg.getName()).append(" ");
+         int i = 0;
+         for (ParsedArg argInner : args) {
+            if (argInner.getType().equals(ParsedArg.Type.OPTION)) {
+               argsString.append("--");
+            }
+            argsString.append(argInner.getName()).append(" ");
+            if (i++ > 1) {
+               break;
+            }
+         }
+         arg = args.incrementAndGet();
+         if (arg.getType().equals(ParsedArg.Type.OPTION)) {
+            argsString.append("--");
+         }
+         argsString.append(arg.getName()).append(" ");
+      }
+
+      assertEquals(Arrays.asList(ARGS_STRING.split(" ")),
+            Arrays.asList(argsString.toString().split(" ")));
+   }
+
+   public void testIndexOutOfBoundsException() throws CmdLineParserException {
+      CmdLineIterable<ParsedArg> args = new CmdLineIterable<ParsedArg>(
+            new StdCmdLineParser().parse(new String[] {}));
+      try {
+         args.iterator().next();
+         fail("Should have thrown IndexOutOfBoundsException");
+      } catch (IndexOutOfBoundsException ignore) { /* expect throw */
+      }
+   }
+
+   private CmdLineIterable<ParsedArg> createArgs() throws 
CmdLineParserException {
+      return new CmdLineIterable<ParsedArg>(
+            new StdCmdLineParser().parse(ARGS_STRING.split(" ")));
+   }
+}


Reply via email to