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

noreply.seb at qos.ch noreply.seb at qos.ch
Fri Mar 9 10:15:14 CET 2007


Author: seb
Date: Fri Mar  9 10:15:13 2007
New Revision: 1417

Added:
   logbackPDE/trunk/plugins/ConsolePluginTest/   (props changed)
   logbackPDE/trunk/plugins/ConsolePluginTest/META-INF/
   logbackPDE/trunk/plugins/ConsolePluginTest/META-INF/MANIFEST.MF
   logbackPDE/trunk/plugins/ConsolePluginTest/build.properties
   logbackPDE/trunk/plugins/ConsolePluginTest/src/
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/AbstractPluginTest.java
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/ConsoleTestPlugin.java
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackTestSuite.java
   logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackViewTest.java
Modified:
   logbackPDE/trunk/plugins/ConsolePlugin/META-INF/MANIFEST.MF
   logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LogbackView.java

Log:
Modified plugin for testing purpose
Added a plugin to test the logback plugin

Modified: logbackPDE/trunk/plugins/ConsolePlugin/META-INF/MANIFEST.MF
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/META-INF/MANIFEST.MF	(original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/META-INF/MANIFEST.MF	Fri Mar  9 10:15:13 2007
@@ -14,5 +14,12 @@
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
  org.eclipse.jface.text,
- org.eclipse.ui.console
+ org.eclipse.ui.console,
+ org.eclipse.jdt,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.core.manipulation,
+ org.eclipse.jdt.source,
+ org.eclipse.jdt.ui,
+ org.eclipse.core.resources
 Eclipse-LazyStart: true
+Export-Package: ch.qos.logback.eclipse.views

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	Fri Mar  9 10:15:13 2007
@@ -30,7 +30,9 @@
 
 public class LogbackView extends ViewPart {
 
-  public static int LOW_WATERMARK = 400000;
+  public static final String ID = "ch.qos.logback.eclipse.views.LogbackView";
+  
+  public static int LOW_WATERMARK = 700000;
   public static int DEFAULT_HIGH_WATERMARK = 1000000;
 
   private TextConsoleViewer viewer;
@@ -59,7 +61,6 @@
     viewer = new TextConsoleViewer(parent, myConsole);
     viewer.setEditable(false);
 
-    
     viewer.configure(new LogbackViewerConfiguration());
     viewer.setDocument(viewer.getDocument());
     
@@ -203,4 +204,9 @@
     initServer();
   }
   
+  public TextConsoleViewer getViewer() {
+    //used in tests
+    return viewer;
+  }
+  
 }
\ No newline at end of file

Added: logbackPDE/trunk/plugins/ConsolePluginTest/META-INF/MANIFEST.MF
==============================================================================
--- (empty file)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/META-INF/MANIFEST.MF	Fri Mar  9 10:15:13 2007
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ConsoleTestPlugin
+Bundle-SymbolicName: ch.qos.logback.eclipse.test
+Bundle-Version: 1.0.0
+Bundle-Activator: ch.qos.logback.eclipse.test.ConsoleTestPlugin
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ ch.qos.logback.eclipse,
+ org.junit,
+ org.eclipse.ui.console,
+ org.eclipse.jface.text
+Eclipse-LazyStart: true

Added: logbackPDE/trunk/plugins/ConsolePluginTest/build.properties
==============================================================================
--- (empty file)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/build.properties	Fri Mar  9 10:15:13 2007
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/AbstractPluginTest.java
==============================================================================
--- (empty file)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/AbstractPluginTest.java	Fri Mar  9 10:15:13 2007
@@ -0,0 +1,58 @@
+package ch.qos.logback.eclipse.test;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Display;
+
+import ch.qos.logback.eclipse.views.LogbackView;
+
+public abstract class AbstractPluginTest extends TestCase {
+
+  public AbstractPluginTest(String name) {
+    super(name);
+  }
+
+  /**
+   * Process UI input but do not return for the specified time interval.
+   * 
+   * @param waitTimeMillis
+   *          the number of milliseconds
+   */
+  public void delay(long waitTimeMillis) {
+    Display display = Display.getCurrent();
+
+    // If this is the UI thread,
+    // then process input.
+    if (display != null) {
+      long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+      while (System.currentTimeMillis() < endTimeMillis) {
+        if (!display.readAndDispatch())
+          display.sleep();
+      }
+      display.update();
+    }
+
+    // Otherwise, perform a simple sleep.
+    else {
+      try {
+        Thread.sleep(waitTimeMillis);
+      } catch (InterruptedException e) {
+        // Ignored.
+      }
+    }
+  }
+
+  /**
+   * Wait until all background tasks are complete.
+   */
+  public void waitForJobs() {
+    while (Platform.getJobManager().currentJob() != null)
+      delay(1000);
+  }
+
+  protected void assertLogbackViewContent(LogbackView logbackView, String expectedContent) {
+    String consoleText = logbackView.getViewer().getTextWidget().getText();
+    assertEquals(expectedContent, consoleText);
+  }
+}

Added: logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/ConsoleTestPlugin.java
==============================================================================
--- (empty file)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/ConsoleTestPlugin.java	Fri Mar  9 10:15:13 2007
@@ -0,0 +1,35 @@
+package ch.qos.logback.eclipse.test;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ConsoleTestPlugin extends AbstractUIPlugin {
+
+  public static final String PLUGIN_ID = "ch.qos.logback.eclipse.test";
+
+  private static ConsoleTestPlugin plugin;
+
+  /**
+   * The constructor
+   */
+  public ConsoleTestPlugin() {
+    plugin = this;
+  }
+
+  public void start(BundleContext context) throws Exception {
+    super.start(context);
+  }
+
+  public void stop(BundleContext context) throws Exception {
+    plugin = null;
+    super.stop(context);
+  }
+
+  public static ConsoleTestPlugin getDefault() {
+    return plugin;
+  }
+
+}

Added: logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackTestSuite.java
==============================================================================
--- (empty file)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackTestSuite.java	Fri Mar  9 10:15:13 2007
@@ -0,0 +1,13 @@
+package ch.qos.logback.eclipse.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class LogbackTestSuite {
+
+  public static Test suite() {
+    TestSuite suite = new TestSuite("Logback test suite");
+    suite.addTest(new TestSuite(LogbackViewTest.class));
+    return suite;
+  }
+}

Added: logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackViewTest.java
==============================================================================
--- (empty file)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/LogbackViewTest.java	Fri Mar  9 10:15:13 2007
@@ -0,0 +1,41 @@
+package ch.qos.logback.eclipse.test;
+
+import org.eclipse.ui.PlatformUI;
+
+import ch.qos.logback.eclipse.views.LogbackView;
+
+public class LogbackViewTest extends AbstractPluginTest {
+
+  private LogbackView testView;
+
+  public LogbackViewTest(String name) {
+    super(name);
+  }
+
+  protected void setUp() throws Exception {
+    super.setUp();
+    // Initialize the test fixture for each test
+    // that is run.
+    waitForJobs();
+    testView = (LogbackView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+        .showView(LogbackView.ID);
+
+    // Delay for 3 seconds so that
+    // the Favorites view can be seen.
+    waitForJobs();
+    delay(3000);
+
+  }
+
+  protected void tearDown() throws Exception {
+    super.tearDown();
+    // Dispose of test fixture.
+    waitForJobs();
+    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(testView);
+  }
+
+  public void testView() {
+    // check that the view is open and empty
+    assertLogbackViewContent(testView, "");
+  }
+}
\ No newline at end of file



More information about the logback-dev mailing list