Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
256 changes: 128 additions & 128 deletions src/test/java/org/apache/commons/cli/AbstractParserTestCase.java

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/test/java/org/apache/commons/cli/ApplicationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Licensed to the Apache Software Foundation (ASF) under one or more

package org.apache.commons.cli;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* This is a collection of tests that test real world applications command lines.
Expand Down
34 changes: 17 additions & 17 deletions src/test/java/org/apache/commons/cli/ArgumentIsOptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ Licensed to the Apache Software Foundation (ASF) under one or more

package org.apache.commons.cli;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

@SuppressWarnings("deprecation") // tests some deprecated classes
public class ArgumentIsOptionTest {

private Options options;
private CommandLineParser parser;

@Before
@BeforeEach
public void setUp() {
options = new Options().addOption("p", false, "Option p").addOption("attr", true, "Option accepts argument");
parser = new PosixParser();
Expand All @@ -41,30 +41,30 @@ public void testOption() throws Exception {
final String[] args = {"-p"};

final CommandLine cl = parser.parse(options, args);
assertTrue("Confirm -p is set", cl.hasOption("p"));
assertFalse("Confirm -attr is not set", cl.hasOption("attr"));
assertEquals("Confirm all arguments recognized", 0, cl.getArgs().length);
assertTrue(cl.hasOption("p"), "Confirm -p is set");
assertFalse(cl.hasOption("attr"), "Confirm -attr is not set");
assertEquals(0, cl.getArgs().length, "Confirm all arguments recognized");
}

@Test
public void testOptionAndOptionWithArgument() throws Exception {
final String[] args = {"-p", "-attr", "p"};

final CommandLine cl = parser.parse(options, args);
assertTrue("Confirm -p is set", cl.hasOption("p"));
assertTrue("Confirm -attr is set", cl.hasOption("attr"));
assertEquals("Confirm arg of -attr", "p", cl.getOptionValue("attr"));
assertEquals("Confirm all arguments recognized", 0, cl.getArgs().length);
assertTrue(cl.hasOption("p"), "Confirm -p is set");
assertTrue(cl.hasOption("attr"), "Confirm -attr is set");
assertEquals("p", cl.getOptionValue("attr"), "Confirm arg of -attr");
assertEquals(0, cl.getArgs().length, "Confirm all arguments recognized");
}

@Test
public void testOptionWithArgument() throws Exception {
final String[] args = {"-attr", "p"};

final CommandLine cl = parser.parse(options, args);
assertFalse("Confirm -p is set", cl.hasOption("p"));
assertTrue("Confirm -attr is set", cl.hasOption("attr"));
assertEquals("Confirm arg of -attr", "p", cl.getOptionValue("attr"));
assertEquals("Confirm all arguments recognized", 0, cl.getArgs().length);
assertFalse(cl.hasOption("p"), "Confirm -p is set");
assertTrue(cl.hasOption("attr"), "Confirm -attr is set");
assertEquals("p", cl.getOptionValue("attr"), "Confirm arg of -attr");
assertEquals(0, cl.getArgs().length, "Confirm all arguments recognized");
}
}
62 changes: 31 additions & 31 deletions src/test/java/org/apache/commons/cli/BasicParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,178 +17,178 @@ Licensed to the Apache Software Foundation (ASF) under one or more

package org.apache.commons.cli;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

@SuppressWarnings("deprecation") // tests some deprecated classes
public class BasicParserTest extends AbstractParserTestCase {
@Override
@Before
@BeforeEach
public void setUp() {
super.setUp();
parser = new BasicParser();
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testAmbiguousLongWithoutEqualSingleDash() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testAmbiguousLongWithoutEqualSingleDash2() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testAmbiguousPartialLongOption1() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testAmbiguousPartialLongOption2() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testAmbiguousPartialLongOption3() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testAmbiguousPartialLongOption4() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testBursting() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testDoubleDash2() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testLongOptionWithEqualsQuoteHandling() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testLongWithEqualDoubleDash() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testLongWithEqualSingleDash() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testLongWithoutEqualSingleDash() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testMissingArgWithBursting() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser (CLI-184)")
@Disabled("not supported by the BasicParser (CLI-184)")
public void testNegativeOption() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testPartialLongOptionSingleDash() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testPropertiesOption1() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testPropertiesOption2() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testShortOptionConcatenatedQuoteHandling() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testShortWithEqual() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testShortWithoutEqual() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testStopBursting() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testStopBursting2() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testUnambiguousPartialLongOption1() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testUnambiguousPartialLongOption2() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testUnambiguousPartialLongOption3() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testUnambiguousPartialLongOption4() throws Exception {
}

@Override
@Test
@Ignore("not supported by the BasicParser")
@Disabled("not supported by the BasicParser")
public void testUnrecognizedOptionWithBursting() throws Exception {
}
}
40 changes: 20 additions & 20 deletions src/test/java/org/apache/commons/cli/CommandLineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Licensed to the Apache Software Foundation (ASF) under one or more

package org.apache.commons.cli;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.Properties;
import java.util.function.Supplier;

import org.junit.Test;
import org.junit.jupiter.api.Test;

@SuppressWarnings("deprecation") // tests some deprecated classes
public class CommandLineTest {
Expand Down Expand Up @@ -78,14 +78,14 @@ public void testGetOptionProperties() throws Exception {
final CommandLine cl = parser.parse(options, args);

final Properties props = cl.getOptionProperties("D");
assertNotNull("null properties", props);
assertEquals("number of properties in " + props, 4, props.size());
assertEquals("property 1", "value1", props.getProperty("param1"));
assertEquals("property 2", "value2", props.getProperty("param2"));
assertEquals("property 3", "true", props.getProperty("param3"));
assertEquals("property 4", "value4", props.getProperty("param4"));

assertEquals("property with long format", "bar", cl.getOptionProperties("property").getProperty("foo"));
assertNotNull(props, "null properties");
assertEquals(4, props.size(), "number of properties in " + props);
assertEquals("value1", props.getProperty("param1"), "property 1");
assertEquals("value2", props.getProperty("param2"), "property 2");
assertEquals("true", props.getProperty("param3"), "property 3");
assertEquals("value4", props.getProperty("param4"), "property 4");

assertEquals("bar", cl.getOptionProperties("property").getProperty("foo"), "property with long format");
}

@Test
Expand All @@ -102,14 +102,14 @@ public void testGetOptionPropertiesWithOption() throws Exception {
final CommandLine cl = parser.parse(options, args);

final Properties props = cl.getOptionProperties(optionD);
assertNotNull("null properties", props);
assertEquals("number of properties in " + props, 4, props.size());
assertEquals("property 1", "value1", props.getProperty("param1"));
assertEquals("property 2", "value2", props.getProperty("param2"));
assertEquals("property 3", "true", props.getProperty("param3"));
assertEquals("property 4", "value4", props.getProperty("param4"));

assertEquals("property with long format", "bar", cl.getOptionProperties(optionProperty).getProperty("foo"));
assertNotNull(props, "null properties");
assertEquals(4, props.size(), "number of properties in " + props);
assertEquals("value1", props.getProperty("param1"), "property 1");
assertEquals("value2", props.getProperty("param2"), "property 2");
assertEquals("true", props.getProperty("param3"), "property 3");
assertEquals("value4", props.getProperty("param4"), "property 4");

assertEquals("bar", cl.getOptionProperties(optionProperty).getProperty("foo"), "property with long format");
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/apache/commons/cli/ConverterTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
*/
package org.apache.commons.cli;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand Down
Loading