[logback-dev] svn commit: r1486 - in logbackPDE/trunk/plugins: ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views ConsolePluginTest/src/ch/qos/logback/eclipse/test

noreply.seb at qos.ch noreply.seb at qos.ch
Thu Mar 29 15:59:50 CEST 2007


Author: seb
Date: Thu Mar 29 15:59:49 2007
New Revision: 1486

Modified:
   logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackViewTest.java
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/SendEventTest.java

Log:
test case with filtering

Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java	(original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java	Thu Mar 29 15:59:49 2007
@@ -35,7 +35,10 @@
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.ViewPart;
 
+import ch.qos.logback.classic.boolex.JaninoEventEvaluator;
 import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.core.filter.EvaluatorFilter;
+import ch.qos.logback.core.spi.FilterReply;
 import ch.qos.logback.eclipse.LogbackPlugin;
 import ch.qos.logback.eclipse.PluginLogger;
 import ch.qos.logback.eclipse.actions.LogbackFilterAction;
@@ -140,9 +143,7 @@
       @Override
       public void run() {
         super.run();
-        LoggingEventManager.getManager().clearEventList();
-        viewer.getTable().setItemCount(0);
-        viewer.refresh();
+        clearAll();
       }
     };
     clearConsoleAction.setText("Clear console");
@@ -182,6 +183,13 @@
     openStackTraceAction = new OpenStackTraceAction(this, "Open stacktrace...");
 
   }
+  
+  public void clearAll() {
+    //public only for testing purpose
+    LoggingEventManager.getManager().clearEventList();
+    viewer.getTable().setItemCount(0);
+    viewer.refresh();
+  }
 
   @Override
   public void setFocus() {
@@ -357,4 +365,17 @@
     return viewer.getTable().getItemCount();
   }
 
+  public void addNoDebugFilter() {
+    //used for testing only
+    EvaluatorFilter filter = FilterContentProvider.getProvider().createNewFilter();
+    JaninoEventEvaluator eval = (JaninoEventEvaluator) filter.getEvaluator();
+    eval.setExpression("level >= INFO");
+    eval.start();
+    filter.setName("test fitler");
+    filter.setOnMatch(FilterReply.NEUTRAL);
+    filter.setOnMismatch(FilterReply.DENY);
+    filter.start();
+    EventFilter.add(filter);
+  }
+
 }
\ No newline at end of file

Modified: logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackViewTest.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackViewTest.java	(original)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackViewTest.java	Thu Mar 29 15:59:49 2007
@@ -21,7 +21,6 @@
     // the Favorites view can be seen.
     waitForJobs();
     delay(3000);
-
   }
 
   protected void tearDown() throws Exception {

Modified: logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/SendEventTest.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/SendEventTest.java	(original)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/SendEventTest.java	Thu Mar 29 15:59:49 2007
@@ -44,6 +44,7 @@
   @Override
   protected void tearDown() throws Exception {
     super.tearDown();
+    view.clearAll();
   }
 
   public void testSendEvent() throws InterruptedException {
@@ -53,4 +54,13 @@
     assertLogbackViewContent(view, 1, "testing");
   }
   
+  public void testSendEventWithFilter() throws InterruptedException {
+    view.addNoDebugFilter();
+    rootLogger.debug("testing debug");
+    rootLogger.info("testing info");
+    waitForJobs();
+    delay(3000);
+    assertLogbackViewContent(view, 1, "testing info");
+  }
+  
 }



More information about the logback-dev mailing list