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.grayfox.server.dao.PoiDaoTest.java
@Test @Transactional/*from www.j av a 2 s . c o m*/ public void testFetchNearestByCategory() { Category category = new Category(); category.setFoursquareId("4bf58dd8d48988d151941735"); category.setName("Taco Place"); category.setIconUrl("https://ss3.4sqi.net/img/categories_v2/food/taco_88.png"); Poi p1 = new Poi(); p1.setFoursquareId("4cdd6a06930af04d92fb9597"); p1.setName("Taquera Los ?ngeles"); p1.setLocation(Location.parse("19.04336700060403,-98.19716334342957")); p1.setCategories(new HashSet<>(Arrays.asList(category))); Poi p2 = new Poi(); p2.setFoursquareId("4c3ce8087c1ee21ebd388d71"); p2.setName("Antigua Taquera La Oriental"); p2.setLocation(Location.parse("19.044926274591635,-98.19751471281052")); p2.setCategories(new HashSet<>(Arrays.asList(category))); List<Poi> expectedPois = Arrays.asList(p1, p2); List<Poi> actualPois = poiDao.findNearestByCategory(Location.parse("19.04365,-98.197968"), 800, category.getFoursquareId(), Locale.ROOT); assertThat(actualPois).isNotNull().isNotEmpty().doesNotContainNull().hasSameSizeAs(expectedPois) .containsOnlyElementsOf(expectedPois); assertThatThrownBy(() -> poiDao.findNearestByCategory(Location.parse("19.04365,-98.197968"), 800, "invalidId", Locale.ROOT)).isInstanceOf(DaoException.class); }
From source file:org.apache.calcite.adapter.elasticsearch.EmbeddedElasticsearchPolicy.java
void insertDocument(String index, ObjectNode document) throws IOException { Objects.requireNonNull(index, "index"); Objects.requireNonNull(document, "document"); String uri = String.format(Locale.ROOT, "/%s/%s/?refresh", index, index); StringEntity entity = new StringEntity(mapper().writeValueAsString(document), ContentType.APPLICATION_JSON); restClient().performRequest("POST", uri, Collections.emptyMap(), entity); }
From source file:com.gargoylesoftware.htmlunit.ExternalTest.java
/** * Tests that the deployed snapshot is not more than two weeks old. * * Currently it is configured to check every week. * * @throws Exception if an error occurs//w w w . j a v a 2 s . c om */ @Test public void snapshot() throws Exception { if (isDifferentWeek()) { final List<String> lines = FileUtils.readLines(new File("pom.xml")); String version = null; for (int i = 0; i < lines.size(); i++) { if ("<artifactId>htmlunit</artifactId>".equals(lines.get(i).trim())) { version = getValue(lines.get(i + 1)); break; } } if (version.contains("SNAPSHOT")) { try (final WebClient webClient = getWebClient()) { final XmlPage page = webClient .getPage("https://oss.sonatype.org/content/repositories/snapshots/" + "net/sourceforge/htmlunit/htmlunit/" + version + "/maven-metadata.xml"); final String timestamp = page.getElementsByTagName("timestamp").get(0).getTextContent(); final DateFormat format = new SimpleDateFormat("yyyyMMdd.HHmmss", Locale.ROOT); final long snapshotMillis = format.parse(timestamp).getTime(); final long nowMillis = System.currentTimeMillis(); final long days = TimeUnit.MILLISECONDS.toDays(nowMillis - snapshotMillis); assertTrue("Snapshot not deployed for " + days + " days", days < 14); } } } }
From source file:org.apache.solr.client.solrj.embedded.JettyWebappTest.java
public void testAdminUI() throws Exception { // Currently not an extensive test, but it does fire up the JSP pages and make // sure they compile ok String adminPath = "http://127.0.0.1:" + port + context + "/"; byte[] bytes = IOUtils.toByteArray(new URL(adminPath).openStream()); assertNotNull(bytes); // real error will be an exception HttpClient client = HttpClients.createDefault(); HttpRequestBase m = new HttpGet(adminPath); HttpResponse response = client.execute(m, HttpClientUtil.createNewHttpClientRequestContext()); assertEquals(200, response.getStatusLine().getStatusCode()); Header header = response.getFirstHeader("X-Frame-Options"); assertEquals("DENY", header.getValue().toUpperCase(Locale.ROOT)); m.releaseConnection();//from www .java 2s . c o m }
From source file:net.pms.encoders.StandardPlayerId.java
/** * Attempts to convert the specified {@link String} to a * {@link StandardPlayerId}. If the conversion fails, {@code null} is * returned./*from w ww . ja v a 2 s . co m*/ * * @param playerIdString the {@link String} to convert. * @return The corresponding {@link StandardPlayerId} or {@code null}. */ public static PlayerId toPlayerID(String playerIdString) { if (isBlank(playerIdString)) { return null; } playerIdString = playerIdString.trim().toUpperCase(Locale.ROOT); switch (playerIdString) { case "AVISYNTHFFMPEG": return AVI_SYNTH_FFMPEG; case "AVISYNTHMENCODER": return AVI_SYNTH_MENCODER; case "FFMPEGAUDIO": return FFMPEG_AUDIO; case "FFMPEGVIDEO": return FFMPEG_VIDEO; case "FFMPEGWEBVIDEO": return FFMPEG_WEB_VIDEO; case "MENCODER": // old name case "MENCODERVIDEO": return MENCODER_VIDEO; case "MENCODERWEBVIDEO": return MENCODER_WEB_VIDEO; case "DCRAW": return DCRAW; case "TSMUXERAUDIO": return TSMUXER_AUDIO; case "TSMUXER": // old name case "TSMUXERVIDEO": return TSMUXER_VIDEO; case "VLCAUDIO": // old name case "VLCAUDIOSTREAMING": return VLC_AUDIO_STREAMING; case "VLCVIDEOSTREAMING": return VLC_VIDEO_STREAMING; case "VLCTRANSCODER": // old name case "VLCVIDEO": return VLC_VIDEO; case "VLCWEBVIDEO": return VLC_WEB_VIDEO; default: LOGGER.warn("Could not parse player id \"{}\"", playerIdString); return null; } }
From source file:com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.java
private static Integer[] getLinesWithWarnAndCheckComments(String aFileName, final int tabWidth) throws IOException { List<Integer> result = new ArrayList<>(); try (BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(aFileName), StandardCharsets.UTF_8))) { int lineNumber = 1; for (String line = br.readLine(); line != null; line = br.readLine()) { Matcher match = LINE_WITH_COMMENT_REGEX.matcher(line); if (match.matches()) { final String comment = match.group(1); final int indentInComment = getIndentFromComment(comment); final int actualIndent = getLineStart(line, tabWidth); if (actualIndent != indentInComment) { throw new IllegalStateException(String.format(Locale.ROOT, "File \"%1$s\" has incorrect indentation in comment." + "Line %2$d: comment:%3$d, actual:%4$d.", aFileName, lineNumber, indentInComment, actualIndent)); }//from w w w . jav a 2s.c o m if (isWarnComment(comment)) { result.add(lineNumber); } if (!isCommentConsistent(comment)) { throw new IllegalStateException(String.format(Locale.ROOT, "File \"%1$s\" has inconsistent comment on line %2$d", aFileName, lineNumber)); } } else if (NONEMPTY_LINE_REGEX.matcher(line).matches()) { throw new IllegalStateException( String.format(Locale.ROOT, "File \"%1$s\" has no indentation comment or its format " + "malformed. Error on line: %2$d", aFileName, lineNumber)); } lineNumber++; } } return result.toArray(new Integer[result.size()]); }
From source file:net.hasor.search.utils.DateUtil.java
/** * Slightly modified from org.apache.commons.httpclient.util.DateUtil.parseDate * <p/>//from w w w . j a v a 2 s .co m * Parses the date value using the given date formats. * * @param dateValue the date value to parse * @param dateFormats the date formats to use * @param startDate During parsing, two digit years will be placed in the range * <code>startDate</code> to <code>startDate + 100 years</code>. This value may * be <code>null</code>. When <code>null</code> is given as a parameter, year * <code>2000</code> will be used. * @return the parsed date * @throws ParseException if none of the dataFormats could parse the dateValue */ public static Date parseDate(String dateValue, Collection<String> dateFormats, Date startDate) throws ParseException { if (dateValue == null) { throw new IllegalArgumentException("dateValue is null"); } if (dateFormats == null) { dateFormats = DEFAULT_HTTP_CLIENT_PATTERNS; } if (startDate == null) { startDate = DEFAULT_TWO_DIGIT_YEAR_START; } // trim single quotes around date if present // see issue #5279 if (dateValue.length() > 1 && dateValue.startsWith("'") && dateValue.endsWith("'")) { dateValue = dateValue.substring(1, dateValue.length() - 1); } SimpleDateFormat dateParser = null; Iterator formatIter = dateFormats.iterator(); while (formatIter.hasNext()) { String format = (String) formatIter.next(); if (dateParser == null) { dateParser = new SimpleDateFormat(format, Locale.ROOT); dateParser.setTimeZone(GMT); dateParser.set2DigitYearStart(startDate); } else { dateParser.applyPattern(format); } try { return dateParser.parse(dateValue); } catch (ParseException pe) { // ignore this exception, we will try the next format } } // we were unable to parse the date throw new ParseException("Unable to parse the date " + dateValue, 0); }
From source file:br.ufrj.ppgi.jemf.mobile.bean.Emergency.java
/** * Set the type as String value. * @param type */ public void setTypeString(String type) { setType(EnumEmergencyType.valueOf(type.toUpperCase(Locale.ROOT))); }
From source file:io.crate.PartitionName.java
@Nullable public String encodeIdent() { if (values.size() == 0) { return null; }/*from www. j ava 2 s . co m*/ BytesStreamOutput streamOutput = new BytesStreamOutput(estimateSize(values)); try { streamOutput.writeVInt(values.size()); for (BytesRef value : values) { StringType.INSTANCE.streamer().writeValueTo(streamOutput, value); } } catch (IOException e) { // } String identBase32 = BASE32.encodeAsString(streamOutput.bytes().toBytes()).toLowerCase(Locale.ROOT); // decode doesn't need padding, remove it int idx = identBase32.indexOf('='); if (idx > -1) { return identBase32.substring(0, idx); } return identBase32; }