Examples of CmdLineOptionInstance


Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

      return option;
   }

   public static CmdLineOptionInstance createOptionInstance(
         CmdLineOption option, String... values) {
      return new CmdLineOptionInstance(option, Lists.newArrayList(values));
   }
View Full Code Here

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

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

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

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

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

         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.
View Full Code Here

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

         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.
View Full Code Here

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

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

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

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

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

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

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

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

Examples of org.apache.oodt.cas.cli.option.CmdLineOptionInstance

            if (option == null) {
               throw new CmdLineConstructionException("Invalid option: '" + arg.getName() + "'");
            }

            // read found option
            CmdLineOptionInstance specifiedOption = getOption(parsedArgs, option);

            // Check if we are currently loading subOptions.
            if (!groupOptions.isEmpty()) {

               CmdLineOptionInstance currentGroup = groupOptions.peek();

               // Check if option is NOT a subOption for current group.
               if (!isSubOption(currentGroup.getOption(), option)) {

                  // Check if current group was expecting more subOptions.
                  Set<CmdLineOption> requiredSubOptions = verifyGroupHasRequiredSubOptions(currentGroup);
                  if (!requiredSubOptions.isEmpty()) {
                     throw new CmdLineConstructionException(
                           "Missing the following required subOptions for '"
                                 + currentGroup.getOption()
                                 + "': "
                                 + sortOptionsByRequiredStatus(requiredSubOptions));

                  } else if (currentGroup.getSubOptions().isEmpty()) {
                     throw new CmdLineConstructionException(
                           "Must specify a subOption for group option '"
                                 + currentGroup.getOption() + "'");

                  } else {

                     // pop group and add to list of specified options.
                     optionInstances.add(groupOptions.pop());
                  }
               // It is a sub-option...
               } else {

                  // Add option to current group subOptions.
                  currentGroup.addSubOption(specifiedOption);
                  continue;

               }
            }

            if (option instanceof GroupCmdLineOption) {

               // Push group as current group.
               groupOptions.push(specifiedOption);
              
               if (!parsedArgs.hasNext()) {
                  throw new CmdLineConstructionException(
                        "Must specify a subOption for group option '"
                              + specifiedOption.getOption() + "'");
               }
            } else if (option.isSubOption()) {
               throw new CmdLineConstructionException("Option '" + option
                     + "' is a subOption, but was used at top level Option");

            } else {

               // Option good to go.
               optionInstances.add(specifiedOption);
            }
         } else {
            throw new CmdLineConstructionException("Invalid argument: '" + arg + "'");
         }
      }
      while (!groupOptions.isEmpty()) {
         CmdLineOptionInstance currentGroup = groupOptions.pop();
         Set<CmdLineOption> requiredSubOptions = verifyGroupHasRequiredSubOptions(currentGroup);
         if (!requiredSubOptions.isEmpty()) {
            throw new CmdLineConstructionException(
                  "Missing the following required subOptions for '"
                        + currentGroup.getOption() + "': "
                        + sortOptionsByRequiredStatus(requiredSubOptions));

         } else {
            optionInstances.add(currentGroup);
         }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.