[logback-dev] svn commit: r1485 - 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:06:42 CEST 2007
Author: seb
Date: Thu Mar 29 15:06:41 2007
New Revision: 1485
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/AbstractPluginTest.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:
Unit tests are working again
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:06:41 2007
@@ -25,6 +25,7 @@
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.ISharedImages;
@@ -342,4 +343,18 @@
}
}
+ public String getLastLine() {
+ //used for testing only
+ if (viewer.getTable().getItemCount() == 0) {
+ return null;
+ }
+ TableItem item = viewer.getTable().getItem((viewer.getTable().getItemCount()-1));
+ return item.getText();
+ }
+
+ public int getNumberOfLines() {
+ //used for testing only
+ return viewer.getTable().getItemCount();
+ }
+
}
\ No newline at end of file
Modified: logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/AbstractPluginTest.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/AbstractPluginTest.java (original)
+++ logbackPDE/trunk/plugins/ConsolePluginTest/src/ch/qos/logback/eclipse/test/AbstractPluginTest.java Thu Mar 29 15:06:41 2007
@@ -3,9 +3,7 @@
import junit.framework.TestCase;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.PlatformUI;
import ch.qos.logback.eclipse.views.LogbackView;
@@ -77,15 +75,13 @@
}
protected void assertLogbackViewContent(LogbackView view, int numberOfLines, String lastLineText) {
- TableViewer viewer = (TableViewer) view.getViewer();
- TableItem[] items = viewer.getTable().getItems();
- assertEquals(numberOfLines, items.length);
+ String last = view.getLastLine();
+ assertEquals(numberOfLines, view.getNumberOfLines());
if (lastLineText != null) {
- if (items.length == 0) {
+ if (last == null) {
fail("Nothing to compare to expected text");
}
- TableItem lastItem = items[items.length-1];
- assertEquals(lastLineText, lastItem.getText());
+ assertEquals(lastLineText, last);
}
}
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:06:41 2007
@@ -1,7 +1,5 @@
package ch.qos.logback.eclipse.test;
-import org.eclipse.ui.PlatformUI;
-
import ch.qos.logback.eclipse.views.LogbackView;
public class LogbackViewTest extends AbstractPluginTest {
@@ -28,9 +26,6 @@
protected void tearDown() throws Exception {
super.tearDown();
- // Dispose of test fixture.
- waitForJobs();
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(testView);
}
public void testView() {
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:06:41 2007
@@ -49,8 +49,8 @@
public void testSendEvent() throws InterruptedException {
rootLogger.debug("testing");
waitForJobs();
- //delay(3000);
- assertLogbackViewContent(view, 1, "testing\n");
+ delay(3000);
+ assertLogbackViewContent(view, 1, "testing");
}
}
More information about the logback-dev
mailing list