Permalink
Browse files

Fixed 2 failing JUNit tests.

  • Loading branch information...
luccioman committed Jan 9, 2017
1 parent bdaef80 commit c9889991b97ab8b62596c0c86a58322c01d18697
@@ -22,7 +22,7 @@ public void testParseLine() {
cal.set(2016, Calendar.JANUARY, 1); // set the target date
// test some date input representations
Set<String> testtext = new LinkedHashSet();
Set<String> testtext = new LinkedHashSet<>();
testtext.add("2016-01-01");
testtext.add("2016/01/01");
testtext.add("1.1.2016");
@@ -43,10 +43,11 @@ public void testParseLine() {
// test holidays
cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
int currentyear = cal.get(Calendar.YEAR); // instance is init to NOW
int currentyear = cal.get(Calendar.YEAR); // instance is initilized to NOW
cal.clear(); // get rid of sec, millisec
cal.set(currentyear, Calendar.JANUARY, 1); // use Calendar const (month is 0 based)
testtext.clear();
testtext.add("Neujahr");
testtext.add("New Year's Day");
@@ -93,7 +94,7 @@ public void testParseLine() {
public void testParseLineNoDate() {
// test input representations
Set<String> testtext = new LinkedHashSet();
Set<String> testtext = new LinkedHashSet<>();
testtext.add("3.1.2.0102"); // example of a program version string
// testtext.add("3.1.20.0102"); // date end-capture not working (on modification conflict with YMD parser)
testtext.add("v3.1.21");
@@ -1,7 +1,6 @@
package net.yacy.utils.translation;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import net.yacy.data.Translator;
@@ -26,7 +25,7 @@ public void setUp() throws Exception {
* test files to test/DATA and compares translation text
*/
@Test
public void testLoadTranslationsListsFromXliff() throws IOException {
public void testLoadTranslationsListsFromXliff() {
List<String> lngFiles = Translator.langFiles(new File("locales"));
for (String filename : lngFiles) {
// load translation list
@@ -35,8 +34,8 @@ public void testLoadTranslationsListsFromXliff() throws IOException {
TranslatorXliff txlif = new TranslatorXliff();
// save as xliff file
File xlftmp = new File("test/Data", filename + ".xlf");
txlif.saveAsXliff(filename.substring(0, 2), xlftmp, origTrans);
File xlftmp = new File(System.getProperty("java.io.tmpdir", ""), filename + ".xlf");
assertTrue(txlif.saveAsXliff(filename.substring(0, 2), xlftmp, origTrans));
// load created xliff file
Map<String, Map<String, String>> xliffTrans = txlif.loadTranslationsListsFromXliff(xlftmp);
@@ -53,9 +52,9 @@ public void testLoadTranslationsListsFromXliff() throws IOException {
for (String ss : origList.keySet()) {
assertTrue("translation key", xliffList.containsKey(ss));
String origVal = origList.get(ss);
// it is possible that intentionally empty translation is given
// it is possible that intentionally empty or equals to source translation is given
// in this case xliff target is missing (=null)
if (origVal != null && !origVal.isEmpty()) {
if (origVal != null && !origVal.isEmpty() &&!origVal.equals(ss)) {
String xliffVal = xliffList.get(ss);
if (!origVal.equals(xliffVal)) {
assertEquals("translation value", origVal, xliffVal);

0 comments on commit c988999

Please sign in to comment.