Index: /code/branches/testing/src/libraries/util/output/AdditionalContextListener.h
===================================================================
--- /code/branches/testing/src/libraries/util/output/AdditionalContextListener.h	(revision 9533)
+++ /code/branches/testing/src/libraries/util/output/AdditionalContextListener.h	(revision 9534)
@@ -50,4 +50,6 @@
     {
         public:
+            virtual ~AdditionalContextListener() {}
+
             virtual void updatedLevelMask(const OutputListener* listener) = 0;
             virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) = 0;
Index: /code/branches/testing/src/libraries/util/output/OutputListener.h
===================================================================
--- /code/branches/testing/src/libraries/util/output/OutputListener.h	(revision 9533)
+++ /code/branches/testing/src/libraries/util/output/OutputListener.h	(revision 9534)
@@ -66,5 +66,5 @@
             void setAdditionalContextsLevelMask(OutputLevel mask);
 
-            void setAdditionalContextsMask(OutputContextMask mask);
+            virtual void setAdditionalContextsMask(OutputContextMask mask);
 
             /// @brief Returns the level mask.
Index: /code/branches/testing/src/libraries/util/output/SubcontextOutputListener.h
===================================================================
--- /code/branches/testing/src/libraries/util/output/SubcontextOutputListener.h	(revision 9533)
+++ /code/branches/testing/src/libraries/util/output/SubcontextOutputListener.h	(revision 9534)
@@ -73,5 +73,5 @@
             virtual ~SubcontextOutputListener();
 
-            void setAdditionalContextsMask(OutputContextMask mask);
+            virtual void setAdditionalContextsMask(OutputContextMask mask);
             void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts);
 
Index: /code/branches/testing/test/util/output/OutputListenerTest.cc
===================================================================
--- /code/branches/testing/test/util/output/OutputListenerTest.cc	(revision 9533)
+++ /code/branches/testing/test/util/output/OutputListenerTest.cc	(revision 9534)
@@ -235,5 +235,103 @@
 
     // test acceptsOutput
+    namespace
+    {
+        void testContext(const OutputListener& listener, const OutputContextContainer& context, bool accepted)
+        {
+            EXPECT_TRUE(listener.acceptsOutput(level::message, context));
+            EXPECT_TRUE(listener.acceptsOutput(level::user_error, context));
+            EXPECT_TRUE(listener.acceptsOutput(level::user_warning, context));
+
+            if (accepted)
+            {
+                EXPECT_TRUE(listener.acceptsOutput(level::user_status, context));
+                EXPECT_TRUE(listener.acceptsOutput(level::internal_error, context));
+                EXPECT_TRUE(listener.acceptsOutput(level::internal_info, context));
+            }
+            else
+            {
+                EXPECT_FALSE(listener.acceptsOutput(level::user_status, context));
+                EXPECT_FALSE(listener.acceptsOutput(level::internal_error, context));
+                EXPECT_FALSE(listener.acceptsOutput(level::internal_info, context));
+            }
+
+            EXPECT_FALSE(listener.acceptsOutput(level::verbose, context));
+            EXPECT_FALSE(listener.acceptsOutput(level::verbose_ultra, context));
+        }
+    }
+
+    TEST(OutputListenerTest, AcceptsOutputNoAdditionalContext)
+    {
+        MockOutputListener listener;
+
+        listener.setLevelMax(level::user_warning);
+
+        testContext(listener, context::undefined(), false);
+        testContext(listener, context::unittest1(), false);
+        testContext(listener, context::unittest2(), false);
+    }
+
+    TEST(OutputListenerTest, AcceptsOutputWithAdditionalContext)
+    {
+        MockOutputListener listener;
+
+        listener.setLevelMax(level::user_warning);
+        listener.setAdditionalContextsMask(context::unittest1().mask);
+        listener.setAdditionalContextsLevelMax(level::internal_info);
+
+        testContext(listener, context::undefined(), false);
+        testContext(listener, context::unittest1(), true);
+        testContext(listener, context::unittest2(), false);
+    }
+
+    TEST(OutputListenerTest, AcceptsOutputWithTwoAdditionalContexts)
+    {
+        MockOutputListener listener;
+
+        listener.setLevelMax(level::user_warning);
+
+        listener.setLevelMax(level::user_warning);
+        listener.setAdditionalContextsMask(context::unittest1().mask | context::unittest2().mask);
+        listener.setAdditionalContextsLevelMax(level::internal_info);
+
+        testContext(listener, context::undefined(), false);
+        testContext(listener, context::unittest1(), true);
+        testContext(listener, context::unittest2(), true);
+    }
+
     // test unfilteredOutput
+    TEST(OutputListenerTest, UnfilteredOutputCallsOutputIfOutputAccepted)
+    {
+        MockOutputListener listener;
+
+        listener.setLevelMax(level::user_warning);
+
+        const OutputLevel& level = level::message;
+        const OutputContextContainer& context = context::undefined();
+
+        EXPECT_TRUE(listener.acceptsOutput(level, context));
+
+        std::vector<std::string> lines;
+        EXPECT_CALL(listener, output(level, ::testing::_, lines)).Times(1);
+
+        listener.unfilteredOutput(level, context, lines);
+    }
+
+    TEST(OutputListenerTest, UnfilteredOutputDoesNotCallOutputIfOutputNotAccepted)
+    {
+        MockOutputListener listener;
+
+        listener.setLevelMax(level::user_warning);
+
+        const OutputLevel& level = level::verbose;
+        const OutputContextContainer& context = context::undefined();
+
+        EXPECT_FALSE(listener.acceptsOutput(level, context));
+
+        std::vector<std::string> lines;
+        EXPECT_CALL(listener, output(level, ::testing::_, lines)).Times(0);
+
+        listener.unfilteredOutput(level, context, lines);
+    }
 
     // Fixture
Index: /code/branches/testing/test/util/output/SubcontextOutputListenerTest.cc
===================================================================
--- /code/branches/testing/test/util/output/SubcontextOutputListenerTest.cc	(revision 9533)
+++ /code/branches/testing/test/util/output/SubcontextOutputListenerTest.cc	(revision 9534)
@@ -1,6 +1,217 @@
 #include <gtest/gtest.h>
+#include <gmock/gmock.h>
 #include "util/Output.h"
+#include "util/output/SubcontextOutputListener.h"
 
 namespace orxonox
 {
+    namespace context
+    {
+        namespace
+        {
+            REGISTER_OUTPUT_CONTEXT(unittest1);
+            REGISTER_OUTPUT_CONTEXT(unittest2);
+            REGISTER_OUTPUT_CONTEXT(unittest3);
+
+            REGISTER_OUTPUT_SUBCONTEXT(unittest3, sub1);
+            REGISTER_OUTPUT_SUBCONTEXT(unittest3, sub2);
+            REGISTER_OUTPUT_SUBCONTEXT(unittest3, sub3);
+        }
+    }
+
+    namespace
+    {
+        class MockSubcontextOutputListener : public SubcontextOutputListener
+        {
+            public:
+                MockSubcontextOutputListener(bool bRegister = true) : SubcontextOutputListener(bRegister) {}
+                MOCK_METHOD3(output, void(OutputLevel, const OutputContextContainer&, const std::vector<std::string>&));
+        };
+    }
+
+    TEST(SubcontextOutputListenerTest, ContextsDefinedCorrectly)
+    {
+        EXPECT_TRUE(context::unittest1().sub_id == context::no_subcontext);
+        EXPECT_TRUE(context::unittest2().sub_id == context::no_subcontext);
+        EXPECT_TRUE(context::unittest3().sub_id == context::no_subcontext);
+        EXPECT_FALSE(context::sub1().sub_id == context::no_subcontext);
+        EXPECT_FALSE(context::sub2().sub_id == context::no_subcontext);
+        EXPECT_FALSE(context::sub3().sub_id == context::no_subcontext);
+    }
+
+    // test setAdditionalContextsMask
+    TEST(SubcontextOutputListenerTest, SetAdditionalContextsMask)
+    {
+        MockSubcontextOutputListener listener;
+
+        listener.setAdditionalContextsMask(context::unittest1().mask | context::unittest2().mask);
+
+        OutputContextMask mask = listener.getAdditionalContextsMask();
+
+        EXPECT_TRUE(mask & context::unittest1().mask);
+        EXPECT_TRUE(mask & context::unittest2().mask);
+        EXPECT_FALSE(mask & context::unittest3().mask);
+    }
+
+    // test setAdditionalSubcontexts
+    TEST(SubcontextOutputListenerTest, SetAdditionalSubcontexts)
+    {
+        MockSubcontextOutputListener listener;
+
+        std::set<const OutputContextContainer*> subcontexts;
+        subcontexts.insert(&context::sub1());
+        subcontexts.insert(&context::sub3());
+
+        listener.setAdditionalSubcontexts(subcontexts);
+        OutputContextMask mask = listener.getAdditionalContextsMask();
+
+        EXPECT_FALSE(mask & context::unittest1().mask);
+        EXPECT_FALSE(mask & context::unittest2().mask);
+        EXPECT_TRUE(mask & context::unittest3().mask);
+    }
+
+    // test setAdditionalContextsMask and setAdditionalSubcontexts
+    TEST(SubcontextOutputListenerTest, SetAdditionalContextsAndSubcontexts)
+    {
+        MockSubcontextOutputListener listener;
+
+        std::set<const OutputContextContainer*> subcontexts;
+        subcontexts.insert(&context::sub1());
+        subcontexts.insert(&context::sub3());
+
+        listener.setAdditionalSubcontexts(subcontexts);
+        listener.setAdditionalContextsMask(context::unittest1().mask | context::unittest2().mask);
+
+        OutputContextMask mask = listener.getAdditionalContextsMask();
+
+        EXPECT_TRUE(mask & context::unittest1().mask);
+        EXPECT_TRUE(mask & context::unittest2().mask);
+        EXPECT_TRUE(mask & context::unittest3().mask);
+    }
+
+    // test acceptsOutput
+    namespace
+    {
+        void testContext(const OutputListener& listener, const OutputContextContainer& context, bool accepted)
+        {
+            EXPECT_TRUE(accepted == listener.acceptsOutput(level::message, context));
+            EXPECT_TRUE(accepted == listener.acceptsOutput(level::user_error, context));
+            EXPECT_TRUE(accepted == listener.acceptsOutput(level::internal_info, context));
+        }
+    }
+
+    TEST(SubcontextOutputListenerTest, NoContext)
+    {
+        MockSubcontextOutputListener listener;
+        listener.setAdditionalContextsLevelMax(level::verbose);
+
+        testContext(listener, context::unittest1(), false);
+        testContext(listener, context::unittest2(), false);
+        testContext(listener, context::unittest3(), false);
+        testContext(listener, context::sub1(), false);
+        testContext(listener, context::sub2(), false);
+        testContext(listener, context::sub3(), false);
+    }
+
+    TEST(SubcontextOutputListenerTest, OneContext)
+    {
+        MockSubcontextOutputListener listener;
+        listener.setAdditionalContextsLevelMax(level::verbose);
+
+        listener.setAdditionalContextsMask(context::unittest1().mask);
+
+        testContext(listener, context::unittest1(), true);
+        testContext(listener, context::unittest2(), false);
+        testContext(listener, context::unittest3(), false);
+        testContext(listener, context::sub1(), false);
+        testContext(listener, context::sub2(), false);
+        testContext(listener, context::sub3(), false);
+    }
+
+    TEST(SubcontextOutputListenerTest, TwoContexts)
+    {
+        MockSubcontextOutputListener listener;
+        listener.setAdditionalContextsLevelMax(level::verbose);
+
+        listener.setAdditionalContextsMask(context::unittest1().mask | context::unittest2().mask);
+
+        testContext(listener, context::unittest1(), true);
+        testContext(listener, context::unittest2(), true);
+        testContext(listener, context::unittest3(), false);
+        testContext(listener, context::sub1(), false);
+        testContext(listener, context::sub2(), false);
+        testContext(listener, context::sub3(), false);
+    }
+
+    TEST(SubcontextOutputListenerTest, OneSubcontext)
+    {
+        MockSubcontextOutputListener listener;
+        listener.setAdditionalContextsLevelMax(level::verbose);
+
+        std::set<const OutputContextContainer*> subcontexts;
+        subcontexts.insert(&context::sub1());
+
+        listener.setAdditionalSubcontexts(subcontexts);
+
+        testContext(listener, context::unittest1(), false);
+        testContext(listener, context::unittest2(), false);
+        testContext(listener, context::unittest3(), false);
+        testContext(listener, context::sub1(), true);
+        testContext(listener, context::sub2(), false);
+        testContext(listener, context::sub3(), false);
+    }
+
+    TEST(SubcontextOutputListenerTest, TwoSubcontexts)
+    {
+        MockSubcontextOutputListener listener;
+        listener.setAdditionalContextsLevelMax(level::verbose);
+
+        std::set<const OutputContextContainer*> subcontexts;
+        subcontexts.insert(&context::sub1());
+        subcontexts.insert(&context::sub3());
+
+        listener.setAdditionalSubcontexts(subcontexts);
+
+        testContext(listener, context::unittest1(), false);
+        testContext(listener, context::unittest2(), false);
+        testContext(listener, context::unittest3(), false);
+        testContext(listener, context::sub1(), true);
+        testContext(listener, context::sub2(), false);
+        testContext(listener, context::sub3(), true);
+    }
+
+    TEST(SubcontextOutputListenerTest, ContextsAndSubcontexts)
+    {
+        MockSubcontextOutputListener listener;
+        listener.setAdditionalContextsLevelMax(level::verbose);
+
+        std::set<const OutputContextContainer*> subcontexts;
+        subcontexts.insert(&context::sub1());
+        subcontexts.insert(&context::sub3());
+
+        listener.setAdditionalContextsMask(context::unittest1().mask | context::unittest2().mask);
+        listener.setAdditionalSubcontexts(subcontexts);
+
+        testContext(listener, context::unittest1(), true);
+        testContext(listener, context::unittest2(), true);
+        testContext(listener, context::unittest3(), false);
+        testContext(listener, context::sub1(), true);
+        testContext(listener, context::sub2(), false);
+        testContext(listener, context::sub3(), true);
+    }
+
+    TEST(SubcontextOutputListenerTest, BaseContextEnablesAllSubcontexts)
+    {
+        MockSubcontextOutputListener listener;
+        listener.setAdditionalContextsLevelMax(level::verbose);
+
+        listener.setAdditionalContextsMask(context::unittest3().mask);
+
+        testContext(listener, context::unittest1(), false);
+        testContext(listener, context::unittest2(), false);
+        testContext(listener, context::unittest3(), true);
+        testContext(listener, context::sub1(), true);
+        testContext(listener, context::sub2(), true);
+        testContext(listener, context::sub3(), true);
+    }
 }
