Example usage for java.util Locale setDefault

List of usage examples for java.util Locale setDefault

Introduction

In this page you can find the example usage for java.util Locale setDefault.

Prototype

public static synchronized void setDefault(Locale newLocale) 

Source Link

Document

Sets the default locale for this instance of the Java Virtual Machine.

Usage

From source file:org.apache.jmeter.junit.JMeterTest.java

public static Test suite() throws Exception {
    TestSuite suite = new TestSuite("JMeterTest");

    // The Locale used to instantiate the GUI objects
    JMeterUtils.setLocale(TEST_LOCALE);/*from  w ww.j av  a2 s .c o  m*/
    Locale.setDefault(TEST_LOCALE);
    // Needs to be done before any GUI classes are instantiated

    suite.addTest(new JMeterTest("readAliases"));
    suite.addTest(new JMeterTest("createTitleSet"));
    suite.addTest(new JMeterTest("createTagSet"));
    suite.addTest(suiteGUIComponents());
    suite.addTest(suiteSerializableElements());
    suite.addTest(suiteBeanComponents());
    suite.addTest(new JMeterTest("checkGuiSet"));

    suite.addTest(new JMeterTest("resetLocale")); // revert
    return suite;
}

From source file:org.opendatakit.common.android.utilities.ODKDataUtilsTest.java

@Test
public void testNormalizeDisplayName2() {
    Map<String, Object> langMap = new TreeMap<String, Object>();
    langMap.put("en_US", "This is a test");
    langMap.put("en_GB", "Test is This");
    langMap.put("en", "Huh Test");
    langMap.put("fr", "Je suis");
    langMap.put("default", "No way!");

    String match;/* w  w  w.  ja v a  2  s. c  om*/

    Locale.setDefault(Locale.US);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("This is a test", match);

    Locale.setDefault(Locale.UK);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("Test is This", match);

    Locale.setDefault(Locale.CANADA);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("Huh Test", match);

    Locale.setDefault(Locale.CANADA_FRENCH);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("Je suis", match);

    Locale.setDefault(Locale.GERMANY);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("No way!", match);

    Locale.setDefault(Locale.US);
}

From source file:fitnesse.responders.files.FileResponderTest.java

@Test
public void testLastModifiedHeader() throws Exception {
    Locale.setDefault(Locale.US);
    request.setResource("files/testFile1");
    responder = (FileResponder) FileResponder.makeResponder(request, SampleFileUtility.base);
    response = responder.makeResponse(context, request);
    String lastModifiedHeader = response.getHeader("Last-Modified");
    assertMatches(HTTP_DATE_REGEXP, lastModifiedHeader);
}

From source file:es.uvigo.ei.sing.laimages.core.entities.datasets.HorizontalElementDatasetTest.java

private final static void testExport(Locale locale, FileFormat format, File expectedFile) throws IOException {
    Locale.setDefault(locale);

    File exportFile = exportElementToTmpCSVFile(Na23, format);

    assertThat(exportFile, hasEqualFileContent(expectedFile));
}

From source file:org.sejda.sambox.pdmodel.TestPDDocument.java

/**
 * PDFBOX-3481: Test whether XRef generation results in unusable PDFs if Arab numbering is default.
 *///from   w ww .ja v a 2  s  .  c o m
public void testSaveArabicLocale() throws IOException {
    Locale defaultLocale = Locale.getDefault();
    try {
        Locale arabicLocale = new Locale.Builder().setLanguageTag("ar-EG-u-nu-arab").build();
        Locale.setDefault(arabicLocale);

        File targetFile = new File(testResultsDir, "pddocument-savearabicfile.pdf");

        // Create PDF with one blank page
        try (PDDocument document = new PDDocument()) {
            document.addPage(new PDPage());
            document.writeTo(targetFile);
        }

        // Load
        try (PDDocument loadDoc = PDFParser.parse(SeekableSources.seekableSourceFrom(targetFile))) {
            assertEquals(1, loadDoc.getNumberOfPages());
        }
    } finally {
        Locale.setDefault(defaultLocale);
    }
}

From source file:org.eclipse.smarthome.binding.ntp.test.NtpOSGiTest.java

@BeforeClass
public static void setUpClass() {
    /*/*w w w.j  a  va2  s. c  om*/
     * Store the initial system time zone and locale value,
     * so that we can restore them at the test end.
     */
    systemTimeZone = TimeZone.getDefault();
    locale = Locale.getDefault();

    /*
     * Set new default time zone and locale,
     * which will be used during the tests execution.
     */
    TimeZone.setDefault(TimeZone.getTimeZone(DEFAULT_TIME_ZONE_ID));
    Locale.setDefault(Locale.US);
}

From source file:com.github.lindenb.jvarkit.util.command.Command.java

public Command() {
    try {//w  w w . java  2 s .c  o  m
        this.messagesBundle = ResourceBundle.getBundle("messages");
    } catch (Exception e) {
        LOG.warn("Cannot get messages bundle ", e);
    }
    /** set locale http://seqanswers.com/forums/showthread.php?p=174020#post174020 */
    Locale.setDefault(Locale.US);
    System.setProperty("file.encoding", "UTF-8");
}

From source file:org.silverpeas.core.util.AbstractUnitTest.java

@After
public void clear() {
    Locale.setDefault(currentLocale);
    bundleCache.clear();
}

From source file:org.apache.maven.doxia.siterenderer.DefaultSiteRendererTest.java

/**
 * @throws java.lang.Exception if something goes wrong.
 * @see org.codehaus.plexus.PlexusTestCase#setUp()
 *//*from   w w  w.java  2 s  .c  o  m*/
@Override
protected void setUp() throws Exception {
    super.setUp();

    renderer = (Renderer) lookup(Renderer.ROLE);

    // copy the default-site.vm and default-site-macros.vm
    copyVm("default-site.vm", "\n\n\n\r\n\r\n\r\n");
    copyVm("default-site-macros.vm", "");

    InputStream skinIS = this.getResourceAsStream("velocity-toolmanager.vm");
    JarOutputStream jarOS = new JarOutputStream(new FileOutputStream(skinJar));
    try {
        jarOS.putNextEntry(new ZipEntry("META-INF/maven/site.vm"));
        IOUtil.copy(skinIS, jarOS);
        jarOS.closeEntry();
    } finally {
        IOUtil.close(skinIS);
        IOUtil.close(jarOS);
    }

    oldLocale = Locale.getDefault();
    Locale.setDefault(Locale.ENGLISH);
}