Hi Simo, You are right. I changed the jira issue adding the same message writen into the change.xml file
ciao -- Marco Speranza <marcospera...@apache.org> Google Code: http://code.google.com/u/marco.speranza79/ Il giorno 19/feb/2012, alle ore 22:33, Simone Tripodi ha scritto: > Hi Marco, > svn log log message and recorded issue activity in changes.xml are > inconsistent > -Simo > > http://people.apache.org/~simonetripodi/ > http://simonetripodi.livejournal.com/ > http://twitter.com/simonetripodi > http://www.99soft.org/ > > > > On Sun, Feb 19, 2012 at 10:26 PM, <marcospera...@apache.org> wrote: >> Author: marcosperanza >> Date: Sun Feb 19 21:26:12 2012 >> New Revision: 1291064 >> >> URL: http://svn.apache.org/viewvc?rev=1291064&view=rev >> Log: >> [SANDBOX-394] Check arguments >> >> Modified: >> commons/sandbox/graph/trunk/src/changes/changes.xml >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectivity/DefaultConnectivityAlgorithmsSelector.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/scc/DefaultSccAlgorithmSelector.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java >> >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java >> >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseMutableGraphTestCase.java >> >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java >> >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java >> >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java >> >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/visit/VisitTestCase.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=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- commons/sandbox/graph/trunk/src/changes/changes.xml (original) >> +++ commons/sandbox/graph/trunk/src/changes/changes.xml Sun Feb 19 21:26:12 >> 2012 >> @@ -23,6 +23,9 @@ >> </properties> >> <body> >> <release version="0.1" date="201?-??-??" description="First release."> >> + <action dev="marcosperanza" type="fix" issue="SANDBOX-394"> >> + Add containsEdge ad containsVertex into Graph interface >> + </action> >> <action dev="marcosperanza" type="fix" issue="SANDBOX-393"> >> Add test for Spanning tree >> </action> >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java >> Sun Feb 19 21:26:12 2012 >> @@ -116,5 +116,26 @@ public interface Graph<V extends Vertex, >> * @return the set of {@link Vertex} on this Edge. >> */ >> VertexPair<V> getVertices( E e ); >> + >> + >> + /** >> + * Returns true if the vertex is contained into the graph >> + * >> + * <b>NOTE</b>: implementors have to take in consideration throwing a >> {@link GraphException} >> + * if an error occurs while performing that operation. >> + * >> + * @return Returns true if the vertex is contained into the graph, >> false otherwise >> + */ >> + boolean containsVertex( V v ); >> + >> + /** >> + * Returns true if the edge is contained into the graph >> + * >> + * <b>NOTE</b>: implementors have to take in consideration throwing a >> {@link GraphException} >> + * if an error occurs while performing that operation. >> + * >> + * @return Returns true if the edge is contained into the graph, false >> otherwise >> + */ >> + boolean containsEdge( E e ); >> >> } >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectivity/DefaultConnectivityAlgorithmsSelector.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectivity/DefaultConnectivityAlgorithmsSelector.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectivity/DefaultConnectivityAlgorithmsSelector.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/connectivity/DefaultConnectivityAlgorithmsSelector.java >> Sun Feb 19 21:26:12 2012 >> @@ -20,6 +20,7 @@ package org.apache.commons.graph.connect >> */ >> >> import static org.apache.commons.graph.CommonsGraph.visit; >> +import static org.apache.commons.graph.utils.Assertions.checkState; >> >> import java.util.ArrayList; >> import java.util.Collection; >> @@ -56,6 +57,7 @@ final class DefaultConnectivityAlgorithm >> >> for ( V v : includedVertices ) >> { >> + checkState( graph.containsVertex( v ), "Vertex %s does not >> exist in the Graph", v ); >> untouchedVertices.add( v ); >> } >> >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java >> Sun Feb 19 21:26:12 2012 >> @@ -92,10 +92,8 @@ public abstract class BaseGraph<V extend >> */ >> public final Iterable<V> getConnectedVertices( V v ) >> { >> + checkGraphCondition( containsVertex( v ), "Vertex %s does not exist >> in the Graph", v ); >> final Set<V> adj = adjacencyList.get( v ); >> - >> - checkGraphCondition( adj != null, "Vertex %s does not exist in the >> Graph", v ); >> - >> return unmodifiableSet( adj ); >> } >> >> @@ -104,8 +102,8 @@ public abstract class BaseGraph<V extend >> */ >> public final E getEdge( V source, V target ) >> { >> - checkGraphCondition( adjacencyList.containsKey( source ), "Vertex >> %s does not exist in the Graph", source ); >> - checkGraphCondition( adjacencyList.containsKey( target ), "Vertex >> %s does not exist in the Graph", target ); >> + checkGraphCondition( containsVertex( source ), "Vertex %s does not >> exist in the Graph", source ); >> + checkGraphCondition( containsVertex( target ), "Vertex %s does not >> exist in the Graph", target ); >> >> return indexedEdges.get( new VertexPair<Vertex>( source, target ) ); >> } >> @@ -119,6 +117,22 @@ public abstract class BaseGraph<V extend >> } >> >> /** >> + * {@inheritDoc} >> + */ >> + public boolean containsVertex( V v ) >> + { >> + return adjacencyList.containsKey( v ); >> + } >> + >> + /** >> + * {@inheritDoc} >> + */ >> + public boolean containsEdge( E e ) >> + { >> + return indexedVertices.containsKey( e ); >> + } >> + >> + /** >> * Returns the adjacency list where stored vertex/edges. >> * >> * @return the adjacency list where stored vertex/edges. >> @@ -199,5 +213,4 @@ public abstract class BaseGraph<V extend >> throw new GraphException( format( errorMessageTemplate, >> errorMessageArgs ) ); >> } >> } >> - >> } >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java >> Sun Feb 19 21:26:12 2012 >> @@ -46,7 +46,7 @@ public abstract class BaseMutableGraph<V >> public final void addVertex( V v ) >> { >> checkGraphCondition( v != null, "Impossible to add a null Vertex to >> the Graph" ); >> - checkGraphCondition( !getAdjacencyList().containsKey( v ), "Vertex >> '%s' already present in the Graph", v ); >> + checkGraphCondition( !containsVertex( v ), "Vertex '%s' already >> present in the Graph", v ); >> >> getAdjacencyList().put( v, new LinkedHashSet<V>() ); >> >> @@ -64,7 +64,7 @@ public abstract class BaseMutableGraph<V >> public final void removeVertex( V v ) >> { >> checkGraphCondition( v != null, "Impossible to remove a null Vertex >> from the Graph" ); >> - checkGraphCondition( getAdjacencyList().containsKey( v ), "Vertex >> '%s' not present in the Graph", v ); >> + checkGraphCondition( containsVertex( v ), "Vertex '%s' not present >> in the Graph", v ); >> >> for ( V tail : getAdjacencyList().get( v ) ) >> { >> @@ -90,8 +90,8 @@ public abstract class BaseMutableGraph<V >> checkGraphCondition( head != null, "Null head Vertex not admitted" ); >> checkGraphCondition( e != null, "Impossible to add a null Edge in >> the Graph" ); >> checkGraphCondition( tail != null, "Null tail Vertex not admitted" ); >> - checkGraphCondition( getAdjacencyList().containsKey( head ), "Head >> Vertex '%s' not present in the Graph", head ); >> - checkGraphCondition( getAdjacencyList().containsKey( tail ), "Head >> Vertex '%s' not present in the Graph", tail ); >> + checkGraphCondition( containsVertex( head ), "Head Vertex '%s' not >> present in the Graph", head ); >> + checkGraphCondition( containsVertex( tail ), "Head Vertex '%s' not >> present in the Graph", tail ); >> checkGraphCondition( getEdge( head, tail ) == null, "Edge %s is >> already present in the Graph", e ); >> >> getAllEdges().add( e ); >> @@ -133,10 +133,8 @@ public abstract class BaseMutableGraph<V >> public final void removeEdge( E e ) >> { >> checkGraphCondition( e != null, "Impossible to remove a null Edge >> from the Graph" ); >> - >> + checkGraphCondition( containsEdge( e ), "Edge '%s' not present in >> the Graph", e ); >> final VertexPair<V> vertexPair = getVertices( e ); >> - checkGraphCondition( vertexPair != null, "Edge '%s' not present in >> the Graph", e ); >> - >> decorateRemoveEdge( e ); >> internalRemoveEdge( vertexPair.getHead(), e, vertexPair.getTail() ); >> getAllEdges().remove( e ); >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java >> Sun Feb 19 21:26:12 2012 >> @@ -207,6 +207,22 @@ public class InMemoryPath<V extends Vert >> /** >> * {@inheritDoc} >> */ >> + public boolean containsVertex( V v ) >> + { >> + return vertices.contains( v ); >> + } >> + >> + /** >> + * {@inheritDoc} >> + */ >> + public boolean containsEdge( E e ) >> + { >> + return edges.contains( e ); >> + } >> + >> + /** >> + * {@inheritDoc} >> + */ >> @Override >> public int hashCode() >> { >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java >> Sun Feb 19 21:26:12 2012 >> @@ -154,4 +154,20 @@ public final class RevertedGraph<V exten >> return directedGraph.getInbound( v ); >> } >> >> + /** >> + * {@inheritDoc} >> + */ >> + public boolean containsVertex( V v ) >> + { >> + return directedGraph.containsVertex( v ); >> + } >> + >> + /** >> + * {@inheritDoc} >> + */ >> + public boolean containsEdge( E e ) >> + { >> + return directedGraph.containsEdge( e ); >> + } >> + >> } >> \ No newline at end of file >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/scc/DefaultSccAlgorithmSelector.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/scc/DefaultSccAlgorithmSelector.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/scc/DefaultSccAlgorithmSelector.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/scc/DefaultSccAlgorithmSelector.java >> Sun Feb 19 21:26:12 2012 >> @@ -22,6 +22,7 @@ package org.apache.commons.graph.scc; >> import static java.lang.Math.min; >> import static org.apache.commons.graph.CommonsGraph.visit; >> import static org.apache.commons.graph.utils.Assertions.checkNotNull; >> +import static org.apache.commons.graph.utils.Assertions.checkState; >> >> import java.util.HashMap; >> import java.util.HashSet; >> @@ -60,6 +61,7 @@ public final class DefaultSccAlgorithmSe >> public Set<V> applyingKosarajuSharir( V source ) >> { >> source = checkNotNull( source, "KosarajuSharir algorithm requires a >> non-null source vertex" ); >> + checkState( graph.containsVertex( source ), "Vertex %s does not >> exist in the Graph", source ); >> >> visit( graph ).from( source ).applyingDepthFirstSearch( new >> KosarajuSharirVisitHandler<V, E, G>( source ) ); >> >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/DefaultSpanningTreeSourceSelector.java >> Sun Feb 19 21:26:12 2012 >> @@ -73,6 +73,7 @@ public final class DefaultSpanningTreeSo >> public SpanningTreeAlgorithmSelector<V, W, WE, G> fromSource( V source ) >> { >> source = checkNotNull( source, "Spanning tree cannot be calculated >> without expressing the source vertex" ); >> + checkState( graph.containsVertex( source ), "Vertex %s does not >> exist in the Graph", source ); >> return new DefaultSpanningTreeAlgorithmSelector<V, W, WE, G>( graph, >> source ); >> } >> >> @@ -81,6 +82,9 @@ public final class DefaultSpanningTreeSo >> */ >> public <OM extends OrderedMonoid<W>> SpanningTree<V, WE, W> >> applyingReverseDeleteAlgorithm( OM orderedMonoid ) >> { >> + >> + checkNotNull( orderedMonoid, "The Reverse-Delete algorithm can't be >> calulated with a null monoid" ); >> + >> final List<WE> sortedEdge = new ArrayList<WE>(); >> final List<WE> visitedEdge = new ArrayList<WE>(); >> >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java >> Sun Feb 19 21:26:12 2012 >> @@ -30,7 +30,6 @@ import org.apache.commons.graph.Weighted >> import org.apache.commons.graph.WeightedGraph; >> >> /** >> - * >> * @param <V> >> * @param <WE> >> * @param <W> >> @@ -135,4 +134,14 @@ final class ReverseDeleteGraph<V extends >> return null; >> } >> >> + public boolean containsVertex( V v ) >> + { >> + return graph.containsVertex( v ); >> + } >> + >> + public boolean containsEdge( WE e ) >> + { >> + return graph.containsEdge( e ); >> + } >> + >> } >> >> Modified: >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitSourceSelector.java >> Sun Feb 19 21:26:12 2012 >> @@ -20,6 +20,7 @@ package org.apache.commons.graph.visit; >> */ >> >> import static org.apache.commons.graph.utils.Assertions.checkNotNull; >> +import static org.apache.commons.graph.utils.Assertions.checkState; >> >> import org.apache.commons.graph.Edge; >> import org.apache.commons.graph.Graph; >> @@ -49,6 +50,7 @@ public final class DefaultVisitSourceSel >> public VisitAlgorithmsSelector<V, E, G> from( V source ) >> { >> source = checkNotNull( source, "Impossible to visit input graph %s >> with null source", graph ); >> + checkState( graph.containsVertex( source ), "Vertex %s does not >> exist in the Graph", source ); >> return new DefaultVisitAlgorithmsSelector<V, E, G>( graph, source ); >> } >> >> >> Modified: >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseMutableGraphTestCase.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseMutableGraphTestCase.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseMutableGraphTestCase.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseMutableGraphTestCase.java >> Sun Feb 19 21:26:12 2012 >> @@ -89,6 +89,8 @@ public class BaseMutableGraphTestCase >> assertEquals( 1, gSimple.getInDegree( two ) ); >> assertEquals( 1, gSimple.getOutDegree( one ) ); >> assertEquals( 0, gSimple.getOutDegree( two ) ); >> + assertFalse( gSimple.containsEdge( new BaseLabeledEdge( "Not Exist >> Edge" ) ) ); >> + assertFalse( gSimple.containsVertex( new BaseLabeledVertex( "Not >> exist vertex" ) ) ); >> } >> >> /** >> >> Modified: >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/BoruvkaTestCase.java >> Sun Feb 19 21:26:12 2012 >> @@ -20,6 +20,7 @@ package org.apache.commons.graph.spannin >> */ >> >> import static junit.framework.Assert.assertEquals; >> +import static junit.framework.Assert.fail; >> import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree; >> >> import org.apache.commons.graph.SpanningTree; >> @@ -53,9 +54,30 @@ public final class BoruvkaTestCase >> @Test( expected = NullPointerException.class ) >> public void testNullMonoid() >> { >> + UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double> input = null; >> + BaseLabeledVertex a = null; >> + try >> + { >> + input = new UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double>(); >> + a = new BaseLabeledVertex( "A" ); >> + input.addVertex( a ); >> + } >> + catch ( NullPointerException e ) >> + { >> + //try..catch need to avoid a possible test success even if a >> NPE is thorw during graph population >> + fail( e.getMessage() ); >> + } >> + >> + minimumSpanningTree( input ).fromSource( a >> ).applyingBoruvkaAlgorithm( null ); >> + } >> + >> + @Test( expected = IllegalStateException.class ) >> + public void testNotExistVertex() >> + { >> UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double> input = >> new UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double>(); >> - minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( "A" >> ) ).applyingBoruvkaAlgorithm( null ); >> + >> + minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( >> "NOT EXIST" ) ); >> } >> >> @Test( expected = IllegalStateException.class ) >> >> Modified: >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/KruskalTestCase.java >> Sun Feb 19 21:26:12 2012 >> @@ -20,6 +20,7 @@ package org.apache.commons.graph.spannin >> */ >> >> import static junit.framework.Assert.assertEquals; >> +import static junit.framework.Assert.fail; >> import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree; >> >> import org.apache.commons.graph.SpanningTree; >> @@ -53,10 +54,30 @@ public final class KruskalTestCase >> @Test( expected = NullPointerException.class ) >> public void testNullMonoid() >> { >> + UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double> input = null; >> + BaseLabeledVertex a = null; >> + try >> + { >> + input = new UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double>(); >> + a = new BaseLabeledVertex( "A" ); >> + input.addVertex( a ); >> + } >> + catch ( NullPointerException e ) >> + { >> + //try..catch need to avoid a possible test success even if a >> NPE is thorw during graph population >> + fail( e.getMessage() ); >> + } >> + >> + minimumSpanningTree( input ).fromSource( a >> ).applyingKruskalAlgorithm( null ); >> + } >> + >> + @Test( expected = IllegalStateException.class ) >> + public void testNotExistVertex() >> + { >> UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double> input = >> new UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double>(); >> >> - minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( "A" >> ) ).applyingKruskalAlgorithm( null ); >> + minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( >> "NOT EXIST" ) ); >> } >> >> @Test( expected = IllegalStateException.class ) >> >> Modified: >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/spanning/PrimTestCase.java >> Sun Feb 19 21:26:12 2012 >> @@ -20,6 +20,7 @@ package org.apache.commons.graph.spannin >> */ >> >> import static junit.framework.Assert.assertEquals; >> +import static junit.framework.Assert.fail; >> import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree; >> >> import org.apache.commons.graph.SpanningTree; >> @@ -53,10 +54,30 @@ public final class PrimTestCase >> @Test( expected = NullPointerException.class ) >> public void testNullMonoid() >> { >> + UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double> input = null; >> + BaseLabeledVertex a = null; >> + try >> + { >> + input = new UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double>(); >> + a = new BaseLabeledVertex( "A" ); >> + input.addVertex( a ); >> + } >> + catch ( NullPointerException e ) >> + { >> + //try..catch need to avoid a possible test success even if a >> NPE is thorw during graph population >> + fail( e.getMessage() ); >> + } >> + >> + minimumSpanningTree( input ).fromSource( a >> ).applyingBoruvkaAlgorithm( null ); >> + } >> + >> + @Test( expected = IllegalStateException.class ) >> + public void testNotExistVertex() >> + { >> UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double> input = >> new UndirectedMutableWeightedGraph<BaseLabeledVertex, >> BaseLabeledWeightedEdge<Double>, Double>(); >> >> - minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( "A" >> ) ).applyingPrimAlgorithm( null ); >> + minimumSpanningTree( input ).fromSource( new BaseLabeledVertex( >> "NOT EXIST" ) ); >> } >> >> @Test( expected = IllegalStateException.class ) >> >> Modified: >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/visit/VisitTestCase.java >> URL: >> http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/visit/VisitTestCase.java?rev=1291064&r1=1291063&r2=1291064&view=diff >> ============================================================================== >> --- >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/visit/VisitTestCase.java >> (original) >> +++ >> commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/visit/VisitTestCase.java >> Sun Feb 19 21:26:12 2012 >> @@ -36,6 +36,24 @@ import org.junit.Test; >> public final class VisitTestCase >> { >> >> + >> + @Test( expected = IllegalStateException.class ) >> + public void testNotExistVertex() >> + { >> + UndirectedMutableGraph<BaseLabeledVertex, BaseLabeledEdge> input = >> + newUndirectedMutableGraph( new >> AbstractGraphConnection<BaseLabeledVertex, BaseLabeledEdge>() >> + { >> + >> + @Override >> + public void connect() >> + { >> + } >> + >> + } ); >> + >> + visit( input ).from( new BaseLabeledVertex( "NOT EXIST" ) ); >> + } >> + >> /** >> * Graph picture can be see >> * <a >> href="http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/GraphAlgor/breadthSearch.htm">here</a> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org >
signature.asc
Description: Message signed with OpenPGP using GPGMail