|
Groovy example source code file (ResourceBundleTest.groovy)
The Groovy ResourceBundleTest.groovy source codepackage groovy.util; import java.util.ResourceBundle; public class ResourceBundleTest extends GroovyTestCase { public void testNoClassLoaderNoLocale() { def results = [] // run test twice, call site optimizations result in call stack differences 2.times { ResourceBundle rb = ResourceBundle.getBundle("groovy.util.i18n") results << rb assert rb.getString('upvote') == '+1' } assert results.size() == 2 } public void testWithLocale() { def results = [] // run test twice, call site optimizations result in call stack differences 2.times { ResourceBundle rb = ResourceBundle.getBundle("groovy.util.i18n", Locale.ENGLISH) results << rb println "en" println "'${rb.getString('yes')}'" println "'${rb.getString('upvote')}'" assert rb.getString('yes') == 'yes' assert rb.getString('upvote') == '+1' rb = ResourceBundle.getBundle("groovy.util.i18n", Locale.FRENCH) results << rb println "fr" println "'${rb.getString('yes')}'" println "'${rb.getString('upvote')}'" assert rb.getString('yes') == 'oui' assert rb.getString('upvote') == '+1' } assert results.size() == 4 } public void testWithClassLoader() { def results = [] ClassLoader cl = this.class.classLoader // run test twice, call site optimizations result in call stack differences 2.times { ResourceBundle rb = ResourceBundle.getBundle("groovy.util.i18n", Locale.ENGLISH, cl) results << rb println "en" println "'${rb.getString('yes')}'" println "'${rb.getString('upvote')}'" assert rb.getString('yes') == 'yes' assert rb.getString('upvote') == '+1' rb = ResourceBundle.getBundle("groovy.util.i18n", Locale.FRENCH, cl) results << rb println "fr" println "'${rb.getString('yes')}'" println "'${rb.getString('upvote')}'" assert rb.getString('yes') == 'oui' assert rb.getString('upvote') == '+1' } assert results.size() == 4 } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy ResourceBundleTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.