Closedown
This commit is contained in:
+98
-2
@@ -14,6 +14,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -39,7 +40,8 @@ import javax.naming.directory.SearchResult;
|
||||
import javax.naming.ldap.InitialLdapContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
/**
|
||||
*
|
||||
* @author boccioli_m
|
||||
@@ -758,7 +760,7 @@ public class NewTest extends javax.swing.JPanel {
|
||||
* @param hmTestParams test parameters. For the details of the structure, see buildParametersMap
|
||||
* @return true if success, false if else
|
||||
*/
|
||||
public boolean generateTestConfig(Path templateDir,
|
||||
public boolean generateTestConfigOld(Path templateDir,
|
||||
Path testDir,
|
||||
String sTestName,
|
||||
String sTestDescription,
|
||||
@@ -818,6 +820,100 @@ public class NewTest extends javax.swing.JPanel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* generate the python script that runs the test
|
||||
*
|
||||
* @param templateDir the path of the template to be used for the generation of theconfig.
|
||||
* it can be: TEMPLATES_TESTCONFIG_FILEPATH, TEMPLATES_DEVICECONFIG_FILEPATH
|
||||
* @param testDir path where the test is located (including the test name dir)
|
||||
* @param sTestName name of the test
|
||||
* @param sTestDescription description of the test
|
||||
* @param sTestSuite test cases/test suite name
|
||||
* @param hmTestParams test parameters. For the details of the structure, see buildParametersMap
|
||||
* @return true if success, false if else
|
||||
*/
|
||||
public boolean generateTestConfig(Path templateDir,
|
||||
Path testDir,
|
||||
String sTestName,
|
||||
String sTestDescription,
|
||||
String sTestSuite,
|
||||
HashMap hmTestParams){
|
||||
//generate test config file from template
|
||||
boolean success = false;
|
||||
try {
|
||||
Path path = Paths.get(testDir.toString(),TESTS_CONFIG_FILENAME);
|
||||
if(Files.exists(path)){
|
||||
Files.delete(path);
|
||||
}
|
||||
Files.copy(templateDir, path);
|
||||
File configFile = path.toFile();
|
||||
|
||||
//Loop among the test parameters and generate variable assignement syntax for python
|
||||
String sTestParameters = "";
|
||||
String name="", value="", description="";
|
||||
for(Object entry : hmTestParams.keySet()){
|
||||
Object param = entry;
|
||||
if(param instanceof String){
|
||||
name = (String) param;
|
||||
HashMap attributes = (HashMap) hmTestParams.get(param);
|
||||
value = (String) attributes.get("value");
|
||||
description = (String) attributes.get("description");
|
||||
//build the python code for getting the test parameter
|
||||
sTestParameters = sTestParameters + name + ":" + value + ":" + description + ";" ;
|
||||
}
|
||||
}
|
||||
FileInputStream in = new FileInputStream(configFile);
|
||||
Properties props = new Properties();
|
||||
props.load(in);
|
||||
in.close();
|
||||
FileOutputStream out = new FileOutputStream(configFile);
|
||||
if(sType == TypeOfNewFile.Device){
|
||||
//creation of device config
|
||||
props.setProperty("name", sTestName);
|
||||
props.setProperty("description", sTestDescription);
|
||||
props.setProperty("tests", sTestSuite);
|
||||
}else{
|
||||
//creation of test config
|
||||
props.setProperty("name", sTestName);
|
||||
props.setProperty("description", sTestDescription);
|
||||
props.setProperty("parameters", sTestParameters);
|
||||
|
||||
}
|
||||
props.store(out, null);
|
||||
out.close();
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("Name", "crunchify.com");
|
||||
obj.put("Author", "App Shah");
|
||||
|
||||
JSONArray company = new JSONArray();
|
||||
company.add("Compnay: eBay");
|
||||
company.add("Compnay: Paypal");
|
||||
company.add("Compnay: Google");
|
||||
obj.put("Company List", company);
|
||||
|
||||
String jsonConfig = obj.toJSONString();
|
||||
|
||||
FileWriter jout = new FileWriter(configFile);
|
||||
|
||||
jout.write(jsonConfig);
|
||||
jout.flush();
|
||||
jout.close();
|
||||
|
||||
success = true;
|
||||
} catch (FileNotFoundException ex) {
|
||||
SwingUtils.showMessage(this, "generateTestConfig()", "Cannot find file: " + ex.toString());
|
||||
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
SwingUtils.showMessage(this, "generateTestConfig()", "Problem with file aaccess: " + ex.toString());
|
||||
Logger.getLogger(NewTest.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* generate the html help file of the test
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#TestingList for pshell: configuration properties
|
||||
#Thu Oct 12 11:14:29 CEST 2017
|
||||
#Thu Oct 12 16:09:44 CEST 2017
|
||||
customPanel=
|
||||
showEnabledTestsOnly=true
|
||||
listFilter=rps-try
|
||||
|
||||
@@ -7,17 +7,19 @@ global sys, inspect, os, traceback
|
||||
import sys, inspect, os, traceback
|
||||
|
||||
from array import *
|
||||
import pickle
|
||||
a = array('i',[50,105,0x8899,0xffffff,1,0,0,0,0,0,0,0,0,0,1])
|
||||
print 'a ', a
|
||||
b = array('i',[0]*10)
|
||||
print 'b ', b
|
||||
a.extend(b)
|
||||
a.append(4)
|
||||
a.fromlist([1,2,3,4])
|
||||
print 'a2', a
|
||||
c = pickle.dumps(a)
|
||||
print 'c2', c
|
||||
a = bytearray()
|
||||
a = array('B',[0x32,0,0x69,0,0x99,0x88,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0])
|
||||
mode = "2,IQCOM,$BMA1,1,DIA"
|
||||
modebytes = array('B', mode)
|
||||
a.extend(modebytes)
|
||||
#a.append(4)
|
||||
#a.fromlist([1,2,3,4])
|
||||
import binascii
|
||||
print binascii.hexlify(a)
|
||||
print a
|
||||
a[16] = 1
|
||||
print a
|
||||
print binascii.hexlify(a)
|
||||
|
||||
def startTest(testName, DEVICE, params):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user