Commit 2afdff6b authored by Arpad Lovassy's avatar Arpad Lovassy
Browse files

fixed indentation


Signed-off-by: Arpad Lovassy's avatarzlovarp <arpad.lovassy@semcon.com>
parent 5aa8b31d
###############################################################################
# Copyright (c) 2000-2019 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
#
# Contributors:
# Lovassy, Arpad
#
###############################################################################
# EDIT THESE LINES TO SET CORRECT JAR LOCATIONS
#---------------------------------------------------------------------
# DO NOT EDIT AFTER THIS LINE
# check if JAVA exists
# http://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script
if type -p java; then
echo found java executable in PATH
_java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
echo found java executable in JAVA_HOME
_java="$JAVA_HOME/bin/java"
else
echo "no java, exiting"; exit 1;
fi
# check java version (>=1.7)
if [[ "$_java" ]]; then
version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
echo version "$version"
if [[ "$version" > "1.7" ]]; then
echo "version is at least 1.7, OK";
else
echo "version is less than 1.7, NOT OK, exiting"; exit 1;
fi
fi
# check java version (>=1.7) in another way
[ $(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q') -ge 17 ] && echo "version is at least 1.7, OK" || { echo "version is less than 1.7, NOT OK, exiting"; exit 1; }
# checks if file exists, exits if not
# @param $1 file full path
function file_exist {
[ -f "$1" ] && echo "$1 FOUND, OK" || { echo "$1 NOT FOUND, exiting"; exit 1; }
}
# checks if directory exists, exits if not
# @param $1 directory full path
function dir_exist {
[ -d "$1" ] && echo "$1 DIRECTORY FOUND, OK" || { echo "$1 DIRECTORY NOT FOUND, exiting"; exit 1; }
}
# check TITAN dependencies
[ ! -z "${TTCN3_DIR}" ] && echo "\$TTCN3_DIR is set to ${TTCN3_DIR}, OK" \
|| { echo "\$TTCN3_DIR is not set, NOT OK, exiting"; exit 1; }
dir_exist ${TTCN3_DIR}
file_exist ${TTCN3_DIR}/lib/libmctrjninative.so
[[ "${LD_LIBRARY_PATH}" == *"${TTCN3_DIR}/lib"* ]] && echo "\$TTCN3_DIR/lib is added to \$LD_LIBRARY_PATH=${LD_LIBRARY_PATH}, OK" \
|| { echo "\$TTCN3_DIR is NOT added to \$LD_LIBRARY_PATH=${LD_LIBRARY_PATH}, NOT OK, exiting"; exit 1; }
# make sure, that the demo is compiled, which is cleaned in make install
pushd ${TTCN3_DIR}/demo
make
popd
file_exist ${TTCN3_DIR}/demo/MyExample
# Check if HelloWorld demo binary is compiled in parallel mode: output of MyExample -v contains "(parallel mode)"
[ `${TTCN3_DIR}/demo/MyExample -v 2>&1 | grep "(parallel mode)" | wc -l` != 0 ] && echo "${TTCN3_DIR}/demo/MyExample is compiled in parallel mode, OK" \
|| { echo "${TTCN3_DIR}/demo/MyExample is compiled in single mode, NOT in parallel mode, NOT OK, exiting"; exit 1; }
# run demo (and build its dependencies if needed)
BASEDIR=$(dirname $0)
echo BASEDIR: $BASEDIR
ant \
-f $BASEDIR/build.xml \
Main
......@@ -16,7 +16,7 @@ import java.io.File;
public class CommonData {
// default values
// default values
private static final String WORKSPACE = "../../titan/Install/";
private static final String CFG_FILE = "demo/MyExample.cfg";
static final String LOCALHOST = "NULL";
......@@ -28,17 +28,17 @@ public class CommonData {
private static String getDefaultWorkspaceDir() {
String ttcn3_dir = System.getenv().get("TTCN3_DIR");
String workspace = WORKSPACE;
if (ttcn3_dir != null && ttcn3_dir.length() > 0) {
workspace = ttcn3_dir;
}
workspace += ( workspace.endsWith( File.separator ) ? "" : File.separator );
return workspace;
if (ttcn3_dir != null && ttcn3_dir.length() > 0) {
workspace = ttcn3_dir;
}
workspace += ( workspace.endsWith( File.separator ) ? "" : File.separator );
return workspace;
}
public static String getDefaultWorkingDir() {
return getDefaultWorkspaceDir() + WORKINGDIR;
}
public static String getDefaultCfgFile() {
return getDefaultWorkspaceDir() + CFG_FILE;
}
......
......@@ -60,53 +60,53 @@ import java.util.Map;
public class DemoFrame extends JFrame {
/** Generated serial version ID to avoid warning */
/** Generated serial version ID to avoid warning */
private static final long serialVersionUID = -7360165029886576581L;
private final JButton mButtonInit = new JButton("Init");
private final JButton mButtonAddHostController = new JButton("Add Host Controller");
private final JButton mButtonSetConfigFilename = new JButton("Set CFG file");
private final JButton mButtonStartSession = new JButton("Start session");
private final JButton mButtonStartHostControllers = new JButton("Start Host Controllers");
private final JButton mButtonConfigure = new JButton("Configure");
private final JButton mButtonCreateMTC = new JButton("Create MTC");
private final JButton mButtonExecuteControl = new JButton("Execute control");
private final JButton mButtonExecuteTestcase = new JButton("Execute testcase");
private final JButton mButtonExecuteCfg = new JButton("Execute CFG");
private final JButton mButtonExitMTC = new JButton("Exit MTC");
private final JButton mButtonShutdownSession = new JButton("Shutdown session");
private final JButton mButtonPause = new JButton("Pause");
private final JButton mButtonStopExecution = new JButton("Stop execution");
private final JButton mButtonContinueExecution = new JButton("Continue execution");
private final JButton mButtonBatch = new JButton("Batch execution");
private final JLabel mLabelCfgFile = new JLabel("Configuration file:");
private final JLabel mLabelHost = new JLabel("Host:");
private final JLabel mLabelWorkingDir = new JLabel("Working directory:");
private final JLabel mLabelExecutable = new JLabel("Executable:");
private final JTextField mTextFieldCfgFile = new JTextField();
private final JTextField mTextFieldHost = new JTextField();
private final JTextField mTextFieldWorkingDir = new JTextField();
private final JTextField mTextFieldExecutable = new JTextField();
private final JButton mButtonCfgFile = new JButton("...");
private final JButton mButtonWorkingDir = new JButton("...");
private final JButton mButtonExecutable = new JButton("...");
private final JLabel mLabelHostControllers = new JLabel("Added Host Controllers:");
/** model for mTableHostControllers */
private final HostControllerTableModel mModel = new HostControllerTableModel(new String[] {"Host","Working directory","Executable"}, 0);
private final JTable mTableHostControllers = new JTable(mModel);
/** style for mTextPaneTitanConsole */
private Style mStyle;
private final JTextPane mTextPaneTitanConsole = new JTextPane();
private final JLabel mLabelState = new JLabel("MC state:");
private final JTextField mTextFieldState = new JTextField();
private final JButton mButtonAddHostController = new JButton("Add Host Controller");
private final JButton mButtonSetConfigFilename = new JButton("Set CFG file");
private final JButton mButtonStartSession = new JButton("Start session");
private final JButton mButtonStartHostControllers = new JButton("Start Host Controllers");
private final JButton mButtonConfigure = new JButton("Configure");
private final JButton mButtonCreateMTC = new JButton("Create MTC");
private final JButton mButtonExecuteControl = new JButton("Execute control");
private final JButton mButtonExecuteTestcase = new JButton("Execute testcase");
private final JButton mButtonExecuteCfg = new JButton("Execute CFG");
private final JButton mButtonExitMTC = new JButton("Exit MTC");
private final JButton mButtonShutdownSession = new JButton("Shutdown session");
private final JButton mButtonPause = new JButton("Pause");
private final JButton mButtonStopExecution = new JButton("Stop execution");
private final JButton mButtonContinueExecution = new JButton("Continue execution");
private final JButton mButtonBatch = new JButton("Batch execution");
private final JLabel mLabelCfgFile = new JLabel("Configuration file:");
private final JLabel mLabelHost = new JLabel("Host:");
private final JLabel mLabelWorkingDir = new JLabel("Working directory:");
private final JLabel mLabelExecutable = new JLabel("Executable:");
private final JTextField mTextFieldCfgFile = new JTextField();
private final JTextField mTextFieldHost = new JTextField();
private final JTextField mTextFieldWorkingDir = new JTextField();
private final JTextField mTextFieldExecutable = new JTextField();
private final JButton mButtonCfgFile = new JButton("...");
private final JButton mButtonWorkingDir = new JButton("...");
private final JButton mButtonExecutable = new JButton("...");
private final JLabel mLabelHostControllers = new JLabel("Added Host Controllers:");
/** model for mTableHostControllers */
private final HostControllerTableModel mModel = new HostControllerTableModel(new String[] {"Host","Working directory","Executable"}, 0);
private final JTable mTableHostControllers = new JTable(mModel);
/** style for mTextPaneTitanConsole */
private Style mStyle;
private final JTextPane mTextPaneTitanConsole = new JTextPane();
private final JLabel mLabelState = new JLabel("MC state:");
private final JTextField mTextFieldState = new JTextField();
/**
* Observer for step-by-step test execution.
*/
* Observer for step-by-step test execution.
*/
private class DemoObserver implements IJniExecutorObserver {
@Override
......@@ -166,9 +166,9 @@ public class DemoFrame extends JFrame {
if ( error > 0 ) {
sb.append("Error: ").append(error).append("<br>");
}
mVerdicts = null;
// Showing “JOptionPane.showMessageDialog” without stopping flow of execution,
// Showing OptionPane.showMessageDialog without stopping flow of execution,
// this line would block the thread:
//JOptionPane.showMessageDialog(DemoFrame.this, sb.toString(), "Verdict statistics", JOptionPane.INFORMATION_MESSAGE);
EventQueue.invokeLater(new Runnable(){
......@@ -184,20 +184,20 @@ public class DemoFrame extends JFrame {
});
}
}
/**
* Observer for step-by-step test execution.
* <p>
* NOTE: This observer is not used for batch test execution.
* @see #batchExecution()
*/
/**
* Observer for step-by-step test execution.
* <p>
* NOTE: This observer is not used for batch test execution.
* @see #batchExecution()
*/
private final DemoObserver mObserver = new DemoObserver();
/**
* Table model for the added HCs to make it non-editable
*/
/**
* Table model for the added HCs to make it non-editable
*/
private class HostControllerTableModel extends DefaultTableModel {
/** Generated serial version ID to avoid warning */
/** Generated serial version ID to avoid warning */
private static final long serialVersionUID = -2214569504530345210L;
public HostControllerTableModel(final String[] columnNames, final int i) {
......@@ -205,49 +205,49 @@ public class DemoFrame extends JFrame {
}
@Override
public boolean isCellEditable(int row, int column) {
//all cells false
return false;
}
}
public boolean isCellEditable(int row, int column) {
//all cells false
return false;
}
}
public DemoFrame() {
super( "TITAN Executor API Demo" );
initUi();
updateUi();
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
setSize( 1200, 750 );
// place to the middle of the screen
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
super( "TITAN Executor API Demo" );
initUi();
updateUi();
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
setSize( 1200, 750 );
// place to the middle of the screen
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
}
/**
* Initialization of the UI elements:
* <ul>
* <li> Setting non-editable elements
* <li> Setting default texts where applicable
* <li> Adding tooltips to UI elements
* <li> Defining behavior of the buttons
* <li> Building layout
* </ul>
*/
/**
* Initialization of the UI elements:
* <ul>
* <li> Setting non-editable elements
* <li> Setting default texts where applicable
* <li> Adding tooltips to UI elements
* <li> Defining behavior of the buttons
* <li> Building layout
* </ul>
*/
private void initUi() {
// init ui elements
mTextPaneTitanConsole.setEditable(false);
mTextFieldState.setEditable(false);
mStyle = mTextPaneTitanConsole.addStyle("standard", null); // standard style
// default values
mTextFieldCfgFile.setText( CommonData.getDefaultCfgFile() );
mTextFieldHost.setText( CommonData.LOCALHOST );
mTextFieldWorkingDir.setText( CommonData.getDefaultWorkingDir() );
mTextFieldExecutable.setText( CommonData.EXECUTABLE );
initTooltips();
initButtonActions();
initLayout();
// init ui elements
mTextPaneTitanConsole.setEditable(false);
mTextFieldState.setEditable(false);
mStyle = mTextPaneTitanConsole.addStyle("standard", null); // standard style
// default values
mTextFieldCfgFile.setText( CommonData.getDefaultCfgFile() );
mTextFieldHost.setText( CommonData.LOCALHOST );
mTextFieldWorkingDir.setText( CommonData.getDefaultWorkingDir() );
mTextFieldExecutable.setText( CommonData.EXECUTABLE );
initTooltips();
initButtonActions();
initLayout();
}
/**
......@@ -267,50 +267,50 @@ public class DemoFrame extends JFrame {
final String TOOLTIPTEXT_EXIT_MTC = "Exits from Main Test Component, use it after testcase execution.";
final String TOOLTIPTEXT_SHUTDOWN_SESSION = "Closes connection to MC.";
final String TOOLTIPTEXT_BATCHEXECUTION = "One step execution. It executes cfg file execute list using 1 HC defined by Host, Working directory, Executable.";
final String TOOLTIPTEXT_CFG_FILE = "TTCN-3 configutation file (.cfg) with full path";
final String TOOLTIPTEXT_HOST = "Host Controller host name. It is localhost in the following cases: NULL, 0.0.0.0, empty string";
final String TOOLTIPTEXT_WORKINGDIR = "Host Controller working directory without the ending /";
final String TOOLTIPTEXT_EXECUTABLE = "Host Controller executable file name without path";
final String TOOLTIPTEXT_TITANCONSOLE = "TITAN Console";
mButtonInit.setToolTipText( TOOLTIPTEXT_INIT );
mButtonAddHostController.setToolTipText( TOOLTIPTEXT_ADDHC );
mButtonSetConfigFilename.setToolTipText( TOOLTIPTEXT_SET_CFG_FILE );
mButtonStartSession.setToolTipText( TOOLTIPTEXT_START_SESSION );
mButtonStartHostControllers.setToolTipText( TOOLTIPTEXT_START_HCS );
mButtonConfigure.setToolTipText( TOOLTIPTEXT_CONFIGURE );
mButtonCreateMTC.setToolTipText( TOOLTIPTEXT_CREATE_MTC );
mButtonExecuteControl.setToolTipText( TOOLTIPTEXT_EXECUTE_CONTROL );
mButtonExecuteTestcase.setToolTipText( TOOLTIPTEXT_EXECUTE_TESTCASE );
mButtonExecuteCfg.setToolTipText( TOOLTIPTEXT_EXECUTE_CFG );
mButtonExitMTC.setToolTipText( TOOLTIPTEXT_EXIT_MTC );
mButtonShutdownSession.setToolTipText( TOOLTIPTEXT_SHUTDOWN_SESSION );
mButtonBatch.setToolTipText( TOOLTIPTEXT_BATCHEXECUTION );
mLabelCfgFile.setToolTipText( TOOLTIPTEXT_CFG_FILE );
mLabelHost.setToolTipText( TOOLTIPTEXT_HOST );
mLabelWorkingDir.setToolTipText( TOOLTIPTEXT_WORKINGDIR );
mLabelExecutable.setToolTipText( TOOLTIPTEXT_EXECUTABLE );
mTextFieldCfgFile.setToolTipText( TOOLTIPTEXT_CFG_FILE );
mTextFieldHost.setToolTipText( TOOLTIPTEXT_HOST );
mTextFieldWorkingDir.setToolTipText( TOOLTIPTEXT_WORKINGDIR );
mTextFieldExecutable.setToolTipText( TOOLTIPTEXT_EXECUTABLE );
mButtonCfgFile.setToolTipText( TOOLTIPTEXT_CFG_FILE );
mButtonWorkingDir.setToolTipText( TOOLTIPTEXT_WORKINGDIR );
mButtonExecutable.setToolTipText( TOOLTIPTEXT_EXECUTABLE );
mTextPaneTitanConsole.setToolTipText( TOOLTIPTEXT_TITANCONSOLE );
mButtonInit.setToolTipText( TOOLTIPTEXT_INIT );
mButtonAddHostController.setToolTipText( TOOLTIPTEXT_ADDHC );
mButtonSetConfigFilename.setToolTipText( TOOLTIPTEXT_SET_CFG_FILE );
mButtonStartSession.setToolTipText( TOOLTIPTEXT_START_SESSION );
mButtonStartHostControllers.setToolTipText( TOOLTIPTEXT_START_HCS );
mButtonConfigure.setToolTipText( TOOLTIPTEXT_CONFIGURE );
mButtonCreateMTC.setToolTipText( TOOLTIPTEXT_CREATE_MTC );
mButtonExecuteControl.setToolTipText( TOOLTIPTEXT_EXECUTE_CONTROL );
mButtonExecuteTestcase.setToolTipText( TOOLTIPTEXT_EXECUTE_TESTCASE );
mButtonExecuteCfg.setToolTipText( TOOLTIPTEXT_EXECUTE_CFG );
mButtonExitMTC.setToolTipText( TOOLTIPTEXT_EXIT_MTC );
mButtonShutdownSession.setToolTipText( TOOLTIPTEXT_SHUTDOWN_SESSION );
mButtonBatch.setToolTipText( TOOLTIPTEXT_BATCHEXECUTION );
mLabelCfgFile.setToolTipText( TOOLTIPTEXT_CFG_FILE );
mLabelHost.setToolTipText( TOOLTIPTEXT_HOST );
mLabelWorkingDir.setToolTipText( TOOLTIPTEXT_WORKINGDIR );
mLabelExecutable.setToolTipText( TOOLTIPTEXT_EXECUTABLE );
mTextFieldCfgFile.setToolTipText( TOOLTIPTEXT_CFG_FILE );
mTextFieldHost.setToolTipText( TOOLTIPTEXT_HOST );
mTextFieldWorkingDir.setToolTipText( TOOLTIPTEXT_WORKINGDIR );
mTextFieldExecutable.setToolTipText( TOOLTIPTEXT_EXECUTABLE );
mButtonCfgFile.setToolTipText( TOOLTIPTEXT_CFG_FILE );
mButtonWorkingDir.setToolTipText( TOOLTIPTEXT_WORKINGDIR );
mButtonExecutable.setToolTipText( TOOLTIPTEXT_EXECUTABLE );
mTextPaneTitanConsole.setToolTipText( TOOLTIPTEXT_TITANCONSOLE );
}
/**
* Sets button behaviors
*/
private void initButtonActions() {
final JniExecutor je = JniExecutor.getInstance();
mButtonInit.addActionListener(new ActionListener() {
final JniExecutor je = JniExecutor.getInstance();
mButtonInit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -322,7 +322,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonAddHostController.addActionListener(new ActionListener() {
mButtonAddHostController.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JniExecutor je = JniExecutor.getInstance();
......@@ -335,7 +335,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonSetConfigFilename.addActionListener(new ActionListener() {
mButtonSetConfigFilename.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -346,7 +346,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonStartSession.addActionListener(new ActionListener() {
mButtonStartSession.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -357,7 +357,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonStartHostControllers.addActionListener(new ActionListener() {
mButtonStartHostControllers.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -367,7 +367,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonConfigure.addActionListener(new ActionListener() {
mButtonConfigure.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -377,7 +377,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonCreateMTC.addActionListener(new ActionListener() {
mButtonCreateMTC.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -387,25 +387,25 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonExecuteControl.addActionListener(new ActionListener() {
mButtonExecuteControl.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ExecuteControlDialog(DemoFrame.this).setVisible(true);
}
});
mButtonExecuteTestcase.addActionListener(new ActionListener() {
mButtonExecuteTestcase.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ExecuteTestcaseDialog(DemoFrame.this).setVisible(true);
}
});
mButtonExecuteCfg.addActionListener(new ActionListener() {
mButtonExecuteCfg.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ExecuteCfgDialog(DemoFrame.this).setVisible(true);
}
});
mButtonExitMTC.addActionListener(new ActionListener() {
mButtonExitMTC.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -415,7 +415,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonShutdownSession.addActionListener(new ActionListener() {
mButtonShutdownSession.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
je.shutdownSession();
......@@ -423,7 +423,7 @@ public class DemoFrame extends JFrame {
updateUi(); // it must be called after synchronous calls
}
});
mButtonPause.addActionListener(new ActionListener() {
mButtonPause.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -435,7 +435,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonStopExecution.addActionListener(new ActionListener() {
mButtonStopExecution.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -445,7 +445,7 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonContinueExecution.addActionListener(new ActionListener() {
mButtonContinueExecution.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
......@@ -455,14 +455,14 @@ public class DemoFrame extends JFrame {
}
}
});
mButtonBatch.addActionListener(new ActionListener() {
mButtonBatch.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
batchExecution();
}
});
mButtonCfgFile.addActionListener(new ActionListener() {
});
mButtonCfgFile.addActionListener(new ActionListener() {
@Override