chore: remove demo code from project #179
@@ -1,12 +0,0 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.example;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple HelloWorld class.
|
|
||||||
*/
|
|
||||||
public class HelloWorld {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println("Hello World");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.example.gui.javafx;
|
|
||||||
|
|
||||||
import javafx.application.Application;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an example JavaFX-Application.
|
|
||||||
*/
|
|
||||||
public class GUI extends Application {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launching this method will not work on some platforms.
|
|
||||||
* What you should do is to create a separate main class and launch the GUI class from there as is done in {@link Main}
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
launch(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start(Stage stage) {
|
|
||||||
String javaVersion = System.getProperty("java.version");
|
|
||||||
String javafxVersion = System.getProperty("javafx.version");
|
|
||||||
Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
|
|
||||||
Scene scene = new Scene(new StackPane(l), 640, 480);
|
|
||||||
stage.setScene(scene);
|
|
||||||
stage.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.example.gui.javafx;
|
|
||||||
|
|
||||||
import javafx.application.Application;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is simply a wrapper to launch the {@link GUI} class.
|
|
||||||
* The reason this class exists is documented in {@link GUI#main(String[])}
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Application.launch(GUI.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
package ch.unibas.dmi.dbis.cs108.example;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An example test class.
|
|
||||||
* Checks the output of the {@link HelloWorld} class and makes sure it contains "Hello World"
|
|
||||||
*/
|
|
||||||
public class HelloWorldTest {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Streams to store system.out and system.err content
|
|
||||||
*/
|
|
||||||
private ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
|
||||||
private ByteArrayOutputStream errStream = new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Here we store the previous pointers to system.out / system.err
|
|
||||||
*/
|
|
||||||
private PrintStream outBackup;
|
|
||||||
private PrintStream errBackup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is executed before each test.
|
|
||||||
* It redirects System.out and System.err to our variables {@link #outStream} and {@link #errStream}.
|
|
||||||
* This allows us to test their content later.
|
|
||||||
*/
|
|
||||||
@BeforeEach
|
|
||||||
public void redirectStdOutStdErr() {
|
|
||||||
outBackup = System.out;
|
|
||||||
errBackup = System.err;
|
|
||||||
System.setOut(new PrintStream(outStream));
|
|
||||||
System.setErr(new PrintStream(errStream));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is run after each test.
|
|
||||||
* It redirects System.out / System.err back to the normal streams.
|
|
||||||
*/
|
|
||||||
@AfterEach
|
|
||||||
public void reestablishStdOutStdErr() {
|
|
||||||
System.setOut(outBackup);
|
|
||||||
System.setErr(errBackup);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is a normal JUnit-Test. It executes the HelloWorld-Method and verifies that it actually wrote "Hello World" to stdout
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
HelloWorld.main(new String[0]);
|
|
||||||
String toTest = outStream.toString();
|
|
||||||
toTest = removeNewline(toTest);
|
|
||||||
assertTrue(toTest.contains("Hello World"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String removeNewline(String str) {
|
|
||||||
return str.replace("\n", "").replace("\r", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user