|
@@ -6,18 +6,25 @@ import java.io.*;
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
|
|
|
public class FileConverterTest {
|
|
public class FileConverterTest {
|
|
|
- public static final String path_to_test_files = "C:\\Users\\piotr\\Documents\\Studia\\IiTA - 8zd\\konwersja-liter\\untitled\\src\\main\\resources\\";
|
|
|
|
|
|
|
+ //public static final String path_to_test_files = "C:\\Users\\piotr\\Documents\\Studia\\IiTA - 8zd\\konwersja-liter\\untitled\\src\\main\\resources\\";
|
|
|
|
|
+ public static final String path_to_test_files = "H:\\Lucja\\itaz\\8\\konwersja-liter\\dir\\";
|
|
|
|
|
+
|
|
|
|
|
+ private FileConverter fileConverter;
|
|
|
|
|
+
|
|
|
|
|
+ FileConverterTest() {
|
|
|
|
|
+ fileConverter = new FileConverter();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
private String basicTest(String file_name) throws IOException {
|
|
private String basicTest(String file_name) throws IOException {
|
|
|
String basic = "abcdfg";
|
|
String basic = "abcdfg";
|
|
|
String path = path_to_test_files + file_name;
|
|
String path = path_to_test_files + file_name;
|
|
|
- String content = FileConverter.readFile(path);
|
|
|
|
|
|
|
+ String content = fileConverter.readFile(path);
|
|
|
assertEquals(basic,content);
|
|
assertEquals(basic,content);
|
|
|
return content;
|
|
return content;
|
|
|
}
|
|
}
|
|
|
private void checkUpperCase (String content) throws IOException {
|
|
private void checkUpperCase (String content) throws IOException {
|
|
|
String basic = "ABCDFG";
|
|
String basic = "ABCDFG";
|
|
|
- assertEquals(basic,FileConverter.toUpperCase(content));
|
|
|
|
|
|
|
+ assertEquals(basic,fileConverter.toUpperCase(content));
|
|
|
}
|
|
}
|
|
|
private void checkIfFileIsUpperCase(String path) throws IOException {
|
|
private void checkIfFileIsUpperCase(String path) throws IOException {
|
|
|
File file = new File(path);
|
|
File file = new File(path);
|
|
@@ -40,18 +47,18 @@ public class FileConverterTest {
|
|
|
String basic = "ABCDFG";
|
|
String basic = "ABCDFG";
|
|
|
String file_name = "file.txt";
|
|
String file_name = "file.txt";
|
|
|
String path = path_to_test_files + file_name;
|
|
String path = path_to_test_files + file_name;
|
|
|
- assertEquals(basic,FileConverter.toUpperCase(FileConverter.readFile(path)));
|
|
|
|
|
|
|
+ assertEquals(basic,fileConverter.toUpperCase(fileConverter.readFile(path)));
|
|
|
|
|
|
|
|
basic = "34A$21B37&#!MALEZNAKI";
|
|
basic = "34A$21B37&#!MALEZNAKI";
|
|
|
file_name = "file_special_characters.txt";
|
|
file_name = "file_special_characters.txt";
|
|
|
path = path_to_test_files + file_name;
|
|
path = path_to_test_files + file_name;
|
|
|
- assertEquals(basic,FileConverter.toUpperCase(FileConverter.readFile(path)));
|
|
|
|
|
|
|
+ assertEquals(basic,fileConverter.toUpperCase(fileConverter.readFile(path)));
|
|
|
}
|
|
}
|
|
|
@Test
|
|
@Test
|
|
|
void testFileConverter() throws IOException {
|
|
void testFileConverter() throws IOException {
|
|
|
String file_name = "file.txt";
|
|
String file_name = "file.txt";
|
|
|
String path = path_to_test_files + file_name;
|
|
String path = path_to_test_files + file_name;
|
|
|
- FileConverter.convertFileToUpperCase(path);
|
|
|
|
|
|
|
+ fileConverter.convertFileToUpperCase(path);
|
|
|
checkIfFileIsUpperCase(path);
|
|
checkIfFileIsUpperCase(path);
|
|
|
}
|
|
}
|
|
|
private static void writeToFile(String filePath, String content) throws IOException {
|
|
private static void writeToFile(String filePath, String content) throws IOException {
|