Add ability to test welcome info retrieval from IDE

This commit is contained in:
SiboVG 2023-02-02 02:31:21 +00:00
parent 90fb0f0470
commit 8171492a8a
2 changed files with 7 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import net.sf.openrocket.util.BuildProperties;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@ -22,7 +23,12 @@ public abstract class WelcomeInfoRetriever {
ClassLoader cl = WelcomeInfoRetriever.class.getClassLoader();
InputStream in = cl.getResourceAsStream("ReleaseNotes.md");
if (in == null) {
throw new FileNotFoundException("ReleaseNotes.md not found");
// Try to load the file from the file system (only really useful when running the unit tests directly from your IDE)
File f = new File("../ReleaseNotes.md");
in = f.toURI().toURL().openStream();
if (in == null) {
throw new FileNotFoundException("ReleaseNotes.md not found");
}
}
InputSource source = new InputSource(new InputStreamReader(in));
ReleaseNotesHandler handler = new ReleaseNotesHandler(version);

View File

@ -9,10 +9,6 @@ import static org.junit.Assert.assertTrue;
public class WelcomeInfoTest extends BaseTestCase {
/**
* Note: this unit test will fail if you don't run it using 'ant unittest', because otherwise
* it can't load the ReleaseNotes.md file.
*/
@Test
public void testWelcomeInfo() throws Exception {
// Test the welcome info for the current build version