use of org.omegat.filters2.text.bundles.ResourceBundleFilter in project omegat by omegat-org.
the class ResourceBundleFilterTest method testWhiteSpace.
@Test
public void testWhiteSpace() throws Exception {
// We want to see full whitespace for this test
boolean removeSpacesOrig = Core.getFilterMaster().getConfig().isRemoveSpacesNonseg();
Core.getFilterMaster().getConfig().setRemoveSpacesNonseg(false);
String f = "test/data/filters/resourceBundle/file-ResourceBundleFilter-WhiteSpace.properties";
ResourceBundleFilter filter = new ResourceBundleFilter();
IProject.FileInfo fi = loadSourceFiles(filter, f);
checkMultiStart(fi, f);
checkMulti("Value", "KEY", null, null, null, "# Tab->\t<-Tab");
checkMulti("Value ", "KEY2", null, null, null, "# Trailing whitespace must be preserved");
checkMulti("Value1\tValue2", "KEY3", null, null, null, "# Significant whitespace on continuation line");
checkMulti("Value1 Value2", "KEY4", null, null, null, null);
checkMultiEnd();
translate(filter, f);
compareBinary(new File("test/data/filters/resourceBundle/file-ResourceBundleFilter-WhiteSpace-gold.properties"), outFile);
// Restore old value
Core.getFilterMaster().getConfig().setRemoveSpacesNonseg(removeSpacesOrig);
}
use of org.omegat.filters2.text.bundles.ResourceBundleFilter in project omegat by omegat-org.
the class ResourceBundleFilterTest method testLoad.
@Test
public void testLoad() throws Exception {
String f = "test/data/filters/resourceBundle/file-ResourceBundleFilter.properties";
ResourceBundleFilter filter = new ResourceBundleFilter();
IProject.FileInfo fi = loadSourceFiles(filter, f);
checkMultiStart(fi, f);
checkMulti("Value", "ID", null, null, null, null);
checkMulti("Value2", "ID2", null, null, null, null);
checkMulti("Value3", "ID3", null, null, null, "# some comment");
checkMulti("Value4", "ID4", null, null, null, "# multiple line\n# comment");
checkMulti("Value5", "ID5", null, null, null, "! alternate comment style");
// U+2603 SNOWMAN
checkMulti("Value\u2603", "ID6", null, null, null, "# Unicode escape \u2603");
checkMultiEnd();
f = "test/data/filters/resourceBundle/file-ResourceBundleFilter-SMP.properties";
fi = loadSourceFiles(filter, f);
checkMultiStart(fi, f);
checkMulti("\uD835\uDC00\uD835\uDC01\uD835\uDC02", "ID", null, null, null, null);
checkMulti("\uD835\uDC03\uD835\uDC04\uD835\uDC05", "ID2", null, null, null, null);
checkMultiEnd();
}
use of org.omegat.filters2.text.bundles.ResourceBundleFilter in project omegat by omegat-org.
the class ResourceBundleFilterTest method testBadUnicodeLiterals.
@Test
public void testBadUnicodeLiterals() throws Exception {
String base = "test/data/filters/resourceBundle/";
ResourceBundleFilter filter = new ResourceBundleFilter();
try {
loadSourceFiles(filter, base + "file-ResourceBundleFilter-BadLiteral1.properties");
fail("Failed to catch invalid Unicode literal: too short");
} catch (TranslationException ex) {
}
try {
loadSourceFiles(filter, base + "file-ResourceBundleFilter-BadLiteral2.properties");
} catch (TranslationException ex) {
fail("Actual Java ResourceBundle loader doesn't prevent you from including characters " + "for which Character.isDefined() returns false.");
}
try {
loadSourceFiles(filter, base + "file-ResourceBundleFilter-BadLiteral3.properties");
fail("Failed to catch invalid Unicode literal: not hex code");
} catch (TranslationException ex) {
}
}
Aggregations