List of usage examples for org.apache.commons.io FilenameUtils concat
public static String concat(String basePath, String fullFilenameToAdd)
From source file:au.org.ala.delta.confor.PrintNTest.java
@Test public void testSamplePrintN() throws Exception { runConfor();/*from ww w . j a v a 2s .com*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/printn.prt")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "printn.prt")); String actual = FileUtils.readFileToString(actualFile, "utf-8"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 16:11 11-OCT-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected.trim(), actual.trim()); }
From source file:au.org.ala.delta.confor.ToNatRTest.java
@Test public void testSampleToNatR() throws Exception { runConfor();//from w w w . j a va 2 s .com File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/descrip.rtf")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "rtf/descrip.rtf")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } actual = actual.replaceAll("\\{\\} ", "\\{\\}"); expected = expected.replaceAll("\\{\\} ", "\\{\\}"); actual = actual.replaceAll(" \\\\", "\\\\"); expected = expected.replaceAll(" \\\\", "\\\\"); // The heading contains the date so will be different. for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } //assertEquals(expected, actual); }
From source file:au.org.ala.delta.confor.PrintCHTest.java
@Test public void testSamplePrintCH() throws Exception { runConfor();/*from ww w. j av a2 s . c o m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/chars.htm")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "www/chars.htm")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // This is because StringEscapeUtils.escapeHtml has already done the // character conversion for left and right quotes. this makes the //line wrapping not match. actual = actual.replace("&lsquo", "‘"); actual = actual.replace("&rsquo", "’"); actual = actual.replace("&ndash", "–"); // The heading contains the date so will be different. for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected, actual); }
From source file:au.org.ala.delta.confor.PrintUncodedTest.java
@Test public void testSamplePrintUncoded() throws Exception { runConfor();//from ww w . ja v a 2 s. c o m File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/uncoded.prt")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "uncoded.prt")); String actual = FileUtils.readFileToString(actualFile, "utf-8"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 11:32 05-OCT-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected.trim(), actual.trim()); }
From source file:au.org.ala.delta.confor.ToNatRPoneriniTest.java
@Test public void testSampleToNatR() throws Exception { runConfor();/*from w w w. j a v a 2 s .c o m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/descrip.rtf")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "rtf/descrip.rtf")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } actual = actual.replaceAll("\\{\\} ", "\\{\\}"); expected = expected.replaceAll("\\{\\} ", "\\{\\}"); actual = actual.replaceAll(" \\\\", "\\\\"); expected = expected.replaceAll(" \\\\", "\\\\"); // The heading contains the date so will be different. for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected, actual); }
From source file:au.org.ala.delta.confor.TranslateUncodedTest.java
@Test public void testSampleTranslateUncoded() throws Exception { runConfor();/* w w w .jav a 2 s . c o m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/translateuncoded.prt")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "translateuncoded.prt")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 11:32 05-OCT-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected.trim(), actual.trim()); }
From source file:au.org.ala.delta.confor.ToPaupTest.java
@Test public void testSampleToPaup() throws Exception { runConfor();/*from w w w .j a v a 2 s. c o m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/paupdata")); String expected = FileUtils.readFileToString(expectedFile, "utf-8"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "paupdata")); String actual = FileUtils.readFileToString(actualFile, "utf-8"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 15:43 22-OCT-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); /*for (int i=0; i<expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: "+i+" Expected: "+expected.charAt(i)+(int)expected.charAt(i)+", Actual: "+actual.charAt(i)+(int)actual.charAt(i)); break; } } BufferedReader expectedReader = new BufferedReader(new StringReader(expected)); BufferedReader actualReader = new BufferedReader(new StringReader(actual)); String expectedLine = expectedReader.readLine(); String actualLine = actualReader.readLine(); while (expectedLine != null) { assertEquals(expectedLine.trim(), actualLine.trim()); expectedLine = expectedReader.readLine(); actualLine = actualReader.readLine(); }*/ assertEquals(expected.trim(), actual.trim()); }
From source file:au.org.ala.delta.confor.ToHenningTest.java
@Test public void testSampleToHenning86() throws Exception { runConfor();/*from w w w. j a v a 2 s . co m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/hendata")); String expected = FileUtils.readFileToString(expectedFile, "utf-8"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "hendata")); String actual = FileUtils.readFileToString(actualFile, "utf-8"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 11:53 15-NOV-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); /*for (int i=0; i<expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: "+i+" Expected: "+expected.charAt(i)+(int)expected.charAt(i)+", Actual: "+actual.charAt(i)+(int)actual.charAt(i)); break; } } BufferedReader expectedReader = new BufferedReader(new StringReader(expected)); BufferedReader actualReader = new BufferedReader(new StringReader(actual)); String expectedLine = expectedReader.readLine(); String actualLine = actualReader.readLine(); while (expectedLine != null) { assertEquals(expectedLine.trim(), actualLine.trim()); expectedLine = expectedReader.readLine(); actualLine = actualReader.readLine(); }*/ assertEquals(expected.trim(), actual.trim()); }
From source file:au.org.ala.delta.confor.FillinTest.java
@Test public void testSampleFillin() throws Exception { String directivesFileName = "fillin"; _directivesFilePath = FilenameUtils.concat(_samplePath, directivesFileName); String resultFileName = "items.new"; runAndTest(resultFileName);// w w w .jav a2 s .c o m }
From source file:au.org.ala.delta.confor.ToNatTest.java
@Test public void testSampleToNat() throws Exception { String directivesFileName = "tonat"; _directivesFilePath = FilenameUtils.concat(_samplePath, directivesFileName); String resultFileName = "tonat.prt"; runAndTest(resultFileName);/*from w w w. j ava 2s .c o m*/ }