mirror of
https://github.com/nasa/trick.git
synced 2025-02-11 05:01:18 +00:00
SIE Application Tests Reimplemented
This commit is contained in:
parent
5bdf7e0151
commit
47862461ee
@ -0,0 +1,75 @@
|
|||||||
|
package trick.sie;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.jdesktop.application.Application;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import trick.common.CheckApplicationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Test SieApplication life cycle.
|
||||||
|
*
|
||||||
|
* @author hchen
|
||||||
|
* @intern mrockwell2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SieApplicationTest {
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
WaitForSieApplication.launchAndWait(WaitForSieApplication.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownAfterClass() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReady() {
|
||||||
|
assertTrue("SieApplicationTest 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 = {"saveVariableDetails", "showVariableDetails"};
|
||||||
|
String[] actionTexts = {"Save Variable Details ...", "Show Details"};
|
||||||
|
|
||||||
|
for (int i = 0; i < actionNames.length; i++) {
|
||||||
|
CheckApplicationProperties.checkAction(application().actionMap, actionNames[i]);
|
||||||
|
CheckApplicationProperties.checkActionText(application().actionMap, actionNames[i], actionTexts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefinedKeyText() {
|
||||||
|
CheckApplicationProperties.checkKeyText(application().resourceMap, "fileMenu.text", "&File");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExit() {
|
||||||
|
application().removeExitListener(application().exitListener);
|
||||||
|
application().exit();
|
||||||
|
assertTrue(application().isEnded);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WaitForSieApplication application() {
|
||||||
|
return Application.getInstance(WaitForSieApplication.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package trick.sie;
|
||||||
|
|
||||||
|
|
||||||
|
import org.jdesktop.application.Application;
|
||||||
|
|
||||||
|
import trick.sie.SieApplication;
|
||||||
|
|
||||||
|
|
||||||
|
public class WaitForSieApplication extends SieApplication {
|
||||||
|
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 SieApplication and block
|
||||||
|
* (wait) until it's startup() method has run.
|
||||||
|
*/
|
||||||
|
public static void launchAndWait(Class<? extends WaitForSieApplication> applicationClass) {
|
||||||
|
synchronized(lock) {
|
||||||
|
// Set path to S_sie.resource (src/test/resources/S_sie.resource)
|
||||||
|
final String sep = java.io.File.separator;
|
||||||
|
sieResourcePath = String.format("src%1$stest%1$sresources%1$sS_sie.resource", sep);
|
||||||
|
|
||||||
|
Application.launch(applicationClass, new String[]{});
|
||||||
|
while(true) {
|
||||||
|
try {
|
||||||
|
lock.wait();
|
||||||
|
}
|
||||||
|
catch (InterruptedException e) {
|
||||||
|
System.err.println("launchAndWait interrupted!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Application app = Application.getInstance(WaitForSieApplication.class);
|
||||||
|
if (app instanceof WaitForSieApplication) {
|
||||||
|
if (((WaitForSieApplication)app).isReady()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user