Skip to content

Commit

Permalink
Fix language tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Apr 20, 2017
1 parent 9ec9dee commit 51ce1ec
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,6 @@ public void allFilesMustHaveSameKeys() {
}
}


private static class DuplicationDetectionProperties extends Properties {

private static final long serialVersionUID = 1L;

private final List<String> duplicates = new LinkedList<>();


public DuplicationDetectionProperties() {
super();
}

/**
* Overriding the HashTable put() so we can check for duplicates
*/
@Override
public synchronized Object put(Object key, Object value) {
// Have we seen this key before?
if (containsKey(key)) {
duplicates.add(String.valueOf(key));
}

return super.put(key, value);
}

public List<String> getDuplicates() {
return duplicates;
}
}


@Test
public void ensureNoDuplicates() {
for (String bundle : Arrays.asList("JabRef", "Menu")) {
Expand Down Expand Up @@ -135,16 +104,15 @@ public void findMissingLocalizationKeys() throws IOException {

@Test
public void findMissingMenuLocalizationKeys() throws IOException {
List<LocalizationEntry> missingKeys = LocalizationParser.find(LocalizationBundleForTest.MENU).stream()
.collect(Collectors.toList());
Set<LocalizationEntry> missingKeys = LocalizationParser.find(LocalizationBundleForTest.MENU);

assertEquals("DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH MENU FILE\n" +
"1. PASTE THESE INTO THE ENGLISH MENU FILE\n" +
"2. EXECUTE: gradlew localizationUpdate\n" +
missingKeys.parallelStream()
.map(key -> String.format("%s=%s", key.getKey(), key.getKey()))
.collect(Collectors.toList()),
Collections.<LocalizationEntry>emptyList(), missingKeys);
Collections.<LocalizationEntry>emptySet(), missingKeys);
}

@Test
Expand Down Expand Up @@ -188,4 +156,33 @@ public void localizationParameterMustIncludeAString() throws IOException {
}
}

private static class DuplicationDetectionProperties extends Properties {

private static final long serialVersionUID = 1L;

private final List<String> duplicates = new LinkedList<>();


public DuplicationDetectionProperties() {
super();
}

/**
* Overriding the HashTable put() so we can check for duplicates
*/
@Override
public synchronized Object put(Object key, Object value) {
// Have we seen this key before?
if (containsKey(key)) {
duplicates.add(String.valueOf(key));
}

return super.put(key, value);
}

public List<String> getDuplicates() {
return duplicates;
}
}

}
9 changes: 7 additions & 2 deletions src/test/java/org/jabref/logic/l10n/LocalizationParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static SortedSet<String> findObsolete(LocalizationBundleForTest type) thr
}
englishKeys.removeAll(keysInFiles);

return englishKeys.stream().collect(Collectors.toCollection(TreeSet::new));
return new TreeSet<>(englishKeys);
}

private static Set<LocalizationEntry> findLocalizationEntriesInFiles(LocalizationBundleForTest type) throws IOException {
Expand Down Expand Up @@ -195,9 +195,14 @@ public boolean containsKey(String key) {
}
};

PlatformImpl.startup(() -> {
});
try {
PlatformImpl.startup(() -> {});
FXMLLoader loader = new FXMLLoader(path.toUri().toURL(), registerUsageResourceBundle);
// We don't want to initialize controller
loader.setControllerFactory(controllerType -> null);
// Don't check if root is null (needed for custom controls, where the root value is normally set in the FXMLLoader)
loader.impl_setStaticLoad(true);
loader.load();
} catch (IOException ignore) {
ignore.printStackTrace();
Expand Down

0 comments on commit 51ce1ec

Please sign in to comment.