List of usage examples for java.util Locale ROOT
Locale ROOT
To view the source code for java.util Locale ROOT.
Click Source Link
From source file:com.astamuse.asta4d.web.test.dispatch.RequestDispatcherTest.java
@BeforeClass public void setConf() { Locale.setDefault(Locale.ROOT); Configuration.setConfiguration(configuration); }
From source file:org.apache.calcite.adapter.elasticsearch.ElasticsearchTable.java
private ElasticsearchSearchResult httpRequest(String query) throws IOException { Objects.requireNonNull(query, "query"); String uri = String.format(Locale.ROOT, "/%s/%s/_search", indexName, typeName); HttpEntity entity = new StringEntity(query, ContentType.APPLICATION_JSON); Response response = restClient.performRequest("POST", uri, Collections.emptyMap(), entity); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { final String error = EntityUtils.toString(response.getEntity()); final String message = String.format(Locale.ROOT, "Error while querying Elastic (on %s/%s) status: %s\nQuery:\n%s\nError:\n%s\n", response.getHost(), response.getRequestLine(), response.getStatusLine(), query, error); throw new RuntimeException(message); }//from w w w . j a v a 2s .com try (InputStream is = response.getEntity().getContent()) { return mapper.readValue(is, ElasticsearchSearchResult.class); } }
From source file:org.elasticsearch.upgrades.FullClusterRestartIT.java
@Before public void setIndex() { index = getTestName().toLowerCase(Locale.ROOT); }
From source file:ch.cyberduck.core.importer.FireFtpBookmarkCollection.java
private void read(final ProtocolFactory protocols, final String entry) { final Host current = new Host(protocols.forScheme(Scheme.ftp)); current.getCredentials().setUsername(PreferencesFactory.get().getProperty("connection.login.anon.name")); for (String attribute : entry.split(", ")) { Scanner scanner = new Scanner(attribute); scanner.useDelimiter(":"); if (!scanner.hasNext()) { log.warn("Missing key in line:" + attribute); continue; }//from w w w . j ava2 s . co m String name = scanner.next().toLowerCase(Locale.ROOT); if (!scanner.hasNext()) { log.warn("Missing value in line:" + attribute); continue; } String value = scanner.next().replaceAll("\"", StringUtils.EMPTY); if ("host".equals(name)) { current.setHostname(value); } else if ("port".equals(name)) { try { current.setPort(Integer.parseInt(value)); } catch (NumberFormatException e) { log.warn("Invalid Port:" + e.getMessage()); } } else if ("remotedir".equals(name)) { current.setDefaultPath(value); } else if ("webhost".equals(name)) { current.setWebURL(value); } else if ("encoding".equals(name)) { current.setEncoding(value); } else if ("notes".equals(name)) { current.setComment(value); } else if ("account".equals(name)) { current.setNickname(value); } else if ("privatekey".equals(name)) { current.getCredentials().setIdentity(LocalFactory.get(value)); } else if ("pasvmode".equals(name)) { if (Boolean.TRUE.toString().equals(value)) { current.setFTPConnectMode(FTPConnectMode.passive); } if (Boolean.FALSE.toString().equals(value)) { current.setFTPConnectMode(FTPConnectMode.active); } } else if ("login".equals(name)) { current.getCredentials().setUsername(value); } else if ("password".equals(name)) { current.getCredentials().setPassword(value); } else if ("anonymous".equals(name)) { if (Boolean.TRUE.toString().equals(value)) { current.getCredentials() .setUsername(PreferencesFactory.get().getProperty("connection.login.anon.name")); } } else if ("security".equals(name)) { if ("authtls".equals(value)) { current.setProtocol(protocols.forScheme(Scheme.ftps)); // Reset port to default current.setPort(-1); } if ("sftp".equals(value)) { current.setProtocol(protocols.forScheme(Scheme.sftp)); // Reset port to default current.setPort(-1); } } } this.add(current); }
From source file:br.ufrj.ppgi.jemf.mobile.bean.Mission.java
/** * Set the priority as String value.//from ww w . j a va 2 s . com * @param priority */ public void setPriorityString(String priority) { setPriority(EnumPriority.valueOf(priority.toUpperCase(Locale.ROOT))); }
From source file:com.puppycrawl.tools.checkstyle.internal.AllChecksTest.java
@Test public void testRequiredTokensAreSubsetOfAcceptableTokens() throws Exception { for (Class<?> check : CheckUtil.getCheckstyleChecks()) { if (Check.class.isAssignableFrom(check)) { final Check testedCheck = (Check) check.getDeclaredConstructor().newInstance(); final int[] requiredTokens = testedCheck.getRequiredTokens(); final int[] acceptableTokens = testedCheck.getAcceptableTokens(); if (!isSubset(requiredTokens, acceptableTokens)) { final String errorMessage = String.format(Locale.ROOT, "%s's required tokens must be a subset" + " of acceptable tokens.", check.getName()); Assert.fail(errorMessage); }/*w w w .j a v a 2 s . c o m*/ } } }
From source file:org.elasticsearch.plugins.SitePluginIT.java
/** * Test normalizing of path/*ww w . j a v a 2s . co m*/ */ @Test public void testThatPathsAreNormalized() throws Exception { // more info: https://www.owasp.org/index.php/Path_Traversal List<String> notFoundUris = new ArrayList<>(); notFoundUris.add("/_plugin/dummy/../../../../../log4j.properties"); notFoundUris.add("/_plugin/dummy/../../../../../%00log4j.properties"); notFoundUris.add("/_plugin/dummy/..%c0%af..%c0%af..%c0%af..%c0%af..%c0%aflog4j.properties"); notFoundUris.add("/_plugin/dummy/%2E%2E/%2E%2E/%2E%2E/%2E%2E/index.html"); notFoundUris.add("/_plugin/dummy/%2e%2e/%2e%2e/%2e%2e/%2e%2e/index.html"); notFoundUris.add("/_plugin/dummy/%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2findex.html"); notFoundUris.add("/_plugin/dummy/%2E%2E/%2E%2E/%2E%2E/%2E%2E/index.html"); notFoundUris.add("/_plugin/dummy/..%5C..%5C..%5C..%5C..%5Clog4j.properties"); for (String uri : notFoundUris) { HttpResponse response = httpClient().path(uri).execute(); String message = String.format(Locale.ROOT, "URI [%s] expected to be not found", uri); assertThat(message, response, hasStatus(NOT_FOUND)); } // using relative path inside of the plugin should work HttpResponse response = httpClient().path("/_plugin/dummy/dir1/../dir1/../index.html").execute(); assertThat(response, hasStatus(OK)); assertThat(response.getBody(), containsString("<title>Dummy Site Plugin</title>")); }
From source file:ch.cyberduck.core.importer.WsFtpBookmarkCollection.java
private boolean parse(final ProtocolFactory protocols, final Host current, final String line) { final Scanner scanner = new Scanner(line); scanner.useDelimiter("="); if (!scanner.hasNext()) { log.warn("Missing key in line:" + line); return false; }// w w w . j a va 2s . co m String name = scanner.next().toLowerCase(Locale.ROOT); if (!scanner.hasNext()) { log.warn("Missing value in line:" + line); return false; } String value = scanner.next().replaceAll("\"", StringUtils.EMPTY); if ("conntype".equals(name)) { try { switch (Integer.parseInt(value)) { case 4: current.setProtocol(protocols.forScheme(Scheme.sftp)); break; case 5: current.setProtocol(protocols.forScheme(Scheme.ftps)); break; } // Reset port to default current.setPort(-1); } catch (NumberFormatException e) { log.warn("Unknown Protocol:" + e.getMessage()); } } else if ("host".equals(name)) { current.setHostname(value); } else if ("port".equals(name)) { try { current.setPort(Integer.parseInt(value)); } catch (NumberFormatException e) { log.warn("Invalid Port:" + e.getMessage()); } } else if ("dir".equals(name)) { current.setDefaultPath(value); } else if ("comment".equals(name)) { current.setComment(value); } else if ("uid".equals(name)) { current.getCredentials().setUsername(value); } return true; }
From source file:com.puppycrawl.tools.checkstyle.JavadocPropertiesGeneratorTest.java
@Test public void testNoDestfileSpecified() throws Exception { JavadocPropertiesGenerator.main(getPath("InputMain.java")); final String expected = String.format(Locale.ROOT, "Missing required option '--destfile=<outputFile>'%n") + USAGE;//from w w w . j a v a 2 s . c om assertEquals("Unexpected error log", expected, systemErr.getLog()); assertEquals("Unexpected output log", "", systemOut.getLog()); }
From source file:com.digitalpebble.stormcrawler.filtering.basic.BasicURLNormalizer.java
@Override public String filter(URL sourceUrl, Metadata sourceMetadata, String urlToFilter) { urlToFilter = urlToFilter.trim();//from www .ja v a 2 s .c o m if (removeAnchorPart) { try { URL theURL = new URL(urlToFilter); String anchor = theURL.getRef(); if (anchor != null) urlToFilter = urlToFilter.replace("#" + anchor, ""); } catch (MalformedURLException e) { return null; } } if (unmangleQueryString) { urlToFilter = unmangleQueryString(urlToFilter); } if (!queryElementsToRemove.isEmpty()) { urlToFilter = filterQueryElements(urlToFilter); } try { URL theURL = new URL(urlToFilter); String file = theURL.getFile(); String protocol = theURL.getProtocol(); String host = theURL.getHost(); boolean hasChanged = false; // lowercased protocol if (!urlToFilter.startsWith(protocol)) { hasChanged = true; } if (host != null) { String newHost = host.toLowerCase(Locale.ROOT); if (!host.equals(newHost)) { host = newHost; hasChanged = true; } } int port = theURL.getPort(); // properly encode characters in path/file using percent-encoding String file2 = unescapePath(file); file2 = escapePath(file2); if (!file.equals(file2)) { hasChanged = true; } if (hasChanged) { urlToFilter = new URL(protocol, host, port, file2).toString(); } } catch (MalformedURLException e) { return null; } if (checkValidURI) { try { URI uri = URI.create(urlToFilter); urlToFilter = uri.normalize().toString(); } catch (java.lang.IllegalArgumentException e) { LOG.info("Invalid URI {}", urlToFilter); return null; } } return urlToFilter; }