Example usage for java.util Locale Locale

List of usage examples for java.util Locale Locale

Introduction

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

Prototype

public Locale(String language) 

Source Link

Document

Construct a locale from a language code.

Usage

From source file:de.ingrid.portal.interfaces.wms.WMSInterfaceTest.java

public void testGetWMSAddedServiceURLWMSServiceDescriptorString() throws UnsupportedEncodingException {
    WMSServiceDescriptor descr = new WMSServiceDescriptor("My WMS Service Name",
            "http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/world/world_map.map&REQUEST=GetCapabilities&SERVICE=wms&VERSION=1.1.0");
    String myUrl = wmsInterface.getWMSAddedServiceURL(descr, "session0815", true, new Locale("de"), true);
    String request = "COMMAND=addWMS";
    String transmittedWmsUrl = "http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/world/world_map.map&REQUEST=GetCapabilities&SERVICE=wms&VERSION=1.1.0";
    if (wmsInterface.getMapbenderVersion().equals(wmsInterface.MAPBENDER_VERSION_2_1)) {
        request = "PREQUEST=setServices";
        transmittedWmsUrl = "http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/world/world_map.map,REQUEST=GetCapabilities,SERVICE=wms,VERSION=1.1.0";
    }//from  w  ww  .  j  ava2  s . co m
    if (config.getProperty("display_viewer_url").toString().indexOf("?") > 0) {
        assertEquals(config.getProperty("display_viewer_url") + "&PHPSESSID=session0815&lang=de&" + request
                + "&wmsName1=" + URLEncoder.encode("My WMS Service Name", "UTF-8") + "&wms1="
                + URLEncoder.encode(transmittedWmsUrl, "UTF-8"), myUrl);
    } else {
        assertEquals(config.getProperty("display_viewer_url") + "?PHPSESSID=session0815&lang=de&" + request
                + "&wmsName1=" + URLEncoder.encode("My WMS Service Name", "UTF-8") + "&wms1="
                + URLEncoder.encode(transmittedWmsUrl, "UTF-8"), myUrl);
    }

}

From source file:ar.com.zauber.commons.xmpp.message.XMPPMessageTest.java

/** todo lo anterior + form extensions! */
@Test/*from  ww w.  jav a 2  s.  c o  m*/
public final void testFormExtension() throws Exception {
    final XMPPMessage c = new XMPPMessage("body", "title");
    final Map<Locale, Resource> msgs = new HashMap<Locale, Resource>();
    msgs.put(new Locale("es"), new StringResource("hola!"));
    msgs.put(Locale.ITALIAN, new StringResource("pronto!"));
    c.setLangBodies(msgs);
    final Form form = new Form(Form.TYPE_FORM);
    form.setInstructions("instructions");
    form.setTitle("Observaciones");
    final FormField field = new FormField("date");
    field.setType(FormField.TYPE_HIDDEN);
    field.setDescription("fecha que se esta observando");
    field.addValue("2009-06-20");
    form.addField(field);
    c.setExtensions(Arrays.asList(new PacketExtension[] { form.getDataFormToSend() }));
    org.jivesoftware.smack.packet.Message m = c.getXMPPMessage("juan");
    m.setPacketID("0");
    // sin setear conection no deberia haber mensaje html 
    Assert.assertEquals(getResult("extension-form.xml"), m.toXML());
}

From source file:edu.kit.trufflehog.model.configdata.PropertiesDataModelTest.java

/**
 * <p>/*w w w  .j  a  v  a 2s . c om*/
 *     Tests whether the property file is copied correctly if it was not run before.
 * </p>
 *
 * @throws Exception Passes any errors that occurred during the test on
 */
@Test
public void testWithNoFile() throws Exception {
    this.fileSystem = mock(FileSystem.class);
    when(fileSystem.getDataFolder()).thenAnswer(answer -> new File("./src/test/resources/data"));
    when(fileSystem.getConfigFolder())
            .thenAnswer(answer -> new File("./src/test/resources/data/config-error-test"));

    if (fileSystem.getConfigFolder().exists()) {
        FileUtils.deleteDirectory(fileSystem.getConfigFolder());
        fileSystem.getConfigFolder().mkdir();
    } else {
        fileSystem.getConfigFolder().mkdir();
    }

    this.propertiesDataModel = new PropertiesDataModel(new Locale("en"), fileSystem);

    boolean exists = new File(fileSystem.getConfigFolder() + File.separator + "system_properties_en.properties")
            .exists();

    if (fileSystem.getConfigFolder().exists()) {
        FileUtils.deleteDirectory(fileSystem.getConfigFolder());
        fileSystem.getConfigFolder().mkdir();
    }

    assertEquals(true, exists);
}

From source file:ru.gelin.android.weather.google.GoogleWeatherSourceTest.java

public void ignoretestQueryTime() throws WeatherException {
    Date now = new Date();
    WeatherSource source = new GoogleWeatherSource();
    Location location = new SimpleLocation("?");
    Weather weather = source.query(location, new Locale("ru"));
    assertNotNull(weather.getQueryTime());
    assertTrue(!weather.getQueryTime().before(now));
}

From source file:de.blizzy.documentr.mail.SubscriptionMailer.java

private void sendNotifications(String projectName, String branchName, String path) throws IOException {

    Map<String, String> settings = systemSettingsStore.getSettings();
    String senderEmail = settings.get(SystemSettingsStore.MAIL_SENDER_EMAIL);
    String senderName = settings.get(SystemSettingsStore.MAIL_SENDER_NAME);
    String subjectPrefix = settings.get(SystemSettingsStore.MAIL_SUBJECT_PREFIX);
    String languageCode = settings.get(SystemSettingsStore.MAIL_DEFAULT_LANGUAGE);
    Locale locale = new Locale(languageCode);
    if (StringUtils.isNotBlank(senderEmail)) {
        JavaMailSender sender = mailSenderFactory.createSender();
        if (sender != null) {
            Set<String> subscriberEmails = subscriptionStore.getSubscriberEmails(projectName, branchName, path);
            if (!subscriberEmails.isEmpty()) {
                Page page = pageStore.getPage(projectName, branchName, path, false);
                String title = page.getTitle();
                String subject = messageSource.getMessage("mail.pageChanged.subject", //$NON-NLS-1$
                        new Object[] { title }, locale);
                if (StringUtils.isNotBlank(subjectPrefix)) {
                    subject = subjectPrefix.trim() + " " + subject; //$NON-NLS-1$
                }//from  ww  w .  ja v  a 2s. c  om
                String pageUrl = createUrl(settings, "/page/" + projectName + "/" + branchName + "/" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        Util.toUrlPagePath(path));
                String changesUrl = createUrl(settings, "/page/" + projectName + "/" + branchName + "/" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        Util.toUrlPagePath(path) + "#changes"); //$NON-NLS-1$
                String text = messageSource.getMessage("mail.pageChanged.text", //$NON-NLS-1$
                        new Object[] { title, pageUrl, changesUrl }, locale);

                sendMail(subject, text, senderEmail, senderName, subscriberEmails, sender);
            } else {
                log.info("no subscribers, not sending mail"); //$NON-NLS-1$
            }
        } else {
            log.info("settings incomplete, not sending mail"); //$NON-NLS-1$
        }
    } else {
        log.info("settings incomplete, not sending mail"); //$NON-NLS-1$
    }
}

From source file:com.nkapps.billing.webservices.AccountWebService.java

private GenericResult initResult(GenericArgument argument, GenericResult result) {
    try {/* w w w  .  j  a  v a 2 s  .c o  m*/
        String username = argument.getUsername();
        String password = md5Encrypt(argument.getPassword());

        WSDao wsDao = (WSDao) getBean("wsDao");
        WsUser user = wsDao.findByUsernameAndPassword(username, password);
        if (user == null) {
            MessageSource messageSource = (MessageSource) getBean("messageSource");
            //                throw new Exception(messageSource.getMessage("auth.login_or_password_not_correct",null,new Locale("ru")));

            Environment environment = (Environment) getBean("environment");
            String a = environment.getProperty("ws.allow_user_add");
            if ("true".equals(a)) {
                if (wsDao.createWsUser(username, password) == null) {
                    throw new Exception(messageSource.getMessage("auth.login_or_password_not_correct", null,
                            new Locale("ru")));
                }
            } else {
                throw new Exception(
                        messageSource.getMessage("auth.login_or_password_not_correct", null, new Locale("ru")));
            }
        }
        result.setStatus(GenericResult.STATUS_INIT);
    } catch (Exception e) {
        logger.error(e.getMessage());
        result.setStatus(GenericResult.STATUS_ERROR_AUTH);
        result.setReason(e.getMessage());
    }
    return result;
}

From source file:net.sourceforge.fenixedu.presentationTier.docs.FenixReport.java

protected String verboseDate(LocalDate date) {
    return "dia " + DateI18NUtil.verboseNumber(date.getDayOfMonth()) + " do ms de "
            + date.toString("MMMM", new Locale("pt")) + " de " + DateI18NUtil.verboseNumber(date.getYear());
}

From source file:fi.helsinki.opintoni.web.rest.privateapi.FavoriteResourceTest.java

@Test
public void thatUnisportReservationsAreReturned() throws Exception {
    unisportServer.expectAuthorization();
    unisportServer.expectUserReservations();

    mockMvc.perform(get("/api/private/v1/favorites/unisport").with(securityContext(studentSecurityContext()))
            .locale(new Locale("fi")).accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
            .andExpect(content().contentType(WebConstants.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$.events[2].name").value("Testikurssin tapahtuma"));
}

From source file:it.imtech.configuration.ChooseServer.java

/**
 * Creates new form ChooseServer/* w ww.j a  v  a 2s.  com*/
 */
public ChooseServer(XMLConfiguration config) {
    initComponents();

    bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader);

    Server[] servers = getServersFromConfig(config, bundle);
    choose_server.setModel(new javax.swing.DefaultComboBoxModel(servers));
    choose_server.setSelectedItem(servers[0]);
    choose_server.setMinimumSize(new Dimension(400, 20));

    getLanguagesFromConfig(config, bundle);
    choose_language.setModel(new javax.swing.DefaultComboBoxModel(Globals.LANGUAGES));
    choose_language.setSelectedItem(this.selected_lang);
    choose_language.setMinimumSize(new Dimension(400, 20));

    updateLanguage();
    MigLayout choose_layout = new MigLayout("fillx, insets 10 20 10 50");
    main_panel = new JPanel(choose_layout);

    main_panel.add(label_server_1, "wrap 20");
    main_panel.add(label_server_2, "wrap 30");
    main_panel.add(label_server_3, "wrap 5");
    main_panel.add(choose_server, "wrap 10");

    main_panel.add(label_server_4, "wrap 5");
    main_panel.add(choose_language, "wrap 10");

    this.setLayout(new BorderLayout());
    this.add(BorderLayout.CENTER, main_panel);

    //Gestione eventi
    choose_language.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            JComboBox comboBox = (JComboBox) event.getSource();
            Language selected = (Language) comboBox.getSelectedItem();
            selected_lang = selected;

            Globals.CURRENT_LOCALE = new Locale(selected.getCode());
            updateLanguage();
            Utility.setDefaultLangCurrent();
        }
    });

    this.setPreferredSize(this.getPreferredSize());
    this.validate();
    this.repaint();
}