Browse Source

Stabile und schnellere Maskenausführung #6

qa_0.6_Release
Daniel Quathamer 1 year ago
parent
commit
68e05ad7f0
  1. 1
      src-modules/module/qa/conf/includes.txt
  2. 15
      src-modules/module/qa/conf/qa.xml
  3. 9
      src-modules/module/qa/datentabellen/qa_mask_execution_result_purge.sql
  4. 11
      src-modules/module/qa/datentabellen/vacuum_pg.sql
  5. 2
      src-modules/module/qa/masken/37020_maskeninfo.unl
  6. 6
      src-modules/module/qa/masken/37040_maskeninfo.unl
  7. 27
      src-modules/module/qa/qa_mask_execution_loop.x
  8. 5
      src-modules/module/qa/qa_update.x
  9. 15
      src-modules/module/qa/upgrade/qa_upgrade_man.sql
  10. 216
      src/de/superx/qa/bin/QaTestcaseExecutor.java
  11. 20
      superx/WEB-INF/conf/edustore/db/bin/qa_mask_execution.x
  12. BIN
      superx/WEB-INF/lib/superx-qa.jar
  13. 197
      superx/xml/tabelle_html_qa.xsl

1
src-modules/module/qa/conf/includes.txt

@ -3,3 +3,4 @@ WEB-INF/conf/edustore/db/bin/SQL_ENV_qa.sam @@ -3,3 +3,4 @@ WEB-INF/conf/edustore/db/bin/SQL_ENV_qa.sam
WEB-INF/conf/edustore/db/bin/qa_mask_execution.x
WEB-INF/conf/edustore/db/bin/qa_tc_execution_mail.x
WEB-INF/lib/superx-qa.jar
xml/tabelle_html_qa.xsl

15
src-modules/module/qa/conf/qa.xml

@ -213,11 +213,11 @@ notnull="true"> @@ -213,11 +213,11 @@ notnull="true">
<column name="result_log" type="TEXT" size="" default="" description="Logdatei Ausführung" notnull="false">
<comment></comment>
</column>
<column name="result_stream" type="TEXT" size="255" default="" notnull="false" description="Ausgabe">
<comment>CSV oder XML</comment>
<column name="result_xml" type="TEXT" size="255" default="" notnull="false" description="Ausgabe (XML)">
<comment>XML</comment>
</column>
<column name="result_stream_contenttype" type="VARCHAR" size="255" default="" notnull="false" description="Ausgabeformat">
<comment>HTML, Text, CSV oder XML</comment>
<column name="result_html" type="TEXT" size="255" default="" notnull="false" description="Ausgabe (HTML)">
<comment>HTML</comment>
</column>
<!--
<column name="result_value" type="VARCHAR" size="255" default="" description="Rückgabewert" notnull="false">
@ -985,7 +985,11 @@ format="%s"> @@ -985,7 +985,11 @@ format="%s">
database=""/>
<nativeaction sql="" scriptfile="$QA_PFAD/datentabellen/qa_dbtest_ausfuehren.sql"
database=""/>
<nativeaction sql="update systeminfo set datum=today() where tid in (260)" scriptfile="" database=""/>
<nativeaction sql="update systeminfo set datum=today() where tid in (260);" scriptfile="" database=""/>
</action>
<action error="stop">
<nativeaction sql="" scriptfile="$QA_PFAD/datentabellen/vacuum_pg.sql"
database="POSTGRES"/>
</action>
</etl-step>
</etl>
@ -1006,6 +1010,7 @@ format="%s"> @@ -1006,6 +1010,7 @@ format="%s">
<action error="stop">
<nativeaction sql="" scriptfile="$QA_PFAD/schluesseltabellen/sx_jobs_fuellen.sql" database=""/>
<nativeaction sql="" scriptfile="$QA_PFAD/schluesseltabellen/sachgebiete_fuellen.sql" database=""/>
<nativeaction sql="" scriptfile="$QA_PFAD/upgrade/qa_upgrade_man.sql" database=""/>
</action>
</upgrade-step>

9
src-modules/module/qa/datentabellen/qa_mask_execution_result_purge.sql

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
--Speicherplatz sparen bei Erfolg:
update qa_mask_execution_result set result_stream=null,
result_stream_contenttype=null
where result_code=0;
--Speicherplatz sparen: leeren der TEXT Spalten nach 6 Monaten:
update qa_mask_execution_result set result_log=null,
result_xml=null,
result_html=null
where date(execution_start) < today()-180;

11
src-modules/module/qa/datentabellen/vacuum_pg.sql

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
select * from xdummy;
--bei Postgres in HIS1 laufen alle Scripte in Transaktionen, daher muss man
--für vacuum erst committen
commit;
vacuum qa_mask_execution_result;
vacuum qa_mask_execution_assert_result;

2
src-modules/module/qa/masken/37020_maskeninfo.unl

@ -363,4 +363,4 @@ Column CID=1 heading_text="Bearbeiten" center_heading\ @@ -363,4 +363,4 @@ Column CID=1 heading_text="Bearbeiten" center_heading\
row_selectable col_selectable heading_platform readonly\
width=5 text_size=200\
</#if>\
@@@^^^Protokoll der Masken-Ausführung ausgeben^drop table tmp_testcase;^^1^440^360^0^1^^
@@@^^^Protokoll der Testfall-Ausführung ausgeben^drop table tmp_testcase;^^1^440^360^0^1^^

6
src-modules/module/qa/masken/37040_maskeninfo.unl

@ -64,7 +64,8 @@ result_log,\ @@ -64,7 +64,8 @@ result_log,\
result_value_min,\
result_value_max,\
result_value,\
result_status_str\
result_status_str,\
'../edit/qa/qa_show_mask_execution_result.jsp|tid=' || tid as nextedit\
from tmp_qa_mask_execution\
order by 1,2,3;^XIL List\
drop_and_delete movable_columns sizable_columns horizontal_scrolling\
@ -94,4 +95,7 @@ Column CID=1 heading_text="Wert" center_heading\ @@ -94,4 +95,7 @@ Column CID=1 heading_text="Wert" center_heading\
Column CID=1 heading_text="Ausführungsstatus" center_heading\
row_selectable col_selectable heading_platform readonly\
width=15 text_size=200\
Column CID=1 heading_text="Ergebnis-HTML" center_heading\
row_selectable col_selectable heading_platform readonly\
width=15 text_size=200\
@@@^^^Detailausgabe des Protokolls einer Maskenausführung^drop table tmp_qa_mask_execution;^^1^440^360^0^1^^

27
src-modules/module/qa/qa_mask_execution_loop.x

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
#!/bin/bash
function exitAfterError
{
echo "Testfall Error"
date
}
trap exitAfterError ERR
TC_ALL=`psql --dbname=$DBNAME --tuples-only -c "select uniquename from qa_mask_execution where is_active=1 order by 1"`
cd $WEBAPP/WEB-INF
for TC in ${TC_ALL} ; do
echo -e "-- Start Testfall $TC `date`"
echo -e "######################################\n\n"
qa_mask_execution.x "-tc:$TC"
echo -e "-- Ende Testfall $TC `date`"
echo -e "######################################\n\n"
done

5
src-modules/module/qa/qa_update.x

@ -37,10 +37,9 @@ fi @@ -37,10 +37,9 @@ fi
date +'%d.%m.%Y' > $QA_LOAD_PFAD/superx.datum
echo "qa-Update startet" >$QA_ERRORDAT
cd $QA_PFAD
qa_mask_execution_loop.x > $QA_PFAD/L_QA_update_Masken$MANDANTID.log 2>&1
cd $WEBAPP/WEB-INF
qa_mask_execution.x > $QA_PFAD/L_QA_update_Masken$MANDANTID.log 2>&1
runAndCheck.x $QA_PFAD "module_etl.x qa $QA_PFAD $QA_LOAD_PFAD" EXIT_ON_ERROR SEND_ERRORMAIL SEND_LOGMAIL "QA update$MANDANTID"
cat $QA_PFAD/L_QA_update_Masken$MANDANTID.log >>$QA_PFAD/L_QA_update$MANDANTID.log
echo "---------------------------Beginn Prüfroutine-----------------------------------" >>$QA_ERRORDAT

15
src-modules/module/qa/upgrade/qa_upgrade_man.sql

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
--mit Version 0.6 werden Erwartungen in den Protokolltabellen mitgespeichert. So wird verhindert dass ein altes Testfall-Ergebnis durch eine Änderung der Erwartung verfälscht wird.
update qa_mask_execution_assert_result set assert_result_value_min=(select A.result_value_min
from qa_mask_execution_assert A where A.tid=qa_mask_execution_assert_result.mask_execution_assert_id)
where assert_result_value_min is null;
update qa_mask_execution_assert_result set assert_result_value_max=(select A.result_value_max
from qa_mask_execution_assert A where A.tid=qa_mask_execution_assert_result.mask_execution_assert_id)
where assert_result_value_max is null;
--Obsolete Maske:
delete from themenbaum where maskeninfo_id=37100;

216
src/de/superx/qa/bin/QaTestcaseExecutor.java

@ -7,17 +7,40 @@ @@ -7,17 +7,40 @@
*/
package de.superx.qa.bin;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.URISyntaxException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.StringTokenizer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;
import org.apache.log4j.Appender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.LoggerFactory;
import org.jaxen.JaxenException;
import org.jaxen.XPath;
@ -30,8 +53,11 @@ import org.jdom.input.SAXBuilder; @@ -30,8 +53,11 @@ import org.jdom.input.SAXBuilder;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletConfig;
import org.w3c.dom.NodeList;
import de.memtext.baseobjects.coll.NamedIdObjectList;
import de.memtext.util.LogUtils;
import de.superx.bin.Dosql;
import de.superx.bin.SxConnection;
import de.superx.common.FieldContainer;
import de.superx.common.Maske;
@ -52,7 +78,7 @@ import net.sf.saxon.sxpath.XPathExpression; @@ -52,7 +78,7 @@ import net.sf.saxon.sxpath.XPathExpression;
public class QaTestcaseExecutor {
private static String tcUniquename;
private static String systeminfoId;
private static int systeminfoId;
private static String fieldSelCmdLine;
private static int maskExecutionId;
private static String maskeninfoId;
@ -64,19 +90,35 @@ public class QaTestcaseExecutor { @@ -64,19 +90,35 @@ public class QaTestcaseExecutor {
private static FieldContainer myFieldContainer;
private static Hashtable<String, String> maskFields ;
private static String resultXml;
private static String resultHtml;
private static String resultLog;
private static String pathToDbProperties;
private static Connection myConnection;
private static String logFile;
public QaTestcaseExecutor() {
this.maskFields = new Hashtable();
initLogging();
resultHtml="";
}
private void init() throws SQLException
private void init() throws SQLException, IOException, SecurityException, URISyntaxException
{
/*File f = new File(logConf);
if (!f.exists()) {
throw new IOException("Datei nicht gefunden: " + logConf);
}
FileInputStream ins = new FileInputStream(logConf);
LogManager MyLogManager = java.util.logging.LogManager.getLogManager();
MyLogManager.readConfiguration(ins);
String level = MyLogManager.getProperty(".level");
logger.info("Using Loggging-Level " + level);
logger.info("Start Lauf");*/
//initLogging(true, Level.INFO);
//logger.info("START");
try {
myConnection = this.getConnection(pathToDbProperties);
} catch (Exception e) {
@ -89,7 +131,7 @@ public class QaTestcaseExecutor { @@ -89,7 +131,7 @@ public class QaTestcaseExecutor {
//System.out.println("fieldSel:"+fieldSel);
System.out.println("inited");
writeToLog("QaTestcaseExecutor inited");
}
@ -110,39 +152,38 @@ public class QaTestcaseExecutor { @@ -110,39 +152,38 @@ public class QaTestcaseExecutor {
}
public static void main(String[] args) {
String usage="usage: java de.superx.qa.bin.QaTestcaseExecutor -dbproperties:$DB_PROPERTIES -tc:abc -systeminfo_id:9 -params:TID=16000 (optional) -outfile:Ausgabedatei (optional)" ;
String usage="usage: java de.superx.qa.bin.QaTestcaseExecutor -userid:1(optional) -tc:abc(optional) -systeminfo_id:9(optional)" ;
GetOpts.setOpts(args);
String isdrin = GetOpts.isAllRequiredOptionsPresent("-logger,-dbproperties");
if (isdrin != null) {
System.err.println(usage);
System.exit(1);
}
int returnCode=0;
int nrOfTestcases=0;
int nrOfSuccessfulTestcases=0;
pathToDbProperties = GetOpts.getValue("-dbproperties");
String tcUniquename="" ;
if (GetOpts.isPresent("-userid"))
userId = Integer.valueOf(GetOpts.getValue("-userid"));
if (GetOpts.isPresent("-tc"))
tcUniquename= GetOpts.getValue("-tc");
String systeminfoId="";
if (GetOpts.isPresent("-systeminfo_id"))
systeminfoId= GetOpts.getValue("-systeminfo_id");
String loggerArg=GetOpts.getValue("-logger");
systeminfoId= Integer.valueOf(GetOpts.getValue("-systeminfo_id"));
QaTestcaseExecutor myExec=new QaTestcaseExecutor(); //TODO:Mandantid
try {
myExec.init();
int[] myTestcases=getTestcases(tcUniquename,systeminfoId);
int[] myTestcases=getTestcases();
nrOfTestcases=myTestcases.length;
if(nrOfTestcases>0)
{
writeToLog("nrOfTestcases: "+nrOfTestcases);
for (int tcNr = 0;tcNr < nrOfTestcases; tcNr++)
{
returnCode=executeTestcase(myTestcases[tcNr]);
//reset static variables:
resultLog="";
resultXml="";
resultHtml="";
tcUniquename="" ;
if(returnCode==0)
nrOfSuccessfulTestcases++;
}
@ -163,7 +204,7 @@ public class QaTestcaseExecutor { @@ -163,7 +204,7 @@ public class QaTestcaseExecutor {
}
private static int[] getTestcases(String tcUniquename,String systeminfoId) throws Exception
private static int[] getTestcases() throws Exception
{
//TODO_ Umlaute erlauben:
//if(!SqlStringUtils.checkValidKeyEntry(tcUniquename) || !SqlStringUtils.checkValidKeyEntry(systeminfoId))
@ -175,10 +216,12 @@ public class QaTestcaseExecutor { @@ -175,10 +216,12 @@ public class QaTestcaseExecutor {
+ "FROM qa_mask_execution E left outer join userinfo U\n"
+ " on (U.tid=E.userinfo_id)"
+ "where E.is_active=1";
if(!tcUniquename.equals(""))
if(tcUniquename!=null)
sql +=" and E.uniquename ='"+tcUniquename+"'";
if(!systeminfoId.equals(""))
if(systeminfoId>0)
sql +=" and E.systeminfo_id="+systeminfoId;
if(userId>0)
sql +=" and E.userinfo_id="+userId;
sql +=" order by 1;";
SuperX_el el = new SuperX_el();
SxSqlHelper sh=new SxSqlHelper();
@ -211,6 +254,7 @@ public class QaTestcaseExecutor { @@ -211,6 +254,7 @@ public class QaTestcaseExecutor {
String fieldSel="";
String felderinfoId="";
String felderinfoName="";
String tcName="";
String fieldValue="";
String sql = ""
+ "SELECT \n"
@ -221,7 +265,9 @@ public class QaTestcaseExecutor { @@ -221,7 +265,9 @@ public class QaTestcaseExecutor {
+ "S.felderinfo_id,\n"
+ "trim(F.name) as felderinfo_name,"
+ "string_not_null(S.field_value) as field_value, \n"
+ "U.administration "
+ "U.administration, \n"
+ "E.name, \n"
+ "E.uniquename \n"
+ "FROM felderinfo F,qa_mask_field_sel S, qa_mask_execution E left outer join userinfo U\n"
+ " on (U.tid=E.userinfo_id)"
+ "where F.tid=S.felderinfo_id "
@ -248,19 +294,22 @@ public class QaTestcaseExecutor { @@ -248,19 +294,22 @@ public class QaTestcaseExecutor {
felderinfoName=row.get(5).toString().trim();
fieldValue=row.get(6).toString().trim();
userAdmin=row.get(7).toString().trim();
tcName=row.get(8).toString().trim();
tcUniquename=row.get(9).toString().trim();
maskFields.put(felderinfoName,fieldValue);
}
System.out.println("Testcase "+ maskExecutionId+" initialized");
writeToLog("Testcase "+tcName + "(Schlüssel="+tcUniquename+" ID="+ maskExecutionId+") initialized");
returnCode=executeMask();
endtime = new java.util.Date().getTime() ;
int maskExecutionResultId=saveExecutionResult(returnCode,resultLog);
writeToLog("Mask "+maskeninfoId +" executed in "+(endtime-starttime)/1000+" sec. with return Code "+returnCode);
int maskExecutionResultId=saveExecutionResult(maskExecutionId,returnCode,resultLog);
if(returnCode ==0)
{
returnCode=checkAssertions(maskExecutionResultId);
returnCode=checkAssertions(maskExecutionId,maskExecutionResultId);
}
else
throw new Exception("Testcase error in masc execution "+maskExecutionId);
writeToLog("Testcase error in masc execution "+maskExecutionId);
return returnCode;
}
private static int executeMask()
@ -288,11 +337,11 @@ public class QaTestcaseExecutor { @@ -288,11 +337,11 @@ public class QaTestcaseExecutor {
user = UserInitializer.initUser(mandantenID, userName, userId, userAdmin);
} catch (Exception e) {
System.err.println("Fehler beim Aufbau der Connection: " + e.toString());
System.exit(1);
writeToLog("Fehler beim Aufbau der Connection: " + e.toString());
return 1;
}
Locale desiredLocale = new Locale(de.superx.util.SqlStringUtils.getEncoding());
SuperXManager.maxRows = 1000000;
SuperXManager.maxRows = 10000;
Maske maske = null;
InputCheckRegistry.registerDefaultChecks();
try {
@ -302,29 +351,40 @@ public class QaTestcaseExecutor { @@ -302,29 +351,40 @@ public class QaTestcaseExecutor {
myFieldContainer.addAll(fields);*/
maske.setFieldDefaults(user, mock, true);
resultXml=getResultXml(mock, mockResponse, maske, user, desiredLocale);
System.out.println("resultXml Länge " + resultXml.length() + " für Maske " + maskeninfoId + " erzeugt");
if(resultXml==null)
{
writeToLog("resultXml für Maske " + maskeninfoId + " konnte nicht erzeugt werden");
}
else
{
writeToLog("resultXml Länge " + resultXml.length() + " für Maske " + maskeninfoId + " erzeugt");
transformResultXmltoHtml();
}
} catch (Exception e) {
e.printStackTrace();
resultLog="Fehler beim Ausführen der Maske " + maskeninfoId + ": " + e.toString();
returnCode=1;
}
user=null;
return returnCode;
}
private static int checkAssertions(int maskExecutionResultId) throws Exception
private static int checkAssertions(int execId,int maskExecutionResultId) throws Exception
{
int resultCode=0;
int assertionId,assertionRownr,assertionColnr;
Double minVal,maxVal,foundVal=null;
String caption;
String sql = "select "
+"tid,"
+"rownr,"
+"colnr,"
+"result_value_min,"
+"result_value_max"
+"result_value_max,"
+ "caption"
+" from qa_mask_execution_assert"
+ " where is_active=1"
+" and mask_execution_id="+maskExecutionId+";";
+" and mask_execution_id="+execId+";";
/*try {
@ -353,19 +413,22 @@ public class QaTestcaseExecutor { @@ -353,19 +413,22 @@ public class QaTestcaseExecutor {
assertionColnr=(Integer) row.get(2);
minVal=(Double) row.get(3);
maxVal=(Double) row.get(4);
caption=(String) row.get(5).toString();
try {
foundVal=getValFromXml(assertionRownr,assertionColnr);
} catch (Exception e) {
System.err.println("Testfall ID " +maskExecutionId+" mit Maskennr. "+maskeninfoId+ " Assertion-ID "+assertionId+ " kein Ergebnis ");
writeToLog("Testfall ID " +execId+" mit Maskennr. "+maskeninfoId+ " Assertion-ID "+assertionId+ " " + caption+ " kein Ergebnis:\n" +e.toString());
resultCode=1;
return resultCode;
}
if(foundVal != null && foundVal >=minVal && foundVal<=maxVal)
{
System.out.println("Testfall ID " +maskExecutionId+" mit Maskennr. "+maskeninfoId+ " Assertion-ID "+assertionId+ " erfolgreich");
writeToLog("Testfall ID " +execId+" mit Maskennr. "+maskeninfoId+ " Assertion-ID "+assertionId+ " " + caption+ " und Wert "+ foundVal+" erfolgreich");
}
else
{
resultCode=1;
System.out.println("Testfall ID " +maskExecutionId+" mit Maskennr. "+maskeninfoId+ " Assertion-ID "+assertionId+ " beendet mit Warnung/Fehler");
writeToLog("Testfall ID " +execId+" mit Maskennr. "+maskeninfoId+ " Assertion-ID "+assertionId+ " " + caption +" und Wert "+ foundVal+ " beendet mit Warnung/Fehler");
}
saveAssertResult(assertionId,maskExecutionResultId,foundVal,resultCode,minVal,maxVal);
}
@ -393,22 +456,22 @@ public class QaTestcaseExecutor { @@ -393,22 +456,22 @@ public class QaTestcaseExecutor {
boolean executed= st.execute();
}
private static int saveExecutionResult(int maskExecutionResult,String log ) throws SQLException
private static int saveExecutionResult(int execId, int maskExecutionResult,String log ) throws SQLException
{
int ret=0;
java.sql.Timestamp startTimeDate = new java.sql.Timestamp(starttime);
java.sql.Timestamp endTimeDate = new java.sql.Timestamp(endtime);
String sql="insert into qa_mask_execution_result(mask_execution_id, execution_start, execution_end, result_code,result_log,result_stream,result_stream_contenttype)";
String sql="insert into qa_mask_execution_result(mask_execution_id, execution_start, execution_end, result_code,result_log,result_xml,result_html)";
sql +="values(?,?,?,?,?,?,?);";
PreparedStatement st=myConnection.prepareStatement(sql);
st.setInt(1,maskExecutionId);
st.setInt(1,execId);
st.setTimestamp(2, startTimeDate);
st.setTimestamp(3, endTimeDate);
st.setInt(4,maskExecutionResult);
st.setString(5,log);
//im Fehler/Warnungsfall Ergebnis speichern:
st.setString(6,resultXml);
st.setString(7,"text/xml");
st.setString(7,resultHtml);
boolean executed= st.execute();
//get generated tid:
@ -435,7 +498,7 @@ public class QaTestcaseExecutor { @@ -435,7 +498,7 @@ public class QaTestcaseExecutor {
String xpathStr = "/ergebnisse/ergebnis/ergebniselement/sqlerg/row[@no="+(assertionRownr-1)+"]/col[@id="+(assertionColnr-1)+"]/wert";
XPath expression = new JDOMXPath(xpathStr);
Element myNode = (Element) expression.selectSingleNode(doc);
if(myNode==null)
if(myNode==null)
return null;
else
{
@ -465,6 +528,75 @@ public class QaTestcaseExecutor { @@ -465,6 +528,75 @@ public class QaTestcaseExecutor {
return currentXml_local;
}
public void initLogging() {
File f;
try {
logFile=PathAndFileUtils.getWebinfPath()+File.separator+"logs"+File.separator+"superx_qa.log" ;
f = new File(logFile);
if(f.exists())
f.delete();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
writeToLog("Start");
}
private static void writeToLog(String msg)
{
FileWriter f;
try {
f = new FileWriter(logFile,true);
long jetzt= new java.util.Date().getTime() ;
Date date = new Date();
date.setTime(jetzt);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
f.write(format.format(date)+": " +msg+"\n");
f.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println(msg);
}
}
private static void transformResultXmltoHtml()
{
String xslFile="";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream myStream = new PrintStream(baos);
try {
StringWriter myOutwriter= new StringWriter();
xslFile=PathAndFileUtils.getWebinfDirectory()+PathAndFileUtils.PATHSEP+".."+PathAndFileUtils.PATHSEP+"xml"+PathAndFileUtils.PATHSEP+"tabelle_html_qa.xsl";
File f=new File(xslFile);
//in development mode the XSL is not available:
if(!f.exists())
xslFile=PathAndFileUtils.getWebinfDirectory()+PathAndFileUtils.PATHSEP+".."+PathAndFileUtils.PATHSEP+"xml"+PathAndFileUtils.PATHSEP+"tabelle_html2.xsl";
javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl",null);
javax.xml.transform.Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(xslFile));
StringReader s1 = new StringReader(resultXml);
transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, SqlStringUtils.getEncoding());
transformer.setOutputProperty(javax.xml.transform.OutputKeys.METHOD, "html");
/* TODO: hier Parameter einzelne Zeile übergeben:
* String paramname = param.substring(0, param.indexOf("="));
String paramvalue = param.substring(param.indexOf("=") + 1, param.length());
transformer.setParameter(paramname, paramvalue);
*/
transformer.transform(new javax.xml.transform.stream.StreamSource(s1), new javax.xml.transform.stream.StreamResult(myOutwriter));
resultHtml=myOutwriter.toString();
myOutwriter.close();
s1.close();
} catch (Exception e) {
writeToLog("resultXml konnte nicht zu HTML konvertiert werden:\n"+ e.toString());
resultLog+=("resultXml konnte nicht zu HTML konvertiert werden:\n"+ e.toString());
resultHtml="resultXml konnte nicht zu HTML konvertiert werden:" + resultXml;
}
}
}

20
superx/WEB-INF/conf/edustore/db/bin/qa_mask_execution.x

@ -1,19 +1,15 @@ @@ -1,19 +1,15 @@
#!/bin/bash
TC_UNIQUENAME=$1
SYSTEMINFO=$2
ARG1=""
ARG2=""
if [ "$TC_UNIQUENAME" != "" ] ; then
ARG1="-tc:$TC_UNIQUENAME"
fi
if [ "$SYSTEMINFO" != "" ] ; then
ARG2="-systeminfo_id:$SYSTEMINFO"
if [ "$1" = "--help" ]
then echo "Aufruf: qa_mask_execution.x -tc:<Testfall-Schlüssel(optional)> -systeminfo_id:<Komponente(optioanl)> -userid:<Userid (optional)>"
echo " "
echo "Aktion: qa_mask_execution.x führt aktive Testfälle aus"
echo "Das Script muss in $WEBAPP/WEB-INF ausgeführt werden"
echo "Logdatei: $WEBAPP/WEB-INF/logs/superx_qa.log"
exit 0
fi
java -cp "$JDBC_CLASSPATH" $JAVA_OPTS de.superx.qa.bin.QaTestcaseExecutor -logger:$SUPERX_DIR/db/conf/logging.properties -dbproperties:$DB_PROPERTIES "$ARG1" "$ARG2"
java -cp "$JDBC_CLASSPATH" $JAVA_OPTS de.superx.qa.bin.QaTestcaseExecutor "$@"

BIN
superx/WEB-INF/lib/superx-qa.jar

Binary file not shown.

197
superx/xml/tabelle_html_qa.xsl

@ -0,0 +1,197 @@ @@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="pageComponents_html.xsl" />
<!--In diesem Stylesheet können Sie individuelle templates unterbringen,
die in ihrer Präzedenz das normale Stylesheet
pageComponents_html.xsl überragt. -->
<xsl:import href="pageComponents_html_final.xsl" />
<xsl:import href="resultset_html.xsl" />
<xsl:import href="interLinks_html.xsl" />
<xsl:decimal-format name="German" grouping-separator="." NaN="" zero-digit ="0" decimal-separator="," />
<xml:output method="html" />
<xsl:template match="/">
<html>
<xsl:call-template name="head" >
<xsl:with-param name="title" select="concat('Ergebnis ',/ergebnisse/ergebnis/ergebniselement/maskenname)" />
</xsl:call-template>
<body onload="isReady=true">
<xsl:choose>
<!--MB -->
<xsl:when test="/ergebnisse/makro/@id !=''">
<h1><xsl:value-of select="/ergebnisse/makro/name" /></h1>
<p><input type="hidden" name="tid">
<xsl:attribute name="value"><xsl:value-of select="/ergebnisse/makro/@id" /></xsl:attribute>
</input>
</p></xsl:when>
<xsl:otherwise>
<p><input type="hidden" name="tid">
<xsl:attribute name="value"><xsl:value-of select="/ergebnisse/ergebnis/maskenname/@id" /></xsl:attribute>
</input></p>
</xsl:otherwise>
</xsl:choose>
<!--<xsl:call-template name="legende" />-->
<xsl:for-each select="ergebnisse/ergebnis/ergebniselement">
<xsl:choose>
<xsl:when test="@typ='image'">
<img>
<xsl:attribute name="src"><xsl:value-of select="@url" /></xsl:attribute>
</img>
<hr/>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:when test="@typ='tabelle'">
<h2><xsl:value-of select="../maskenname" /></h2>
<!-- MB legende bei jeder Tabelle -->
<p class="legende">
<xsl:for-each select="../felder/feld">
<xsl:if test="value !=''">
<span class="feldname"><xsl:value-of select="@varname" /></span>:&#160;
<xsl:if test="string-length(wert/caption) &lt; 50">
<!-- MB 22.12.04 statt caption value_caption-->
<span class="feldwert"><xsl:value-of select="value_caption" /></span>
</xsl:if>
<!-- MB 22.12.04 statt caption value_caption-->
<xsl:if test="string-length(wert/caption) &gt; 49">
<span class="feldwert"><xsl:value-of select="substring(value_caption,0,50)" />...</span>
</xsl:if>
;
</xsl:if>
</xsl:for-each>
Stand: <xsl:value-of select="../stand" /></p>
<!-- MB fehlermeldung direkt vom Servlet
<xsl:if test="errmsg !=''"><p class="errmsg"><xsl:copy-of select="errmsg" /></p></xsl:if>
-->
<table class="ergtabelle" border="1">
<tr>
<xsl:for-each select="sqlerg/headers/header">
<xsl:call-template name="header">
<xsl:with-param name="derwert" select="wert" />
</xsl:call-template>
</xsl:for-each>
<!--<td></td>-->
</tr>
<xsl:for-each select="sqlerg/row">
<tr>
<xsl:for-each select="col">
<td class="ergfeld">
<xsl:choose>
<!--<xsl:when test="@id='0'">
<xsl:attribute name="class">themenspalte</xsl:attribute>
</xsl:when>
<xsl:when test="@typ='1'"> String
<xsl:attribute name="class">string</xsl:attribute>
<xsl:value-of select="wert" />
</xsl:when>-->
<xsl:when test="@typ='2' or @typ='8' or @typ='3'"> <!-- DecimalFormat -->
<xsl:attribute name="class">decimal</xsl:attribute>
<!--<xsl:value-of select="wert" />-->
<xsl:choose>
<xsl:when test="wert != ''">
<xsl:value-of select="format-number(wert,'###.###.###.###.##0,00','German')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'&#160;'" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@typ='4'"> <!-- Integer -->
<xsl:attribute name="class">integer</xsl:attribute>
<!--<xsl:value-of select="wert" />-->
<xsl:choose>
<xsl:when test="wert != ''">
<xsl:value-of select="format-number(wert,'###.###.###.###.###','German')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'&#160;'" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!--Typ=1 ist string und wird defaultmäßig behandelt -->
<xsl:call-template name="field_type" />
<xsl:variable name="zs">
<xsl:call-template name="field_value">
</xsl:call-template>
</xsl:variable>
<xsl:variable name="zs3">
<xsl:call-template name="resultsetLink">
<xsl:with-param name="zs2" select="$zs" />
</xsl:call-template>
</xsl:variable>
<!--Ab hier können Benutzerspezifische Transformationen nach Feldnamen oder Typ beginnen
Bei leeren Zellen wird nbsp übergeben, weil
der IE die Zellen sonst ohne Rahmen darstellt.
Standardmmäßig wird der Feldinhalt nur noch kopiert.-->
<xsl:call-template name="get_val_or_nbsp">
<xsl:with-param name="zs4"><xsl:copy-of select="$zs3" /></xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
<!--<td></td>-->
</tr>
</xsl:for-each>
</table>
</xsl:when>
<xsl:otherwise>
<xsl:text>
Nicht unterstützter Ergebnistyp </xsl:text><xsl:value-of select="@type" />
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="navigationsfuss" />
</xsl:for-each>
<!--<div id="inhalt" class="versteckt"><p><TEXTAREA NAME="content" ROWS="40" COLS="80" WRAP="off" READONLY="true">
<ergebnis><xsl:copy-of select="/ergebnis/*|@*|text()" /></ergebnis>
</TEXTAREA>
</p></div>
<script language="Javascript">
versteckeText("inhalt");
</script>-->
</body>
</html>
</xsl:template>
<xsl:template name="tabwert">
<xsl:choose>
<xsl:when test="wert/@type='numeric'"><xsl:value-of select="wert" />
<!--<xsl:value-of select="format-number(wert,'#.###.##0,00','de_DE')" />-->
</xsl:when>
<xsl:otherwise><xsl:value-of select="wert" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="create_url">
<xsl:param name="stylesheet"/>
<xsl:text>/superx/servlet/SuperXmlTabelle?</xsl:text>
<xsl:if test="$stylesheet!=''"><xsl:text>stylesheet=</xsl:text><xsl:value-of select="$stylesheet" /><xsl:text>&amp;</xsl:text>
</xsl:if>
<xsl:text>UserID=</xsl:text><xsl:value-of select="/ergebnis/userid" /><xsl:text>&amp;tid=</xsl:text><xsl:value-of select="/ergebnisse/ergebnis/maskenname/@id" />
<xsl:for-each select="/ergebnis/tabelle/felder/feld">
<xsl:if test="wert/value !=''">
<xsl:text>&amp;</xsl:text><xsl:value-of select="wert/@varname" /><xsl:text>=</xsl:text><xsl:value-of select="wert/value" />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Loading…
Cancel
Save