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 =
"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 Environment env = new Environment();
private boolean fork = false;
@@ -385,7 +382,8 @@ public class Java extends Task {
*/
public void setClassname(String s) throws BuildException {
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);
}
@@ -400,7 +398,8 @@ public class Java extends Task {
*/
public void setModule(String module) throws BuildException {
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);
}


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

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

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

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

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



Loading…
Cancel
Save