You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by th...@apache.org on 2008/04/18 08:22:49 UTC
svn commit: r649381 - in /db/derby/code/trunk/java:
drda/org/apache/derby/impl/drda/ drda/org/apache/derby/loc/drda/
testing/org/apache/derbyTesting/functionTests/tests/derbynet/
Author: thomanie
Date: Thu Apr 17 23:22:46 2008
New Revision: 649381
URL: http://svn.apache.org/viewvc?rev=649381&view=rev
Log:
DERBY-3543: NetworkServerControl with options but no command does not give usage message.
Patch contributed by Martin Zaun
Patch file: DERBY-3542-1.diff (wrong name, correct file)
Modified:
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=649381&r1=649380&r2=649381&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Thu Apr 17 23:22:46 2008
@@ -2103,12 +2103,10 @@
// For convenience just use NetworkServerControlImpls log writer for user messages
logWriter = makePrintWriter(System.out);
- int command = COMMAND_START;
- if (args.length > 0)
- command = findCommand(args);
- else
+ int command = findCommand(args);
+ if (command == COMMAND_UNKNOWN)
{
- consolePropertyMessage("DRDA_NoArgs.U");
+ consolePropertyMessage("DRDA_NoCommand.U");
}
return command;
@@ -2273,10 +2271,11 @@
return i;
}
}
+
+ // didn't find command
+ consolePropertyMessage("DRDA_UnknownCommand.U",
+ (String) commandArgs.firstElement());
}
- // didn't find command
- consolePropertyMessage("DRDA_UnknownCommand.U",
- (String) commandArgs.firstElement());
} catch (Exception e) {
if (e.getMessage().equals(NetworkServerControlImpl.UNEXPECTED_ERR))
throw e;
Modified: db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties?rev=649381&r1=649380&r2=649381&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties Thu Apr 17 23:22:46 2008
@@ -36,7 +36,7 @@
DRDA_DBShutdownSuccess.I=Shutting down database, {0}, successful.
DRDA_CommandError.S=Error occurred in processing command {0}.
DRDA_NotImplemented.S={0} is not implemented.
-DRDA_NoArgs.U=No arguments given.
+DRDA_NoCommand.U=No command given.
DRDA_UnknownArgument.U=Argument {0} is unknown.
DRDA_UnknownCommand.U=Command {0} is unknown.
DRDA_InvalidValue.U=Invalid value, {0}, for {1}.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java?rev=649381&r1=649380&r2=649381&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java Thu Apr 17 23:22:46 2008
@@ -32,7 +32,6 @@
import org.apache.derbyTesting.junit.TestConfiguration;
import java.io.File;
-import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.AccessController;
@@ -59,6 +58,43 @@
* TODO: Add tests for other API calls.
*/
+ /**
+ * Test other commands. These should all give a helpful error and the
+ * usage message
+ */
+ public void testWrongUsage() throws Exception
+ {
+ final String nsc = "org.apache.derby.drda.NetworkServerControl";
+ // we'll assume that we get the full message if we get 'Usage'
+ // because sometimes, the message gets returned with carriage return,
+ // and sometimes it doesn't, checking for two different parts...
+ final String usage = "Usage: ";
+
+ // no arguments
+ String[] cmd = new String[] {nsc};
+ assertExecJavaCmdAsExpected(new String[]
+ {"No command given.", usage}, cmd, 1);
+
+ // some option but no command
+ cmd = new String[] {nsc, "-h", "localhost"};
+ assertExecJavaCmdAsExpected(new String[]
+ {"No command given.", usage}, cmd, 1);
+
+ // unknown command
+ cmd = new String[] {nsc, "unknowncmd"};
+ assertExecJavaCmdAsExpected(new String[]
+ {"Command unknowncmd is unknown.", usage}, cmd, 1);
+
+ // unknown option
+ cmd = new String[] {nsc, "-unknownarg"};
+ assertExecJavaCmdAsExpected(new String[]
+ {"Argument -unknownarg is unknown.", usage}, cmd, 1);
+
+ // wrong number of arguments
+ cmd = new String[] {nsc, "ping", "arg1"};
+ assertExecJavaCmdAsExpected(new String[]
+ {"Invalid number of arguments for command ping.", usage}, cmd, 1);
+ }
/**
* @throws Exception
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy?rev=649381&r1=649380&r2=649381&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy Thu Apr 17 23:22:46 2008
@@ -153,6 +153,9 @@
// Access all files under ${user.dir}to write the test directory structure
permission java.io.FilePermission "${user.dir}${/}-", "read,write,delete";
+ // just add the complete gross policy change for NetworkServerControlApiTest
+ // execute permission is for 'java', but this can be at a variety of locations.
+ permission java.io.FilePermission "<<ALL FILES>>", "execute";
// When running with useprocess=false need to install and uninstall
// the security manager and allow setIO to change the system err and out
@@ -177,6 +180,9 @@
permission java.io.FilePermission "${derby.system.home}${/}derby.log", "read, write, delete";
permission java.io.FilePermission "${derby.system.home}", "read";
permission java.io.FilePermission "${derby.system.home}${/}-", "read, write, delete";
+ // just add the complete gross policy change for NetworkServerControlApiTest
+ // execute permission is for 'java', but this can be at a variety of locations.
+ permission java.io.FilePermission "<<ALL FILES>>", "execute";
// combination of client and server side.
permission java.net.SocketPermission "127.0.0.1", "accept,connect,resolve";
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java?rev=649381&r1=649380&r2=649381&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java Thu Apr 17 23:22:46 2008
@@ -108,8 +108,8 @@
badServerProperties, new String[] {}, true));
// The other fixtures, testToggleTrace (trace on/off),
- // testToggleLogConnections (logconnections on/off) , and
- // testWrongCommands can all use the default setup with adjusted policy
+ // and testToggleLogConnections (logconnections on/off)
+ // can all use the default setup with adjusted policy
// need english locale so we can compare command output for those tests
if (!Locale.getDefault().getLanguage().equals("en"))
@@ -636,34 +636,5 @@
assertSuccessfulCmd("Log Connections changed to off.", cmd);
// traceAll should be back to false
verifyProperties(expectedLogConnectionsOff);
- }
-
-
- /**
- * Test other commands. These should all give a helpful error and the
- * usage message
- * Note: maybe these test cases should be moved to another Test,
- * as they don't actually test any properties.
- */
- public void testWrongCommands()
- throws SQLException, IOException, InterruptedException
- {
- String nsc = "org.apache.derby.drda.NetworkServerControl";
- // no arguments
- String[] cmd = new String[] {nsc};
- // we'll assume that we get the full message if we get 'Usage'
- // because sometimes, the message gets returned with carriage return,
- // and sometimes it doesn't, checking for two different parts...
- assertExecJavaCmdAsExpected(new String[]
- {"No arguments given.", "Usage: "}, cmd, 1);
- //Unknown command
- cmd = new String[] {nsc, "unknowncmd"};
- assertExecJavaCmdAsExpected(new String[]
- {"Command unknowncmd is unknown.", "Usage: "}, cmd, 0);
- // wrong number of arguments
- cmd = new String[] {nsc, "ping", "arg1"};
- assertExecJavaCmdAsExpected(new String[]
- {"Invalid number of arguments for command ping.",
- "Usage: "}, cmd, 1);
}
}