Skip to content

Commit

Permalink
Modernize (#93)
Browse files Browse the repository at this point in the history
Apply changes reported by Modernizer
  • Loading branch information
cstamas authored Sep 10, 2024
1 parent ce388e0 commit 8cecae7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assume;
Expand Down Expand Up @@ -63,7 +64,7 @@ public void testBasic() throws Exception {
}

private void write(File file, String string) throws IOException {
try (Writer w = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) {
try (Writer w = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
w.write(string);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
Expand Down Expand Up @@ -234,7 +235,8 @@ protected ProjectBuildingRequest getProjectBuildingRequest(MavenExecutionRequest

protected File getPomFile(File pom) throws IOException {
if (!pom.exists()) {
try (BufferedWriter w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(pom), "UTF-8"))) {
try (BufferedWriter w =
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(pom), StandardCharsets.UTF_8))) {
w.write("<?xml version='1.0' encoding='UTF-8'?>\n");
w.write("<project>\n");
w.write("<modelVersion>4.0.0</modelVersion>\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -117,7 +118,7 @@ public void addLoadURL(URL url) {
}

public void store(OutputStream os) throws IOException {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os, "UTF-8")); // $NON-NLS-1$
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8)); // $NON-NLS-1$
out.write(String.format("main is %s from %s\n", mainType, mainRealm));
for (Map.Entry<String, List<String>> realm : realms.entrySet()) {
out.write(String.format("[%s]\n", realm.getKey()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public boolean supportsTestTemplate(ExtensionContext context) {
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
String displayName = context.getDisplayName();
String[] installations = context.getTestClass()
.get()
.orElseThrow()
.getAnnotation(MavenInstallations.class)
.value();
return Arrays.stream(installations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public boolean supportsTestTemplate(ExtensionContext context) {
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
String displayName = context.getDisplayName();
String[] versions =
context.getTestClass().get().getAnnotation(MavenVersions.class).value();
String[] versions = context.getTestClass()
.orElseThrow()
.getAnnotation(MavenVersions.class)
.value();
List<TestTemplateInvocationContext> contexts = new ArrayList<>();
List<Throwable> errors = new ArrayList<>();

Expand Down

0 comments on commit 8cecae7

Please sign in to comment.