tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject [2/2] incubator-tamaya git commit: [TAMAYA-164] All classes related to the output of the banner are now only within the org.apache.tamaya package available.
Date Thu, 24 Nov 2016 20:21:12 GMT
[TAMAYA-164] All classes related to the output of the banner are now only within the org.apache.tamaya
package available.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/dcd3e69e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/dcd3e69e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/dcd3e69e

Branch: refs/heads/master
Commit: dcd3e69e302ef597c16fa2379c50ecaff6d4ff29
Parents: 4bce88a
Author: Oliver B. Fischer <plexus@apache.org>
Authored: Sat Nov 19 21:25:32 2016 +0100
Committer: Oliver B. Fischer <plexus@apache.org>
Committed: Thu Nov 24 21:20:57 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/tamaya/BannerManager.java   | 136 +++++++++++++++++++
 .../java/org/apache/tamaya/BannerPrinter.java   |  21 +++
 .../apache/tamaya/ConfigurationProvider.java    |   1 -
 .../tamaya/banner/AbstractBannerPrinter.java    |  59 --------
 .../org/apache/tamaya/banner/BannerManager.java |  58 --------
 .../org/apache/tamaya/banner/BannerPrinter.java |  31 -----
 .../tamaya/banner/ConsoleBannerPrinter.java     |  29 ----
 .../tamaya/banner/LoggingBannerPrinter.java     |  33 -----
 .../tamaya/banner/SilentBannerPrinter.java      |  28 ----
 .../org/apache/tamaya/BannerManagerTest.java    |  74 ++++++++++
 .../apache/tamaya/banner/BannerManagerTest.java |  74 ----------
 11 files changed, 231 insertions(+), 313 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/BannerManager.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/BannerManager.java b/code/api/src/main/java/org/apache/tamaya/BannerManager.java
new file mode 100644
index 0000000..9ae81bc
--- /dev/null
+++ b/code/api/src/main/java/org/apache/tamaya/BannerManager.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya;
+
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+class BannerManager {
+    enum BannerTarget {
+        OFF, CONSOLE, LOGGER
+    }
+
+    private BannerTarget bannerTarget;
+
+    public BannerManager(String value) {
+        value = Objects.requireNonNull(value).toUpperCase(Locale.getDefault());
+
+        try {
+            bannerTarget = BannerTarget.valueOf(value);
+        } catch (NullPointerException | IllegalArgumentException e) {
+            bannerTarget = BannerTarget.OFF;
+        }
+    }
+
+    public void outputBanner() {
+        BannerPrinter bp = new SilentBannerPrinter();
+
+        switch (bannerTarget) {
+            case CONSOLE:
+                bp = new ConsoleBannerPrinter();
+                break;
+            case LOGGER:
+                bp = new LoggingBannerPrinter();
+                break;
+            case OFF:
+            default:
+                break;
+        }
+
+        bp.outputBanner();
+    }
+}
+
+abstract class AbstractBannerPrinter implements BannerPrinter {
+    private static final Logger log = Logger.getLogger(AbstractBannerPrinter.class.getName());
+
+    @Override
+    public void outputBanner() {
+        try {
+            URL url = ConfigurationProvider.class.getResource("/tamaya-banner.txt");
+
+            if (url != null) {
+                Path path = Paths.get(url.toURI());
+                List<String> content = Files.readAllLines(path, StandardCharsets.UTF_8);
+
+                for (String line : content) {
+                    outputSingleLine(line);
+                }
+            }
+        } catch (Exception e) {
+            log.log(Level.FINE, "Failed to output the banner of tamaya.", e);
+        }
+    }
+
+    abstract void outputSingleLine(String line);
+}
+
+
+/**
+ * Outputs the Tamaya banner to an implementation specific output channel
+ * as STDOUT or the logging system.
+ */
+interface BannerPrinter {
+    /**
+     * Outputs the banner to the output channel
+     * used by the implementation.
+     */
+    void outputBanner();
+}
+
+/**
+ * Silent implementation of a {@link BannerPrinter}.
+ */
+class SilentBannerPrinter implements BannerPrinter {
+    @Override
+    public void outputBanner() {
+    }
+}
+
+/**
+ * Logs the banner via JUL at level {@link java.util.logging.Level#INFO}.
+ */
+class LoggingBannerPrinter extends AbstractBannerPrinter {
+    private static final Logger log = Logger.getLogger(LoggingBannerPrinter.class.getName());
+
+    @Override
+    void outputSingleLine(String line) {
+        log.log(Level.INFO, line);
+    }
+}
+
+/**
+ * Prints the banner to the console.
+ */
+class ConsoleBannerPrinter extends AbstractBannerPrinter {
+    @Override
+    void outputSingleLine(String line) {
+        System.out.println(line);
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/BannerPrinter.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/BannerPrinter.java b/code/api/src/main/java/org/apache/tamaya/BannerPrinter.java
new file mode 100644
index 0000000..2f74836
--- /dev/null
+++ b/code/api/src/main/java/org/apache/tamaya/BannerPrinter.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya;
+
+

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java b/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
index 7c65da0..0c5d9b1 100644
--- a/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
+++ b/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tamaya;
 
-import org.apache.tamaya.banner.BannerManager;
 import org.apache.tamaya.spi.ConfigurationContext;
 import org.apache.tamaya.spi.ConfigurationContextBuilder;
 import org.apache.tamaya.spi.ConfigurationProviderSpi;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/banner/AbstractBannerPrinter.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/banner/AbstractBannerPrinter.java b/code/api/src/main/java/org/apache/tamaya/banner/AbstractBannerPrinter.java
deleted file mode 100644
index 5ad975c..0000000
--- a/code/api/src/main/java/org/apache/tamaya/banner/AbstractBannerPrinter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.banner;
-
-import org.apache.tamaya.ConfigurationProvider;
-
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Abstract base class for an implementation of the
- * {@link BannerPrinter} providing the common functionality
- * of all implementations.
- */
-abstract class AbstractBannerPrinter implements BannerPrinter {
-    private static final Logger log = Logger.getLogger(AbstractBannerPrinter.class.getName());
-
-    @Override
-    public void outputBanner() {
-        try {
-            URL url = ConfigurationProvider.class.getResource("/tamaya-banner.txt");
-
-            if (url != null) {
-                Path path = Paths.get(url.toURI());
-                List<String> content = Files.readAllLines(path, StandardCharsets.UTF_8);
-
-                for (String line : content) {
-                    outputSingleLine(line);
-                }
-            }
-        } catch (Exception e) {
-            log.log(Level.FINE, "Failed to output the banner of tamaya.", e);
-        }
-    }
-
-    abstract void outputSingleLine(String line);
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/banner/BannerManager.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/banner/BannerManager.java b/code/api/src/main/java/org/apache/tamaya/banner/BannerManager.java
deleted file mode 100644
index 79e3ce4..0000000
--- a/code/api/src/main/java/org/apache/tamaya/banner/BannerManager.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.banner;
-
-import java.util.Locale;
-import java.util.Objects;
-
-public class BannerManager {
-    enum BannerTarget {
-        OFF, CONSOLE, LOGGER
-    }
-
-    private BannerTarget bannerTarget;
-
-    public BannerManager(String value) {
-        value = Objects.requireNonNull(value).toUpperCase(Locale.getDefault());
-
-        try {
-            bannerTarget = BannerTarget.valueOf(value);
-        } catch (NullPointerException | IllegalArgumentException e) {
-            bannerTarget = BannerTarget.OFF;
-        }
-    }
-
-    public void outputBanner() {
-        BannerPrinter bp = new SilentBannerPrinter();
-
-        switch (bannerTarget) {
-            case CONSOLE:
-                bp = new ConsoleBannerPrinter();
-                break;
-            case LOGGER:
-                bp = new LoggingBannerPrinter();
-                break;
-            case OFF:
-            default:
-                break;
-        }
-
-        bp.outputBanner();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/banner/BannerPrinter.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/banner/BannerPrinter.java b/code/api/src/main/java/org/apache/tamaya/banner/BannerPrinter.java
deleted file mode 100644
index 96b2aad..0000000
--- a/code/api/src/main/java/org/apache/tamaya/banner/BannerPrinter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.banner;
-
-/**
- * Outputs the Tamaya banner to an implementation specific output channel
- * as STDOUT or the logging system.
- */
-public interface BannerPrinter {
-    /**
-     * Outputs the banner to the output channel
-     * used by the implementation.
-     */
-    void outputBanner();
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/banner/ConsoleBannerPrinter.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/banner/ConsoleBannerPrinter.java b/code/api/src/main/java/org/apache/tamaya/banner/ConsoleBannerPrinter.java
deleted file mode 100644
index 37ee424..0000000
--- a/code/api/src/main/java/org/apache/tamaya/banner/ConsoleBannerPrinter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.banner;
-
-/**
- * Prints the banner to the console.
- */
-public class ConsoleBannerPrinter extends AbstractBannerPrinter {
-    @Override
-    void outputSingleLine(String line) {
-        System.out.println(line);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/banner/LoggingBannerPrinter.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/banner/LoggingBannerPrinter.java b/code/api/src/main/java/org/apache/tamaya/banner/LoggingBannerPrinter.java
deleted file mode 100644
index 26cbbb2..0000000
--- a/code/api/src/main/java/org/apache/tamaya/banner/LoggingBannerPrinter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.banner;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Logs the banner via JUL at level {@link java.util.logging.Level#INFO}.
- */
-public class LoggingBannerPrinter extends AbstractBannerPrinter {
-    private static final Logger log = Logger.getLogger(LoggingBannerPrinter.class.getName());
-    @Override
-    void outputSingleLine(String line) {
-        log.log(Level.INFO, line);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/main/java/org/apache/tamaya/banner/SilentBannerPrinter.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/banner/SilentBannerPrinter.java b/code/api/src/main/java/org/apache/tamaya/banner/SilentBannerPrinter.java
deleted file mode 100644
index 8669ad4..0000000
--- a/code/api/src/main/java/org/apache/tamaya/banner/SilentBannerPrinter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.banner;
-
-/**
- * Silent implementation of a {@link BannerPrinter}.
- */
-public class SilentBannerPrinter implements BannerPrinter {
-    @Override
-    public void outputBanner() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/test/java/org/apache/tamaya/BannerManagerTest.java
----------------------------------------------------------------------
diff --git a/code/api/src/test/java/org/apache/tamaya/BannerManagerTest.java b/code/api/src/test/java/org/apache/tamaya/BannerManagerTest.java
new file mode 100644
index 0000000..3bec943
--- /dev/null
+++ b/code/api/src/test/java/org/apache/tamaya/BannerManagerTest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.io.PrintStream;
+import java.util.logging.Logger;
+
+@RunWith(MockitoJUnitRunner.class)
+public class BannerManagerTest {
+
+    @Mock
+    private PrintStream printStream;
+
+    @Mock
+    private Logger logger;
+
+    @Test
+    public void valueConsoleSendsBannerToSystemOut() {
+        PrintStream standard = System.out;
+
+        System.setOut(printStream);
+
+        try {
+            BannerManager bm = new BannerManager("console");
+            bm.outputBanner();
+
+        } finally {
+            System.setOut(standard);
+        }
+
+        Mockito.verify(printStream, Mockito.atLeastOnce()).println(Mockito.anyString());
+    }
+
+    @Test
+    public void invalidValueAvoidsLoggingToConsonle() {
+
+        PrintStream standard = System.out;
+
+        System.setOut(printStream);
+
+        try {
+            BannerManager bm = new BannerManager("snafu");
+            bm.outputBanner();
+
+        } finally {
+            System.setOut(standard);
+        }
+
+        Mockito.verify(printStream, Mockito.never()).println(Mockito.anyString());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dcd3e69e/code/api/src/test/java/org/apache/tamaya/banner/BannerManagerTest.java
----------------------------------------------------------------------
diff --git a/code/api/src/test/java/org/apache/tamaya/banner/BannerManagerTest.java b/code/api/src/test/java/org/apache/tamaya/banner/BannerManagerTest.java
deleted file mode 100644
index e5ba859..0000000
--- a/code/api/src/test/java/org/apache/tamaya/banner/BannerManagerTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.banner;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import java.io.PrintStream;
-import java.util.logging.Logger;
-
-@RunWith(MockitoJUnitRunner.class)
-public class BannerManagerTest {
-
-    @Mock
-    private PrintStream printStream;
-
-    @Mock
-    private Logger logger;
-
-    @Test
-    public void valueConsoleSendsBannerToSystemOut() {
-        PrintStream standard = System.out;
-
-        System.setOut(printStream);
-
-        try {
-            BannerManager bm = new BannerManager("console");
-            bm.outputBanner();
-
-        } finally {
-            System.setOut(standard);
-        }
-
-        Mockito.verify(printStream, Mockito.atLeastOnce()).println(Mockito.anyString());
-    }
-
-    @Test
-    public void invalidValueAvoidsLoggingToConsonle() {
-
-        PrintStream standard = System.out;
-
-        System.setOut(printStream);
-
-        try {
-            BannerManager bm = new BannerManager("snafu");
-            bm.outputBanner();
-
-        } finally {
-            System.setOut(standard);
-        }
-
-        Mockito.verify(printStream, Mockito.never()).println(Mockito.anyString());
-    }
-
-}


Mime
View raw message