Fix OPENDJ-476: Manage Account fails with NPE if target DN does not exist
Fix precommit tests failure.
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int returnCode = main(args, System.out, System.err); |
| | | int returnCode = main(args, true, System.out, System.err); |
| | | if (returnCode != 0) |
| | | { |
| | | System.exit(filterExitCode(returnCode)); |
| | |
| | | * appropriate processing. |
| | | * |
| | | * @param args The command-line arguments provided to this program. |
| | | * @param initServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * {@code null} if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | |
| | | * |
| | | * @return A result code indicating whether the processing was successful. |
| | | */ |
| | | public static int main(String[] args, OutputStream outStream, |
| | | OutputStream errStream) |
| | | public static int main(String[] args, Boolean initServer, |
| | | OutputStream outStream, OutputStream errStream) |
| | | { |
| | | |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | |
| | | |
| | | |
| | | // Parse the command-line arguments provided to the program. |
| | | int result = parseArgsAndConnect(args); |
| | | int result = parseArgsAndConnect(args, initServer); |
| | | if (result < 0) |
| | | { |
| | | // This should only happen if we're only displaying usage information or |
| | |
| | | * Initializes the argument parser for this tool, parses the provided |
| | | * arguments, and establishes a connection to the server. |
| | | * |
| | | * @param args Command arguments to parse. |
| | | * @param initServer Indicates whether to initialize the server. |
| | | * @return A result code that indicates the result of the processing. A |
| | | * value of zero indicates that all processing completed |
| | | * successfully. A value of -1 indicates that only the usage |
| | | * information was displayed and no further action is required. |
| | | */ |
| | | private static int parseArgsAndConnect(String[] args) |
| | | private static int parseArgsAndConnect(String[] args, Boolean initServer) |
| | | { |
| | | argParser = new SubCommandArgumentParser( |
| | | CLASS_NAME, INFO_PWPSTATE_TOOL_DESCRIPTION.get(), |
| | |
| | | targetDNString = targetDN.getValue(); |
| | | |
| | | // Bootstrap and initialize directory data structures. |
| | | EmbeddedUtils.initializeForClientUse(); |
| | | |
| | | if (initServer) |
| | | { |
| | | EmbeddedUtils.initializeForClientUse(); |
| | | } |
| | | // Create the LDAP connection options object, which will be used to |
| | | // customize the way that we connect to the server and specify a set of |
| | | // basic defaults. |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | |
| | | @Test() |
| | | public void testHelpNoSubCommand() |
| | | { |
| | | assertEquals(ManageAccount.main(new String[] { "-H" }, null, System.err), |
| | | assertEquals(ManageAccount.main(new String[] { "-H" }, |
| | | false, null, System.err), |
| | | 0); |
| | | assertEquals(ManageAccount.main(new String[] { "--help" }, null, |
| | | assertEquals(ManageAccount.main(new String[] { "--help" }, false, null, |
| | | System.err), |
| | | 0); |
| | | assertEquals(ManageAccount.main(new String[] { "-?" }, null, System.err), |
| | | assertEquals(ManageAccount.main(new String[] { "-?" }, false, |
| | | null, System.err), |
| | | 0); |
| | | } |
| | | |
| | |
| | | "--help" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, null, System.err), 0); |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, null, null) == 0); |
| | | assertFalse(ManageAccount.main(args, false, null, null) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, null, null) == 0); |
| | | assertFalse(ManageAccount.main(args, false, null, null) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, null, System.err) == 0); |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, null, System.err) == 0); |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, null, System.err), 0); |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test", |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, null, System.err), 0); |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "not-appropriate-for-this-subcommand" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, null, System.err) == 0); |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "true" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, null, System.err), 0); |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "false" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, null, System.err), 0); |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "nonboolean" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, null, System.err) == 0); |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, null, System.err), 0); |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", GeneralizedTimeSyntax.format(System.currentTimeMillis()) |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, null, System.err), 0); |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "invalid" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, null, System.err) == 0); |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test", |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, null, System.err), 0); |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | } |
| | | } |
| | | |