Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated utility methods #2762

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 2 additions & 24 deletions testng-collections/src/main/java/org/testng/util/Strings.java
Expand Up @@ -10,17 +10,6 @@ private Strings() {
// Utility class. Defeat instantiation.
}

// TODO: When TestNG moves to JDK11 as the default JDK this method needs to be deprecated and
// removed
// because now this method is present in JDK11 as part of the JDK itself.
// See
// https://hg.openjdk.java.net/jdk/jdk/file/fc16b5f193c7/src/java.base/share/classes/java/lang/String.java#l2984
/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
@Deprecated
public static String repeat(String text, int count) {
return text.repeat(count);
}

public static boolean isNullOrEmpty(String string) {
return Optional.ofNullable(string).orElse("").trim().isEmpty();
}
Expand All @@ -29,17 +18,6 @@ public static boolean isNotNullAndNotEmpty(String string) {
return !isNullOrEmpty(string);
}

/**
* @param string - The input String.
* @return - Returns an empty string if the input String is <code>null</code> (or) empty, else it
* returns back the input string.
* @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code>
*/
@Deprecated
public static String getValueOrEmpty(String string) {
return Optional.ofNullable(string).orElse("");
}

private static final Map<String, String> ESCAPE_HTML_MAP = Maps.newLinkedHashMap();

static {
Expand All @@ -60,8 +38,8 @@ public static String valueOf(Map<?, ?> m) {
return m.values().stream().map(Object::toString).collect(Collectors.joining(" "));
}

/** @deprecated - This is deprecated of TestNG <code>7.6.0</code> */
@Deprecated
// Don't remove this method. This is being called as part of the Gradle build. Removing this
krmahadevan marked this conversation as resolved.
Show resolved Hide resolved
// causes build to fail due to NoSuchMethodError
public static String join(String delimiter, String[] parts) {
return String.join(delimiter, parts);
}
Expand Down
63 changes: 0 additions & 63 deletions testng-core/src/main/java/org/testng/reporters/Files.java
@@ -1,18 +1,9 @@
package org.testng.reporters;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;

Expand All @@ -22,63 +13,9 @@ private Files() {
// defeat instantiation
}

/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
@Deprecated
public static String readFile(File f) throws IOException {
try (InputStream is = new FileInputStream(f)) {
return readFile(is);
}
}

public static String readFile(InputStream is) throws IOException {
return new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))
.lines()
.collect(Collectors.joining("\n"));
}

/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
@Deprecated
public static void writeFile(String string, File f) throws IOException {
f.getParentFile().mkdirs();
try (FileWriter fw = new FileWriter(f);
BufferedWriter bw = new BufferedWriter(fw)) {
bw.write(string);
}
}

/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
@Deprecated
public static void copyFile(InputStream from, File to) throws IOException {
if (!to.getParentFile().exists()) {
to.getParentFile().mkdirs();
}

try (OutputStream os = new FileOutputStream(to)) {
byte[] buffer = new byte[65536];
int count = from.read(buffer);
while (count > 0) {
os.write(buffer, 0, count);
count = from.read(buffer);
}
}
}

/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
@Deprecated
public static String streamToString(InputStream is) throws IOException {
if (is != null) {
Writer writer = new StringWriter();

char[] buffer = new char[1024];
try (Reader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
int n;
while ((n = reader.read(buffer)) != -1) {
writer.write(buffer, 0, n);
}
}
return writer.toString();
} else {
return "";
}
}
}