From ec70921a964be0c38fbceff8a01c16bcad9ebd40 Mon Sep 17 00:00:00 2001 From: Gintas Grigelionis Date: Sun, 4 Nov 2018 10:23:51 +0100 Subject: [PATCH] Revert a regression, improve tests --- src/main/org/apache/tools/ant/taskdefs/Java.java | 9 ++++----- .../junit/org/apache/tools/ant/taskdefs/JavaTest.java | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java b/src/main/org/apache/tools/ant/taskdefs/Java.java index 560002701..58fcffb2c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Java.java +++ b/src/main/org/apache/tools/ant/taskdefs/Java.java @@ -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); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java index 1406600f2..c661a0dd0 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java @@ -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"); }