Closedown

This commit is contained in:
boccioli_m
2015-06-25 10:41:00 +02:00
parent 05b4f2ec06
commit a2fd5b8594
3 changed files with 36 additions and 98 deletions

View File

@@ -74,7 +74,7 @@ public class TestingList extends Panel {
* @param exception
*/
@Override
protected void onExecutedFile(String fileName, Object result, Throwable exception) {
protected void onExecutedFile(String fileName, Object result) {
int iCurrentTestPos = 0;
try {
Object ret = eval("ret");
@@ -133,16 +133,16 @@ public class TestingList extends Panel {
*/
public enum COL {
CHECK (0),
TIME (1),
DEVICENAME (2),
DEVICEDESCR (3),
TESTSUITE (4),
TESTNAME (5),
TESTPATH (6),
TESTPARAMS (7),
TESTDESCR (8),
TESTHELP (9),
STARTSEQUENCE (10),
STARTSEQUENCE(1),
TIME (2),
DEVICENAME (3),
DEVICEDESCR (4),
TESTSUITE (5),
TESTNAME (6),
TESTPATH (7),
TESTPARAMS (8),
TESTDESCR (9),
TESTHELP (10),
RESULT (11),
STATUS (12),
ICON (13);
@@ -318,14 +318,14 @@ public class TestingList extends Panel {
},
new String [] {
"Select", "Time", "Device Name", "Device Description", "Test Suite", "Test Name", "Test Peth", "Test Parameters", "Test Description", "Test Help", "Start", "Last Test Result", "Status", ""
"Select", "Start", "Time", "Device Name", "Device Description", "Test Suite", "Test Name", "Test Peth", "Test Parameters", "Test Description", "Test Help", "Last Test Result", "Status", ""
}
) {
Class[] types = new Class [] {
java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, javax.swing.Icon.class
};
boolean[] canEdit = new boolean [] {
true, false, false, false, false, false, false, false, false, false, true, false, false, false
true, true, false, false, false, false, false, false, false, false, false, false, false, false
};
public Class getColumnClass(int columnIndex) {
@@ -442,6 +442,7 @@ public class TestingList extends Panel {
private void jButtonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRunActionPerformed
if(this.jButtonRun.getToolTipText().equals("Run selected tests")){
setButtonToStart();
updateStatus();
executeTest(0);
}
else{
@@ -726,16 +727,20 @@ public class TestingList extends Panel {
String sStart;
for (int row = 0; row <= jTable1.getRowCount() - 1; row++) {
bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
sStart = String.valueOf(jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal()));
if (bSelected) {
sStatus = TestStatus.PENDING.toString();
icon = TestStatus.PENDING.Icon();
if(sStart == "") sStart = StartSequence.START_SEQ_AFTER.toString();
} else {
sStatus = TestStatus.DISABLED.toString();
icon = TestStatus.DISABLED.Icon();
sStart = "";
}
jTable1.setValueAt(bSelected, row, COL.CHECK.ordinal());
jTable1.setValueAt(icon, row, COL.ICON.ordinal());
jTable1.setValueAt(sStatus, row, COL.STATUS.ordinal());
jTable1.setValueAt(sStart, row, COL.STARTSEQUENCE.ordinal());
}
}
@@ -803,18 +808,20 @@ public class TestingList extends Panel {
int[] selectedTestsRows = {};
//scan through the table starting from 'position' and execute the first selected test found
int row = position;
if (row >=0 && row <= jTable1.getRowCount()-1 ) {
for(row = position ; row <= jTable1.getRowCount()-1 ; row++){
if (row >=0 && row < jTable1.getRowCount() ) {
for(row = position ; row < jTable1.getRowCount() ; row++){
bSelected = (boolean) jTable1.getValueAt(row, COL.CHECK.ordinal());
sStartSequence = jTable1.getValueAt(row, COL.STARTSEQUENCE.ordinal()).toString();
sStatus = jTable1.getValueAt(row, COL.STATUS.ordinal()).toString();
//collect tests to be launched in parallel
//the test must be: selected, set as start with previous, pending.
//alternatively, the test must be: selected, first of the list.
System.out.println(String.valueOf(row) +"\t"+ String.valueOf(bSelected) +"\t"+ String.valueOf(selectedTestsRows.length) +"\t"+ sStartSequence +"\t"+ sStatus);
if( bSelected &&
(selectedTestsRows.length == 0 || //the test must be: selected, first of the list.
(sStartSequence.equals(StartSequence.START_SEQ_TOGETHER.toString()) && //or the test must be: selected, set as start with previous, pending.
sStatus.equals(TestStatus.PENDING.toString()) ))){
sStatus.equals(TestStatus.PENDING.toString()) ))){
selectedTestsRows = append(selectedTestsRows, row);
} else if (bSelected && //if this test must be executed...
selectedTestsRows.length > 0 && //but there are already tests to be executed in parallel....
@@ -822,8 +829,10 @@ public class TestingList extends Panel {
break;
}
}
if (bSelected) { //at least one test is selected: launch it (or them)
executeParallelTestsGroup(selectedTestsRows);
if (selectedTestsRows.length > 0) { //at least one test is selected: launch it (or them)
if (executeParallelTestsGroup(selectedTestsRows) < 0){ //last execution did not find a test file. Continue with next execution
executeTest(position+1);
}
}
}
if(!bSelected){ //No test to play. Stop
@@ -832,20 +841,23 @@ public class TestingList extends Panel {
}
}
private void executeParallelTestsGroup(int[] rowsToExecute){
//start all the tests in the rowsToExecute
private int executeParallelTestsGroup(int[] rowsToExecute){
HashMap args = new HashMap();
int iRet = -1;
for(int row: rowsToExecute){
//build the .py test file path
String sDeviceName = jTable1.getValueAt(row, COL.DEVICENAME.ordinal()).toString();
String sTestName = jTable1.getValueAt(row, COL.TESTNAME.ordinal()).toString();
String sTestCaseName = jTable1.getValueAt(row, COL.TESTSUITE.ordinal()).toString();
String sTestPath = jTable1.getValueAt(row, COL.TESTPATH.ordinal()).toString();
HashMap mParameters = buildParametersMap(String.valueOf(jTable1.getValueAt(row, COL.TESTPARAMS.ordinal())));
System.out.println(String.valueOf(row) +"\t"+ sDeviceName +"\t"+ sTestName +"\t"+ sTestCaseName +"\t"+ String.valueOf(rowsToExecute.length));
try{
File f = new File(sTestPath);
if(!f.exists() || f.isDirectory()){
logger.log(Level.SEVERE, "Cannot find test script: " + sTestPath);
showResult(sDeviceName, sTestPath, "Cannot find test script: " + sTestPath, TestStatus.FAILURE.toString());
iRet = -1;
continue;
}
showResult(sDeviceName, sTestPath, "Test running", TestStatus.RUNNING.toString());
@@ -860,6 +872,7 @@ public class TestingList extends Panel {
logger.log(Level.INFO, "Running Test '" + sTestName + "'. No parameters found.");
}
runAsync(sTestPath, args);
iRet = 0;
} catch (Exception ex) {
SwingUtils.showMessage(this, "executeTest()", ex.toString());
logger.log(Level.SEVERE, ex.toString());
@@ -867,6 +880,7 @@ public class TestingList extends Panel {
setButtonToStop();
}
}
return iRet;
}
/**
@@ -920,7 +934,7 @@ public class TestingList extends Panel {
ImageIcon icon = null;// new ImageIcon(getClass().getResource("/icons/button_pause-16px.png"));
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
String testPath = FilenameUtils.separatorsToSystem(TESTS_TESTS_DEFAULT_DIR + testSuite + "/" + testName + "/" + testName + ".py");
model.addRow(new Object[]{false, sDate, deviceName, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, StartSequence.START_SEQ_AFTER.toString(), "", "Pending", icon});
model.addRow(new Object[]{false, "", sDate, deviceName, deviceDescription, testSuite, testName, testPath, testParams, testDescription, testHelp, "", "Pending", icon});
jTable1.setModel(model);
updateStatus();
}