Author: rwesten
Date: Tue Feb 28 14:10:12 2012
New Revision: 1294665

URL: http://svn.apache.org/viewvc?rev=1294665&view=rev
Log:
CLEREZZA-683: Updated UnitTest to use/print a seed of the randomly generated 
graph used for testing. This should allow to debug the cause for failed 
filtered iterator validations against the SimpleMGraph implementation such as 
[1]


[1] 
https://builds.apache.org/job/stanbol-trunk-1.6/765/org.apache.stanbol$org.apache.stanbol.commons.indexedgraph/testReport/junit/org.apache.stanbol.commons.indexedgraph/IndexedGraphTest/testPerformance/

Modified:
    
incubator/stanbol/trunk/commons/indexedgraph/src/test/java/org/apache/stanbol/commons/indexedgraph/IndexedGraphTest.java

Modified: 
incubator/stanbol/trunk/commons/indexedgraph/src/test/java/org/apache/stanbol/commons/indexedgraph/IndexedGraphTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/indexedgraph/src/test/java/org/apache/stanbol/commons/indexedgraph/IndexedGraphTest.java?rev=1294665&r1=1294664&r2=1294665&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/commons/indexedgraph/src/test/java/org/apache/stanbol/commons/indexedgraph/IndexedGraphTest.java
 (original)
+++ 
incubator/stanbol/trunk/commons/indexedgraph/src/test/java/org/apache/stanbol/commons/indexedgraph/IndexedGraphTest.java
 Tue Feb 28 14:10:12 2012
@@ -19,15 +19,12 @@ package org.apache.stanbol.commons.index
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.ConcurrentModificationException;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Random;
 import java.util.Set;
 
-import javax.swing.DebugGraphics;
-import javax.xml.soap.Text;
-
 import org.apache.clerezza.rdf.core.BNode;
 import org.apache.clerezza.rdf.core.Language;
 import org.apache.clerezza.rdf.core.LiteralFactory;
@@ -175,10 +172,13 @@ public class IndexedGraphTest  extends M
     }
     @Test
     public void testPerformance(){
+        //Reduced values to fix STANBOL-
         MGraph sg = new SimpleMGraph();
         int iterations = 100; //reduced from 1000
         int graphsize = 100000;
-        createGraph(sg, graphsize);
+        Long seed = System.currentTimeMillis();
+        log.info("Test Seed: {}",seed);
+        createGraph(sg, graphsize, seed);
         MGraph ig = new IndexedMGraph(sg);
         long start;
         //Simple Graph reference test
@@ -365,7 +365,11 @@ public class IndexedGraphTest  extends M
         return count;
     }
     
-    private static void createGraph(TripleCollection tc, int triples){
+    private static void createGraph(TripleCollection tc, int triples, Long 
seed){
+        Random rnd = new Random();
+        if(seed != null){
+             rnd.setSeed(seed);
+        }
         LiteralFactory lf = LiteralFactory.getInstance();
         //randoms are in the range [0..3]
         double l = 1.0; //literal
@@ -396,7 +400,7 @@ public class IndexedGraphTest  extends M
         List<BNode> bNodes = new ArrayList<BNode>();
         bNodes.add(new BNode());
         for (int count = 0; tc.size() < triples; count++) {
-            random = Math.random() * 3;
+            random = rnd.nextDouble() * 3;
             if (random >= 2.5 || count == 0) {
                 if (random <= 2.75) {
                     subject = new UriRef(URI_PREFIX + count);


Reply via email to