diff --git a/trick_source/java/pom.xml b/trick_source/java/pom.xml
index 8e3908a1..09fc9d52 100644
--- a/trick_source/java/pom.xml
+++ b/trick_source/java/pom.xml
@@ -324,14 +324,14 @@
true
**/SimControlApplicationTest.java
-
+ **/DreApplicationTest.java
**/TrickDPApplicationTest.java
**/TrickQPApplicationTest.java
**/MonteMonitorApplicationTest.java
**/MtvApplicationTest.java
**/SieApplicationTest.java
**/SnifferApplicationTest.java
- **/TVApplicationTest.java
+
diff --git a/trick_source/java/src/test/.gitignore b/trick_source/java/src/test/.gitignore
new file mode 100644
index 00000000..fcae7e14
--- /dev/null
+++ b/trick_source/java/src/test/.gitignore
@@ -0,0 +1,2 @@
+resources/RUN_gui_test/*
+!resources/RUN_gui_test/input.py
\ No newline at end of file
diff --git a/trick_source/java/src/test/java/trick/tv/MockTVApplication.java b/trick_source/java/src/test/java/trick/tv/MockTVApplication.java
new file mode 100644
index 00000000..4205eeb2
--- /dev/null
+++ b/trick_source/java/src/test/java/trick/tv/MockTVApplication.java
@@ -0,0 +1,18 @@
+package trick.tv;
+
+
+import org.jdesktop.application.Application;
+
+
+public class MockTVApplication extends TVApplication {
+
+ @Override
+ protected void initialize(String[] args) {
+ for(int i = 0; i < args.length; i++)
+ System.out.println((i+1) + ": " + args[i]);
+ super.initialize(args);
+ }
+ public static void main(String[] args) {
+ Application.launch(MockTVApplication.class, args);
+ }
+}
\ No newline at end of file
diff --git a/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java b/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java
index d113078d..67bae9ea 100644
--- a/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java
+++ b/trick_source/java/src/test/java/trick/tv/TVApplicationTest.java
@@ -1,6 +1,7 @@
package trick.tv;
-import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.net.ServerSocket;
import org.jdesktop.application.Application;
import org.junit.After;
@@ -9,7 +10,15 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import trick.common.ApplicationTest;
import trick.common.CheckApplicationProperties;
+import trick.dre.MockDreApplication;
+import trick.dre.fixtures.DreFixture;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assumptions.assumeThat;
+import static org.assertj.swing.launcher.ApplicationLauncher.application;
+import static org.junit.Assert.assertTrue;
/**
*
@@ -18,75 +27,38 @@ import trick.common.CheckApplicationProperties;
* @author hchen
*
*/
-public class TVApplicationTest {
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- WaitForTVApplication.launchAndWait(WaitForTVApplication.class);
- }
+public class TVApplicationTest extends ApplicationTest {
+ private static final int PORT = getOpenPort();
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
+ @BeforeClass
+ public static void onSetUpBeforeClass() {
+ System.out.println("Port: " + PORT);
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testReady() {
- assertTrue("TVApplicationTest is not ready yet!", application().isReady());
- }
-
- /**
- * Verify that all implemented actions exist as well as their text, shortDescription properties.
- */
- /*@Test
- public void testDefinedActions() {
- String[] actionNames = {"newSession", "openSession", "openAndSet", "set", "saveSession", "startMonitoring",
- "stopMonitoring", "stripchartSelection", "removeSelection", "addVariablesFromTree",
- "addVariablesFromList", "purgeBadRefs", "commitVariableAddition"};
- String[] actionTexts = {"New", "Open", "Open & Set", "Set", "Save", "Start the Monitor", "Stop the Monitor",
- "Stripchart Selection", "Remove Selection", "Add Selection", "Add Selection",
- "Purge BAD_REFs", "Ok"};
- String[] actionShortDescriptions = {"Clear the variable table.", "Replace the variable table with a TV input file without setting the values.",
- "Replace the variable table with a TV input file and set each value.",
- "Set the variable values from a TV input file without changing the variable table.",
- "Save the variable table to a TV input file.",
- "Start updating variable values.", "Stop updating variable values.",
- "Stripchart the selected variables.", "Delete the selected rows.",
- "Begin watching the selected variables.", "Begin watching the selected variables.",
- "Remove all variables that failed to resolve.", "Commit the variable additions."};
- for (int i = 0; i < actionNames.length; i++) {
- CheckApplicationProperties.checkAction(application().actionMap, actionNames[i]);
- CheckApplicationProperties.checkActionText(application().actionMap, actionNames[i], actionTexts[i]);
- CheckApplicationProperties.checkActionShortDescription(application().actionMap, actionNames[i], actionShortDescriptions[i]);
- }
- }*/
-
- @Test
- public void testDefinedKeyText() {
- CheckApplicationProperties.checkKeyText(application().resourceMap, "fileMenu.text", "&File");
- /*CheckApplicationProperties.checkKeyText(application().resourceMap, "actionsMenu.text", "&Actions");
- CheckApplicationProperties.checkKeyText(application().resourceMap, "preferencesMenu.text", "&Preferences");
- CheckApplicationProperties.checkKeyText(application().resourceMap, "notifyOnDisconnectCheckBoxMenuItem.text", "Not&ify on Disconnect");
- CheckApplicationProperties.checkKeyText(application().resourceMap, "caseInsensitiveCheckBox.text", "Case Insensitive");
- CheckApplicationProperties.checkKeyText(application().resourceMap, "containsRadioButton.text", "Contains");
- CheckApplicationProperties.checkKeyText(application().resourceMap, "regularExpressionRadioButton.text", "RegEx");*/
}
-
- @Test
- public void testExit() {
- application().removeExitListener(application().exitListener);
- application().exit();
- assertTrue(application().isEnded);
+
+ public static int getOpenPort() {
+ int port = -1;
+ try {
+ ServerSocket temp = new ServerSocket(0);
+ port = temp.getLocalPort();
+ temp.close();
+ } catch(IOException e) {
+ System.out.println("Free Port Not Found");
+ }
+
+ return port;
}
-
- private static WaitForTVApplication application() {
- return Application.getInstance(WaitForTVApplication.class);
+
+ @Override
+ protected void onSetUp() {
+ application(MockTVApplication.class).start();
+
+ sleep(1500);
}
+
+ @Test
+ public void testGeneric() {
+ sleep(5000);
+ assertThat(true).isTrue();
+ }
}
\ No newline at end of file
diff --git a/trick_source/java/src/test/java/trick/tv/WaitForTVApplication.java b/trick_source/java/src/test/java/trick/tv/WaitForTVApplication.java
deleted file mode 100644
index 260d229e..00000000
--- a/trick_source/java/src/test/java/trick/tv/WaitForTVApplication.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package trick.tv;
-
-
-import org.jdesktop.application.Application;
-
-
-public class WaitForTVApplication extends TVApplication {
- static Object lock = new Object();
-
- boolean isEnded;
-
- @Override
- protected void end() {
- isEnded = true;
- }
-
- @Override
- protected void ready() {
- super.ready();
- synchronized(lock) {
- lock.notifyAll();
- }
- }
-
-
- /**
- * Launch the specified subclsas of TVApplication and block
- * (wait) until it's startup() method has run.
- */
- public static void launchAndWait(Class extends WaitForTVApplication> applicationClass) {
- synchronized(lock) {
- Application.launch(applicationClass, new String[]{});
- while(true) {
- try {
- lock.wait();
- }
- catch (InterruptedException e) {
- System.err.println("launchAndWait interrupted!");
- break;
- }
- Application app = Application.getInstance(WaitForTVApplication.class);
- if (app instanceof WaitForTVApplication) {
- if (((WaitForTVApplication)app).isReady()) {
- break;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/trick_source/java/src/test/resources/RUN_gui_test/input.py b/trick_source/java/src/test/resources/RUN_gui_test/input.py
new file mode 100644
index 00000000..5f6e5432
--- /dev/null
+++ b/trick_source/java/src/test/resources/RUN_gui_test/input.py
@@ -0,0 +1,32 @@
+
+def get_port():
+ from os import remove
+ from os.path import dirname, abspath
+
+ port_info = dirname(abspath(__file__)) + "/port.info"
+
+ try:
+ f = open(port_info, "r")
+ port_num = int(f.read())
+
+ f.close()
+ remove(port_info)
+
+ print(f"Using Port '{port_num}'")
+ return port_num
+
+ except:
+ print("Port Not Parsed. Using '39595'")
+ return 39595
+
+trick.frame_log_on()
+trick.real_time_enable()
+trick.exec_set_software_frame(0.1)
+trick.itimer_enable()
+
+trick.exec_set_enable_freeze(True)
+trick.exec_set_freeze_command(True)
+
+portnum = get_port()
+
+trick.var_server_set_port(portnum)
\ No newline at end of file