@Test
public void testBuildRandomSeededSameInitalClusters() throws Exception {

   List<VectorWritable> points = getPoints();
   Job job = new Job();
   Configuration conf = job.getConfiguration();
   job.setMapOutputValueClass(VectorWritable.class);
   Path input = getTestTempFilePath("random-input");
   Path output = getTestTempDirPath("random-output");
   ClusteringTestUtils.writePointsToFile(points, input, fs, conf);
   long randSeed=1;
   
   RandomSeedGenerator.buildRandom(conf, input, output, 4, new ManhattanDistanceMeasure(), randSeed);
   
   int[] clusterIDSeq = new int[4];
   
   /** run through all clusters once and set sequence of IDs  */  
   int clusterCount = 0;
   for (ClusterWritable clusterWritable :
        new SequenceFileValueIterable<ClusterWritable>(new Path(output, "part-randomSeed"), true, conf)) {      
     Cluster cluster = clusterWritable.getValue();
     clusterIDSeq[clusterCount] = cluster.getId();
     clusterCount++; 
   }
   
   /* Rebuild cluster and run through again making sure all IDs are in the same random sequence
    * Needs a better test because in this case passes when seeded with 1 and 2  fails with 1, 3
    * passes when set to two */
   RandomSeedGenerator.buildRandom(conf, input, output, 4, new ManhattanDistanceMeasure(), randSeed);     clusterCount = 0;    
   for (ClusterWritable clusterWritable :
        new SequenceFileValueIterable<ClusterWritable>(new Path(output, "part-randomSeed"), true, conf)) {       
     Cluster cluster = clusterWritable.getValue();
     // Make sure cluster ids are in same random sequence
     assertEquals(clusterIDSeq[clusterCount], cluster.getId());
     clusterCount++;
   }
}