Example usage for java.util Locale FRANCE

List of usage examples for java.util Locale FRANCE

Introduction

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

Prototype

Locale FRANCE

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

Click Source Link

Document

Useful constant for country.

Usage

From source file:org.talend.dataquality.statistics.datetime.CustomDateTimePatternManagerTest.java

@Test
public void testDateWithLocaleDE() {
    // simulate a JVM
    Locale.setDefault(Locale.GERMANY);

    final List<String> pattern = Collections.<String>singletonList("MMMM d ?? yyyy");
    final String[] dates = new String[] { "January 9 ?? 1970", // EN
            "janvier 9 ?? 1970", // FR
            "Januar 9 ?? 1970", // DE
            " 9 ?? 1970", // CN
    };/*  w  w w. ja  v  a  2 s  .c o m*/
    final boolean[] EXPECTED_IS_DATE_DEFAULT = new boolean[] { true, false, false, false };
    final boolean[] EXPECTED_IS_DATE_US = new boolean[] { true, false, false, false };
    final boolean[] EXPECTED_IS_DATE_FR = new boolean[] { true, true, false, false };
    final boolean[] EXPECTED_IS_DATE_DE = new boolean[] { true, false, true, false };
    final boolean[] EXPECTED_IS_DATE_CN = new boolean[] { true, false, false, true };
    // final String[] EXPECTED_PATTERN_STRING = new String[] { "", };

    StringBuilder sb = new StringBuilder("\n");
    sb.append("-------------- JVM Locale: " + Locale.getDefault().toString() + " ------\n");
    sb.append("Input \\ UserLocale\tN/A\tEN\tFR\tDE\tCN\n");
    for (int i = 0; i < dates.length; i++) {
        sb.append(dates[i]).append("   \t");
        sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern)).append("\t");
        sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.US)).append("\t");
        sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.FRANCE)).append("\t");
        sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.GERMANY)).append("\t");
        sb.append(CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.CHINA)).append("\t");
        sb.append("\n");

        assertEquals(EXPECTED_IS_DATE_DEFAULT[i], CustomDateTimePatternManager.isDate(dates[i], pattern));
        assertEquals(EXPECTED_IS_DATE_US[i], CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.US));
        assertEquals(EXPECTED_IS_DATE_FR[i],
                CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.FRANCE));
        assertEquals(EXPECTED_IS_DATE_DE[i],
                CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.GERMANY));
        assertEquals(EXPECTED_IS_DATE_CN[i],
                CustomDateTimePatternManager.isDate(dates[i], pattern, Locale.CHINA));
    }

    LOGGER.info(sb.toString());
}

From source file:fr.bde_eseo.eseomega.plans.PlansActivity.java

/**
 * Restrict data in array (search mode)//from  ww w.j  a  va2 s  .  c o m
 */
private void searchInArray(String search) {
    String sLow = search.toLowerCase(Locale.FRANCE);
    roomItemsDisplay.clear();
    int size = roomItems.size();
    for (int i = 0; i < size; i++) {
        RoomItem ci = roomItems.get(i);
        if (
        // Recherche sur le nom
        ci.getName().toLowerCase(Locale.FRANCE).contains(sLow) ||
        // Recherche sur la salle
                ci.getNumber().toLowerCase(Locale.FRANCE).contains(sLow) ||
                // Recherche sur les infos
                ci.getInfo().toLowerCase(Locale.FRANCE).contains(sLow)

        ) {
            roomItemsDisplay.add(ci);
        }
    }
}

From source file:eu.eubrazilcc.lvl.storage.LeishmaniaCollectionTest.java

@Test
public void test() {
    System.out.println("LeishmaniaCollectionTest.test()");
    try {/*from   w ww . j a va  2s  .co  m*/
        // create sequence         
        final GBSeq sequence = GBSEQ_XML_FACTORY.createGBSeq().withGBSeqPrimaryAccession("ABC12345678")
                .withGBSeqAccessionVersion("3.0")
                .withGBSeqOtherSeqids(GBSEQ_XML_FACTORY.createGBSeqOtherSeqids().withGBSeqid(
                        GBSEQ_XML_FACTORY.createGBSeqid().withvalue(Integer.toString(Integer.MAX_VALUE))))
                .withGBSeqOrganism("organism").withGBSeqLength("850");

        // insert
        final Leishmania leishmania = Leishmania.builder().dataSource(GENBANK).accession("ABC12345678")
                .version("3.0").gi(Integer.MAX_VALUE).definition("definition").organism("organism").length(850)
                .countryFeature("Spain: Murcia")
                .location(Point.builder()
                        .coordinates(LngLatAlt.builder().coordinates(-122.913837d, 38.081473d).build()).build())
                .locale(new Locale("es", "ES")).sequence(sequence).build();
        final SequenceKey leishmaniaKey = SequenceKey.builder().dataSource(leishmania.getDataSource())
                .accession(leishmania.getAccession()).build();
        LEISHMANIA_DAO.insert(leishmania);

        // find
        Leishmania leishmania2 = LEISHMANIA_DAO.find(leishmaniaKey);
        assertThat("leishmania is not null", leishmania2, notNullValue());
        assertThat("leishmania coincides with original", leishmania2, equalTo(leishmania));
        assertThat("leishmania contains original sequence", leishmania2.getSequence(), notNullValue());
        System.out.println(leishmania2.toString());

        // find by GenBank GenInfo Identifier
        leishmania2 = LEISHMANIA_DAO.find(
                SequenceGiKey.builder().dataSource(leishmania.getDataSource()).gi(leishmania.getGi()).build());
        assertThat("leishmania is not null", leishmania2, notNullValue());
        assertThat("leishmania coincides with original", leishmania2, equalTo(leishmania));
        System.out.println(leishmania2.toString());

        // duplicates are not allowed
        try {
            LEISHMANIA_DAO.insert(leishmania2);
            fail("Duplicate leishmanias are not allowed");
        } catch (Exception e) {
            System.out.println("Exception caught while trying to insert a duplicate leishmania");
        }

        // insert element with hard link
        final GBSeq sequence1 = GBSEQ_XML_FACTORY.createGBSeq().withGBSeqPrimaryAccession("EFHJ90864")
                .withGBSeqAccessionVersion("3.0")
                .withGBSeqOtherSeqids(GBSEQ_XML_FACTORY.createGBSeqOtherSeqids().withGBSeqid(
                        GBSEQ_XML_FACTORY.createGBSeqid().withvalue(Integer.toString(Integer.MAX_VALUE - 1))))
                .withGBSeqOrganism("organism").withGBSeqLength("200");
        final Leishmania leishmania1 = Leishmania.builder()
                .links(newArrayList(Link.fromUri("http://example.com/leishmania/gb:EFHJ90864").rel(SELF)
                        .type(APPLICATION_JSON).build()))
                .dataSource(GENBANK).accession("EFHJ90864").version("3.0").gi(Integer.MAX_VALUE - 1)
                .definition("definition").organism("organism").length(200).countryFeature("Spain: Murcia")
                .location(Point.builder()
                        .coordinates(LngLatAlt.builder().coordinates(-122.913837d, 38.081473d).build()).build())
                .locale(new Locale("es", "ES")).pmids(newHashSet("1234R", "AV99O0")).sequence(sequence1)
                .build();
        final SequenceKey leishmaniaKey1 = SequenceKey.builder().dataSource(leishmania1.getDataSource())
                .accession(leishmania1.getAccession()).build();

        LEISHMANIA_DAO.insert(leishmania1);
        leishmania1.setLinks(null);

        // find element after insertion (hard link should be removed)
        leishmania2 = LEISHMANIA_DAO.find(leishmaniaKey1);
        assertThat("leishmania inserted with hard link is not null", leishmania2, notNullValue());
        assertThat("leishmania inserted with hard link coincides with expected", leishmania2,
                equalTo(leishmania1));
        System.out.println(leishmania2.toString());

        LEISHMANIA_DAO.delete(leishmaniaKey1);

        // update
        leishmania.setVersion("4.0");
        LEISHMANIA_DAO.update(leishmania);

        // find after update
        leishmania2 = LEISHMANIA_DAO.find(leishmaniaKey);
        assertThat("leishmania is not null", leishmania2, notNullValue());
        assertThat("leishmania coincides with original", leishmania2, equalTo(leishmania));
        System.out.println(leishmania2.toString());

        // search leishmania near a point and within a maximum distance
        List<Leishmania> leishmanias = LEISHMANIA_DAO.getNear(
                Point.builder().coordinates(LngLatAlt.builder().coordinates(-122.90d, 38.08d).build()).build(),
                10000.0d);
        assertThat("leishmania is not null", leishmanias, notNullValue());
        assertThat("ids is not empty", !leishmanias.isEmpty());

        // search leishmania within an area
        leishmanias = LEISHMANIA_DAO.geoWithin(Polygon.builder()
                .exteriorRing(LngLatAlt.builder().coordinates(-140.0d, 30.0d).build(),
                        LngLatAlt.builder().coordinates(-110.0d, 30.0d).build(),
                        LngLatAlt.builder().coordinates(-110.0d, 50.0d).build(),
                        LngLatAlt.builder().coordinates(-140.0d, 30.0d).build())
                .build());
        assertThat("leishmania is not null", leishmanias, notNullValue());
        assertThat("ids is not empty", !leishmanias.isEmpty());

        // remove
        LEISHMANIA_DAO.delete(leishmaniaKey);
        final long numRecords = LEISHMANIA_DAO.count();
        assertThat("number of leishmania stored in the database coincides with expected", numRecords,
                equalTo(0l));

        // create a large dataset to test complex operations
        final Random random = new Random();
        final String[] countries = { "Kenya", "Senegal", "Pakistan", "Italy", "Greece", "France", "Tunisia",
                "Ethiopia", "Egypt", "Spain", "Lebanon", "Oman", "Syrian Arab Republic", "Cyprus", "Portugal",
                "Morocco", "Turkey", "Malta", "Madagascar", "New Caledonia", "Brazil" };
        final List<String> ids = newArrayList();
        final int numItems = 11;
        for (int i = 0; i < numItems; i++) {
            final GBSeq sequence3 = GBSEQ_XML_FACTORY.createGBSeq()
                    .withGBSeqPrimaryAccession(Integer.toString(i)).withGBSeqAccessionVersion("1." + i)
                    .withGBSeqOtherSeqids(GBSEQ_XML_FACTORY.createGBSeqOtherSeqids()
                            .withGBSeqid(GBSEQ_XML_FACTORY.createGBSeqid().withvalue(Integer.toString(i))))
                    .withGBSeqOrganism("organism").withGBSeqLength(Integer.toString(i * 123));
            final Set<String> gene = newHashSet();
            switch (i) {
            case 0:
                gene.add("abc");
                gene.add("def");
                break;
            case 1:
                gene.add("def");
                break;
            case 2:
                gene.add("abc");
                break;
            case 3:
                gene.add("abc");
                break;
            default:
                break;
            }
            final Point location = i % 2 == 0 ? Point.builder()
                    .coordinates(LngLatAlt.builder().coordinates(-122.913837d, 38.081473d).build()).build()
                    : null;
            final Leishmania leishmania3 = Leishmania.builder().dataSource(GENBANK)
                    .accession(Integer.toString(i)).version("1." + i).definition("This is an example").gi(i)
                    .length(i * 123).countryFeature(countries[random.nextInt(countries.length)])
                    .locale(i % 2 != 0 ? Locale.ENGLISH : Locale.FRANCE).location(location).gene(gene)
                    .sequence(sequence3).build();
            ids.add(leishmania3.getAccession());
            LEISHMANIA_DAO.insert(leishmania3);
        }

        // pagination
        final int size = 3;
        int start = 0;
        leishmanias = null;
        final MutableLong count = new MutableLong(0l);
        do {
            leishmanias = LEISHMANIA_DAO.list(start, size, null, null, null, count);
            if (leishmanias.size() != 0) {
                System.out.println("Paging: first item " + start + ", showing " + leishmanias.size() + " of "
                        + count.getValue() + " items");
            }
            start += leishmanias.size();
        } while (!leishmanias.isEmpty());

        // collection statistics
        final Map<String, List<SimpleStat>> stats = LEISHMANIA_DAO.collectionStats();
        assertThat("leishmania collection stats is not null", stats, notNullValue());
        // uncomment for additional output
        for (final Map.Entry<String, List<SimpleStat>> entry : stats.entrySet()) {
            System.err.println(" >> Field: " + entry.getKey());
            for (final SimpleStat stat : entry.getValue()) {
                System.err.println("   >> " + stat);
            }
        }

        // filter: keyword matching search         
        ImmutableMap<String, String> filter = of("source", GENBANK);
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered leishmania is not null", leishmanias, notNullValue());
        assertThat("number of filtered leishmania coincides with expected", leishmanias.size(),
                equalTo(numItems));

        // filter: keyword matching search
        filter = of("accession", Integer.toString(random.nextInt(numItems)));
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered leishmania is not null", leishmanias, notNullValue());
        assertThat("number of filtered leishmania coincides with expected", leishmanias.size(), equalTo(1));

        // filter: keyword matching search
        filter = of("locale", Locale.ENGLISH.toString());
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered leishmania is not null", leishmanias, notNullValue());
        assertThat("number of filtered leishmania coincides with expected", leishmanias.size(),
                equalTo(numItems / 2));

        // filter: combined keyword matching search
        filter = of("source", GENBANK, "accession", Integer.toString(random.nextInt(numItems)));
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered leishmania is not null", leishmanias, notNullValue());
        assertThat("number of filtered leishmania coincides with expected", leishmanias.size(), equalTo(1));

        // filter: full-text search
        filter = of("text", "an example");
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered leishmania is not null", leishmanias, notNullValue());
        assertThat("number of filtered leishmania coincides with expected", leishmanias.size(),
                equalTo(numItems));

        // filter: combined full-text search with keyword matching search
        filter = of("source", GENBANK, "locale", Locale.ENGLISH.toString(), "text", "example");
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered leishmania is not null", leishmanias, notNullValue());
        assertThat("number of filtered leishmania coincides with expected", leishmanias.size(),
                equalTo(numItems / 2));

        // invalid filter
        filter = of("filter_name", "filter_content");
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered leishmania is not null", leishmanias, notNullValue());
        assertThat("number of filtered leishmania coincides with expected", leishmanias.size(), equalTo(0));

        // sorting by accession in ascending order
        Sorting sorting = Sorting.builder().field("accession").order(Order.ASC).build();
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, null, sorting, null, null);
        assertThat("sorted leishmania is not null", leishmanias, notNullValue());
        assertThat("number of sorted leishmania coincides with expected", leishmanias.size(),
                equalTo(numItems));
        String last = "-1";
        for (final Leishmania seq : leishmanias) {
            assertThat("leishmania are properly sorted", seq.getAccession().compareTo(last) > 0);
            last = seq.getAccession();
        }

        // sorting by country in descending order
        sorting = Sorting.builder().field("countryFeature").order(Order.DESC).build();
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, null, sorting, null, null);
        assertThat("sorted leishmania is not null", leishmanias, notNullValue());
        assertThat("number of sorted leishmania coincides with expected", leishmanias.size(),
                equalTo(numItems));
        last = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
        for (final Leishmania seq : leishmanias) {
            assertThat("leishmania are properly sorted", seq.getCountryFeature().compareTo(last) <= 0);
            last = seq.getCountryFeature();
        }

        // invalid sort
        sorting = Sorting.builder().field("sort_name").order(Order.DESC).build();
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, null, sorting, null, null);
        assertThat("sorted leishmania is not null", leishmanias, notNullValue());
        assertThat("number of sorted leishmania coincides with expected", leishmanias.size(), equalTo(0));

        // projection
        leishmanias = LEISHMANIA_DAO.list(0, Integer.MAX_VALUE, null, null,
                ImmutableMap.of(ORIGINAL_SEQUENCE_KEY, false), null);
        assertThat("projected leishmania is not null", leishmanias, notNullValue());
        assertThat("number of projected leishmania coincides with expected", leishmanias.size(),
                equalTo(numItems));
        assertThat("sequence was filtered from database response",
                leishmanias.get((new Random()).nextInt(numItems)).getSequence(), nullValue());

        // clean-up and display database statistics
        for (final String id2 : ids) {
            LEISHMANIA_DAO.delete(SequenceKey.builder().dataSource(GENBANK).accession(id2).build());
        }
        LEISHMANIA_DAO.stats(System.out);
    } catch (Exception e) {
        e.printStackTrace(System.err);
        fail("LeishmaniaCollectionTest.test() failed: " + e.getMessage());
    } finally {
        System.out.println("LeishmaniaCollectionTest.test() has finished");
    }
}

From source file:eu.eubrazilcc.lvl.storage.SandflyCollectionTest.java

@Test
public void test() {
    System.out.println("SandflyCollectionTest.test()");
    try {//from   w w  w . j  a  v a 2  s.  co m
        // create sequence         
        final GBSeq sequence = GBSEQ_XML_FACTORY.createGBSeq().withGBSeqPrimaryAccession("ABC12345678")
                .withGBSeqAccessionVersion("3.0")
                .withGBSeqOtherSeqids(GBSEQ_XML_FACTORY.createGBSeqOtherSeqids().withGBSeqid(
                        GBSEQ_XML_FACTORY.createGBSeqid().withvalue(Integer.toString(Integer.MAX_VALUE))))
                .withGBSeqOrganism("organism").withGBSeqLength("850");

        // insert
        final Sandfly sandfly = Sandfly.builder().dataSource(GENBANK).accession("ABC12345678").version("3.0")
                .gi(Integer.MAX_VALUE).definition("definition").organism("organism").gene(newHashSet("COI"))
                .length(850) // use a large value here to enable length filters, additional entries will be created in the interval 100-111
                .countryFeature("Spain: Murcia")
                .location(Point.builder()
                        .coordinates(LngLatAlt.builder().coordinates(-122.913837d, 38.081473d).build()).build())
                .locale(new Locale("es", "ES")).sequence(sequence).build();
        final SequenceKey sandflyKey = SequenceKey.builder().dataSource(sandfly.getDataSource())
                .accession(sandfly.getAccession()).build();
        SANDFLY_DAO.insert(sandfly);

        // find
        Sandfly sandfly2 = SANDFLY_DAO.find(sandflyKey);
        assertThat("sandfly is not null", sandfly2, notNullValue());
        assertThat("sandfly coincides with original", sandfly2, equalTo(sandfly));
        assertThat("sandfly contains original sequence", sandfly2.getSequence(), notNullValue());
        System.out.println(sandfly2.toString());

        // find by GenBank GenInfo Identifier
        sandfly2 = SANDFLY_DAO
                .find(SequenceGiKey.builder().dataSource(sandfly.getDataSource()).gi(sandfly.getGi()).build());
        assertThat("sandfly is not null", sandfly2, notNullValue());
        assertThat("sandfly coincides with original", sandfly2, equalTo(sandfly));
        System.out.println(sandfly2.toString());

        // duplicates are not allowed
        try {
            SANDFLY_DAO.insert(sandfly2);
            fail("Duplicate sandflies are not allowed");
        } catch (Exception e) {
            System.out.println("Exception caught while trying to insert a duplicate sandfly");
        }

        // insert element with hard link
        final GBSeq sequence1 = GBSEQ_XML_FACTORY.createGBSeq().withGBSeqPrimaryAccession("EFHJ90864")
                .withGBSeqAccessionVersion("3.0")
                .withGBSeqOtherSeqids(GBSEQ_XML_FACTORY.createGBSeqOtherSeqids().withGBSeqid(
                        GBSEQ_XML_FACTORY.createGBSeqid().withvalue(Integer.toString(Integer.MAX_VALUE - 1))))
                .withGBSeqOrganism("organism");
        final Sandfly sandfly1 = Sandfly.builder()
                .links(newArrayList(Link.fromUri("http://example.com/sandfly/gb:EFHJ90864").rel(SELF)
                        .type(APPLICATION_JSON).build()))
                .dataSource(GENBANK).accession("EFHJ90864").version("3.0").gi(Integer.MAX_VALUE - 1)
                .definition("definition").organism("organism").countryFeature("Spain: Murcia")
                .location(Point.builder()
                        .coordinates(LngLatAlt.builder().coordinates(-122.913837d, 38.081473d).build()).build())
                .locale(new Locale("es", "ES")).pmids(newHashSet("1234R", "AV99O0")).sequence(sequence1)
                .build();
        final SequenceKey sandflyKey1 = SequenceKey.builder().dataSource(sandfly1.getDataSource())
                .accession(sandfly1.getAccession()).build();

        SANDFLY_DAO.insert(sandfly1);
        sandfly1.setLinks(null);

        // find element after insertion (hard link should be removed)
        sandfly2 = SANDFLY_DAO.find(sandflyKey1);
        assertThat("sandfly inserted with hard link is not null", sandfly2, notNullValue());
        assertThat("sandfly inserted with hard link coincides with expected", sandfly2, equalTo(sandfly1));
        System.out.println(sandfly2.toString());

        SANDFLY_DAO.delete(sandflyKey1);

        // update
        sandfly.setVersion("4.0");
        SANDFLY_DAO.update(sandfly);

        // find after update
        sandfly2 = SANDFLY_DAO.find(sandflyKey);
        assertThat("sandfly is not null", sandfly2, notNullValue());
        assertThat("sandfly coincides with original", sandfly2, equalTo(sandfly));
        System.out.println(sandfly2.toString());

        // search sandfly near a point and within a maximum distance
        List<Sandfly> sandflies = SANDFLY_DAO.getNear(
                Point.builder().coordinates(LngLatAlt.builder().coordinates(-122.90d, 38.08d).build()).build(),
                10000.0d);
        assertThat("sandfly is not null", sandflies, notNullValue());
        assertThat("ids is not empty", !sandflies.isEmpty());

        // search sandfly within an area
        sandflies = SANDFLY_DAO.geoWithin(Polygon.builder()
                .exteriorRing(LngLatAlt.builder().coordinates(-140.0d, 30.0d).build(),
                        LngLatAlt.builder().coordinates(-110.0d, 30.0d).build(),
                        LngLatAlt.builder().coordinates(-110.0d, 50.0d).build(),
                        LngLatAlt.builder().coordinates(-140.0d, 30.0d).build())
                .build());
        assertThat("sandfly is not null", sandflies, notNullValue());
        assertThat("ids is not empty", !sandflies.isEmpty());

        // remove
        SANDFLY_DAO.delete(sandflyKey);
        final long numRecords = SANDFLY_DAO.count();
        assertThat("number of sandfly stored in the database coincides with expected", numRecords, equalTo(0l));

        // create a large dataset to test complex operations
        final Random random = new Random();
        final String[] countries = { "Kenya", "Senegal", "Pakistan", "Italy", "Greece", "France", "Tunisia",
                "Ethiopia", "Egypt", "Spain", "Lebanon", "Oman", "Syrian Arab Republic", "Cyprus", "Portugal",
                "Morocco", "Turkey", "Malta", "Madagascar", "New Caledonia", "Brazil" };
        final List<String> ids = newArrayList();
        final int numItems = 11, initialLength = 100;
        for (int i = 0; i < numItems; i++) {
            final GBSeq sequence3 = GBSEQ_XML_FACTORY.createGBSeq()
                    .withGBSeqPrimaryAccession(Integer.toString(i)).withGBSeqAccessionVersion("3.0")
                    .withGBSeqOtherSeqids(GBSEQ_XML_FACTORY.createGBSeqOtherSeqids()
                            .withGBSeqid(GBSEQ_XML_FACTORY.createGBSeqid().withvalue(Integer.toString(i))))
                    .withGBSeqOrganism(i < numItems / 2 ? "papatasi" : "lutzomyia")
                    .withGBSeqLength(Integer.toString(initialLength + i));
            final Set<String> gene = newHashSet();
            switch (i) {
            case 0:
                gene.add("abc");
                gene.add("def");
                break;
            case 1:
                gene.add("def");
                break;
            case 2:
                gene.add("abc");
                break;
            case 3:
                gene.add("abc");
                break;
            default:
                break;
            }
            final Point location = i % 2 == 0 ? Point.builder()
                    .coordinates(LngLatAlt.builder().coordinates(-122.913837d, 38.081473d).build()).build()
                    : null;
            final Sandfly sandfly3 = Sandfly.builder().dataSource(GENBANK).accession(Integer.toString(i))
                    .definition("This is an example").gi(i)
                    .organism(i < numItems / 2 ? "papatasi" : "lutzomyia").length(initialLength + i)
                    .countryFeature(countries[random.nextInt(countries.length)])
                    .locale(i % 2 != 0 ? Locale.ENGLISH : Locale.FRANCE).location(location).gene(gene)
                    .sequence(sequence3).build();
            ids.add(sandfly3.getAccession());
            SANDFLY_DAO.insert(sandfly3);
        }

        // pagination
        final int size = 3;
        int start = 0;
        sandflies = null;
        final MutableLong count = new MutableLong(0l);
        do {
            sandflies = SANDFLY_DAO.list(start, size, null, null, null, count);
            if (sandflies.size() != 0) {
                System.out.println("Paging: first item " + start + ", showing " + sandflies.size() + " of "
                        + count.getValue() + " items");
            }
            start += sandflies.size();
        } while (!sandflies.isEmpty());

        // collection statistics
        final Map<String, List<SimpleStat>> stats = SANDFLY_DAO.collectionStats();
        assertThat("sandflies collection stats is not null", stats, notNullValue());
        // uncomment for additional output
        for (final Map.Entry<String, List<SimpleStat>> entry : stats.entrySet()) {
            System.err.println(" >> Field: " + entry.getKey());
            for (final SimpleStat stat : entry.getValue()) {
                System.err.println("   >> " + stat);
            }
        }

        // filter: keyword matching search         
        ImmutableMap<String, String> filter = of("source", GENBANK);
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(), equalTo(numItems));

        // filter: keyword matching search
        filter = of("accession", Integer.toString(random.nextInt(numItems)));
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(), equalTo(1));

        // filter: keyword matching search
        filter = of("locale", Locale.ENGLISH.toString());
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(),
                equalTo(numItems / 2));

        // filter: combined keyword matching search
        filter = of("source", GENBANK, "accession", Integer.toString(random.nextInt(numItems)));
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(), equalTo(1));

        // filter: full-text search
        filter = of("text", "an example");
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(), equalTo(numItems));

        // filter: combined full-text search with keyword matching search
        filter = of("source", GENBANK, "locale", Locale.ENGLISH.toString(), "text", "example");
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(),
                equalTo(numItems / 2));

        // invalid filter
        filter = of("filter_name", "filter_content");
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(), equalTo(0));

        // filter with numeric comparison operator (valid lengths: 100-111)
        filter = of("length", Integer.toString(initialLength));
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(), equalTo(1));

        filter = of("length", ">" + initialLength);
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(),
                equalTo(numItems - 1));

        filter = of("length", "<=" + initialLength + numItems);
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(), equalTo(numItems));

        // filter using a duplicated field
        filter = of("organism", "papatasi", "organism", "lutzomyia");
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, filter, null, null, null);
        assertThat("filtered sandfly is not null", sandflies, notNullValue());
        assertThat("number of filtered sandfly coincides with expected", sandflies.size(), equalTo(numItems));

        // TODO : db.sandflies.find({"$or":[{"sandfly.accession":"AB288341"}, {"sandfly.accession":"AB174770"}]}).count()

        // sorting by accession in ascending order
        Sorting sorting = Sorting.builder().field("accession").order(Order.ASC).build();
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, null, sorting, null, null);
        assertThat("sorted sandfly is not null", sandflies, notNullValue());
        assertThat("number of sorted sandfly coincides with expected", sandflies.size(), equalTo(numItems));
        String last = "-1";
        for (final Sandfly seq : sandflies) {
            assertThat("sandfly are properly sorted", seq.getAccession().compareTo(last) > 0);
            last = seq.getAccession();
        }

        // sorting by country in descending order
        sorting = Sorting.builder().field("countryFeature").order(Order.DESC).build();
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, null, sorting, null, null);
        assertThat("sorted sandfly is not null", sandflies, notNullValue());
        assertThat("number of sorted sandfly coincides with expected", sandflies.size(), equalTo(numItems));
        last = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
        for (final Sandfly seq : sandflies) {
            assertThat("sandfly are properly sorted", seq.getCountryFeature().compareTo(last) <= 0);
            last = seq.getCountryFeature();
        }

        // invalid sort
        sorting = Sorting.builder().field("sort_name").order(Order.DESC).build();
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, null, sorting, null, null);
        assertThat("sorted sandfly is not null", sandflies, notNullValue());
        assertThat("number of sorted sandfly coincides with expected", sandflies.size(), equalTo(0));

        // projection
        sandflies = SANDFLY_DAO.list(0, Integer.MAX_VALUE, null, null,
                ImmutableMap.of(ORIGINAL_SEQUENCE_KEY, false), null);
        assertThat("projected sandfly is not null", sandflies, notNullValue());
        assertThat("number of projected sandfly coincides with expected", sandflies.size(), equalTo(numItems));
        assertThat("sequence was filtered from database response",
                sandflies.get((new Random()).nextInt(numItems)).getSequence(), nullValue());

        // clean-up and display database statistics
        for (final String id2 : ids) {
            SANDFLY_DAO.delete(SequenceKey.builder().dataSource(GENBANK).accession(id2).build());
        }
        SANDFLY_DAO.stats(System.out);
    } catch (Exception e) {
        e.printStackTrace(System.err);
        fail("SandflyCollectionTest.test() failed: " + e.getMessage());
    } finally {
        System.out.println("SandflyCollectionTest.test() has finished");
    }
}

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

/** Test.
 * @throws ServletException e/*ww  w .j  ava 2  s  .  co m*/
 * @throws IOException e */
@Test
public void testDoFilterWithSession() throws ServletException, IOException {
    final HttpServletRequest request = createNiceMock(HttpServletRequest.class);
    final HttpSession session = createNiceMock(HttpSession.class);
    expect(request.getSession(false)).andReturn(session);
    expect(request.getLocale()).andReturn(Locale.FRANCE);
    replay(session);
    doFilter(request);
    verify(session);
}

From source file:xml.sk.Parser.java

/**
 * Parses AgeSk.xml.//  ww w  .j  av a  2s . c o m
 *
 * @param manager age manager to store data
 * @throws javax.xml.parsers.ParserConfigurationException
 * @throws org.xml.sax.SAXException
 * @throws java.io.IOException
 */
public void parseAgeSk(AgeManagerImpl manager) throws ParserConfigurationException, SAXException, IOException,
        XPathExpressionException, ParseException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse("src/main/java/xml/sk/AgeSk.xml");

    NodeList educationList = doc.getElementsByTagName("PRAC_strMzdyVek");
    for (int i = 0; i < educationList.getLength(); i++) {
        Element educationNode = (Element) educationList.item(i);

        if (!"EUR".equals(educationNode.getElementsByTagName("MJ").item(0).getTextContent()))
            continue;

        String ageStr = educationNode.getElementsByTagName("UKAZ2").item(0).getTextContent();
        Scanner in = new Scanner(ageStr).useDelimiter("[^0-9]+");
        Integer age1 = in.nextInt();
        Integer age2 = null;
        if (in.hasNext())
            age2 = in.nextInt();

        String sex = educationNode.getElementsByTagName("UKAZ1").item(0).getTextContent();
        String[] splited = sex.split(" ");
        sex = splited[splited.length - 1];

        NodeList years = educationNode.getChildNodes();

        for (int j = 0; j < years.getLength(); j++) {
            if (years.item(j).getNodeType() == Node.TEXT_NODE) {
                continue;
            }
            Element yearNode = (Element) years.item(j);
            if ("MJ".equals(yearNode.getNodeName()) || "UKAZ".equals(yearNode.getNodeName().substring(0, 4)))
                continue;

            String year = yearNode.getNodeName().substring(1);
            if (".".equals(yearNode.getTextContent()) || "".equals(yearNode.getTextContent())) {
                continue;
            }
            String salaryStr = yearNode.getTextContent().replaceAll(" ", "");
            NumberFormat format = NumberFormat.getInstance(Locale.FRANCE);
            Number number = format.parse(salaryStr);
            double salaryDouble = number.doubleValue();

            Age age = new Age();

            if (age2 == null) {
                if (age1 == 19) {
                    age1 = 0;
                    age2 = 19;
                }
                if (age1 == 60)
                    age2 = 99;
            }
            age.setAgeFrom(age1);
            age.setAgeTo(age2);
            age.setCountry("sk");
            age.setYear(year);
            age.setAverageSalary(salaryDouble);
            if (!"spolu".equals(sex))
                age.setSex(sex);

            manager.createAge(age);
        }
    }
}

From source file:org.ocelotds.core.services.ArgumentConvertorTest.java

private Map<String, Locale> getMapOfLocale() {
    Map<String, Locale> map = new HashMap<>();
    map.put("FR", Locale.FRANCE);
    map.put("US", Locale.US);
    return map;//from  w  w w.  jav a2 s. c o m
}

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

/** Test.
 * @throws ServletException e//from  ww w  .j  a v a 2  s  .  c  o  m
 * @throws IOException e */
@Test
public void testDoFilterWithSessionTer() throws ServletException, IOException {
    final HttpServletRequest request = createNiceMock(HttpServletRequest.class);
    final HttpSession session = createNiceMock(HttpSession.class);
    expect(request.getSession(false)).andReturn(session);
    expect(session.getAttribute(SessionListener.SESSION_COUNTRY_KEY)).andReturn(Locale.FRANCE.getCountry())
            .anyTimes();
    expect(session.getAttribute(SessionListener.SESSION_REMOTE_ADDR)).andReturn("somewhere").anyTimes();
    expect(session.getAttribute(SessionListener.SESSION_REMOTE_USER)).andReturn("me").anyTimes();
    replay(session);
    doFilter(request);
    verify(session);
}

From source file:dk.dma.msinm.legacy.nm.NmPdfExtractor.java

/**
 * Reads and updates the locations from the line
 * @param locLine the line containing the locations
 * @param lang the language//from   ww  w.j  a v a2  s.com
 * @param notice the notice to update
 */
void readLocation(String locLine, String lang, Message notice) {
    NumberFormat format = NumberFormat.getInstance(Locale.FRANCE);
    String posPattern = "(\\d+)I?\\s+(\\d+,?\\d+)J?\\s+(N|S)\\s+(\\d+)I?\\s+(\\d+,?\\d+)J?\\s+(E|W),?(.*)";
    Pattern p1 = Pattern.compile(posPattern);
    Pattern p2 = Pattern.compile("(\\d+)\\)\\s+" + posPattern);

    Location location = new Location();
    String[] lines = locLine.split("\n");
    for (int x = 0; x < lines.length; x++) {

        String line = lines[x].trim();
        if (line.endsWith(".")) {
            line = line.substring(0, line.length() - 1);
        }

        Matcher m1 = p1.matcher(line);
        Matcher m2 = p2.matcher(line);
        if (m1.matches() || m2.matches()) {
            Point pt = new Point();
            pt.setLocation(location);
            try {
                int i = 1;

                Matcher m;
                if (m1.matches()) {
                    m = m1;
                    pt.setIndex(x + 1);
                } else {
                    m = m2;
                    pt.setIndex(Integer.valueOf(m.group(i++)));
                }

                pt.setLat(parsePos(Integer.parseInt(m.group(i++)), format.parse(m.group(i++)).doubleValue(),
                        m.group(i++)));
                pt.setLon(parsePos(Integer.parseInt(m.group(i++)), format.parse(m.group(i++)).doubleValue(),
                        m.group(i++)));
                String desc = m.group(i).trim();
                if (StringUtils.isNotBlank(desc)) {
                    pt.checkCreateDesc(lang).setDescription(desc);
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
            location.getPoints().add(pt);
        } else {
            log.warn("No match " + lines[x]);
        }

    }

    if (location.getPoints().size() > 0) {
        location.setType(location.getPoints().size() == 1 ? Location.LocationType.POINT
                : (location.getPoints().size() == 2 ? Location.LocationType.POLYLINE
                        : Location.LocationType.POLYGON));
        notice.getLocations().add(location);
    }
}

From source file:fr.bde_eseo.eseomega.lacommande.OrderDetailsActivity.java

public Date getParsedDate(String strDate) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.FRANCE);
    Date date = null;/*w w  w. j  a  v a  2s .  co m*/
    try {
        date = format.parse(strDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}