Browse Source

Revert a regression, improve tests

master
Gintas Grigelionis 6 years ago
parent
commit
ec70921a96
2 changed files with 8 additions and 9 deletions
  1. +4
    -5
      src/main/org/apache/tools/ant/taskdefs/Java.java
  2. +4
    -4
      src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java

+ 4
- 5
src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -56,9 +56,6 @@ public class Java extends Task {
private static final String WRONG_ATTRIBUTES_MESSAGE = private static final String WRONG_ATTRIBUTES_MESSAGE =
"Cannot use combination of 'classname', 'jar', 'module', 'sourcefile' attributes in same command"; "Cannot use combination of 'classname', 'jar', 'module', 'sourcefile' attributes in same command";


private static final String WRONG_CLASSNAME_ATTRIBUTES_MESSAGE =
"Cannot use combination of 'classname', 'jar', 'sourcefile' attributes in same command";

private CommandlineJava cmdl = new CommandlineJava(); private CommandlineJava cmdl = new CommandlineJava();
private Environment env = new Environment(); private Environment env = new Environment();
private boolean fork = false; private boolean fork = false;
@@ -385,7 +382,8 @@ public class Java extends Task {
*/ */
public void setClassname(String s) throws BuildException { public void setClassname(String s) throws BuildException {
if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) { if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) {
throw new BuildException(WRONG_CLASSNAME_ATTRIBUTES_MESSAGE);
throw new BuildException(
"Cannot use combination of 'classname', 'jar', 'sourcefile' attributes in same command");
} }
getCommandLine().setClassname(s); getCommandLine().setClassname(s);
} }
@@ -400,7 +398,8 @@ public class Java extends Task {
*/ */
public void setModule(String module) throws BuildException { public void setModule(String module) throws BuildException {
if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) { if (getCommandLine().getJar() != null || getCommandLine().getSourceFile() != null) {
throw new BuildException(WRONG_CLASSNAME_ATTRIBUTES_MESSAGE);
throw new BuildException(
"Cannot use combination of 'jar', 'module', 'sourcefile' attributes in same command");
} }
getCommandLine().setModule(module); getCommandLine().setModule(module);
} }


+ 4
- 4
src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java View File

@@ -108,28 +108,28 @@ public class JavaTest {
@Test @Test
public void testJarAndClassName() { public void testJarAndClassName() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use combination of ");
thrown.expectMessage("Cannot use combination of 'classname', 'jar', 'sourcefile'");
buildRule.executeTarget("testJarAndClassName"); buildRule.executeTarget("testJarAndClassName");
} }


@Test @Test
public void testClassnameAndJar() { public void testClassnameAndJar() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use combination of ");
thrown.expectMessage("Cannot use combination of 'classname', 'jar', 'module'");
buildRule.executeTarget("testClassnameAndJar"); buildRule.executeTarget("testClassnameAndJar");
} }


@Test @Test
public void testJarAndModule() { public void testJarAndModule() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use combination of ");
thrown.expectMessage("Cannot use combination of 'jar', 'module', 'sourcefile'");
buildRule.executeTarget("testJarAndModule"); buildRule.executeTarget("testJarAndModule");
} }


@Test @Test
public void testModuleAndJar() { public void testModuleAndJar() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("Cannot use combination of ");
thrown.expectMessage("Cannot use combination of 'classname', 'jar', 'module'");
buildRule.executeTarget("testModuleAndJar"); buildRule.executeTarget("testModuleAndJar");
} }




Loading…
Cancel
Save