Author: rozagh
Date: 2012-04-17 13:40:27 -0700 (Tue, 17 Apr 2012)
New Revision: 28861
Added:
core3/api/trunk/application-api/src/test/java/org/cytoscape/application/events/CyShutdownEventTest.java
core3/api/trunk/application-api/src/test/java/org/cytoscape/application/events/CyStartEventTest.java
Log:
fixes #878 added missing tests
Added:
core3/api/trunk/application-api/src/test/java/org/cytoscape/application/events/CyShutdownEventTest.java
===================================================================
---
core3/api/trunk/application-api/src/test/java/org/cytoscape/application/events/CyShutdownEventTest.java
(rev 0)
+++
core3/api/trunk/application-api/src/test/java/org/cytoscape/application/events/CyShutdownEventTest.java
2012-04-17 20:40:27 UTC (rev 28861)
@@ -0,0 +1,80 @@
+package org.cytoscape.application.events;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
+
+import org.cytoscape.application.CyApplicationManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+public class CyShutdownEventTest {
+
+
+ @Mock
+ private CyApplicationManager source;
+
+ @Before
+ public void initMocks() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testGetSource() {
+ CyShutdownEvent e = new CyShutdownEvent(source);
+ assertEquals( source, e.getSource() );
+ }
+
+ @Test
+ public void testGetListenerClass() {
+ Object i = new Object();
+ CyShutdownEvent e = new CyShutdownEvent(i);
+ assertEquals( CyShutdownListener.class, e.getListenerClass() );
+ }
+
+ @Test(expected=NullPointerException.class)
+ public void testNullSource() {
+ new CyShutdownEvent(null);
+ }
+
+ @Test
+ public void testGoodCyShutdownEvent() {
+
+ final CyShutdownEvent e = new CyShutdownEvent(source);
+ assertNull(e.abortShutdownReason()); //reason should be
initially null
+ }
+
+ @Test
+ public void testAbortShutdownWithReason(){
+ String r = "dummy reason";
+ final CyShutdownEvent e = new CyShutdownEvent(source);
+ e.abortShutdown(r);
+ assertEquals(e.abortShutdownReason(), r);
+
+ }
+
+ @Test
+ public void testAbortShutdownEmptyReason(){
+ String r = "";
+ final CyShutdownEvent e = new CyShutdownEvent(source);
+ e.abortShutdown(r);
+ assertNull(e.abortShutdownReason());
+ }
+
+ @Test
+ public void testAbortShutdownNullReason(){
+ final CyShutdownEvent e = new CyShutdownEvent(source);
+ e.abortShutdown(null);
+ assertNull(e.abortShutdownReason());
+ }
+
+ @Test
+ public void testActuallyShutdown(){
+ final CyShutdownEvent e = new CyShutdownEvent(source);
+ assertTrue(e.actuallyShutdown());
+ e.abortShutdown("dummy reason");
+ assertFalse(e.actuallyShutdown());
+ }
+
+}
Added:
core3/api/trunk/application-api/src/test/java/org/cytoscape/application/events/CyStartEventTest.java
===================================================================
---
core3/api/trunk/application-api/src/test/java/org/cytoscape/application/events/CyStartEventTest.java
(rev 0)
+++
core3/api/trunk/application-api/src/test/java/org/cytoscape/application/events/CyStartEventTest.java
2012-04-17 20:40:27 UTC (rev 28861)
@@ -0,0 +1,28 @@
+package org.cytoscape.application.events;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class CyStartEventTest {
+
+ @Test
+ public void testGetSource() {
+ Integer i = new Integer(1);
+ CyStartEvent e = new CyStartEvent(i);
+ assertEquals( i, e.getSource() );
+ }
+
+ @Test
+ public void testGetListenerClass() {
+ Object i = new Object();
+ CyStartEvent e = new CyStartEvent(i);
+ assertEquals( CyStartListener.class, e.getListenerClass() );
+ }
+
+ @Test(expected=NullPointerException.class)
+ public void testNullSource() {
+ new CyStartEvent(null);
+ }
+
+}
--
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.