package com.klarna.hiverunner;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import static com.google.common.base.Charsets.UTF_8;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.util.List;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;

import com.klarna.hiverunner.annotations.HiveSQL;

@RunWith(StandaloneHiveRunner.class)
public class ExecuteFileBasedScriptIntegrationTest {

	  @Rule
	  public TemporaryFolder temp = new TemporaryFolder();

	  @HiveSQL(files = {})
	  private HiveShell hiveShell;

	  @Test
	  public void testExecuteFileBasedScript() throws IOException {
	    File hqlScriptFile = temp.newFile("get_current_database.hql");

	    try (PrintStream out = new PrintStream(hqlScriptFile)) {
	      out.println("select current_database(), NULL, 100;");
	    }

	    hiveShell.execute(hqlScriptFile);

	    Charset optionalCharset = UTF_8;
		List<String> results = hiveShell.executeQuery(optionalCharset, hqlScriptFile, " optional_column_delimiter ", "optional_null_replacement");
	    
		assertThat(results.size(), is(1));
		assertThat(results.get(0), is("default optional_column_delimiter optional_null_replacement optional_column_delimiter 100"));
	  }
}

@@ -567,17 +567,20 @@
  %7B%0A%0A
-%09
+    
   @Rule%0A
 %09  p
@@ -575,17 +575,20 @@
   @Rule%0A
-%09
+    
   public
@@ -635,17 +635,20 @@
 der();%0A%0A
-%09
+    
   @HiveS
@@ -662,17 +662,20 @@
 s = %7B%7D)%0A
-%09
+    
   privat
@@ -702,17 +702,20 @@
 l;%0A%0A
-%09
+    
   @Test%0A
 %09  p
@@ -710,17 +710,20 @@
   @Test%0A
-%09
+    
   public
@@ -778,17 +778,20 @@
 ption %7B%0A
-%09
+    
     File
@@ -846,25 +846,28 @@
 ase.hql%22);%0A%0A
-%09
+    
     try (Pri
@@ -919,15 +919,18 @@
 ) %7B%0A
-%09
+   
       
+ 
 out.
@@ -983,17 +983,23 @@
 %22);%0A
-%09
+    
     %7D%0A%0A
-%09
+    
     
@@ -1033,17 +1033,20 @@
 File);%0A%0A
-%09
+    
     Char
@@ -1074,18 +1074,24 @@
  UTF_8;%0A
-%09%09
+        
 List%3CStr
@@ -1225,16 +1225,25 @@
 %22);%0A
-%09
+    
     %0A
-%09%09
+        
 asse
@@ -1277,10 +1277,16 @@
 ));%0A
-%09%09
+        
 asse
@@ -1410,9 +1410,12 @@
 ));%0A
-%09
+    
   %7D%0A

Remove tabs