import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.LinkedHashSet;
} catch (IOException e) {
throw new IllegalStateException("Cannot write error response body", e);
}
- try {
- return outputStream.toString(StandardCharsets.UTF_8.name());
- } catch (UnsupportedEncodingException e) {
- throw new IllegalStateException("Output stream cannot be converted to string representation", e);
- }
+ return outputStream.toString(StandardCharsets.UTF_8);
}
/**
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
writer.writeTo(patchStatusContext, PatchStatusContext.class, null, EMPTY_ANNOTATIONS,
MediaType.APPLICATION_JSON_TYPE, null, outputStream);
- return outputStream.toString(StandardCharsets.UTF_8.name());
+ return outputStream.toString(StandardCharsets.UTF_8);
}
private static String toJson(final NormalizedNodeContext readData) throws IOException {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
writer.writeTo(readData, NormalizedNodeContext.class, null, EMPTY_ANNOTATIONS,
MediaType.APPLICATION_JSON_TYPE, null, outputStream);
- return outputStream.toString(StandardCharsets.UTF_8.name());
+ return outputStream.toString(StandardCharsets.UTF_8);
}
private static boolean isDataMissing(final Exception exception) {
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Optional;
import javax.ws.rs.core.Response;
Response response = PostDataTransactionUtil.postData(this.uriInfo, payload,
new MdsalRestconfStrategy(transactionChainHandler), this.schema, null, null);
assertEquals(201, response.getStatus());
- assertThat(URLDecoder.decode(response.getLocation().toString(), "UTF-8"),
+ assertThat(URLDecoder.decode(response.getLocation().toString(), StandardCharsets.UTF_8),
containsString(identifier.getValue(identifier.keySet().iterator().next()).toString()));
verify(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, node);
verify(this.readWrite).put(LogicalDatastoreType.CONFIGURATION, node, data.getValue().iterator().next());
response = PostDataTransactionUtil.postData(this.uriInfo, payload,
new NetconfRestconfStrategy(netconfService), this.schema, null, null);
assertEquals(201, response.getStatus());
- assertThat(URLDecoder.decode(response.getLocation().toString(), "UTF-8"),
+ assertThat(URLDecoder.decode(response.getLocation().toString(), StandardCharsets.UTF_8),
containsString(identifier.getValue(identifier.keySet().iterator().next()).toString()));
verify(this.netconfService).getConfig(node);
verify(this.netconfService).create(LogicalDatastoreType.CONFIGURATION, node, data.getValue().iterator().next(),