List of usage examples for java.nio.charset StandardCharsets UTF_8
Charset UTF_8
To view the source code for java.nio.charset StandardCharsets UTF_8.
Click Source Link
From source file:io.github.swagger2markup.internal.component.ProducesComponentTest.java
@Test public void testProducesComponent() throws URISyntaxException { List<String> produces = new ArrayList<>(); produces.add("application/json"); produces.add("application/xml"); Swagger2MarkupConverter.Context context = createContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); markupDocBuilder = new ProducesComponent(context).apply(markupDocBuilder, ProducesComponent.parameters(produces, OverviewDocument.SECTION_TITLE_LEVEL)); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); }
From source file:edu.kit.scc.http.client.HttpClientTest.java
@Test public void testMakeHttpGetRequestWithAuthorization() { String url = "http://www.kit.edu"; String restUser = "test"; String restPassword = "test"; String auth = restUser + ":" + restPassword; byte[] authZheader = auth.getBytes(); String authorizationHeader = "Basic " + new String(Base64.encodeBase64(authZheader), StandardCharsets.UTF_8); HttpResponse response = client.makeHttpGetRequest(restUser, restPassword, url); assertNotNull(response);/*from w ww . jav a 2 s . c o m*/ assertTrue(response.getStatusCode() == 200); }
From source file:io.lavagna.web.helper.GsonHttpMessageConverter.java
@Override protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException { try (Reader reader = new InputStreamReader(inputMessage.getBody(), StandardCharsets.UTF_8)) { return gson.fromJson(reader, clazz); } catch (JsonSyntaxException e) { throw new HttpMessageNotReadableException("Could not read JSON: " + e.getMessage(), e); }//w w w.j a v a 2s . c o m }
From source file:com.jivesoftware.os.amza.api.ring.RingMember.java
@JsonCreator public RingMember(@JsonProperty("member") String member) { this.memberAsBytes = member.getBytes(StandardCharsets.UTF_8); this.member = member; int hashCode = 7; hashCode = 73 * hashCode + Arrays.hashCode(this.memberAsBytes); this.hash = hashCode; }
From source file:eu.itesla_project.modules.rules.CheckSecurityTool.java
private static void writeCsv( Map<String, Map<SecurityIndexType, SecurityRuleCheckStatus>> checkStatusPerContingency, Set<SecurityIndexType> securityIndexTypes, Path outputCsvFile) throws IOException { Objects.requireNonNull(outputCsvFile); try (BufferedWriter writer = Files.newBufferedWriter(outputCsvFile, StandardCharsets.UTF_8)) { writer.write("Contingency"); for (SecurityIndexType securityIndexType : securityIndexTypes) { writer.write(CSV_SEPARATOR); writer.write(securityIndexType.toString()); }//from w w w. jav a 2 s .c om writer.newLine(); for (Map.Entry<String, Map<SecurityIndexType, SecurityRuleCheckStatus>> entry : checkStatusPerContingency .entrySet()) { String contingencyId = entry.getKey(); Map<SecurityIndexType, SecurityRuleCheckStatus> checkStatus = entry.getValue(); writer.write(contingencyId); for (SecurityIndexType securityIndexType : securityIndexTypes) { writer.write(CSV_SEPARATOR); writer.write(checkStatus.get(securityIndexType).name()); } writer.newLine(); } } }
From source file:org.opendaylight.sfc.sbrest.json.SfstExporterTest.java
private String gatherServiceFunctionSchedulerTypeJsonStringFromFile(String testFileName) { String jsonString = null;//from w w w . j av a2 s .c o m try { URL fileURL = getClass().getResource(testFileName); jsonString = TestUtil.readFile(fileURL.toURI(), StandardCharsets.UTF_8); } catch (IOException | URISyntaxException e) { e.printStackTrace(); } for (SfstTestValues sfstTestValue : SfstTestValues.values()) { if (jsonString != null) { jsonString = jsonString.replaceAll("\\b" + sfstTestValue.name() + "\\b", sfstTestValue.getValue()); } } return jsonString; }
From source file:org.elasticsearch.xpack.core.rollup.RollupRestTestStateCleaner.java
private void waitForPendingTasks() throws Exception { ESTestCase.assertBusy(() -> {//from ww w. j av a 2 s .c om try { Response response = adminClient.performRequest("GET", "/_cat/tasks", Collections.singletonMap("detailed", "true")); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { try (BufferedReader responseReader = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8))) { int activeTasks = 0; String line; StringBuilder tasksListString = new StringBuilder(); while ((line = responseReader.readLine()) != null) { // We only care about Rollup jobs, otherwise this fails too easily due to unrelated tasks if (line.startsWith(RollupJob.NAME) == true) { activeTasks++; tasksListString.append(line); tasksListString.append('\n'); } } assertEquals(activeTasks + " active tasks found:\n" + tasksListString, 0, activeTasks); } } } catch (IOException e) { throw new AssertionError("Error getting active tasks list", e); } }); }
From source file:com.hp.autonomy.idolutils.GenerateIndexableXmlDocumentTest.java
@Test public void generateFile() throws IOException { final Collection<String> numericFields = new ArrayList<>(1000); final Random random = new Random(); for (int i = 0; i < 1000; i++) { numericFields.add(String.valueOf(1451610061 + random.nextInt(1000))); }/*from w ww .ja v a2 s .c om*/ final Collection<SampleDoc> sampleDocs = new ArrayList<>(numericFields.size()); int i = 0; for (final String numericField : numericFields) { sampleDocs.add(new SampleDoc(UUID.randomUUID().toString(), "Sample Date Title " + i++, "Sample Date Content", numericField)); } @SuppressWarnings("TypeMayBeWeakened") final IdolXmlMarshaller marshaller = new IdolXmlMarshallerImpl(); final File outputFile = new File(TEST_DIR, "sampleFile.xml"); FileUtils.writeStringToFile(outputFile, marshaller.generateXmlDocument(sampleDocs, SampleDoc.class, StandardCharsets.UTF_8)); assertTrue(outputFile.exists()); }
From source file:io.github.swagger2markup.internal.component.TagsComponentTest.java
@Test public void testTagsComponent() throws URISyntaxException { List<Tag> tags = new ArrayList<>(); tags.add(new Tag().name("Tag1").description("description")); tags.add(new Tag().name("Tag2")); Swagger2MarkupConverter.Context context = createContext(); MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder(); markupDocBuilder = new TagsComponent(context).apply(markupDocBuilder, TagsComponent.parameters(tags, OverviewDocument.SECTION_TITLE_LEVEL)); markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8); Path expectedFile = getExpectedFile(COMPONENT_NAME); DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME)); }
From source file:com.blackducksoftware.integration.hub.detect.DetectInfoUtility.java
public String findDetectVersionFromResources() { try {/*w w w . j av a 2s .c o m*/ return ResourceUtil.getResourceAsString(this.getClass(), "/version.txt", StandardCharsets.UTF_8.toString()); } catch (final IOException e) { throw new RuntimeException(e); } }