Searching for AUT-Path-Parameter instead of AUT-Config [message #912784] |
Fri, 14 September 2012 03:24  |
Eclipse User |
|
|
|
Is there an alternative to the -c Parameter of testexec? I want to directly specify a path to an (RCP) application to automatically test different (release)versions of an application with different paths, without manually needing to replace the Path in Test -> Property -> <AUTNAME> -> <AUTOCONFIG>. Is there a way to quick-change this via command-line.
A possible workaround is directly accessing this property with a script via SQL, but a Parameter would make this easier.
Edit: I already have written a workaround in groovy for that this morning. Oracle drivers in groovy-lib needed.
def updateWorking(conn, user, password, autname, exepath, workpath) {
driver = oracle.jdbc.driver.OracleDriver
sql = groovy.sql.Sql.newInstance(conn,user,password)
//find out ID of AUT by name
sql.eachRow("select AUT_CONF from AUT_CONF_ATTR where ATTR_VALUE LIKE '"+autname+"'") {row -> id = row[0]}
//update exepath and workpath
sql.executeUpdate("update AUT_CONF_ATTR set ATTR_VALUE='"+exepath+"' where AUT_CONF = "+id+" and ATTR_KEY like 'EXECUTABLE'")
sql.executeUpdate("update AUT_CONF_ATTR set ATTR_VALUE='"+workpath+"' where AUT_CONF = "+id+" and ATTR_KEY like 'WORKING_DIR'")
}
//call of function
updateWorking('jdbc:oracle:thin:@***:TESTDB', "JUBULA", "***", "MSS@localhost",$/E:\***.exe/$, $/E:\***/$)
Edit2: Javacode because groovy made problems with the classloading
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Dbsetter {
public static void main(String[] args) {
System.out.println("Exe: "+args[0]);
System.out.println("Path: "+args[1]);
connect("jdbc:oracle:thin:@*:1521:TESTDB", "JUBULA", "*", "*@localhost",args[0], args[1]);
}
private static void connect(String url, String username, String password, String autname, String exe, String path) {
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
connection = DriverManager.getConnection(url, username, password);
PreparedStatement ps = connection.prepareStatement("select AUT_CONF from AUT_CONF_ATTR where ATTR_VALUE LIKE ?");
ps.setString(1, autname);
ps.execute();
ResultSet rs = ps.getResultSet();
int id=-1;
while(rs.next())
id=rs.getInt(1);
System.out.println("Aut-ID of "+autname+" is "+id);
PreparedStatement ps2=connection.prepareStatement("update AUT_CONF_ATTR set ATTR_VALUE=? where AUT_CONF = ? and ATTR_KEY like 'EXECUTABLE'");
ps2.setString(1, exe);
ps2.setInt(2, id);
PreparedStatement ps3=connection.prepareStatement("update AUT_CONF_ATTR set ATTR_VALUE=? where AUT_CONF = ? and ATTR_KEY like 'WORKING_DIR'");
ps3.setString(1, path);
ps3.setInt(2, id);
ps2.execute();
ps3.execute();
System.out.println("Update done!");
} catch (ClassNotFoundException e) {
e.printStackTrace();
// Could not find the database driver
} catch (SQLException e) {
e.printStackTrace();
// Could not connect to the database
}
}
}
[Updated on: Tue, 18 September 2012 03:18] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03997 seconds