package ru.ematveev;

import org.junit.Test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

/**
 * @author Matveev Evgeny.
 */
public class SortBigFileTest {
    /**
     * Тест проверяет правильность сортировки файла.
     *
     * @throws Exception Exception.
     */
    @Test
    public void testSort() throws Exception {
        String sr = File.separator;
//        File fR = new File(sr + "Users" + sr + "apple" + sr + "Documents" + sr + "JAVA" + sr + "J" + sr + "textR.txt");
//        File fW = new File(sr + "Users" + sr + "apple" + sr + "Documents" + sr + "JAVA" + sr + "J" + sr + "textW.txt");
        File fR = new File(sr + "Users" + sr + "apple" + sr + "Documents" + sr + "JAVA" + sr + "Parsentev" + sr + "CoursJava" + sr + "chapter_003" + sr + "textR.txt");
        File fW = new File(sr + "Users" + sr + "apple" + sr + "Documents" + sr + "JAVA" + sr + "Parsentev" + sr + "CoursJava" + sr + "chapter_003" + sr + "textW.txt");

        SortBigFile sortBigFiler = new SortBigFile();
        sortBigFiler.sort(fR, fW);

        String line = "";
//        File newFw = new File(sr + "Users" + sr + "apple" + sr + "Documents" + sr + "JAVA" + sr + "J" + sr + "textW.txt");
        File newFw = new File(sr + "Users" + sr + "apple" + sr + "Documents" + sr + "JAVA" + sr + "Parsentev" + sr + "CoursJava" + sr + "chapter_003" + sr + "textW.txt");

        try {
            Scanner fileScanner = new Scanner(new FileReader(newFw));
            while (fileScanner.hasNext()) {
                line = line + fileScanner.nextLine();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        assertThat(line, is("Оля" + "Евгений" + "Александр"));
    }
}


@@ -15,16 +15,41 @@
 tveev;%0A%0A
+import org.junit.Before;%0A
 import o
@@ -334,71 +334,101 @@
     
-/**%0A     * %D0%A2%D0%B5%D1%81%D1%82 %D0%BF%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D1%8F%D0%B5%D1%82 %D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D0%BB%D1%8C%D0%BD%D0%BE%D1%81%D1%82%D1%8C %D1%81%D0%BE%D1%80%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%BA%D0%B8 %D1%84%D0%B0%D0%B9%D0%BB%D0%B0.%0A     *
+private File fR;%0A    private File fW;%0A%0A    /**%0A     * Method will be before start testSort().
 %0A   
@@ -473,20 +473,22 @@
 */%0A    @
-Test
+Before
 %0A    pub
@@ -496,24 +496,21 @@
 ic void 
-testSort
+setUp
 () throw
@@ -559,26 +559,24 @@
 arator;%0A
-//
         
 File fR 
@@ -571,120 +571,51 @@
     
-File fR = new File(sr + %22Users%22 + sr + %22apple%22 + sr + %22Documents%22 + sr + %22JAVA%22 + sr + %22J%22 + sr + %22textR
+fW = File.createTempFile(%22textW%22, %22
 .txt%22);%0A
 //  
@@ -610,26 +610,24 @@
 .txt%22);%0A
-//
         
 File fW 
@@ -610,39 +610,34 @@
 .txt%22);%0A        
-File fW
+fR
  = new File(sr +
@@ -708,33 +708,33 @@
 %22J%22 + sr + %22text
-W
+R
 .txt%22);%0A        
@@ -733,751 +733,293 @@
     
+%7D%0A%0A
     
-File fR = new File(sr + %22Users%22 + sr + %22apple%22 + sr + %22Documents%22 + sr + %22JAVA%22 + sr + %22Parsentev%22 + sr + %22CoursJava%22 + sr + %22chapter_003%22 + sr + %22textR.txt%22);%0A        File fW = new File(sr + %22Users%22 + sr + %22apple%22 + sr + %22Documents%22 + sr + %22JAVA%22 + sr + %22Parsentev%22 + sr + %22CoursJava%22 + sr + %22chapter_003%22 + sr + %22textW.txt%22);%0A%0A        SortBigFile sortBigFiler = new SortBigFile();%0A        sortBigFiler.sort(fR, fW);%0A%0A        String line = %22%22;%0A//        File newFw = new File(sr + %22Users%22 + sr + %22apple%22 + sr + %22Documents%22 + sr + %22JAVA%22 + sr + %22J%22 + sr + %22textW.txt%22);%0A        File newFw = new File(sr + %22Users%22 + sr + %22apple%22 + sr + %22Documents%22 + sr + %22JAVA%22 + sr + %22Parsentev%22 + sr + %22CoursJava%22 + sr + %22chapter_003%22 + sr + %22textW.txt%22)
+/**%0A     * %D0%A2%D0%B5%D1%81%D1%82 %D0%BF%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D1%8F%D0%B5%D1%82 %D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D0%BB%D1%8C%D0%BD%D0%BE%D1%81%D1%82%D1%8C %D1%81%D0%BE%D1%80%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%BA%D0%B8 %D1%84%D0%B0%D0%B9%D0%BB%D0%B0.%0A     *%0A     * @throws Exception Exception.%0A     */%0A    @Test%0A    public void testSort() throws Exception %7B%0A        SortBigFile sortBigFiler = new SortBigFile();%0A        sortBigFiler.sort(fR, fW);%0A%0A        String line = %22%22
 ;%0A%0A 
@@ -1096,13 +1096,10 @@
 der(
-newFw
+fW
 ));%0A
@@ -1369,8 +1369,12 @@
    %7D%0A%7D%0A%0A
+%0A%0A%0A%0A

change new File() on File.createTempFile in the SortBigFileTest