Example usage for java.util Locale FRENCH

List of usage examples for java.util Locale FRENCH

Introduction

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

Prototype

Locale FRENCH

To view the source code for java.util Locale FRENCH.

Click Source Link

Document

Useful constant for language.

Usage

From source file:test.integ.be.fedict.commons.eid.client.JCATest.java

@Test
public void testLocale() throws Exception {
    Security.addProvider(new BeIDProvider());

    KeyStore keyStore = KeyStore.getInstance("BeID");
    BeIDKeyStoreParameter beIDKeyStoreParameter = new BeIDKeyStoreParameter();
    beIDKeyStoreParameter.setLocale(Locale.FRENCH);
    beIDKeyStoreParameter.setLogger(new TestLogger());
    keyStore.load(beIDKeyStoreParameter);

    PrivateKey privateKey = (PrivateKey) keyStore.getKey("Signature", null);

    Signature signature = Signature.getInstance("SHA1withRSA");
    signature.initSign(privateKey);//from www. j a va 2  s. c om

    byte[] toBeSigned = "hello world".getBytes();
    signature.update(toBeSigned);
    signature.sign();
}

From source file:net.bull.javamelody.TestMonitoringFilter.java

/** Test.
 * @throws ServletException e/*from ww  w  . j a  v a2s  .  com*/
 * @throws IOException e */
@Test
public void testDoFilterWithSessionBis() throws ServletException, IOException {
    final HttpServletRequest request = createNiceMock(HttpServletRequest.class);
    final HttpSession session = createNiceMock(HttpSession.class);
    expect(request.getSession(false)).andReturn(session);
    // Locale sans pays
    expect(request.getLocale()).andReturn(Locale.FRENCH).anyTimes();
    // "X-Forwarded-For"
    expect(request.getHeader("X-Forwarded-For")).andReturn("somewhere").anyTimes();
    // getRemoteUser
    expect(request.getRemoteUser()).andReturn("me").anyTimes();
    replay(session);
    doFilter(request);
    verify(session);
}

From source file:org.alfresco.repo.node.NodeServiceTest.java

@Test
public void testLocaleSupport() throws Exception {
    // Ensure that the root node has the default locale
    Locale locale = (Locale) nodeService.getProperty(rootNodeRef, ContentModel.PROP_LOCALE);
    assertNotNull("Locale property must occur on every node", locale);
    assertEquals("Expected default locale on the root node", I18NUtil.getLocale(), locale);
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(rootNodeRef, ContentModel.ASPECT_LOCALIZED));

    // Now switch to a specific locale and create a new node
    I18NUtil.setLocale(Locale.CANADA_FRENCH);

    // Create a node using an explicit locale
    NodeRef nodeRef1 = nodeService//from   w w w . j  a v a 2  s.c o  m
            .createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
                    QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
                    ContentModel.TYPE_CONTAINER,
                    Collections.singletonMap(ContentModel.PROP_LOCALE, (Serializable) Locale.GERMAN))
            .getChildRef();
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(nodeRef1, ContentModel.ASPECT_LOCALIZED));
    assertEquals("Didn't set the explicit locale during create. ", Locale.GERMAN,
            nodeService.getProperty(nodeRef1, ContentModel.PROP_LOCALE));

    // Create a node using the thread's locale
    NodeRef nodeRef2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
            ContentModel.TYPE_CONTAINER).getChildRef();
    assertTrue("Every node must have sys:localized",
            nodeService.hasAspect(nodeRef2, ContentModel.ASPECT_LOCALIZED));
    assertEquals("Didn't set the locale during create. ", Locale.CANADA_FRENCH,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Switch Locale and modify ml:text property
    I18NUtil.setLocale(Locale.CHINESE);
    nodeService.setProperty(nodeRef2, ContentModel.PROP_DESCRIPTION, "Chinese description");
    I18NUtil.setLocale(Locale.FRENCH);
    nodeService.setProperty(nodeRef2, ContentModel.PROP_DESCRIPTION, "French description");

    // Expect that we have MLText (if we are ML aware)
    boolean wasMLAware = MLPropertyInterceptor.setMLAware(true);
    try {
        MLText checkDescription = (MLText) nodeService.getProperty(nodeRef2, ContentModel.PROP_DESCRIPTION);
        assertEquals("Chinese description", checkDescription.getValue(Locale.CHINESE));
        assertEquals("French description", checkDescription.getValue(Locale.FRENCH));
    } finally {
        MLPropertyInterceptor.setMLAware(wasMLAware);
    }
    // But the node locale must not have changed
    assertEquals("Node modification should not affect node locale. ", Locale.CANADA_FRENCH,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Now explicitly set the node's locale
    nodeService.setProperty(nodeRef2, ContentModel.PROP_LOCALE, Locale.ITALY);
    assertEquals("Node locale must be settable. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
    // But mltext must be unchanged
    assertEquals("Canada-French must be closest to French. ", "French description",
            nodeService.getProperty(nodeRef2, ContentModel.PROP_DESCRIPTION));

    // Finally, ensure that setting Locale to 'null' is takes the node back to its original locale
    nodeService.setProperty(nodeRef2, ContentModel.PROP_LOCALE, null);
    assertEquals("Node locale set to 'null' does nothing. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
    nodeService.removeProperty(nodeRef2, ContentModel.PROP_LOCALE);
    assertEquals("Node locale removal does nothing. ", Locale.ITALY,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));

    // Mass-set the properties, changing the locale in the process
    Map<QName, Serializable> props = nodeService.getProperties(nodeRef2);
    props.put(ContentModel.PROP_LOCALE, Locale.GERMAN);
    nodeService.setProperties(nodeRef2, props);
    assertEquals("Node locale not set in setProperties(). ", Locale.GERMAN,
            nodeService.getProperty(nodeRef2, ContentModel.PROP_LOCALE));
}

From source file:fr.certu.chouette.command.Command.java

/**
 * @param beans// w  w w .j ava 2s  . co m
 * @param commandNumber
 * @param command
 * @return
 * @throws ChouetteException
 * @throws Exception
 */
public List<NeptuneIdentifiedObject> executeCommand(List<NeptuneIdentifiedObject> beans, int commandNumber,
        CommandArgument command) throws ChouetteException, Exception {
    String name = command.getName();
    Map<String, List<String>> parameters = command.getParameters();
    if (verbose) {
        traceCommand(commandNumber, name, parameters);
    }
    logger.info("Command " + commandNumber + " : " + name);
    for (String key : parameters.keySet()) {
        logger.info("    parameters " + key + " : " + Arrays.toString(parameters.get(key).toArray()));
    }

    if (name.equals("verbose")) {
        verbose = !(getBoolean(parameters, "off"));
        return beans;
    }
    if (name.equals("help")) {
        String cmd = getSimpleString(parameters, "cmd", "");
        if (cmd.length() > 0) {
            printCommandDetail(cmd);
        } else {
            printCommandSyntax(true);
        }
        return beans;
    }
    if (name.equals("lang")) {
        if (getBoolean(parameters, "en")) {
            locale = Locale.ENGLISH;
        } else if (getBoolean(parameters, "fr")) {
            locale = Locale.FRENCH;
        } else {
            System.out.println(locale);
        }
        return beans;
    }

    if (name.equals("checkObjectId")) {
        String fileName = getSimpleString(parameters, "sqlfile", "invalid.sql");
        boolean checkType = getBoolean(parameters, "checktype");
        String prefix = getSimpleString(parameters, "objectidprefix", null);
        checkObjectId.checkObjectId(fileName, checkType, prefix);
        return beans;
    }

    if (name.equals("propagateBarycentre")) {
        executePropagateBarycentre();
        return beans;
    }

    INeptuneManager<NeptuneIdentifiedObject> manager = getManager(parameters);
    long tdeb = System.currentTimeMillis();

    if (name.equals("get")) {
        beans = executeGet(manager, parameters);
    } else if (name.equals("new")) {
        beans = executeNew(manager, parameters);
    } else if (name.equals("set")) {
        if (beans == null || beans.isEmpty())
            throw new Exception("Command " + commandNumber
                    + ": Invalid command sequence : setAttribute must follow a reading command");
        executeSet(beans, parameters);
    } else if (name.equals("add")) {
        if (beans == null || beans.isEmpty())
            throw new Exception("Command " + commandNumber
                    + ": Invalid command sequence : setAttribute must follow a reading command");
        executeAdd(beans, parameters);
    } else if (name.equals("remove")) {
        if (beans == null || beans.isEmpty())
            throw new Exception("Command " + commandNumber
                    + ": Invalid command sequence : setAttribute must follow a reading command");
        executeRemove(beans, parameters);
    } else if (name.equals("save")) {
        if (beans == null || beans.isEmpty())
            throw new Exception("Command " + commandNumber
                    + ": Invalid command sequence : save must follow a reading command");
        executeSave(beans, manager, parameters);
    } else if (name.equals("delete")) {
        if (beans == null || beans.isEmpty()) {
            System.out.println("Command " + commandNumber + ": nothing to delete");
        } else {
            executeDelete(beans, manager, parameters);
        }
    } else if (name.equals("complete")) {
        if (beans == null || beans.isEmpty()) {
            System.out.println("Command " + commandNumber + ": nothing to complete");
        } else {
            executeComplete(beans, manager, parameters);
        }
    } else if (name.equals("getImportFormats")) {
        executeGetImportFormats(manager, parameters);
    } else if (name.equals("import")) {
        beans = executeImport(manager, parameters);
    }

    else if (name.equals("print")) {
        if (beans == null || beans.isEmpty())
            throw new Exception("Command " + commandNumber
                    + ": Invalid command sequence : print must follow a reading command");
        executePrint(beans, parameters);
    } else if (name.equals("validate")) {
        if (beans == null || beans.isEmpty())
            throw new Exception("Command " + commandNumber
                    + ": Invalid command sequence : validate must follow a reading command");
        executeValidate(beans, manager, parameters);
    } else if (name.equals("getExportFormats")) {
        executeGetExportFormats(manager, parameters);
    } else if (name.equals("export")) {
        if (beans == null || beans.isEmpty())
            throw new Exception("Command " + commandNumber
                    + ": Invalid command sequence : export must follow a reading command");
        executeExport(beans, manager, parameters);
    } else if (name.equals("getDeletionExportFormats")) {
        executeGetDeletionFormats(manager, parameters);
    } else if (name.equals("exportForDeletion")) {
        if (beans == null || beans.isEmpty())
            throw new Exception("Command " + commandNumber
                    + ": Invalid command sequence : export must follow a reading command");
        executeExportDeletion(beans, manager, parameters);
    } else if (name.equals("info")) {
        executeInfo(manager);
    } else if (name.equals("setValidationParameters")) {
        executeSetValidationParameters(parameters);
    } else if (name.equals("showValidationParameters")) {
        executeShowValidationParameters();
    } else if (name.equals("infoValidationParameters")) {
        executeInfoValidationParameters();
    } else {
        throw new Exception("Command " + commandNumber + ": unknown command :" + command.getName());
    }
    long tfin = System.currentTimeMillis();
    if (verbose) {
        System.out.println("command " + command.getName() + " executed in " + getTimeAsString(tfin - tdeb));
    }
    return beans;
}

From source file:org.xwiki.search.solr.internal.metadata.DocumentSolrMetadataExtractorTest.java

@Test
public void getDocumentThrowingException() throws Exception {
    DocumentReference frenchDocumentReference = new DocumentReference(this.documentReference, Locale.FRENCH);
    XWikiException thrown = new XWikiException(XWikiException.MODULE_XWIKI_STORE,
            XWikiException.ERROR_XWIKI_STORE_HIBERNATE_READING_DOC, "Unreadable document");
    when(this.xcontext.getWiki().getDocument(frenchDocumentReference, this.xcontext)).thenThrow(thrown);

    try {//  w ww .j  av a2s. c o  m
        this.mocker.getComponentUnderTest().getSolrDocument(frenchDocumentReference);
        fail("An exception was expected.");
    } catch (SolrIndexerException ex) {
        assertEquals("Failed to get input Solr document for entity '" + frenchDocumentReference + "'",
                ex.getMessage());
        assertSame(thrown, ex.getCause());
    }
}

From source file:fr.certu.chouette.gui.command.Command.java

/**
 * @param beans//from  w  w  w.ja  va2 s . com
 * @param commandNumber
 * @param command
 * @return
 * @throws ChouetteException
 * @throws Exception
 */
public void executeCommand(int commandNumber, CommandArgument command) throws Exception {
    String name = command.getName();
    Map<String, List<String>> parameters = command.getParameters();
    if (verbose) {
        traceCommand(commandNumber, name, parameters);
    }
    logger.info("Command " + commandNumber + " : " + name);
    for (String key : parameters.keySet()) {
        logger.info("    parameters " + key + " : " + Arrays.toString(parameters.get(key).toArray()));
    }

    if (name.equals("verbose")) {
        verbose = !(getBoolean(parameters, "off"));
        return;
    }
    if (name.equals("help")) {
        String cmd = getSimpleString(parameters, "cmd", "");
        if (cmd.length() > 0) {
            printCommandDetail(cmd);
        } else {
            printCommandSyntax(true);
        }
        return;
    }
    if (name.equals("lang")) {
        if (getBoolean(parameters, "en")) {
            locale = Locale.ENGLISH;
        } else if (getBoolean(parameters, "fr")) {
            locale = Locale.FRENCH;
        } else {
            System.out.println(locale);
        }
        return;
    }

    INeptuneManager<NeptuneIdentifiedObject> manager = getManager(parameters);
    long tdeb = System.currentTimeMillis();

    if (name.equals("import")) {
        int code = executeImport(manager, parameters);
        if (code > 0) {
            logger.error("   command failed with code " + code);
            System.exit(code);
        }
    } else if (name.equals("validate")) {
        int code = executeValidate(manager, parameters);
        if (code > 0) {
            logger.error("   command failed with code " + code);
            System.exit(code);
        }
    } else if (name.equals("export")) {
        int code = executeExport(manager, parameters);
        if (code > 0) {
            logger.error("   command failed with code " + code);
            System.exit(code);
        }
    } else if (name.equals("exportForDeletion")) {
        int code = executeExportDeletion(manager, parameters);
        if (code > 0) {
            logger.error("   command failed with code " + code);
            System.exit(code);
        }
    } else {
        throw new Exception("Command " + commandNumber + ": unknown command :" + command.getName());
    }
    long tfin = System.currentTimeMillis();
    if (verbose) {
        System.out.println("command " + command.getName() + " executed in " + getTimeAsString(tfin - tdeb));
    }
    logger.info("    command " + command.getName() + " executed in " + getTimeAsString(tfin - tdeb));
    return;
}

From source file:com.doculibre.constellio.lucene.BaseLuceneIndexHelper.java

public synchronized final void rebuild() {
    deleteAll();// w  w w .  j av a2s  . com
    try {
        Directory directory = FSDirectory.open(indexDir);
        Analyzer analyzer = analyzerProvider.getAnalyzer(Locale.FRENCH);
        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_44, analyzer);
        IndexWriter indexWriter = new IndexWriter(directory, config);
        List<T> objects = getAll();
        for (T object : objects) {
            add(object, indexWriter);
        }
        //            indexWriter.optimize();
        indexWriter.close();
        directory.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.geoserver.wms.web.data.StyleEditPageTest.java

@Test
public void testGenerateTemplateFrenchLocale() throws Exception {
    final Session session = tester.getSession();
    try {//from   ww  w  .  java  2  s . c om
        session.clear();
        session.setLocale(Locale.FRENCH);

        StyleEditPage edit = new StyleEditPage(buildingsStyle);
        tester.startPage(edit);
        // print(tester.getLastRenderedPage(), true, true);

        // test the copy style link
        tester.newFormTester("styleForm").select("context:panel:templates", 1);
        tester.executeAjaxEvent("styleForm:context:panel:templates", "onchange");
        Component generateLink = tester.getComponentFromLastRenderedPage("styleForm:context:panel:generate");
        tester.executeAjaxEvent(generateLink, "onClick");
        // check single quote in the message has been escaped
        assertTrue(tester.getLastResponseAsString().contains("l\\'diteur"));
    } finally {
        session.clear();
        session.setLocale(Locale.getDefault());
    }
}

From source file:com.squarespace.template.plugins.CoreFormattersTest.java

@Test
public void testDateLocale() throws CodeException {
    String tzNewYork = "America/New_York";
    String format = "%B %d";

    assertEquals(formatDate(format, MAY_13_2013_010000_UTC, tzNewYork, Locale.GERMANY), "Mai 12");
    assertEquals(formatDate(format, MAY_13_2013_010000_UTC, tzNewYork, Locale.FRENCH), "mai 12");
    assertEquals(formatDate(format, MAY_13_2013_010000_UTC, tzNewYork, new Locale("es", "MX")), "mayo 12");
    assertEquals(formatDate(format, MAY_13_2013_010000_UTC, tzNewYork, new Locale("es", "SP")), "mayo 12");

    format = "%A";
    assertEquals(formatDate(format, NOV_15_2013_123030_UTC, tzNewYork, Locale.GERMANY), "Freitag");
    assertEquals(formatDate(format, NOV_15_2013_123030_UTC, tzNewYork, new Locale("es", "MX")), "viernes");
}