From 769a4f06af790ddd713bb280ffd5f657886ae90a Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Wed, 12 Feb 2014 16:11:06 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1343 Migrate dsconfig / OPENDJ-1303 "opendj-cli" - added classes needeed by DSConfig.
---
opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/ConsoleApplicationTestCase.java | 44 +++++++++++++++++++++++++++++++-------------
1 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/ConsoleApplicationTestCase.java b/opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/ConsoleApplicationTestCase.java
index f0aa277..4b291a6 100644
--- a/opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/ConsoleApplicationTestCase.java
+++ b/opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/ConsoleApplicationTestCase.java
@@ -41,6 +41,10 @@
*/
public class ConsoleApplicationTestCase extends CliTestCase {
+ final LocalizableMessage msg = LocalizableMessage.raw("Language is the source of misunderstandings.");
+ final LocalizableMessage msg2 = LocalizableMessage
+ .raw("If somebody wants a sheep, that is a proof that one exists.");
+
/**
* For test purposes only.
*/
@@ -49,6 +53,7 @@
private static ByteArrayOutputStream err;
private boolean verbose = false;
private boolean interactive = false;
+ private boolean quiet = false;
private MockConsoleApplication(PrintStream out, PrintStream err) {
super(out, err);
@@ -82,6 +87,12 @@
return interactive;
}
+ /** {@inheritDoc} */
+ @Override
+ public boolean isQuiet() {
+ return quiet;
+ }
+
public void setVerbose(boolean v) {
verbose = v;
}
@@ -89,12 +100,14 @@
public void setInteractive(boolean inter) {
interactive = inter;
}
+
+ public void setQuiet(boolean q) {
+ quiet = q;
+ }
}
@Test()
public void testWriteLineInOutputStream() throws UnsupportedEncodingException {
- final LocalizableMessage msg = LocalizableMessage
- .raw("If somebody wants a sheep, that is a proof that one exists.");
final MockConsoleApplication ca = MockConsoleApplication.getDefault();
ca.print(msg);
assertThat(ca.getOut()).contains(msg.toString());
@@ -103,7 +116,6 @@
@Test()
public void testWriteLineInErrorStream() throws UnsupportedEncodingException {
- final LocalizableMessage msg = LocalizableMessage.raw("Language is the source of misunderstandings.");
final MockConsoleApplication ca = MockConsoleApplication.getDefault();
ca.errPrintln(msg);
assertThat(ca.getOut()).isEmpty();
@@ -112,8 +124,6 @@
@Test()
public void testWriteOutputStreamVerbose() throws UnsupportedEncodingException {
- final LocalizableMessage msg = LocalizableMessage
- .raw("If somebody wants a sheep, that is a proof that one exists.");
final MockConsoleApplication ca = MockConsoleApplication.getDefault();
ca.printVerboseMessage(msg);
assertThat(ca.isVerbose()).isFalse();
@@ -128,7 +138,6 @@
@Test()
public void testWriteErrorStreamVerbose() throws UnsupportedEncodingException {
- final LocalizableMessage msg = LocalizableMessage.raw("Language is the source of misunderstandings.");
final MockConsoleApplication ca = MockConsoleApplication.getDefault();
ca.errPrintVerboseMessage(msg);
assertThat(ca.isVerbose()).isFalse();
@@ -149,9 +158,6 @@
*/
@Test()
public void testNonInteractiveApplicationShouldNotStdoutErrors() throws UnsupportedEncodingException {
- final LocalizableMessage msg = LocalizableMessage.raw("Language is the source of misunderstandings.");
- final LocalizableMessage msg2 = LocalizableMessage
- .raw("If somebody wants a sheep, that is a proof that one exists.");
final MockConsoleApplication ca = MockConsoleApplication.getDefault();
assertFalse(ca.isInteractive());
@@ -170,10 +176,6 @@
*/
@Test()
public void testInteractiveApplicationShouldStdoutErrors() throws UnsupportedEncodingException {
- final LocalizableMessage msg = LocalizableMessage.raw("Language is the source of misunderstandings.");
- final LocalizableMessage msg2 = LocalizableMessage
- .raw("If somebody wants a sheep, that is a proof that one exists.");
-
final MockConsoleApplication ca = MockConsoleApplication.getDefault();
assertFalse(ca.isInteractive());
@@ -186,4 +188,20 @@
assertThat(ca.getOut()).contains(msg2.toString());
assertThat(ca.getErr()).isEmpty();
}
+
+ /**
+ * In quiet mode, only the stderr should contain lines.
+ * @throws UnsupportedEncodingException
+ */
+ @Test()
+ public void testQuietMode() throws UnsupportedEncodingException {
+ final MockConsoleApplication ca = MockConsoleApplication.getDefault();
+ ca.setQuiet(true);
+ assertTrue(ca.isQuiet());
+ ca.println(msg);
+ ca.errPrintln(msg2);
+ assertThat(ca.getOut()).isEmpty();
+ assertThat(ca.getErr()).contains(msg2.toString());
+ assertThat(ca.getErr()).doesNotContain(msg.toString());
+ }
}
--
Gitblit v1.10.0