summaryrefslogtreecommitdiffstats
path: root/base/java-tools
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2017-03-24 02:29:31 +0100
committerEndi S. Dewata <edewata@redhat.com>2017-03-27 17:34:23 +0200
commita404c8b827214ae8a4a431d3c9ec74da8fbd654e (patch)
tree54c446fea63fe7018a354420f87547c9a1caf1a0 /base/java-tools
parent707486923941cffa307e6c8a404fe5248cb10d83 (diff)
downloadpki-a404c8b827214ae8a4a431d3c9ec74da8fbd654e.tar.gz
pki-a404c8b827214ae8a4a431d3c9ec74da8fbd654e.tar.xz
pki-a404c8b827214ae8a4a431d3c9ec74da8fbd654e.zip
Refactored SelfTestCLI.
The SelfTestCLI and its submodules have been modified to use lazy initialization to get the PKIClient object.
Diffstat (limited to 'base/java-tools')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/selftests/SelfTestCLI.java9
-rw-r--r--base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java6
-rw-r--r--base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java4
4 files changed, 16 insertions, 7 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestCLI.java
index 2e64e0576..1e674267d 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestCLI.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import org.jboss.resteasy.plugins.providers.atom.Link;
+import com.netscape.certsrv.client.PKIClient;
import com.netscape.certsrv.selftests.SelfTestClient;
import com.netscape.certsrv.selftests.SelfTestData;
import com.netscape.cmstools.cli.CLI;
@@ -40,12 +41,14 @@ public class SelfTestCLI extends CLI {
addModule(new SelfTestShowCLI(this));
}
- public void execute(String[] args) throws Exception {
+ public SelfTestClient getSelfTestClient() throws Exception {
- client = parent.getClient();
+ if (selfTestClient != null) return selfTestClient;
+
+ PKIClient client = getClient();
selfTestClient = (SelfTestClient)parent.getClient("selftest");
- super.execute(args);
+ return selfTestClient;
}
public static void printSelfTestData(SelfTestData selfTestData) throws IOException {
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
index e98ab21d6..3b480533c 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
@@ -24,6 +24,7 @@ import java.util.Collection;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
+import com.netscape.certsrv.selftests.SelfTestClient;
import com.netscape.certsrv.selftests.SelfTestCollection;
import com.netscape.certsrv.selftests.SelfTestData;
import com.netscape.cmstools.cli.CLI;
@@ -75,7 +76,8 @@ public class SelfTestFindCLI extends CLI {
s = cmd.getOptionValue("size");
Integer size = s == null ? null : Integer.valueOf(s);
- SelfTestCollection result = selfTestCLI.selfTestClient.findSelfTests(filter, start, size);
+ SelfTestClient selfTestClient = selfTestCLI.getSelfTestClient();
+ SelfTestCollection result = selfTestClient.findSelfTests(filter, start, size);
MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java
index 59f8a71a8..924455efd 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestRunCLI.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.lang.StringUtils;
+import com.netscape.certsrv.selftests.SelfTestClient;
import com.netscape.certsrv.selftests.SelfTestResult;
import com.netscape.certsrv.selftests.SelfTestResults;
import com.netscape.cmstools.cli.CLI;
@@ -68,17 +69,18 @@ public class SelfTestRunCLI extends CLI {
String[] cmdArgs = cmd.getArgs();
+ SelfTestClient selfTestClient = selfTestCLI.getSelfTestClient();
SelfTestResults results;
if (cmdArgs.length == 0) {
- results = selfTestCLI.selfTestClient.runSelfTests();
+ results = selfTestClient.runSelfTests();
} else {
results = new SelfTestResults();
for (String selfTestID : cmdArgs) {
- SelfTestResult result = selfTestCLI.selfTestClient.runSelfTest(selfTestID);
+ SelfTestResult result = selfTestClient.runSelfTest(selfTestID);
results.addEntry(result);;
}
}
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
index cce4fb587..b8ff12aa3 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestShowCLI.java
@@ -25,6 +25,7 @@ import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
+import com.netscape.certsrv.selftests.SelfTestClient;
import com.netscape.certsrv.selftests.SelfTestData;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -71,7 +72,8 @@ public class SelfTestShowCLI extends CLI {
String selfTestID = args[0];
String output = cmd.getOptionValue("output");
- SelfTestData selfTestInfo = selfTestCLI.selfTestClient.getSelfTest(selfTestID);
+ SelfTestClient selfTestClient = selfTestCLI.getSelfTestClient();
+ SelfTestData selfTestInfo = selfTestClient.getSelfTest(selfTestID);
if (output == null) {
MainCLI.printMessage("SelfTest \"" + selfTestID + "\"");