X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=svjatoslav_commons.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Feu%2Fsvjatoslav%2Fcommons%2Fcommandline%2Fparameterparser%2FParserTest.java;h=c5fcda45d64cc0a4f17e987f4a01a202b69fe34b;hp=c61533ef6faad390da2ab565ced01ecae50fc0e3;hb=9bf004ce4e9b5edff36c65fcc8cc0f303390d7fc;hpb=f05caf52a82cdd174ded6bc6d8042200221b18d6 diff --git a/src/test/java/eu/svjatoslav/commons/commandline/parameterparser/ParserTest.java b/src/test/java/eu/svjatoslav/commons/commandline/parameterparser/ParserTest.java index c61533e..c5fcda4 100755 --- a/src/test/java/eu/svjatoslav/commons/commandline/parameterparser/ParserTest.java +++ b/src/test/java/eu/svjatoslav/commons/commandline/parameterparser/ParserTest.java @@ -1,57 +1,55 @@ /* * Svjatoslav Commons - shared library of common functionality. - * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation. + * modify it under the terms of version 3 of the GNU Lesser General Public License + * or later as published by the Free Software Foundation. */ package eu.svjatoslav.commons.commandline.parameterparser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - +import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter; import org.junit.Before; import org.junit.Test; -import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter; +import static org.junit.Assert.*; public class ParserTest { - Parser parser; + Parser parser; - @Before - public void setUp() throws Exception { - parser = new Parser(); - } + @Before + public void setUp() throws Exception { + parser = new Parser(); + } - @Test - public void testParse() { + @Test + public void testParse() { - // define allowed parameters - final StringParameter helpParameter = parser - .createStringParameter("Show help screen") - .addAliases("--help", "-h").setMandatory(); + // define allowed parameters + final StringParameter helpParameter = parser + .add(new StringParameter("Show help screen")) + .addAliases("--help", "-h").setMandatory(); - final StringParameter compileParameter = parser.createStringParameter( - "Compile code").addAliases("--compile", "-c"); + final StringParameter compileParameter = parser.add( + new StringParameter("Compile code")).addAliases("--compile", + "-c"); - // check help generation - parser.showHelp(); + // check help generation + parser.showHelp(); - // parse arguments - parser.parse(new String[] { "--help", "section" }); + // parse arguments + parser.parse(new String[]{"--help", "section"}); - // --help was in the arguments - assertTrue(helpParameter.isParameterSpecified()); + // --help was in the arguments + assertTrue(helpParameter.isParameterSpecified()); - // compile was not present - assertFalse(compileParameter.isParameterSpecified()); + // compile was not present + assertFalse(compileParameter.isParameterSpecified()); - // validate that help argument was "section" - assertEquals("section", helpParameter.getValue()); + // validate that help argument was "section" + assertEquals("section", helpParameter.getValue()); - } + } }