Author: mes
Date: 2009-12-23 11:20:44 -0800 (Wed, 23 Dec 2009)
New Revision: 18801

Added:
   core3/log-swing/trunk/src/test/java/org/
   core3/log-swing/trunk/src/test/java/org/cytoscape/
   core3/log-swing/trunk/src/test/java/org/cytoscape/log/
   core3/log-swing/trunk/src/test/java/org/cytoscape/log/internal/
   
core3/log-swing/trunk/src/test/java/org/cytoscape/log/internal/LogViewerTest.java
Modified:
   core3/log-swing/trunk/pom.xml
   core3/log-swing/trunk/src/main/resources/META-INF/spring/bundle-context.xml
Log:
added a proof-of-concept unit test

Modified: core3/log-swing/trunk/pom.xml
===================================================================
--- core3/log-swing/trunk/pom.xml       2009-12-23 00:25:39 UTC (rev 18800)
+++ core3/log-swing/trunk/pom.xml       2009-12-23 19:20:44 UTC (rev 18801)
@@ -45,6 +45,13 @@
                        </resource>
                </resources>
                <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                </configuration>
+            </plugin>
                        <plugin>
                                <groupId>org.ops4j</groupId>
                                <artifactId>maven-pax-plugin</artifactId>
@@ -116,6 +123,12 @@
 
        <dependencies>
                <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>${junit.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
                        <groupId>org.cytoscape</groupId>
                        <artifactId>work-api</artifactId>
                        <version>1.0-SNAPSHOT</version>

Modified: 
core3/log-swing/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- core3/log-swing/trunk/src/main/resources/META-INF/spring/bundle-context.xml 
2009-12-23 00:25:39 UTC (rev 18800)
+++ core3/log-swing/trunk/src/main/resources/META-INF/spring/bundle-context.xml 
2009-12-23 19:20:44 UTC (rev 18801)
@@ -3,16 +3,14 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:aop="http://www.springframework.org/schema/aop";
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:lang="http://www.springframework.org/schema/lang"; 
xmlns:osgi="http://www.springframework.org/schema/osgi";
-       xsi:schemaLocation="
-    http://www.springframework.org/schema/beans
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
     http://www.springframework.org/schema/aop
     http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
     http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-2.5.xsd
            http://www.springframework.org/schema/lang 
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
-            http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd";
-       default-lazy-init="false">
+            http://www.springframework.org/schema/osgi 
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd"; 
default-lazy-init="false">
 
        <context:annotation-config />
 

Added: 
core3/log-swing/trunk/src/test/java/org/cytoscape/log/internal/LogViewerTest.java
===================================================================
--- 
core3/log-swing/trunk/src/test/java/org/cytoscape/log/internal/LogViewerTest.java
                           (rev 0)
+++ 
core3/log-swing/trunk/src/test/java/org/cytoscape/log/internal/LogViewerTest.java
   2009-12-23 19:20:44 UTC (rev 18801)
@@ -0,0 +1,57 @@
+package org.cytoscape.log.internal;
+
+import org.junit.Test;
+import org.junit.Before;
+import static org.junit.Assert.*;
+import java.util.Map;
+import java.util.HashMap;
+import javax.swing.JScrollBar;
+
+public class LogViewerTest {
+
+       LogViewer lv;
+       Map<String,String> config; 
+
+       @Before
+       public void setUp() {
+               config = new HashMap<String,String>();
+               config.put("colorParityTrue","ffffff");
+               config.put("colorParityFalse","eeeeee");
+               config.put("entryTemplate","<html><body><ul><li>%s %s %s 
%s</li><ul></body></html>");
+               config.put("baseHTMLPath","homer");
+               config.put("level","level.icon");
+               lv = new LogViewer(config);
+       }
+
+       @Test
+       public void testAppend() {
+               int initLen = lv.document.getLength();
+               lv.append("level","hello world","this is a test");
+               int newLen = lv.document.getLength();
+               assertTrue(initLen < newLen);
+       }
+
+       @Test
+       public void testClear() {
+               lv.append("level","hello world","this is a test");
+               int initLen = lv.document.getLength();
+               lv.clear();
+               int newLen = lv.document.getLength();
+               assertTrue(initLen > newLen);
+       }
+
+       @Test
+       public void testScrollToBottom() {
+               lv.append("level","hello world","this is a test");
+               lv.scrollToBottom();
+               JScrollBar sb = lv.scrollPane.getVerticalScrollBar();
+
+               // SKETCHY!!! 
+               // this gives scrollToBottom() time to run 
+               // is there a better way?
+               try { Thread.sleep(1000); } catch (Exception e) { fail(); }
+
+               assertEquals( sb.getMaximum(), sb.getValue() ); 
+       }
+}
+

--

You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.


Reply via email to