Example usage for java.util Locale ROOT

List of usage examples for java.util Locale ROOT

Introduction

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

Prototype

Locale ROOT

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

Click Source Link

Document

Useful constant for the root locale.

Usage

From source file:org.matsim.contrib.parking.parkingchoice.lib.GeneralLib.java

/**
 * Write out a list of Strings//from   w  w w. j a va  2  s  .  c  o  m
 * 
 * after each String in the list a "\n" is added.
 * 
 * @param list
 * @param fileName
 */
public static void writeList(ArrayList<String> list, String fileName) {
    Writer writer = null;
    if (fileName.toLowerCase(Locale.ROOT).endsWith(".gz")) {
        writer = IOUtils.getBufferedWriter(fileName);
    }

    try {
        if (writer == null) {
            FileOutputStream fos = new FileOutputStream(fileName);
            writer = new OutputStreamWriter(fos);
        }
        char[] charArray = Lists.getCharsOfAllArrayItemsWithNewLineCharacterInbetween(list);
        writer.write(charArray);

        writer.flush();
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.hawkular.metrics.clients.ptrans.fullstack.CollectdITest.java

@Test
public void shouldFindCollectdMetricsOnServer() throws Exception {
    ptransProcessBuilder.command().addAll(ImmutableList.of("-c", ptransConfFile.getAbsolutePath()));
    ptransProcess = ptransProcessBuilder.start();
    assertPtransHasStarted(ptransProcess, ptransOut);

    File stdbuf = new File("/usr/bin/stdbuf");
    ImmutableList.Builder<String> collectdCmd = ImmutableList.builder();
    if (stdbuf.exists() && stdbuf.canExecute()) {
        collectdCmd.add(stdbuf.getAbsolutePath(), "-o0", "-e0");
    }//from   ww w  . j  a  va  2 s  .  c om
    collectdCmd.add(COLLECTD_PATH, "-C", collectdConfFile.getAbsolutePath(), "-f");
    collectdProcessBuilder.command(collectdCmd.build());
    collectdProcess = collectdProcessBuilder.start();

    waitForCollectdValues();

    kill(collectdProcess, Signal.SIGUSR1); // Flush data
    kill(collectdProcess, Signal.SIGTERM);
    collectdProcess.waitFor();

    Thread.sleep(MILLISECONDS.convert(1, SECONDS)); // Wait to make sure pTrans can send everything

    kill(ptransProcess, Signal.SIGTERM);
    ptransProcess.waitFor();

    List<Point> expectedData = getExpectedData();
    List<Point> serverData = getServerData();

    String failureMsg = String.format(Locale.ROOT, "Expected:%n%s%nActual:%n%s%n", pointsToString(expectedData),
            pointsToString(serverData));

    assertEquals(failureMsg, expectedData.size(), serverData.size());

    for (int i = 0; i < expectedData.size(); i++) {
        Point expectedPoint = expectedData.get(i);
        Point serverPoint = serverData.get(i);

        long timeDiff = expectedPoint.getTimestamp() - serverPoint.getTimestamp();
        assertTrue(failureMsg, Math.abs(timeDiff) < 2);

        assertEquals(failureMsg, expectedPoint.getType(), serverPoint.getType());
        assertEquals(failureMsg, expectedPoint.getValue(), serverPoint.getValue(), 0.1);
    }
}

From source file:de.austinpadernale.holidays.Holiday.java

public String getName(Locale locale) {
    String result;//from  w  w  w  .j a  v  a2  s.  com
    if (names == null || names.isEmpty()) {
        result = createName();
    } else if (locale == null || locale.equals(Locale.ROOT)) {
        HolidayName hn = null;
        for (HolidayName n : names) {
            if (n.getLanguage() == null || n.getLanguage().equals(Locale.ROOT)) {
                hn = n;
                break;
            }
        }
        result = holidayNameToName(hn);
    } else {
        HolidayName rn = null;
        HolidayName ln2 = null;
        HolidayName ln = null;
        HolidayName cn = null;
        for (HolidayName n : names) {
            Locale l = n.getLanguage();
            if (l == null || l.equals(Locale.ROOT)) {
                if (rn == null) {
                    rn = n;
                }
                continue;
            }
            if (equals(l.getLanguage(), locale.getLanguage()) && StringUtils.isEmpty(l.getCountry())) {
                if (ln == null) {
                    ln = n;
                }
                continue;
            }
            if (equals(l.getLanguage(), locale.getLanguage()) && !StringUtils.isEmpty(l.getCountry())) {
                if (ln2 == null) {
                    ln2 = n;
                }
                continue;
            }
            if (equals(l.getLanguage(), locale.getLanguage()) && equals(l.getCountry(), locale.getCountry())) {
                if (cn == null) {
                    cn = n;
                }
            }
        }
        if (cn != null) {
            result = holidayNameToName(cn);
        } else if (ln != null) {
            result = holidayNameToName(ln);
        } else if (ln2 != null) {
            result = holidayNameToName(ln2);
        } else if (rn != null) {
            result = holidayNameToName(rn);
        } else {
            result = createName();
        }
    }
    return result;
}

From source file:org.apache.solr.cloud.TestTlogReplica.java

@Repeat(iterations = 2) // 2 times to make sure cleanup is complete and we can create the same collection
public void testCreateDelete() throws Exception {
    try {/*w  w w. j  ava2  s  . c  om*/
        switch (random().nextInt(3)) {
        case 0:
            CollectionAdminRequest.createCollection(collectionName, "conf", 2, 0, 4, 0).setMaxShardsPerNode(100)
                    .process(cluster.getSolrClient());
            break;
        case 1:
            // Sometimes don't use SolrJ
            String url = String.format(Locale.ROOT,
                    "%s/admin/collections?action=CREATE&name=%s&collection.configName=%s&numShards=%s&tlogReplicas=%s&maxShardsPerNode=%s",
                    cluster.getRandomJetty(random()).getBaseUrl(), collectionName, "conf", 2, // numShards
                    4, // tlogReplicas
                    100); // maxShardsPerNode
            HttpGet createCollectionGet = new HttpGet(url);
            HttpResponse httpResponse = cluster.getSolrClient().getHttpClient().execute(createCollectionGet);
            assertEquals(200, httpResponse.getStatusLine().getStatusCode());
            break;
        case 2:
            // Sometimes use V2 API
            url = cluster.getRandomJetty(random()).getBaseUrl().toString() + "/____v2/c";
            String requestBody = String.format(Locale.ROOT,
                    "{create:{name:%s, config:%s, numShards:%s, tlogReplicas:%s, maxShardsPerNode:%s}}",
                    collectionName, "conf", 2, // numShards
                    4, // tlogReplicas
                    100); // maxShardsPerNode
            HttpPost createCollectionPost = new HttpPost(url);
            createCollectionPost.setHeader("Content-type", "application/json");
            createCollectionPost.setEntity(new StringEntity(requestBody));
            httpResponse = cluster.getSolrClient().getHttpClient().execute(createCollectionPost);
            assertEquals(200, httpResponse.getStatusLine().getStatusCode());
            break;
        }

        boolean reloaded = false;
        while (true) {
            DocCollection docCollection = getCollectionState(collectionName);
            assertNotNull(docCollection);
            assertEquals("Expecting 2 shards", 2, docCollection.getSlices().size());
            assertEquals("Expecting 4 relpicas per shard", 8, docCollection.getReplicas().size());
            assertEquals("Expecting 8 tlog replicas, 4 per shard", 8,
                    docCollection.getReplicas(EnumSet.of(Replica.Type.TLOG)).size());
            assertEquals("Expecting no nrt replicas", 0,
                    docCollection.getReplicas(EnumSet.of(Replica.Type.NRT)).size());
            assertEquals("Expecting no pull replicas", 0,
                    docCollection.getReplicas(EnumSet.of(Replica.Type.PULL)).size());
            for (Slice s : docCollection.getSlices()) {
                assertTrue(s.getLeader().getType() == Replica.Type.TLOG);
                List<String> shardElectionNodes = cluster.getZkClient().getChildren(
                        ZkStateReader.getShardLeadersElectPath(collectionName, s.getName()), null, true);
                assertEquals("Unexpected election nodes for Shard: " + s.getName() + ": "
                        + Arrays.toString(shardElectionNodes.toArray()), 4, shardElectionNodes.size());
            }
            assertUlogPresence(docCollection);
            if (reloaded) {
                break;
            } else {
                // reload
                CollectionAdminResponse response = CollectionAdminRequest.reloadCollection(collectionName)
                        .process(cluster.getSolrClient());
                assertEquals(0, response.getStatus());
                reloaded = true;
            }
        }
    } finally {
        zkClient().printLayoutToStdOut();
    }
}

From source file:com.netflix.discovery.shared.Applications.java

/**
 * Gets the list of secure <em>instances</em> associated to a virtual host
 * name.//from  w  w  w  . jav a  2s  . co  m
 *
 * @param secureVirtualHostName
 *            the virtual hostname for which the secure instances need to be
 *            returned.
 * @return list of <em>instances</em>.
 */
public List<InstanceInfo> getInstancesBySecureVirtualHostName(String secureVirtualHostName) {
    AtomicReference<List<InstanceInfo>> ref = this.shuffledSecureVirtualHostNameMap
            .get(secureVirtualHostName.toUpperCase(Locale.ROOT));
    if (ref == null || ref.get() == null) {
        return new ArrayList<InstanceInfo>();
    } else {
        return ref.get();
    }
}

From source file:com.gargoylesoftware.htmlunit.ExternalTest.java

/**
 * Returns if now we are in different week than the last finished build one.
 *//*w w  w  .j a va 2 s .com*/
private static boolean isDifferentWeek() throws Exception {
    try (final WebClient webClient = getWebClient()) {
        HtmlPage page = webClient.getPage("https://ci.canoo.com/teamcity/viewLog.html"
                + "?buildTypeId=HtmlUnit_FastBuild&buildId=lastSuccessful");
        page = page.getAnchorByText("Log in as guest").click();
        webClient.waitForBackgroundJavaScript(1000);
        final HtmlTable table = page.getFirstByXPath("//table[@class='statusTable']");
        assumeNotNull(page.asXml(), table);
        final HtmlTableCell cell = table.getRow(1).getCell(3);
        final String triggerText = cell.asText();

        final String marker = " on ";
        final int start = triggerText.indexOf(marker);
        final String triggerDate = triggerText.substring(start + marker.length());

        final Calendar buildCalendar = Calendar.getInstance(Locale.ROOT);
        buildCalendar.setTime(TEAM_CITY_FORMAT_.parse(triggerDate));
        return Calendar.getInstance().get(Calendar.WEEK_OF_YEAR) != buildCalendar.get(Calendar.WEEK_OF_YEAR);
    }
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLImageElement.java

/**
 * Returns the value of the {@code align} property.
 * @return the value of the {@code align} property
 *///from www. j  a  v  a2  s  .  c om
@JsxGetter
public String getAlign() {
    final boolean acceptArbitraryValues = getBrowserVersion().hasFeature(JS_ALIGN_ACCEPTS_ARBITRARY_VALUES);

    final String align = getDomNodeOrDie().getAttribute("align");
    if (acceptArbitraryValues) {
        return align;
    }

    final String normalizedValue = NORMALIZED_ALIGN_VALUES.get(align.toLowerCase(Locale.ROOT));
    if (null != normalizedValue) {
        return normalizedValue;
    }
    return "";
}

From source file:org.elasticsearch.xpack.ml.integration.MlJobIT.java

public void testCantCreateJobWithSameID() throws Exception {
    String jobTemplate = "{\n" + "  \"analysis_config\" : {\n"
            + "        \"detectors\" :[{\"function\":\"metric\",\"field_name\":\"responsetime\"}]\n"
            + "    },\n" + "  \"data_description\": {},\n" + "  \"results_index_name\" : \"%s\"}";

    String jobConfig = String.format(Locale.ROOT, jobTemplate, "index-1");

    String jobId = "cant-create-job-with-same-id-job";
    Response response = client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId,
            Collections.emptyMap(), new StringEntity(jobConfig, ContentType.APPLICATION_JSON));
    assertEquals(200, response.getStatusLine().getStatusCode());

    final String jobConfig2 = String.format(Locale.ROOT, jobTemplate, "index-2");
    ResponseException e = expectThrows(ResponseException.class,
            () -> client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId,
                    Collections.emptyMap(), new StringEntity(jobConfig2, ContentType.APPLICATION_JSON)));

    assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(400));
    assertThat(e.getMessage(),/*from   w  w w. j a v a2 s.co  m*/
            containsString("The job cannot be created with the Id '" + jobId + "'. The Id is already used."));
}

From source file:org.phenotips.data.internal.MonarchPatientScorer.java

private Date now() {
    return Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT).getTime();
}

From source file:com.puppycrawl.tools.checkstyle.AllChecksTest.java

@Test
public void testAllCheckstyleModulesHaveXdocDocumentation() throws Exception {
    final Set<Class<?>> checkstyleModules = getCheckstyleModules();
    final Set<String> checkstyleModulesNames = getSimpleNames(checkstyleModules);
    final String xdocsDirectoryPath = "src" + File.separator + "xdocs";
    final Set<String> modulesNamesWhichHaveXdocs = getModulesNamesWhichHaveXdoc(xdocsDirectoryPath);

    for (String moduleName : checkstyleModulesNames) {
        if (!modulesNamesWhichHaveXdocs.contains(moduleName)) {
            final String missingModuleMessage = String.format(Locale.ROOT,
                    "Module %s does not have xdoc documentation.", moduleName);
            Assert.fail(missingModuleMessage);
        }/*  w  w w .  j  a  va 2  s  .  c  om*/
    }
}