List of usage examples for java.util Locale setDefault
public static synchronized void setDefault(Locale newLocale)
From source file:org.apache.solr.morphlines.solr.AbstractSolrMorphlineTestBase.java
@BeforeClass public static void beforeClass() throws Exception { assumeFalse("This test fails on Java 9 (https://issues.apache.org/jira/browse/SOLR-8876)", Constants.JRE_IS_MINIMUM_JAVA9); // TODO: test doesn't work with some Locales, see SOLR-6458 savedLocale = Locale.getDefault(); Locale.setDefault(Locale.ENGLISH); // we leave this in case the above is addressed assumeFalse(/*from w ww . j ava2s.com*/ "This test fails on UNIX with Turkish default locale (https://issues.apache.org/jira/browse/SOLR-6387)", new Locale("tr").getLanguage().equals(Locale.getDefault().getLanguage())); myInitCore(DEFAULT_BASE_DIR); }
From source file:com.smartmarmot.orabbix.Orabbixmon.java
@Override public void run() { try {//from w w w. j a v a2s . c o m Configurator cfg = null; try { cfg = new Configurator(configFile); } catch (Exception e) { SmartLogger.logThis(Level.ERROR, "Error while creating configurator with " + configFile + " " + e); } RuntimeMXBean rmxb = ManagementFactory.getRuntimeMXBean(); String pid = rmxb.getName(); SmartLogger.logThis(Level.INFO, Constants.PROJECT_NAME + " started with pid:" + pid.split("@")[0].toString()); // System.out.print("pid: "+pid.split("@")[0].toString()); String pidfile = cfg.getPidFile(); try { Utility.writePid(pid.split("@")[0].toString(), pidfile); } catch (Exception e) { SmartLogger.logThis(Level.ERROR, "Error while trying to write pidfile " + e); } Locale.setDefault(Locale.US); DBConn[] myDBConn = cfg.getConnections(); if (myDBConn == null) { SmartLogger.logThis(Level.ERROR, "ERROR on main - Connections is null"); throw new Exception("ERROR on main - Connections is null"); } else if (myDBConn.length == 0) { SmartLogger.logThis(Level.ERROR, "ERROR on main - Connections is empty"); throw new Exception("ERROR on main - Connections is empty"); } /** * retrieve maxThread */ Integer maxThread = 0; try { maxThread = cfg.getMaxThread(); } catch (Exception e) { SmartLogger.logThis(Level.WARN, "MaxThread not defined calculated maxThread = " + myDBConn.length * 3); } if (maxThread == null) maxThread = 0; if (maxThread == 0) { maxThread = myDBConn.length * 3; } ExecutorService executor = Executors.newFixedThreadPool(maxThread.intValue()); /** * populate qbox */ Hashtable<String, Querybox> qbox = new Hashtable<String, Querybox>(); for (int i = 0; i < myDBConn.length; i++) { Querybox qboxtmp = Configurator.buildQueryBoxbyDBName(myDBConn[i].getName()); qbox.put(myDBConn[i].getName(), qboxtmp); } // for (int i = 0; i < myDBConn.length; i++) { cfg = null; /** * daemon begin here */ while (running) { /** * istantiate a new configurator */ Configurator c = new Configurator(configFile); /* * here i rebuild DB's List */ if (!c.isEqualsDBList(myDBConn)) { // rebuild connections DBConn[] myDBConn = c.rebuildDBList(myDBConn); for (int i = 1; i < myDBConn.length; i++) { if (!qbox.containsKey(myDBConn[i].getName())) { Querybox qboxtmp = Configurator.buildQueryBoxbyDBName(myDBConn[i].getName()); qbox.put(myDBConn[i].getName(), qboxtmp); } } } // if (!c.isEqualsDBList(myDBConn)) { /* * ready to run query */ for (int i = 0; i < myDBConn.length; i++) { Querybox actqb = qbox.get(myDBConn[i].getName()); actqb.refresh(); Query[] q = actqb.getQueries(); SharedPoolDataSource spds = myDBConn[i].getSPDS(); Hashtable<String, Integer> zabbixServers = c.getZabbixServers(); SmartLogger.logThis(Level.DEBUG, "Ready to run DBJob for dbname ->" + myDBConn[i].getName()); Runnable runner = new DBJob(spds, q, Constants.QUERY_LIST, zabbixServers, myDBConn[i].getName()); executor.execute(runner); } // for (int i = 0; i < myDBConn.length; i++) { Thread.sleep(60 * 1000); SmartLogger.logThis(Level.DEBUG, "Waking up Goood Morning"); } } catch (Exception e1) { // TODO Auto-generated catch block System.out.println("Stopping"); e1.printStackTrace(); stopped = true; } }
From source file:org.jbake.app.template.AbstractTemplateEngineRenderingTest.java
@Before public void setup() throws Exception { currentLocale = Locale.getDefault(); Locale.setDefault(Locale.ENGLISH); ModelExtractorsDocumentTypeListener listener = new ModelExtractorsDocumentTypeListener(); DocumentTypes.addListener(listener); URL sourceUrl = this.getClass().getResource("/"); sourceFolder = new File(sourceUrl.getFile()); if (!sourceFolder.exists()) { throw new Exception("Cannot find sample data structure!"); }//from w w w . j a v a 2s. c o m destinationFolder = folder.getRoot(); templateFolder = new File(sourceFolder, templateDir); if (!templateFolder.exists()) { throw new Exception("Cannot find template folder!"); } config = ConfigUtil.load(new File(this.getClass().getResource("/").getFile())); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { String key = keys.next(); if (key.startsWith("template") && key.endsWith(".file")) { String old = (String) config.getProperty(key); config.setProperty(key, old.substring(0, old.length() - 4) + "." + templateExtension); } } Assert.assertEquals(".html", config.getString(ConfigUtil.Keys.OUTPUT_EXTENSION)); db = DBUtil.createDataStore("memory", "documents" + System.currentTimeMillis()); crawler = new Crawler(db, sourceFolder, config); crawler.crawl(new File(sourceFolder.getPath() + File.separator + "content")); parser = new Parser(config, sourceFolder.getPath()); renderer = new Renderer(db, destinationFolder, templateFolder, config); setupExpectedOutputStrings(); }
From source file:org.talend.dataprep.schema.xls.XlsSerializerTest.java
@After public void tearDown() throws Exception { Locale.setDefault(previousLocale); }
From source file:org.apache.james.imap.tester.base.AbstractSimpleScriptedTestProtocol.java
/** * Reads test elements from the protocol session file and adds them to the * {@link #testElements} ProtocolSession. Then calls {@link #runSessions}. * //w w w .j av a2 s. c om * @param locale * execute the test using this locale */ protected void scriptTest(String fileName, Locale locale) throws Exception { Locale.setDefault(locale); addTestFile(fileName + ".test", testElements); runSessions(); }
From source file:org.milyn.smooks.mule.RouterGeneralFunctionalTest.java
@Override protected void doSetUp() throws Exception { super.doSetUp(); TimeZone.setDefault(TimeZone.getTimeZone("EST")); Locale.setDefault(Locale.ENGLISH); FileUtils.deleteDirectory(routingTestDir); if (reportFile.exists()) { reportFile.delete();/* w w w .jav a 2s .c o m*/ } }
From source file:com.gargoylesoftware.htmlunit.ScriptExceptionTest.java
private void testScriptStackTrace(final String baseFileName) throws Exception { try {// ww w. j av a 2 s . co m final Locale locale = Locale.getDefault(); // Set the default locale to US because Rhino messages are localized Locale.setDefault(Locale.US); loadPage(getBrowserVersion(), getFileContent(baseFileName + ".html"), null, new URL("http://www.gargoylesoftware.com/")); Locale.setDefault(locale); } catch (final ScriptException e) { final StringWriter stringWriter = new StringWriter(); final PrintWriter printWriter = new PrintWriter(stringWriter); e.printScriptStackTrace(printWriter); final String expectedTrace = getFileContent(baseFileName + ".txt"); assertEquals(expectedTrace, stringWriter.toString()); return; } fail("Exception not thrown"); }
From source file:test.unit.be.fedict.eid.applet.MessagesTest.java
@Test public void testDefaultLocale() throws Exception { Locale defaultLocale = Locale.FRENCH; Locale.setDefault(defaultLocale); Locale locale = Locale.ENGLISH; Messages messages = new Messages(locale); String message = messages.getMessage(Messages.MESSAGE_ID.GENERIC_ERROR); LOG.debug("message: " + message); assertEquals("Generic Error.", message); }
From source file:org.obm.push.protocol.data.TimeZoneEncoderImplTest.java
@Before public void setUp() { Locale.setDefault(Locale.US); serializer = new TimeZoneEncoderImpl(new IntEncoder(), new WCHAREncoder(), new SystemTimeEncoder()); intEncoder = new IntEncoder(); systemTimeEncoder = new SystemTimeEncoder(); defaultBiasInMinutes = 10;/*from w w w . j a v a 2s . co m*/ defaultStandardBiasInMinutes = 100; defaultStandardDate = anySystemTime(); defaultDayLightBiasInMinutes = 100; defaultDayLightDate = anySystemTime(); }
From source file:org.pegadi.client.LoginDialog.java
private void jbInit() { Locale.setDefault(new Locale("no", "NO")); this.setTitle(str.getString("title")); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(WindowEvent e) { this_windowOpened(e); }//ww w . ja v a 2 s.c o m }); loginLabel.setText(str.getString("login")); userNameLabel.setText(str.getString("username")); okButton.setText("OK"); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { okButton_actionPerformed(e); } }); quitButton.setText(str.getString("quit")); quitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { quitButton_actionPerformed(e); } }); userNameField.setColumns(10); userNameField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(KeyEvent e) { userNameField_keyReleased(e); } }); passwordLabel.setText(str.getString("password")); passwordField.setColumns(10); passwordField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(KeyEvent e) { passwordField_keyReleased(e); } }); serverLabel.setText(str.getString("server")); Set keyset = servers.keySet(); for (Object aKeyset : keyset) { String serverKey = (String) aKeyset; serverChooser.addItem(serverKey); } serverChooser.setEnabled(false); // gui starts JPanel mainPanel = new JPanel(); this.getContentPane().add(mainPanel); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); JPanel labelPanel = new JPanel(); loginLabel.setFont(new Font(null, Font.PLAIN, 20)); // add icon URL iu = getClass().getResource("/images/pegadi_icon.png"); Image icon = Toolkit.getDefaultToolkit().getImage(iu); MediaTracker mt = new MediaTracker(this); mt.addImage(icon, 0); try { mt.waitForID(0); } catch (InterruptedException ie) { icon = null; } if (icon != null) { loginLabel.setIcon(new ImageIcon(icon)); loginLabel.setVerticalTextPosition(JLabel.BOTTOM); loginLabel.setHorizontalTextPosition(JLabel.CENTER); } labelPanel.add(loginLabel); labelPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mainPanel.add(labelPanel); JPanel fieldPanel = new JPanel(new SpringLayout()); fieldPanel.add(userNameLabel); fieldPanel.add(userNameField); fieldPanel.add(passwordLabel); fieldPanel.add(passwordField); fieldPanel.add(serverLabel); fieldPanel.add(serverChooser); SpringUtilities.makeCompactGrid(fieldPanel, 3, 2, //rows, cols 5, 5, //initialX, initialY 10, 5);//xPad, yPad mainPanel.add(fieldPanel); JPanel buttonPanel = new JPanel(); JPanel buttonWrapperPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); buttonWrapperPanel.add(okButton); buttonWrapperPanel.add(quitButton); buttonPanel.add(buttonWrapperPanel, BorderLayout.CENTER); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mainPanel.add(buttonPanel); }