commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1240513 - in /commons/sandbox/graph/trunk/src: changes/changes.xml test/java/org/apache/commons/graph/connectivity/FindConnectedComponetTestCase.java
Date Sat, 04 Feb 2012 14:58:51 GMT
Author: simonetripodi
Date: Sat Feb  4 14:58:51 2012
New Revision: 1240513

URL: http://svn.apache.org/viewvc?rev=1240513&view=rev
Log:
[SANDBOX-383] Add test for Connectivity - patch provided by Marco Speranza

Modified:
    commons/sandbox/graph/trunk/src/changes/changes.xml
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/connectivity/FindConnectedComponetTestCase.java

Modified: commons/sandbox/graph/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/changes/changes.xml?rev=1240513&r1=1240512&r2=1240513&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/changes/changes.xml (original)
+++ commons/sandbox/graph/trunk/src/changes/changes.xml Sat Feb  4 14:58:51 2012
@@ -23,6 +23,9 @@
   </properties>
   <body>
   <release version="0.1" date="201?-??-??" description="First release.">
+    <action dev="simonetripodi" type="fix" issue="SANDBOX-383" due-to="Marco Speranza">
+      Add test for Connectivity
+    </action>
     <action dev="simonetripodi" type="fix" issue="SANDBOX-382" due-to="Marco Speranza">
       Add new test for coloring
     </action>

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/connectivity/FindConnectedComponetTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/connectivity/FindConnectedComponetTestCase.java?rev=1240513&r1=1240512&r2=1240513&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/connectivity/FindConnectedComponetTestCase.java
(original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/connectivity/FindConnectedComponetTestCase.java
Sat Feb  4 14:58:51 2012
@@ -21,13 +21,16 @@ package org.apache.commons.graph.connect
 
 import static org.apache.commons.graph.CommonsGraph.findConnectedComponent;
 import static org.apache.commons.graph.CommonsGraph.newUndirectedMutableGraph;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.commons.graph.Edge;
+import org.apache.commons.graph.Graph;
+import org.apache.commons.graph.Vertex;
 import org.apache.commons.graph.builder.AbstractGraphConnection;
 import org.apache.commons.graph.model.BaseLabeledEdge;
 import org.apache.commons.graph.model.BaseLabeledVertex;
@@ -39,6 +42,51 @@ import org.junit.Test;
 public final class FindConnectedComponetTestCase
 {
 
+    
+    @Test(expected=NullPointerException.class)
+    public void verifyNullGraph()
+    {
+        findConnectedComponent( (Graph<Vertex, Edge>) null ).includingAllVertices().applyingMinimumSpanningTreeAlgorithm();
+    }
+    
+    @Test
+    public void verifyEmptyGraph()
+    {
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge> graph =
+            newUndirectedMutableGraph( new AbstractGraphConnection<BaseLabeledVertex,
BaseLabeledEdge>()
+            {
+
+                public void connect()
+                {
+                    //empty
+                }
+
+            } );
+        Collection<List<BaseLabeledVertex>> c = findConnectedComponent( graph
).includingAllVertices().applyingMinimumSpanningTreeAlgorithm();
+        assertNotNull( c );
+        assertEquals( 0, c.size() );
+    }
+    
+    @Test
+    public void verifyNullVerticesGraph()
+    {
+        UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge> graph =
+            newUndirectedMutableGraph( new AbstractGraphConnection<BaseLabeledVertex,
BaseLabeledEdge>()
+            {
+
+                public void connect()
+                {
+                    addVertex( new BaseLabeledVertex( "B" ) );
+                    addVertex( new BaseLabeledVertex( "C" ) );
+                }
+
+            } );
+        Collection<List<BaseLabeledVertex>> c =
+            findConnectedComponent( graph ).includingVertices().applyingMinimumSpanningTreeAlgorithm();
+        assertNotNull( c );
+        assertEquals( 0, c.size() );
+    }
+    
     @Test
     public void verifyConnectedComponents()
     {



Mime
View raw message