Skip to content

Commit 90dc04c

Browse files
committed
Merge remote-tracking branch 'origin/GP-0-dragonmacher-test-fixes-2-8-24' into patch
2 parents 3d5f8a5 + 4099544 commit 90dc04c

File tree

2 files changed

+24
-33
lines changed

2 files changed

+24
-33
lines changed

Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java

+12-21
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.awt.image.BufferedImage;
2222
import java.io.*;
2323
import java.lang.reflect.*;
24-
import java.net.*;
2524
import java.nio.file.*;
2625
import java.util.*;
2726
import java.util.List;
@@ -328,18 +327,6 @@ public static Window windowForComponent(Component c) {
328327
return WindowUtilities.windowForComponent(c);
329328
}
330329

331-
public File getLocalResourceFile(String relativePath) {
332-
URL resource = getClass().getResource(relativePath);
333-
try {
334-
URI uri = resource.toURI();
335-
return new File(uri);
336-
}
337-
catch (URISyntaxException e) {
338-
Msg.error(this, "Unable to convert URL to URI", e);
339-
}
340-
return null;
341-
}
342-
343330
/**
344331
* Load a text resource file into an ArrayList. Each line of the file is
345332
* stored as an item in the list.
@@ -355,13 +342,14 @@ public static List<String> loadTextResource(Class<?> cls, String name) throws IO
355342
if (is == null) {
356343
throw new IOException("Could not find resource: " + name);
357344
}
345+
Msg.debug(AbstractGenericTest.class, "Loading classpath resource: " + name);
358346
BufferedReader br = new BufferedReader(new InputStreamReader(is));
359-
ArrayList<String> text = readText(br);
347+
List<String> text = readText(br);
360348
br.close();
361349
return text;
362350
}
363351

364-
private static ArrayList<String> readText(BufferedReader br) throws IOException {
352+
private static List<String> readText(BufferedReader br) throws IOException {
365353
ArrayList<String> list = new ArrayList<>();
366354
String line = "";
367355
while (line != null) {
@@ -374,10 +362,11 @@ private static ArrayList<String> readText(BufferedReader br) throws IOException
374362

375363
}
376364

377-
public static ArrayList<String> loadTextResource(String name) throws IOException {
365+
public static List<String> loadTextResource(String name) throws IOException {
378366
File file = getTestDataFile(name);
367+
Msg.debug(AbstractGenericTest.class, "Loading text file: " + file);
379368
BufferedReader reader = new BufferedReader(new FileReader(file));
380-
ArrayList<String> text = readText(reader);
369+
List<String> text = readText(reader);
381370
reader.close();
382371
return text;
383372
}
@@ -396,6 +385,7 @@ public static ArrayList<String> loadTextResource(String name) throws IOException
396385
*/
397386
public static File getTestDataFile(String path) throws FileNotFoundException {
398387
ResourceFile resourceFile = Application.getModuleDataFile("TestResources", path);
388+
Msg.debug(AbstractGenericTest.class, "Loading test data file: " + resourceFile);
399389
return resourceFile.getFile(false);
400390
}
401391

@@ -429,6 +419,7 @@ public static File getTestDataDir(String relativePath)
429419
public static File findTestDataFile(String path) {
430420
try {
431421
ResourceFile resourceFile = Application.getModuleDataFile("TestResources", path);
422+
Msg.debug(AbstractGenericTest.class, "Loading test data file: " + resourceFile);
432423
return resourceFile.getFile(false);
433424
}
434425
catch (FileNotFoundException e) {
@@ -809,10 +800,10 @@ public File createTempFileForTest(String suffix) throws IOException {
809800
}
810801

811802
/**
812-
* Creates a file in the Java temp directory using the given name as a
803+
* Creates a file in the Application temp directory using the given name as a
813804
* prefix and the given suffix. The final filename will also include the
814805
* current test name, as well as any data added by
815-
* {@link File#createTempFile(String, String)}. The file suffix will be
806+
* {@link File#createTempFile(String, String, File)}. The file suffix will be
816807
* <code>.tmp</code>
817808
* <p>
818809
* The file will be marked to delete on JVM exit. This will not work if the
@@ -830,10 +821,10 @@ public File createTempFile(String name) throws IOException {
830821
}
831822

832823
/**
833-
* Creates a file in the Java temp directory using the given name as a
824+
* Creates a file in the Application temp directory using the given name as a
834825
* prefix and the given suffix. The final filename will also include the
835826
* current test name, as well as any data added by
836-
* {@link File#createTempFile(String, String)}.
827+
* {@link File#createTempFile(String, String, File)}.
837828
* <p>
838829
* The file will be marked to delete on JVM exit. This will not work if the
839830
* JVM is taken down the hard way, as when pressing the stop button in

Ghidra/Framework/Gui/src/test/java/ghidra/util/HTMLUtilitiesTest.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ public void testToHTML_WithoutNewlines() {
4343
public void testToHTML_WithNewlinesOnly() {
4444
String s = "This text has\na newline character";
4545
String html = HTMLUtilities.toHTML(s);
46-
assertEquals(HTML + "This text has<BR>\na newline character", html);
46+
assertEquals(HTML + "This text has<br>\na newline character", html);
4747
}
4848

4949
@Test
5050
public void testToHTML_WithBrTagsOnly() {
51-
String s = "This text has<BR>an existing BR tag";
51+
String s = "This text has<br>an existing BR tag";
5252
String html = HTMLUtilities.toHTML(s);
5353
assertEquals(HTML + s, html);
5454
spyLogger.assertLogMessage("cannot", "wrap");
5555
}
5656

5757
@Test
5858
public void testToHTML_WithNewlinesAndBrTags() {
59-
String s = "This text has<BR>\nan existing BR tag and a newline";
59+
String s = "This text has<br>\nan existing BR tag and a newline";
6060
String html = HTMLUtilities.toHTML(s);
6161
assertEquals(HTML + s, html);
6262
spyLogger.assertLogMessage("cannot", "wrap");
@@ -68,7 +68,7 @@ public void testToWrappedHTML_DefaultWrapLimit() {
6868
"This is a line that is longer than the default line limit of seventy-five characters";
6969
String html = HTMLUtilities.toWrappedHTML(s);
7070
assertEquals(HTML +
71-
"This is a line that is longer than the default line limit of seventy-five<BR>\n" +
71+
"This is a line that is longer than the default line limit of seventy-five<br>\n" +
7272
"characters", html);
7373
}
7474

@@ -77,14 +77,14 @@ public void testToWrappedHTML_MultipleNewlines_NoLimit() {
7777
// note: toWrappedHTML preserves whitespace
7878
String s = "Wrap\n\nhere\n\n\n";
7979
String html = HTMLUtilities.toWrappedHTML(s, 0);
80-
assertEquals(HTML + "Wrap<BR>\n<BR>\nhere<BR>\n<BR>\n<BR>\n", html);
80+
assertEquals(HTML + "Wrap<br>\n<br>\nhere<br>\n<br>\n<br>\n", html);
8181
}
8282

8383
@Test
8484
public void testToWrappedHTML_SpecifiedWrapLimit() {
8585
String s = "Wrap here";
8686
String html = HTMLUtilities.toWrappedHTML(s, 4);
87-
assertEquals(HTML + "Wrap<BR>\nhere", html);
87+
assertEquals(HTML + "Wrap<br>\nhere", html);
8888
}
8989

9090
@Test
@@ -107,16 +107,16 @@ public void testToLiteralHTML() {
107107

108108
@Test
109109
public void testToLiteralHTML_AlreadyStartingWithHTML() {
110-
String s = "<html>Wrap<BR>here";
110+
String s = "<html>Wrap<br>here";
111111
String html = HTMLUtilities.toLiteralHTML(s, 4);
112-
assertEquals(HTML + "&lt;HTM<BR>\nL&gt;Wr<BR>\nap&lt;B<BR>\nR&gt;he<BR>\nre", html);
112+
assertEquals(HTML + "&lt;htm<br>\nl&gt;Wr<br>\nap&lt;b<br>\nr&gt;he<br>\nre", html);
113113
}
114114

115115
@Test
116116
public void testToLiteralHTML_NoExisingHTML_SpecifiedLimit() {
117117
String s = "Wrap here";
118118
String html = HTMLUtilities.toLiteralHTML(s, 4);
119-
assertEquals(HTML + "Wrap<BR>\n&nbsp;<BR>\nhere", html);
119+
assertEquals(HTML + "Wrap<br>\n&nbsp;<br>\nhere", html);
120120
}
121121

122122
@Test
@@ -143,23 +143,23 @@ public void testLinkPlaceholder() {
143143
String placeholderStr =
144144
HTMLUtilities.wrapWithLinkPlaceholder("Stuff inside link tag", "targetstr");
145145
String htmlStr = HTMLUtilities.convertLinkPlaceholdersToHyperlinks(placeholderStr);
146-
assertEquals("<A HREF=\"targetstr\">Stuff inside link tag</A>", htmlStr);
146+
assertEquals("<a href=\"targetstr\">Stuff inside link tag</a>", htmlStr);
147147
}
148148

149149
@Test
150150
public void testLinkPlaceholder_Regex_backrefs() {
151151
String placeholderStr =
152152
HTMLUtilities.wrapWithLinkPlaceholder("Stuff inside link tag", "test$1");
153153
String htmlStr = HTMLUtilities.convertLinkPlaceholdersToHyperlinks(placeholderStr);
154-
assertEquals("<A HREF=\"test$1\">Stuff inside link tag</A>", htmlStr);
154+
assertEquals("<a href=\"test$1\">Stuff inside link tag</a>", htmlStr);
155155
}
156156

157157
@Test
158158
public void testLinkPlaceholder_htmlchars() {
159159
String placeholderStr =
160160
HTMLUtilities.wrapWithLinkPlaceholder("Stuff inside <b>link</b> tag", "test");
161161
String htmlStr = HTMLUtilities.convertLinkPlaceholdersToHyperlinks(placeholderStr);
162-
assertEquals("<A HREF=\"test\">Stuff inside <b>link</b> tag</A>", htmlStr);
162+
assertEquals("<a href=\"test\">Stuff inside <b>link</b> tag</a>", htmlStr);
163163
}
164164

165165
@Test

0 commit comments

Comments
 (0)