mirror of
https://github.com/nasa/trick.git
synced 2025-04-07 19:34:23 +00:00
#521 added unit tests to build and 3rd party XML formatter that does not rely on ant
This commit is contained in:
parent
050e552d7c
commit
86eb23c7de
BIN
libexec/trick/java/lib/JUnitXmlFormatter.jar
Normal file
BIN
libexec/trick/java/lib/JUnitXmlFormatter.jar
Normal file
Binary file not shown.
@ -15,7 +15,8 @@ EXTERNAL_JARS = \
|
||||
jfreesvg-2.1.jar \
|
||||
jopt-simple-4.8.jar \
|
||||
junit-4.12.jar \
|
||||
swingx-1.6.1.jar
|
||||
swingx-1.6.1.jar \
|
||||
hamcrest-core-1.3.jar
|
||||
|
||||
external_jars : ${EXTERNAL_JARS}
|
||||
|
||||
@ -35,6 +36,8 @@ junit-4.12.jar:
|
||||
curl -O http://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar
|
||||
swingx-1.6.1.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/org/swinglabs/swingx/1.6.1/swingx-1.6.1.jar
|
||||
hamcrest-core-1.3.jar :
|
||||
curl -O http://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
|
||||
|
||||
clean:
|
||||
rm -f ${EXTERNAL_JARS}
|
||||
|
69
trick_source/java/test/Makefile
Normal file
69
trick_source/java/test/Makefile
Normal file
@ -0,0 +1,69 @@
|
||||
# To run new unit tests, add new tests to the "test" target
|
||||
|
||||
TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../../..)
|
||||
|
||||
# Get JAVAC definition
|
||||
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
||||
|
||||
JAVAC ?= javac
|
||||
JAVAC_FLAGS = -g -Xlint:unchecked -Xlint:deprecation
|
||||
# delineate 'javac -version' for version number
|
||||
JAVAC_VERSION := $(shell ${JAVAC} -version 2>&1 | perl -ne 'print /(\d+)/')
|
||||
|
||||
# include java.se.ee for JAXB xml annotations (for trick-tv) in java version 9
|
||||
ifeq ($(JAVAC_VERSION),9)
|
||||
JAVAC_FLAGS += --add-modules java.se.ee
|
||||
endif
|
||||
|
||||
SRC_DIR = src
|
||||
SRC_FILES = $(shell find ${SRC_DIR} -type f -name \*.java)
|
||||
BUILD_DIR = build
|
||||
DEST_DIR = ${BUILD_DIR}/classes
|
||||
LIB_DIR = ${TRICK_HOME}/$(LIBEXEC)/trick/java/lib
|
||||
DIST_DIR = ${TRICK_HOME}/$(LIBEXEC)/trick/java/dist
|
||||
TEST_DIR = ${TRICK_HOME}/$(LIBEXEC)/trick/java/test
|
||||
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
CLASS_PATH = $(subst $(space),:,$(wildcard ${LIB_DIR}/*.jar):${DIST_DIR}/trick.jar)
|
||||
|
||||
RESOURCES = $(subst src/,,$(shell find src/trick -name resources))
|
||||
RESOURCES += $(subst src/,,$(shell find src/trick -name jaxb.index))
|
||||
|
||||
all: test
|
||||
@echo "[32mJava test successful[0m"
|
||||
test: ${TEST_DIR}/test.jar
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_RunTimeTrickApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.common.RunTimeTrickApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_TrickApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.common.TrickApplicationTest
|
||||
# java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_LogHeaderReaderTest.xml barrypitman.junitXmlFormatter.Runner trick.common.utils.LogHeaderReaderTest
|
||||
# java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_UnitTypeTest.xml barrypitman.junitXmlFormatter.Runner trick.common.utils.UnitTypeTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_TrickDPApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.dataproducts.trickdp.TrickDPApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_TrickQPApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.dataproducts.trickqp.TrickQPApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_DreApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.dre.DreApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_MonteMonitorApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.montemonitor.MonteMonitorApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_MtvApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.mtv.MtvApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_SieApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.sie.SieApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_SimControlApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.simcontrol.SimControlApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_SnifferApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.sniffer.SnifferApplicationTest
|
||||
java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_TVApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.tv.TVApplicationTest
|
||||
|
||||
${DEST_DIR} ${TEST_DIR}:
|
||||
mkdir -p $@
|
||||
|
||||
${TEST_DIR}/test.jar: compile ${TEST_DIR}
|
||||
@echo "[36mCreating jar file...[0m"
|
||||
@jar cf ${TEST_DIR}/test.jar -C ${DEST_DIR} .
|
||||
|
||||
trick_guis:
|
||||
@ $(MAKE) -C ..
|
||||
|
||||
compile: ${DEST_DIR} trick_guis
|
||||
@echo "[36mBuilding Trick GUI tests ..[0m"
|
||||
@${JAVAC} ${JAVAC_FLAGS} -classpath ${CLASS_PATH} -d ${DEST_DIR} -sourcepath ${SRC_DIR} ${SRC_FILES}
|
||||
|
||||
clean:
|
||||
rm -rf ${BUILD_DIR}
|
||||
rm -rf ${TEST_DIR}
|
||||
|
||||
clean_obj:
|
||||
rm -rf ${BUILD_DIR}
|
@ -1,79 +0,0 @@
|
||||
package trick.stripchart;
|
||||
|
||||
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 StripchartApplication life cycle.
|
||||
*
|
||||
* @author hchen
|
||||
*
|
||||
*/
|
||||
public class StripchartApplicationTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
WaitForStripchartApplication.launchAndWait(WaitForStripchartApplication.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("StripchartApplicationTest 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 = {"toggle_xrange", "start_stop", "legend_onoff", "postscript"};
|
||||
String[] actionTexts = {"Toggle Range", "Toggle Start/Stop", "Legend On/Off", "Postscript..."};
|
||||
String[] actionShortDescriptions = {"Set x-axis range to automatic scaling (All), or fixed-width (Strip).",
|
||||
"Start/Stop graph refreshing.",
|
||||
"Hide/Display the graph's Legend.",
|
||||
"Save a copy of the graph to postscript file."};
|
||||
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, "settingsMenu.text", "&Settings");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExit() {
|
||||
application().removeExitListener(application().exitListener);
|
||||
application().exit();
|
||||
assertTrue(application().isEnded);
|
||||
}
|
||||
|
||||
private static WaitForStripchartApplication application() {
|
||||
return Application.getInstance(WaitForStripchartApplication.class);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package trick.stripchart;
|
||||
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
|
||||
|
||||
public class WaitForStripchartApplication extends StripchartApplication {
|
||||
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 StripchartApplication and block
|
||||
* (wait) until it's startup() method has run.
|
||||
*/
|
||||
public static void launchAndWait(Class<? extends WaitForStripchartApplication> applicationClass) {
|
||||
synchronized(lock) {
|
||||
String[] args = new String[] {"-demo"};
|
||||
try {
|
||||
Application.launch(applicationClass, args);
|
||||
} catch (Exception e) {
|
||||
lock.notifyAll();
|
||||
return;
|
||||
}
|
||||
|
||||
while(true) {
|
||||
try {
|
||||
lock.wait();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
System.err.println("launchAndWait interrupted!");
|
||||
break;
|
||||
}
|
||||
Application app = Application.getInstance(WaitForStripchartApplication.class);
|
||||
if (app instanceof WaitForStripchartApplication) {
|
||||
if (((WaitForStripchartApplication)app).isReady()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user