package water.parser;

import static org.junit.Assert.assertEquals;

import java.io.File;

import org.junit.BeforeClass;
import org.junit.Test;

import water.*;
import water.util.FileIntegrityChecker;

public class ParseProgressTest extends TestUtil {

  @BeforeClass public static void stall() { stall_till_cloudsize(1); }

  // Attempt a multi-jvm parse of covtype.
  // Silently exits if it cannot find covtype.
  @Test public void testCovtype() {
    File f = find_test_file("../datasets/UCI/UCI-large/covtype/covtype.data");
    if( f == null || !f.exists() )
      f = find_test_file("../demo/UCI-large/covtype/covtype.data");

    if( f == null || !f.exists() ) {
      System.out.println("Could not find covtype.data, skipping ParseProgressTest.testCovtype()");
      return;
    }

    FileIntegrityChecker c = FileIntegrityChecker.check(f,false);
    assertEquals(1,c.size());   // Exactly 1 file
    Key k = c.importFile(0, null);
    assertEquals(true,k!=null);

    for( int i=0; i<1; i++ ) {
      Key covkey = Key.make("c"+i+".hex");
      ParseDataset.parse(covkey,new Key[]{k});
      ValueArray ary = DKV.get(covkey).get();
      UKV.remove(covkey);
    }

    UKV.remove(k);
  }
}

@@ -452,117 +452,273 @@
     
-File f = find_test_file(%22../datasets/UCI/UCI-large/covtype/covtype.data%22)
+String%5B%5D covtype_locations = new String%5B%5D%7B%22../datasets/UCI/UCI-large/covtype/covtype.data%22, %22../datasets/UCI/UCI-large/covtype/covtype.data.gz%22,  %22../demo/UCI-large/covtype/covtype.data%22, %7D
 ;%0A    
-if(
+File
  f =
-=
  null
- %7C%7C !f.exists() )
+;%0A    for (String covtype_location : covtype_locations) %7B
 %0A   
@@ -743,60 +743,93 @@
 ile(
-%22../demo/UCI-large/covtype/covtype.data%22);%0A
+ covtype_location );%0A      if (f != null && f.exists())%0A        break;%0A    %7D
 %0A    if
-(
  
+(
 f ==
@@ -848,17 +848,16 @@
 exists()
- 
 ) %7B%0A    
@@ -965,19 +965,17 @@
 return;%0A
-   
+%09
  %7D%0A%0A    

add another location for covtype data