List of usage examples for java.util Locale setDefault
public static synchronized void setDefault(Locale newLocale)
From source file:test.unit.be.fedict.eid.applet.MessagesTest.java
@Test public void testUnsupportedLanguage() throws Exception { Locale.setDefault(new Locale("nl")); Locale locale = Locale.JAPANESE; Messages messages = new Messages(locale); String message = messages.getMessage(Messages.MESSAGE_ID.GENERIC_ERROR); LOG.debug("message: " + message); assertEquals("Algemene fout.", message); }
From source file:de.tbuchloh.kiskis.persistence.importer.CSVImportTest.java
/** * {@inheritDoc}//from ww w . j av a 2 s. c o m */ @Override protected void tearDown() throws Exception { super.tearDown(); Locale.setDefault(_locale); }
From source file:net.sf.dynamicreports.test.jasper.chart.LayeredBarChartTest.java
@Override protected void configureReport(JasperReportBuilder rb) { TextColumnBuilder<String> column1; TextColumnBuilder<Integer> column2; Locale.setDefault(Locale.ENGLISH); rb.columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class)) .summary(/*from w w w . ja v a 2s .co m*/ cht.layeredBarChart().customizers(new ChartCustomizer()).setCategory(column1) .series(cht.serie(column2)).setShowLabels(true).setShowTickLabels(false) .setShowTickMarks(false), cht.layeredBarChart().setCategory(column1).series(cht.serie(column2)) .setCategoryAxisFormat(cht.axisFormat().setLabel("category") .setLabelColor(Color.BLUE).setLabelFont(stl.fontArialBold()) .setTickLabelFont(stl.fontArial().setItalic(true)) .setTickLabelColor(Color.CYAN).setTickLabelRotation(45d) .setLineColor(Color.LIGHT_GRAY)), cht.layeredBarChart().setCategory(column1).series(cht.serie(column2)) .setValueAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE) .setLabelFont(stl.fontArialBold()) .setTickLabelFont(stl.fontArial().setItalic(true)) .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00") .setLineColor(Color.LIGHT_GRAY).setRangeMinValueExpression(1) .setRangeMaxValueExpression(15))); }
From source file:com.loadsensing.app.ImatgeXarxaSensors.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Definimos idioma SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(ImatgeXarxaSensors.this); Locale locale = new Locale(settings.getString("location", "es")); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale;/*from ww w . ja v a 2 s. c o m*/ getApplicationContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); setContentView(new TouchView(this)); }
From source file:com.gcrm.security.AuthenticationFilter.java
@Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { if (!request.getMethod().equals("POST")) { throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); }/* w w w. j a v a2 s . c om*/ String username = obtainUsername(request); String password = obtainPassword(request); // Validates username and password username = username.trim(); String localValue = obtainLanguage(request); String[] locals = localValue.split("_"); Locale locale = new Locale(locals[0], locals[1]); request.getSession().setAttribute("WW_TRANS_I18N_LOCALE", locale); request.getSession().setAttribute("locale", localValue); Locale.setDefault(locale); User user = UserUtil.getUser(username); Md5PasswordEncoder encoder = new Md5PasswordEncoder(); password = encoder.encodePassword(password, AuthenticationFilter.SALT); if (user == null || !user.getPassword().equals(password)) { ResourceBundle rb = CommonUtil.getResourceBundle(); String errorMessage = rb.getString("error.login.denied"); throw new AuthenticationServiceException(errorMessage); } UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password); setDetails(request, authRequest); // return authRequest; return this.getAuthenticationManager().authenticate(authRequest); }
From source file:net.pms.configuration.RendererConfigurationTest.java
@Before public void setUp() { // Silence all log messages from the PMS code that is being tested LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); context.reset();/* w w w . ja v a 2s . c om*/ // Set locale to EN to ignore translations for renderers Locale.setDefault(Locale.ENGLISH); // Cases that are too generic should not match anything testCases.put("User-Agent: UPnP/1.0 DLNADOC/1.50", null); testCases.put("User-Agent: Unknown Renderer", null); testCases.put("X-Unknown-Header: Unknown Content", null); // From AirPlayer.conf: testCases.put("User-Agent: AirPlayer/1.0.09 CFNetwork/485.13.9 Darwin/11.0.0", "AirPlayer"); testCases.put("User-Agent: Lavf52.54.0", "AirPlayer"); // From BraviaEX.conf: testCases.put("X-AV-Client-Info: av=5.0; cn=\"Sony Corporation\"; mn=\"BRAVIA KDL-32CX520\"; mv=\"1.7\";", "Sony Bravia EX"); // From BraviaHX.conf: testCases.put("X-AV-Client-Info: av=5.0; cn=\"Sony Corporation\"; mn=\"BRAVIA KDL-55HX750\"; mv=\"1.7\";", "Sony Bravia HX"); // From Dlink510.conf: testCases.put("User-Agent: DLNADOC/1.50 INTEL_NMPR/2.1", "D-Link DSM-510"); // From iPad-iPhone.conf: testCases.put("User-Agent: 8player lite 2.2.3 (iPad; iPhone OS 5.0.1; nl_NL)", "iPad / iPhone"); testCases.put("User-Agent: yxplayer2%20lite/1.2.7 CFNetwork/485.13.9 Darwin/11.0.0", "iPad / iPhone"); testCases.put("User-Agent: MPlayer 1.0rc4-4.2.1", "iPad / iPhone"); testCases.put("User-Agent: NSPlayer/4.1.0.3856", "iPad / iPhone"); // From Philips.conf: testCases.put("User-Agent: Allegro-Software-WebClient/4.61 DLNADOC/1.00", "Philips Aurea"); // From PhilipsPFL.conf: testCases.put("User-Agent: Windows2000/0.0 UPnP/1.0 PhilipsIntelSDK/1.4 DLNADOC/1.50", "Philips TV"); // From PS3.conf: testCases.put("User-Agent: PLAYSTATION 3", "PlayStation 3"); testCases.put( "X-AV-Client-Info: av=5.0; cn=\"Sony Computer Entertainment Inc.\"; mn=\"PLAYSTATION 3\"; mv=\"1.0\"", "PlayStation 3"); // From Realtek.conf: // FIXME: Actual conflict here! Popcorn Hour is returned... //testCases.put("User-Agent: POSIX UPnP/1.0 Intel MicroStack/1.0.2718, RealtekMediaCenter, DLNADOC/1.50", "Realtek"); testCases.put("User-Agent: RealtekVOD neon/0.27.2", "Realtek"); // From SamsungAllShare.conf: testCases.put("User-Agent: SEC_HHP_[HT]D5500/1.0", "Samsung AllShare"); testCases.put("User-Agent: SEC_HHP_[TV]UE32D5000/1.0", "Samsung AllShare"); testCases.put("User-Agent: SEC_HHP_ Family TV/1.0", "Samsung AllShare"); testCases.put("User-Agent: SEC_HHP_[TV]PS51D6900/1.0", "Samsung AllShare"); testCases.put("User-Agent: DLNADOC/1.50 SEC_HHP_[TV]UE32D5000/1.0", "Samsung AllShare"); testCases.put("User-Agent: DLNADOC/1.50 SEC_HHP_[TV]UN55D6050/1.0", "Samsung AllShare"); testCases.put("User-Agent: DLNADOC/1.50 SEC_HHP_ Family TV/1.0", "Samsung AllShare"); // From Samsung-SMT-G7400.conf: testCases.put("User-Agent: Linux/2.6.35 UPnP/1.0 NDS_MHF DLNADOC/1.50", "Samsung SMT-G7400"); // From WDTVLive.conf: testCases.put("User-Agent: INTEL_NMPR/2.1 DLNADOC/1.50 Intel MicroStack/1.0.1423", "WD TV Live"); // From XBMC.conf: testCases.put("User-Agent: XBMC/10.0 r35648 (Mac OS X; 11.2.0 x86_64; http://www.xbmc.org)", "XBMC"); testCases.put("User-Agent: Platinum/0.5.3.0, DLNADOC/1.50", "XBMC"); }
From source file:com.hangum.tadpole.engine.manager.TadpoleSQLManager.java
/** * <pre>/* ww w.j av a 2 s . c o m*/ * DB ?. * * ? ??? . * ?? " ' ? ? . * * </pre> * * @param userDB * @return * @throws Exception */ public static SqlMapClient getInstance(final UserDBDAO userDB) throws TadpoleSQLManagerException { SqlMapClient sqlMapClient = null; Connection conn = null; // synchronized (dbManager) { String searchKey = getKey(userDB); try { sqlMapClient = dbManager.get(searchKey); if (sqlMapClient == null) { // oracle ? try { if (userDB.getDBDefine() == DBDefine.ORACLE_DEFAULT | userDB.getDBDefine() == DBDefine.TIBERO_DEFAULT) { DriverManager.setLoginTimeout(10); if (userDB.getLocale() != null && !"".equals(userDB.getLocale())) { Locale.setDefault(new Locale(userDB.getLocale())); } } } catch (Exception e) { logger.error("set locale error", e); } // connection pool ? . sqlMapClient = SQLMap.getInstance(userDB); dbManager.put(searchKey, sqlMapClient); // metadata . conn = sqlMapClient.getDataSource().getConnection(); // don't belive keyword. --;; setMetaData(searchKey, userDB, conn.getMetaData()); } } catch (Exception e) { // String strAddReqInfo = ""; // try { // strAddReqInfo = RequestInfoUtils.requestInfo("db connection exception ", SessionManager.getEMAIL()); // } catch(Exception ee) { // logger.error("request error", ee); // } logger.error("===\n get DB Instance \n seq is " + userDB.getSeq() + "\n", e); dbManager.remove(searchKey); throw new TadpoleSQLManagerException(e); } finally { if (conn != null) try { conn.close(); } catch (Exception e) { } } // } return sqlMapClient; }
From source file:net.sf.dynamicreports.test.jasper.chart.DifferenceChartTest.java
@Override protected void configureReport(JasperReportBuilder rb) { TextColumnBuilder<Date> column1; TextColumnBuilder<Timestamp> column2; TextColumnBuilder<Integer> column3; TextColumnBuilder<Integer> column4; Locale.setDefault(Locale.ENGLISH); rb.columns(column1 = col.column("Column1", "field1", Date.class), column2 = col.column("Column2", "field2", Timestamp.class), column3 = col.column("Column3", "field3", Integer.class), column4 = col.column("Column4", "field4", Integer.class)) .summary(//from w w w . ja v a 2 s.com cht.differenceChart().customizers(new ChartCustomizer()).setTimePeriod(column1) .series(cht.serie(column3), cht.serie(column4)).setTimePeriodType(TimePeriod.DAY) .setShowShapes(false).setPositiveColor(Color.BLUE).setNegativeColor(Color.MAGENTA), cht.differenceChart().setTimePeriod(column1).series(cht.serie(column3)) .setTimeAxisFormat(cht.axisFormat().setLabel("time").setLabelColor(Color.BLUE) .setLabelFont(stl.fontArialBold()) .setTickLabelFont(stl.fontArial().setItalic(true)) .setTickLabelColor(Color.CYAN).setLineColor(Color.LIGHT_GRAY) .setVerticalTickLabels(true)), cht.differenceChart().setTimePeriod(column2).series(cht.serie(column3)) .setValueAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE) .setLabelFont(stl.fontArialBold()) .setTickLabelFont(stl.fontArial().setItalic(true)) .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00") .setLineColor(Color.LIGHT_GRAY).setRangeMinValueExpression(1) .setRangeMaxValueExpression(15).setVerticalTickLabels(true))); }
From source file:org.openengsb.itests.htmlunit.TaskboxUiIT.java
@BeforeClass public static void initialize() { Locale.setDefault(Locale.ENGLISH); }
From source file:org.opendatakit.common.android.utilities.ODKDataUtilsTest.java
@Test public void testNormalizeDisplayName() throws JsonProcessingException { 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 value = ODKFileUtils.mapper.writeValueAsString(langMap); String match;//w w w .j ava 2 s .c o m Locale.setDefault(Locale.US); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("This is a test", match); Locale.setDefault(Locale.UK); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Test is This", match); Locale.setDefault(Locale.CANADA); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Huh Test", match); Locale.setDefault(Locale.CANADA_FRENCH); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("Je suis", match); Locale.setDefault(Locale.GERMANY); match = ODKDataUtils.getLocalizedDisplayName(value); assertEquals("No way!", match); Locale.setDefault(Locale.US); }