Java Code Examples for org.apache.commons.cli.ParseException#printStackTrace()

The following examples show how to use org.apache.commons.cli.ParseException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testDefaults() {
  String[] arguments = new String[]{"a-marc-file.mrc"};
  try {
    CommonParameters parameters = new CommonParameters(arguments);
    assertFalse(parameters.doHelp());

    assertTrue(parameters.doLog);

    assertNotNull(parameters.getArgs());
    assertEquals(1, parameters.getArgs().length);
    assertEquals("a-marc-file.mrc", parameters.getArgs()[0]);

  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 2
Source File: RunJobCliParsingTensorFlowTest.java    From submarine with Apache License 2.0 6 votes vote down vote up
@Test
public void testNoInputPathOptionSpecified() throws Exception {
  RunJobCli runJobCli = new RunJobCli(RunJobCliParsingCommonTest.getMockClientContext());
  String expectedErrorMessage = "\"--" + CliConstants.INPUT_PATH +
      "\" is absent";
  String actualMessage = "";
  try {
    runJobCli.run(
        new String[]{"--framework", "tensorflow",
            "--name", "my-job", "--docker_image", "tf-docker:1.1.0",
            "--checkpoint_path", "hdfs://output",
            "--num_workers", "1", "--worker_launch_cmd", "python run-job.py",
            "--worker_resources", "memory=4g,vcores=2", "--tensorboard",
            "true", "--verbose", "--wait_job_finish"});
  } catch (ParseException e) {
    actualMessage = e.getMessage();
    e.printStackTrace();
  }
  assertEquals(expectedErrorMessage, actualMessage);
}
 
Example 3
Source File: ValidatorParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testDefaults() {
  String[] arguments = new String[]{"a-marc-file.mrc"};
  try {
    ValidatorParameters parameters = new ValidatorParameters(arguments);

    assertNotNull(parameters.getArgs());
    assertEquals(1, parameters.getArgs().length);
    assertEquals("a-marc-file.mrc", parameters.getArgs()[0]);

    assertFalse(parameters.doHelp());

    assertNotNull(parameters.getDetailsFileName());
    assertEquals("validation-report.txt", parameters.getDetailsFileName());
    assertFalse(parameters.useStandardOutput());

    assertEquals(-1, parameters.getLimit());
    assertEquals(-1, parameters.getOffset());

    assertFalse(parameters.doSummary());

    assertEquals(ValidationErrorFormat.TEXT, parameters.getFormat());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 4
Source File: FormatterParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testSearchWithSpace() {
  String[] arguments = new String[]{"--search", "920$a=color book", "a-marc-file.mrc"};
  try {
    FormatterParameters parameters = new FormatterParameters(arguments);

    assertNotNull(parameters.getSearch());
    assertTrue(parameters.hasSearch());
    assertEquals("920$a=color book", parameters.getSearch());
    assertEquals("920$a", parameters.getPath());
    assertEquals("color book", parameters.getQuery());

  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 5
Source File: FunctionalAnalysis.java    From metadata-qa-marc with GNU General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) {
  MarcFileProcessor processor = null;
  try {
    processor = new FunctionalAnalysis(args);
  } catch (ParseException e) {
    logger.severe("ERROR. " + e.getLocalizedMessage());
    e.printStackTrace();
    System.exit(0);
  }
  if (processor.getParameters().getArgs().length < 1) {
    logger.severe("Please provide a MARC file name!");
    processor.printHelp(processor.getParameters().getOptions());
    System.exit(0);
  }
  if (processor.getParameters().doHelp()) {
    processor.printHelp(processor.getParameters().getOptions());
    System.exit(0);
  }
  RecordIterator iterator = new RecordIterator(processor);
  iterator.start();
}
 
Example 6
Source File: MarcToSolrParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testDefaults() {
  String[] arguments = new String[]{"a-marc-file.mrc"};
  try {
    MarcToSolrParameters parameters = new MarcToSolrParameters(arguments);

    assertNotNull(parameters.getArgs());
    assertEquals(1, parameters.getArgs().length);
    assertEquals("a-marc-file.mrc", parameters.getArgs()[0]);

    assertFalse(parameters.doHelp());

    assertNull(parameters.getSolrUrl());
    assertFalse(parameters.doCommit());
    assertNotNull(parameters.getSolrFieldType());
    assertEquals(SolrFieldType.MARC, parameters.getSolrFieldType());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 7
Source File: ThompsonTraillCompletenessParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testOffset() {
  String[] arguments = new String[]{"--offset", "3", "a-marc-file.mrc"};
  try {
    ThompsonTraillCompletenessParameters parameters = new ThompsonTraillCompletenessParameters(arguments);
    assertEquals(3, parameters.getOffset());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 8
Source File: ValidatorParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testSummary() {
  String[] arguments = new String[]{"--summary", "a-marc-file.mrc"};
  try {
    ValidatorParameters parameters = new ValidatorParameters(arguments);
    assertTrue(parameters.doSummary());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 9
Source File: MarcToSolrParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testSolrFieldTypeMixed() {
  String[] arguments = new String[]{"--solrFieldType", "mixed", "a-marc-file.mrc"};
  try {
    MarcToSolrParameters parameters = new MarcToSolrParameters(arguments);
    assertEquals(SolrFieldType.MIXED, parameters.getSolrFieldType());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 10
Source File: MarcToSolrParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testSolrFieldTypeHuman() {
  String[] arguments = new String[]{"--solrFieldType", "human-readable", "a-marc-file.mrc"};
  try {
    MarcToSolrParameters parameters = new MarcToSolrParameters(arguments);
    assertEquals(SolrFieldType.HUMAN, parameters.getSolrFieldType());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 11
Source File: CommonParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testNoLog() {
  String[] arguments = new String[]{"--nolog", "a-marc-file.mrc"};
  try {
    CommonParameters parameters = new CommonParameters(arguments);
    assertFalse(parameters.doLog());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 12
Source File: FormatterParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testFormat() {
  String[] arguments = new String[]{"--format", "xyz", "a-marc-file.mrc"};
  try {
    FormatterParameters parameters = new FormatterParameters(arguments);

    assertNotNull(parameters.getFormat());
    assertEquals("xyz", parameters.getFormat());

  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 13
Source File: FormatterParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testId() {
  String[] arguments = new String[]{"--id", "xyz", "a-marc-file.mrc"};
  try {
    FormatterParameters parameters = new FormatterParameters(arguments);

    assertNotNull(parameters.getId());
    assertEquals("xyz", parameters.getId());

  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 14
Source File: SVMRunner.java    From twister2 with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  LOG.log(Level.INFO, "SVM Simple Config");

  try {
    initCmdArgs(args);
    printArgs();
    submitJob();
  } catch (ParseException e) {
    e.printStackTrace();
  }

}
 
Example 15
Source File: Main.java    From TRADFRI2MQTT with Apache License 2.0 5 votes vote down vote up
/**
 * @param args Command line arguments
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException {
	Options options = new Options();
	options.addOption("psk", true, "The Secret on the base of the gateway");
	options.addOption("ip", true, "The IP address of the gateway");
	options.addOption("broker", true, "MQTT URL");
	options.addOption("retained", "Topics are retained");
	options.addOption("help", "Shows this usage information");

	CommandLineParser parser = new DefaultParser();
	CommandLine cmd = null;
	try {
		cmd = parser.parse(options, args);
	} catch (ParseException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	String psk = cmd.getOptionValue("psk");
	String ip = cmd.getOptionValue("ip");
	String broker = cmd.getOptionValue("broker");
	boolean retained = cmd.hasOption("retained");
	boolean help = cmd.hasOption("help");

	if (help || psk == null || ip == null || broker == null) {
		HelpFormatter formatter = new HelpFormatter();
		formatter.printHelp("TRADFRI2MQTT", options);
		System.exit(1);
	}

	Main m = new Main(psk, ip, broker, retained);
	m.discover();
}
 
Example 16
Source File: ThompsonTraillCompletenessParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testFileNameStdOut() {
  String[] arguments = new String[]{"--fileName", "stdout", "a-marc-file.mrc"};
  try {
    ThompsonTraillCompletenessParameters parameters = new ThompsonTraillCompletenessParameters(arguments);
    assertEquals("stdout", parameters.getFileName());
    assertTrue(parameters.useStandardOutput());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 17
Source File: ValidatorParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testStdOut() {
  String[] arguments = new String[]{"--detailsFileName", "stdout", "a-marc-file.mrc"};
  try {
    ValidatorParameters parameters = new ValidatorParameters(arguments);

    assertNotNull(parameters.getDetailsFileName());
    assertEquals("stdout", parameters.getDetailsFileName());
    assertTrue(parameters.useStandardOutput());

  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 18
Source File: ValidatorParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testOffset() {
  String[] arguments = new String[]{"--offset", "3", "a-marc-file.mrc"};
  try {
    ValidatorParameters parameters = new ValidatorParameters(arguments);
    assertEquals(3, parameters.getOffset());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}
 
Example 19
Source File: AbstractCommand.java    From COLA with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CommandLine parse(){
    try {
        return parser.parse(options, cmdRaw.split(StringUtils.SPACE));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 20
Source File: ValidatorParametersTest.java    From metadata-qa-marc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testHelp() {
  String[] arguments = new String[]{"--help", "a-marc-file.mrc"};
  try {
    ValidatorParameters parameters = new ValidatorParameters(arguments);
    assertTrue(parameters.doHelp());
  } catch (ParseException e) {
    e.printStackTrace();
  }
}