Package org.apache.oodt.cas.cli.action

Examples of org.apache.oodt.cas.cli.action.PrintMessageAction


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());
   }
View Full Code Here


      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());
   }
View Full Code Here

      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));
   }
View Full Code Here

   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());
   }
View Full Code Here

   }

   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());
View Full Code Here

      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));
   }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.cli.action.PrintMessageAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.