mirror of
https://github.com/nasa/trick.git
synced 2025-02-20 17:22:52 +00:00
Merge pull request #581 from nasa/java-unit-test
Java GUI unit tests reintegrated with Trick
This commit is contained in:
commit
f68950db9f
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}
|
||||
|
@ -1,165 +0,0 @@
|
||||
<project name="trick" default="dist" basedir=".">
|
||||
<description>
|
||||
Build file for Trick JAVA resources
|
||||
</description>
|
||||
<!-- set global properties for this build -->
|
||||
<property environment="env"/>
|
||||
<property name="lib" location="${env.TRICK_HOME}/bin/java/lib" />
|
||||
<property name="src" location="src"/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="build.classes" location="build/classes" />
|
||||
<property name="dist" location="${env.TRICK_HOME}/bin/java/dist"/>
|
||||
<property name="docs" location="docs" />
|
||||
<property name="apidocs" location="docs/api" />
|
||||
<property name="test" location="test" />
|
||||
<property name="test.src" location="test/src" />
|
||||
<property name="build.test" location="build/test" />
|
||||
<property name="test.reports" location="test/reports" />
|
||||
<property name="resources" location="${env.TRICK_HOME}/bin/java/resources" />
|
||||
|
||||
<!--############################################
|
||||
## CLEAN
|
||||
## Remove items from previous build
|
||||
#############################################-->
|
||||
<target name="clean" description="clean up" >
|
||||
<!-- Delete the ${build} and ${dist} directory trees -->
|
||||
<delete dir="${build}"/>
|
||||
<delete dir="${dist}"/>
|
||||
<delete dir="${test.reports}"/>
|
||||
<delete dir="${resources}"/>
|
||||
</target>
|
||||
|
||||
<!--############################################
|
||||
## CHECK JAVA VERSION
|
||||
## Test to see if we have the right version of JVM.
|
||||
#############################################-->
|
||||
<property name="java_minimum_version" value="1.6" />
|
||||
<target name="get-java">
|
||||
<condition property="java.supported">
|
||||
<or>
|
||||
<contains string="${java.version}" substring="${java_minimum_version}" />
|
||||
<contains string="${java.version}" substring="1.7" />
|
||||
<contains string="${java.version}" substring="1.8" />
|
||||
</or>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="check-java" depends="get-java" unless="java.supported">
|
||||
<fail message="Your version of Java (${java.version}) is not supported. Trick requires a minimum of Java ${java_minimum_version}."/>
|
||||
</target>
|
||||
|
||||
<!--############################################
|
||||
## INIT
|
||||
## Initialization of variables for this build
|
||||
#############################################-->
|
||||
<target name="init" depends="check-java">
|
||||
<!-- Create the time stamp -->
|
||||
<tstamp/>
|
||||
<!-- Create the build directory structure used by compile -->
|
||||
<mkdir dir="${build.classes}"/>
|
||||
</target>
|
||||
|
||||
<!--############################################
|
||||
## COMPILE
|
||||
## Compile src/java to ${build}
|
||||
#############################################-->
|
||||
<target name="compile" depends="init" description="compile the source" >
|
||||
|
||||
<!-- Compile the java code from ${src} into ${build} -->
|
||||
<javac srcdir="${src}" destdir="${build.classes}" debug="true" debuglevel="lines,vars,source">
|
||||
<compilerarg value="-Xlint:unchecked"/>
|
||||
<compilerarg value="-Xlint:deprecation"/>
|
||||
<compilerarg value="-g"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!--############################################
|
||||
## DIST
|
||||
## Create distribution directory and build
|
||||
## trick jar
|
||||
#############################################-->
|
||||
<target name="dist" depends="compile,resources" description="generate the distribution" >
|
||||
<!-- Create the distribution directory -->
|
||||
<mkdir dir="${dist}"/>
|
||||
<jar jarfile="${dist}/trick.jar">
|
||||
<fileset dir="${build.classes}" />
|
||||
<fileset dir="${src}" excludes="**/*.java"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="resources" description="copy resources to destination file" >
|
||||
<mkdir dir="${resources}"/>
|
||||
<copy file="src/trick/common/resources/trick_icon.png" todir="${resources}"/>
|
||||
</target>
|
||||
|
||||
<!--############################################
|
||||
## TEST
|
||||
## Compile & Run JUnit tests
|
||||
## Generate test reports in test/reports
|
||||
#############################################-->
|
||||
<target name="pre-compile-test" depends="dist" >
|
||||
<mkdir dir="${build.test}" />
|
||||
<mkdir dir="${test.reports}" />
|
||||
</target>
|
||||
|
||||
<target name="test" depends="pre-compile-test" description="compile and run the JUnit tests" >
|
||||
<javac srcdir="${test.src}" destdir="${build.test}" classpath="${build.classes}" debug="true" debuglevel="lines,vars,source"/>
|
||||
|
||||
<junit printsummary="yes" failureproperty="junit.failure" showoutput="yes" >
|
||||
<classpath>
|
||||
<pathelement location="${build.test}" />
|
||||
</classpath>
|
||||
<classpath location="${dist}/trick.jar" />
|
||||
<batchtest todir="${test.reports}" >
|
||||
<fileset dir="${test.src}" >
|
||||
<include name="**/*Test.java" />
|
||||
</fileset>
|
||||
<formatter type="xml" />
|
||||
</batchtest>
|
||||
</junit>
|
||||
|
||||
<junitreport todir="${test.reports}">
|
||||
<fileset dir="${test.reports}" includes="*.xml" />
|
||||
<report format="frames" todir="${test.reports}/html" />
|
||||
</junitreport>
|
||||
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
|
||||
</target>
|
||||
|
||||
<!--############################################
|
||||
## JAVADOC targets
|
||||
## Targets for building javadocs, running Sun's
|
||||
## doccheck tool, and cleanup of docs
|
||||
#############################################-->
|
||||
<target name="javadoc">
|
||||
<mkdir dir="${apidocs}"/>
|
||||
<javadoc packagenames="trick.*" sourcepath="${src}" Windowtitle="Trick GUI API"
|
||||
destdir="${apidocs}">
|
||||
<link href="http://docs.oracle.com/javase/6/docs/api/"/>
|
||||
<link href="http://www.jdocs.com/swingx/1.0/overview-summary.html"/>
|
||||
<link href="http://www.jfree.org/jfreechart/api/javadoc/"/>
|
||||
<link href="http://junit.sourceforge.net/javadoc/"/>
|
||||
<classpath>
|
||||
<fileset dir="${lib}">
|
||||
<include name="**/*.jar"/> <!-- build against all libraries in ${lib} directory structure -->
|
||||
</fileset>
|
||||
</classpath>
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
<target name="doccheck">
|
||||
<mkdir dir="${apidocs}/doccheck"/>
|
||||
<javadoc packagenames="trick.*" sourcepath="${src}" destdir="${apidocs}/doccheck">
|
||||
<doclet name="com.sun.tools.doclets.doccheck.DocCheck" path="${lib}/doccheck.jar"/>
|
||||
<classpath>
|
||||
<fileset dir="${lib}">
|
||||
<include name="**/*.jar"/> <!-- build against all libraries in ${lib} directory structure -->
|
||||
</fileset>
|
||||
</classpath>
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
<target name="clean_docs">
|
||||
<delete dir="${apidocs}" />
|
||||
</target>
|
||||
|
||||
</project>
|
@ -13,6 +13,10 @@ ifeq ($(JAVAC_VERSION),9)
|
||||
JAVAC_FLAGS += --add-modules java.se.ee
|
||||
endif
|
||||
|
||||
ifeq ($(JAVAC_VERSION),10)
|
||||
JAVAC_FLAGS += --add-modules java.se.ee
|
||||
endif
|
||||
|
||||
SRC_DIR = src
|
||||
SRC_FILES = $(shell find ${SRC_DIR} -type f -name \*.java)
|
||||
BUILD_DIR = build
|
||||
|
@ -110,9 +110,9 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
// if we want to put the properties into a different location, change here.
|
||||
static {
|
||||
try {
|
||||
propDirectory = System.getProperty("user.home") + System.getProperty("file.separator") + ".trick";
|
||||
propDirectory = System.getProperty("user.home") + java.io.File.separator + ".trick";
|
||||
} catch (Exception e) {
|
||||
propDirectory = System.getenv("TRICK_USER_HOME") + System.getProperty("file.separator") + ".trick";
|
||||
propDirectory = System.getenv("TRICK_USER_HOME") + java.io.File.separator + ".trick";
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
applicationName = getContext().getApplicationClass().getSimpleName();
|
||||
|
||||
// set directory for session storage
|
||||
getContext().getLocalStorage().setDirectory(new File(propDirectory + System.getProperty("file.separator") + "." + applicationName));
|
||||
getContext().getLocalStorage().setDirectory(new File(propDirectory + java.io.File.separator + "." + applicationName));
|
||||
|
||||
// register property for JToggleButton class so that its state can be saved
|
||||
getContext().getSessionStorage().putProperty(JToggleButton.class, this);
|
||||
@ -330,7 +330,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
// Load any saved user settable properties from properties file
|
||||
trickProperties = new Properties();
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(propDirectory + System.getProperty("file.separator") + applicationName + ".properties");
|
||||
FileInputStream in = new FileInputStream(propDirectory + java.io.File.separator + applicationName + ".properties");
|
||||
trickProperties.load(in);
|
||||
in.close();
|
||||
}
|
||||
@ -384,7 +384,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
|
||||
// Save any user settable properties to properties file in user's home directory in .trick dir
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(propDirectory + System.getProperty("file.separator") + applicationName +".properties");
|
||||
FileOutputStream out = new FileOutputStream(propDirectory + java.io.File.separator + applicationName +".properties");
|
||||
trickProperties.store(out, "--- Trick User Properties ---");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
|
@ -748,11 +748,11 @@ public class UIUtils {
|
||||
ImageIcon imgIcon = null;
|
||||
|
||||
// if the fileName is a full path
|
||||
if (fileName.indexOf(System.getProperty("file.separator")) != -1) {
|
||||
if (fileName.indexOf(java.io.File.separator) != -1) {
|
||||
imgIcon = new ImageIcon(fileName);
|
||||
} else {
|
||||
// if only a file name specified, try to find it at common resources folder
|
||||
URL imgURL = TrickApplication.class.getResource("resources" + System.getProperty("file.separator") + fileName);
|
||||
URL imgURL = TrickApplication.class.getResource("resources" + java.io.File.separator + fileName);
|
||||
if (imgURL != null) {
|
||||
imgIcon = new ImageIcon(imgURL);
|
||||
}
|
||||
@ -778,11 +778,11 @@ public class UIUtils {
|
||||
try {
|
||||
InputStream ins = null;
|
||||
// if the fileName is a full path
|
||||
if (fileName.indexOf(System.getProperty("file.separator")) != -1) {
|
||||
if (fileName.indexOf(java.io.File.separator) != -1) {
|
||||
ins = new FileInputStream(fileName);
|
||||
} else {
|
||||
// if only a file name, then find it at common resources area
|
||||
ins = TrickApplication.class.getResourceAsStream("resources" + System.getProperty("file.separator") + fileName);
|
||||
ins = TrickApplication.class.getResourceAsStream("resources" + java.io.File.separator + fileName);
|
||||
}
|
||||
return ins;
|
||||
} catch (NullPointerException npe) {
|
||||
|
@ -356,7 +356,7 @@ public class TrickDPApplication extends DataProductsApplication {
|
||||
while (!simFilePath.getName().startsWith("SIM_")) {
|
||||
simFilePath = simFilePath.getParentFile();
|
||||
}
|
||||
String simExeArg = eachItem+System.getProperty("file.separator")+"input.py";
|
||||
String simExeArg = eachItem+java.io.File.separator+"input.py";
|
||||
ProcessBuilder pb = new ProcessBuilder(simExe, simExeArg);
|
||||
pb.directory(simFilePath);
|
||||
printStatusMessage("cd " + simFilePath.getPath() + "\n");
|
||||
@ -869,7 +869,7 @@ public class TrickDPApplication extends DataProductsApplication {
|
||||
// TODO: use TrickFileFilter
|
||||
FilenameFilter simFilter = new FilenameFilter() {
|
||||
public boolean accept(File path, String filename) {
|
||||
File myFullPath = new File(path + System.getProperty("file.separator") + filename);
|
||||
File myFullPath = new File(path + java.io.File.separator + filename);
|
||||
if ( myFullPath.isDirectory() && filename.contains("SIM") ) {
|
||||
return true;
|
||||
} else {
|
||||
@ -894,7 +894,7 @@ public class TrickDPApplication extends DataProductsApplication {
|
||||
*/
|
||||
private String appendDirsFromPropertyFile(String simDirs) {
|
||||
// prevent the duplicate ones
|
||||
File myDpPropFile = new File(propDirectory + System.getProperty("file.separator") + applicationName + ".properties");
|
||||
File myDpPropFile = new File(propDirectory + java.io.File.separator + applicationName + ".properties");
|
||||
if ( myDpPropFile.exists() ) {
|
||||
String dpSimDirsProperty = trickProperties.getProperty("TRICK_DP_SIM_DIRS");
|
||||
// if the property doesn't exist, return the original string
|
||||
|
@ -300,7 +300,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection
|
||||
|
||||
// For PS view
|
||||
private void psView() {
|
||||
File selectedFirstFile = new File(fileDir + System.getProperty("file.separator") + selectedPSFileList.getSelectedFirstData().toString());
|
||||
File selectedFirstFile = new File(fileDir + java.io.File.separator + selectedPSFileList.getSelectedFirstData().toString());
|
||||
try {
|
||||
if (selectedFirstFile.exists() && Desktop.isDesktopSupported()) {
|
||||
Desktop.getDesktop().open(selectedFirstFile);
|
||||
@ -324,7 +324,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection
|
||||
for (Object obj : selectedData) {
|
||||
commandBuf.append(" ");
|
||||
commandBuf.append(fileDir);
|
||||
commandBuf.append(System.getProperty("file.separator"));
|
||||
commandBuf.append(java.io.File.separator);
|
||||
commandBuf.append(obj.toString());
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection
|
||||
for (Object obj : selectedData) {
|
||||
commandBuf.append(" ");
|
||||
commandBuf.append(fileDir);
|
||||
commandBuf.append(System.getProperty("file.separator"));
|
||||
commandBuf.append(java.io.File.separator);
|
||||
commandBuf.append(obj.toString());
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ public class TrickDPActionController {
|
||||
public void launchQP(String[] initialArgs) {
|
||||
// the command variable program command name and arguments
|
||||
List<String> command = new ArrayList<String>();
|
||||
String fileSeparator = System.getProperty("file.separator");
|
||||
String fileSeparator = java.io.File.separator;
|
||||
String pathSeparator = System.getProperty("path.separator");
|
||||
|
||||
String javaPath = UIUtils.getTrickHome() + fileSeparator + "libexec/trick" + fileSeparator + "java";
|
||||
|
@ -487,7 +487,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
|
||||
for (int i = 0; i < simRunDirField.length; i++) {
|
||||
if (i==0) {
|
||||
simRunDirField[i] = new JTextField(results[4] + System.getProperty("file.separator") + results[5] + " " + results[6]);
|
||||
simRunDirField[i] = new JTextField(results[4] + java.io.File.separator + results[5] + " " + results[6]);
|
||||
} else {
|
||||
simRunDirField[i] = new JTextField();
|
||||
}
|
||||
@ -495,7 +495,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
overrunField[i].setPreferredSize( new Dimension(60, overrunField[i].getHeight()) );
|
||||
}
|
||||
simRunDir = results[7];
|
||||
simRunDir = results[4] + System.getProperty("file.separator") + simRunDir;
|
||||
simRunDir = results[4] + java.io.File.separator + simRunDir;
|
||||
|
||||
simState.setRunPath(simRunDir);
|
||||
|
||||
@ -510,7 +510,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
"trick.sim_serives.var_send( ) \n" +
|
||||
"trick.sim_services.var_clear( ) \n");
|
||||
results = commandSimcom.get().split("\t");
|
||||
simRunDirField[i].setText(results[1] + System.getProperty("file.separator") + results[2] + " " + results[2]);*/
|
||||
simRunDirField[i].setText(results[1] + java.io.File.separator + results[2] + " " + results[2]);*/
|
||||
simRunDirField[i].setText("Slave " + i);
|
||||
}
|
||||
|
||||
@ -736,7 +736,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
*/
|
||||
private void printSendHS() {
|
||||
if (simState != null) {
|
||||
File sendHS = new File(simState.getRunPath() + System.getProperty("file.separator") + "send_hs");
|
||||
File sendHS = new File(simState.getRunPath() + java.io.File.separator + "send_hs");
|
||||
if (!sendHS.exists()) {
|
||||
return;
|
||||
}
|
||||
|
87
trick_source/java/test/Makefile
Normal file
87
trick_source/java/test/Makefile
Normal file
@ -0,0 +1,87 @@
|
||||
# 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
|
||||
ifeq ($(JAVAC_VERSION),10)
|
||||
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
|
||||
TRICK_TEST = ${TRICK_HOME}/trick_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 ${TRICK_TEST}
|
||||
@echo "[36mtrick.common.RunTimeTrickApplicationTest[0m"
|
||||
@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
|
||||
@echo "[36mtrick.common.TrickApplicationTest[0m"
|
||||
@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
|
||||
@echo "[36mtrick.common.utils.LogHeaderReaderTest[0m"
|
||||
@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
|
||||
@# Error with UnitTypeTest
|
||||
@# 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
|
||||
@echo "[36mtrick.dataproducts.trickdp.TrickDPApplicationTest[0m"
|
||||
@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
|
||||
@echo "[36mtrick.dataproducts.trickqp.TrickQPApplicationTest[0m"
|
||||
@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
|
||||
@echo "[36mtrick.dre.DreApplicationTest[0m"
|
||||
@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
|
||||
@echo "[36mtrick.montemonitor.MonteMonitorApplicationTest[0m"
|
||||
@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
|
||||
@echo "[36mtrick.mtv.MtvApplicationTest[0m"
|
||||
@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
|
||||
@# SieApplicationTest needs to be updated
|
||||
@# 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
|
||||
@echo "[36mtrick.sniffer.SnifferApplicationTest[0m"
|
||||
@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
|
||||
@echo "[36mtrick.tv.TrickApplicationTest[0m"
|
||||
@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
|
||||
@echo "[36mtrick.simcontrol.SimControlApplicationTest[0m"
|
||||
@echo "[33mCLICK OK ON GUI TO CONTINUE[0m"
|
||||
@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
|
||||
|
||||
${DEST_DIR} ${TEST_DIR} ${TRICK_TEST}:
|
||||
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}
|
@ -43,8 +43,8 @@ public class TrickApplicationTest {
|
||||
public void testPropertyLocation() {
|
||||
application();
|
||||
application();
|
||||
boolean rightLocation = (TrickApplication.propDirectory.equals(System.getenv("HOME") + System.getProperty("file.separator") + ".trick"))
|
||||
|| (TrickApplication.propDirectory.equals(System.getenv("TRICK_USER_HOME") + System.getProperty("file.separator") + ".trick"));
|
||||
boolean rightLocation = (TrickApplication.propDirectory.equals(System.getenv("HOME") + java.io.File.separator + ".trick"))
|
||||
|| (TrickApplication.propDirectory.equals(System.getenv("TRICK_USER_HOME") + java.io.File.separator + ".trick"));
|
||||
assertTrue("The default property location is not at ../.trick!", rightLocation);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class LogHeaderReaderTest {
|
||||
|
||||
@Test(expected = FileNotFoundException.class)
|
||||
public void testGetContentsWithNotFoundFile() throws FileNotFoundException, IOException {
|
||||
DataReader reader = new LogHeaderReader("test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "unknowFile.header");
|
||||
DataReader reader = new LogHeaderReader("resources" + java.io.File.separator + "unknowFile.header");
|
||||
reader.processHeader();
|
||||
}
|
||||
|
||||
@ -61,15 +61,15 @@ public class LogHeaderReaderTest {
|
||||
expectedVarList[8].setUnits("N");
|
||||
|
||||
// ASCII
|
||||
DataReader reader = new LogHeaderReader("test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "log_Ball.header");
|
||||
DataReader reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball.header");
|
||||
assertArrayEquals("Error in getContents for ASCII in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray());
|
||||
|
||||
// HDF5
|
||||
reader = new LogHeaderReader("test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "log_Ball2.header");
|
||||
reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball2.header");
|
||||
assertArrayEquals("Error in getContents for HDF5 in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray());
|
||||
|
||||
// little_endian
|
||||
reader = new LogHeaderReader("test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "log_Ball3.header");
|
||||
reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball3.header");
|
||||
assertArrayEquals("Error in getContents for little_endian in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray());
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class WaitForDreApplication extends DreApplication {
|
||||
*/
|
||||
public static void launchAndWait(Class<? extends WaitForDreApplication> applicationClass) {
|
||||
synchronized(lock) {
|
||||
sieResourcePath = "test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "S_sie.resource";
|
||||
sieResourcePath ="resources" + java.io.File.separator + "S_sie.resource";
|
||||
Application.launch(applicationClass, new String[]{});
|
||||
while(true) {
|
||||
try {
|
||||
|
@ -29,7 +29,7 @@ public class WaitForSieApplication extends SieApplication {
|
||||
*/
|
||||
public static void launchAndWait(Class<? extends WaitForSieApplication> applicationClass) {
|
||||
synchronized(lock) {
|
||||
sieResourcePath = "test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "S_sie.resource";
|
||||
sieResourcePath = "resources" + java.io.File.separator + "S_sie.resource";
|
||||
Application.launch(applicationClass, new String[]{});
|
||||
while(true) {
|
||||
try {
|
||||
|
@ -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