Skip to content

Commit 68d9c48

Browse files
committed
Remove deprecated utility methods
1 parent 53ea2ad commit 68d9c48

File tree

2 files changed

+2
-87
lines changed
  • testng-collections/src/main/java/org/testng/util
  • testng-core/src/main/java/org/testng/reporters

2 files changed

+2
-87
lines changed

testng-collections/src/main/java/org/testng/util/Strings.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,6 @@ private Strings() {
1010
// Utility class. Defeat instantiation.
1111
}
1212

13-
// TODO: When TestNG moves to JDK11 as the default JDK this method needs to be deprecated and
14-
// removed
15-
// because now this method is present in JDK11 as part of the JDK itself.
16-
// See
17-
// https://hg.openjdk.java.net/jdk/jdk/file/fc16b5f193c7/src/java.base/share/classes/java/lang/String.java#l2984
18-
/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
19-
@Deprecated
20-
public static String repeat(String text, int count) {
21-
return text.repeat(count);
22-
}
23-
2413
public static boolean isNullOrEmpty(String string) {
2514
return Optional.ofNullable(string).orElse("").trim().isEmpty();
2615
}
@@ -29,17 +18,6 @@ public static boolean isNotNullAndNotEmpty(String string) {
2918
return !isNullOrEmpty(string);
3019
}
3120

32-
/**
33-
* @param string - The input String.
34-
* @return - Returns an empty string if the input String is <code>null</code> (or) empty, else it
35-
* returns back the input string.
36-
* @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code>
37-
*/
38-
@Deprecated
39-
public static String getValueOrEmpty(String string) {
40-
return Optional.ofNullable(string).orElse("");
41-
}
42-
4321
private static final Map<String, String> ESCAPE_HTML_MAP = Maps.newLinkedHashMap();
4422

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

63-
/** @deprecated - This is deprecated of TestNG <code>7.6.0</code> */
64-
@Deprecated
41+
// Don't remove this method. This is being called as part of the Gradle build. Removing this
42+
// causes build to fail due to NoSuchMethodError
6543
public static String join(String delimiter, String[] parts) {
6644
return String.join(delimiter, parts);
6745
}
Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
package org.testng.reporters;
22

33
import java.io.BufferedReader;
4-
import java.io.BufferedWriter;
5-
import java.io.File;
6-
import java.io.FileInputStream;
7-
import java.io.FileOutputStream;
8-
import java.io.FileWriter;
94
import java.io.IOException;
105
import java.io.InputStream;
116
import java.io.InputStreamReader;
12-
import java.io.OutputStream;
13-
import java.io.Reader;
14-
import java.io.StringWriter;
15-
import java.io.Writer;
167
import java.nio.charset.StandardCharsets;
178
import java.util.stream.Collectors;
189

@@ -22,63 +13,9 @@ private Files() {
2213
// defeat instantiation
2314
}
2415

25-
/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
26-
@Deprecated
27-
public static String readFile(File f) throws IOException {
28-
try (InputStream is = new FileInputStream(f)) {
29-
return readFile(is);
30-
}
31-
}
32-
3316
public static String readFile(InputStream is) throws IOException {
3417
return new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))
3518
.lines()
3619
.collect(Collectors.joining("\n"));
3720
}
38-
39-
/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
40-
@Deprecated
41-
public static void writeFile(String string, File f) throws IOException {
42-
f.getParentFile().mkdirs();
43-
try (FileWriter fw = new FileWriter(f);
44-
BufferedWriter bw = new BufferedWriter(fw)) {
45-
bw.write(string);
46-
}
47-
}
48-
49-
/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
50-
@Deprecated
51-
public static void copyFile(InputStream from, File to) throws IOException {
52-
if (!to.getParentFile().exists()) {
53-
to.getParentFile().mkdirs();
54-
}
55-
56-
try (OutputStream os = new FileOutputStream(to)) {
57-
byte[] buffer = new byte[65536];
58-
int count = from.read(buffer);
59-
while (count > 0) {
60-
os.write(buffer, 0, count);
61-
count = from.read(buffer);
62-
}
63-
}
64-
}
65-
66-
/** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
67-
@Deprecated
68-
public static String streamToString(InputStream is) throws IOException {
69-
if (is != null) {
70-
Writer writer = new StringWriter();
71-
72-
char[] buffer = new char[1024];
73-
try (Reader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
74-
int n;
75-
while ((n = reader.read(buffer)) != -1) {
76-
writer.write(buffer, 0, n);
77-
}
78-
}
79-
return writer.toString();
80-
} else {
81-
return "";
82-
}
83-
}
8421
}

0 commit comments

Comments
 (0)