Commit 343a7f52 authored by wwalkowski's avatar wwalkowski

No commit message

No commit message
parent 5aa267ca
......@@ -6,23 +6,20 @@ package parser;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import java.io.*;
import java.util.HashMap;
import java.util.Vector;
public class ExtractDLNAResults
{
private HashMap<String, Vector<Rec>> map = new HashMap<String, Vector<Rec>>();
private HashMap<String, Vector<Rec>> testCaseResultMap = new HashMap<String, Vector<Rec>>();
public static class Rec
{
......@@ -46,18 +43,29 @@ public class ExtractDLNAResults
}
// The branch name is passed in as an argument, and the code will
// extrapolate all file names using that.
public static void main ( String[] args )
{
if ( args.length != 2 )
{
System.out.println ( "Number of args was not 2. Need 1 argument as branch name and 1 as name of tool" );
System.exit ( SharedConstants.failValue );
}
int exitValue = SharedConstants.successValue;
ExtractDLNAResults ex = new ExtractDLNAResults();
try
{
ex.execute();
ex.execute ( args[0], args[1] );
}
catch ( Exception e )
{
e.printStackTrace();
exitValue = SharedConstants.failValue;
}
......@@ -68,56 +76,40 @@ public class ExtractDLNAResults
/*
* Process the result file
*/
public void execute()
public void execute ( String branch, String toolName )
throws Exception
{
Utilities ut = new Utilities();
File file = new File ( SharedConstants.dlnaCttParserLogFile );
file.delete();
File inputFile = new File ( SharedConstants.dlnaInputResultsFile );
// Determine file names
String baseDir;
if ( toolName.equals("dlna") )
{
baseDir = SharedConstants.dlnaBaseDir;
}
else
{
baseDir = SharedConstants.mcvtBaseDir;
}
String summaryFileName = baseDir + branch + "_" + toolName + "_summary.txt";
String inputFileName = baseDir + branch + "_" + toolName + "_ctt_results.trf";
String resultsFileName = baseDir + branch + "_" + toolName + "_ctt_results_parsed.txt";
// Create file writers
MyFileWriter resultsFile = new MyFileWriter ( resultsFileName );
MyFileWriter summaryFile = new MyFileWriter ( summaryFileName );
// Parse XML results file
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
Document doc = null;
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = null;
try
{
dBuilder = dbFactory.newDocumentBuilder();
}
catch ( ParserConfigurationException e )
{
e.printStackTrace();
log ( "Parser Configuration Exception\r\n" + ut.getExceptionString(e) );
throw new Exception();
}
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
try
{
doc = dBuilder.parse(inputFile);
}
catch ( SAXException e )
{
e.printStackTrace();
log ( "SAX Exception\r\n" + new Utilities().getExceptionString(e) );
throw new Exception();
}
catch ( IOException e )
{
e.printStackTrace();
log ( "IO Exception\r\n" + new Utilities().getExceptionString(e) );
throw new Exception();
}
Document doc = dBuilder.parse(inputFileName);
doc.getDocumentElement().normalize();
......@@ -147,59 +139,35 @@ public class ExtractDLNAResults
}
// Loop through all status types to count first
MyFileWriter countFile = new MyFileWriter ( ut.getCountFileName() );
MyFileWriter resultsFile = new MyFileWriter ( ut.getResultsFileName() );
int total = 0;
try
for ( String s : testCaseResultMap.keySet() )
{
for ( String s : map.keySet() )
{
countFile.write ( s + "\t" + map.get(s).size() );
summaryFile.write ( s + "\t" + testCaseResultMap.get(s).size() );
total += map.get(s).size();
}
countFile.write ( "-----------------------" );
countFile.write ( "Total\t" + total );
countFile.write ( "\r\n\r\nThese files are in SVN located at: \r\n" +
"https://community.cablelabs.com/svn/oc/ocap_ri/trunk/ri/QA/dlna_ctt/MarketDMS%20Automated%20Results" );
countFile.close();
}
catch ( IOException e )
{
e.printStackTrace();
log ( "IO Exception\r\n" + new Utilities().getExceptionString(e) );
throw new Exception();
total += testCaseResultMap.get(s).size();
}
try
summaryFile.write ( "-----------------------" );
summaryFile.write ( "Total\t" + total );
summaryFile.write ( "\r\n\r\nThese files are in Bitbucket located at: \r\n" +
"https://community.cablelabs.com/svn/oc/ocap_ri/trunk/ri/QA/dlna_ctt/MarketDMS%20Automated%20Results" );
summaryFile.close();
// Now loop through again to display
for ( String s : testCaseResultMap.keySet() )
{
// Now loop through again to display
for ( String s : map.keySet() )
for ( Rec r : testCaseResultMap.get(s) )
{
for ( Rec r : map.get(s) )
{
resultsFile.write ( r.toString() );
}
resultsFile.write ( r.toString() );
}
resultsFile.close();
}
catch ( IOException e )
{
e.printStackTrace();
log ( "IO Exception\r\n" + new Utilities().getExceptionString(e) );
throw new Exception();
}
resultsFile.close();
}
......@@ -259,36 +227,16 @@ public class ExtractDLNAResults
Rec rec = new Rec ( status, time, assertion, comment );
Vector<Rec> results = map.get(rec.status);
Vector<Rec> results = testCaseResultMap.get(rec.status);
if ( results == null )
{
results = new Vector<Rec>();
map.put ( rec.status, results );
testCaseResultMap.put ( rec.status, results );
}
results.add(rec);
}
private void log ( String message )
{
MyFileWriter mfw = new MyFileWriter ( SharedConstants.dlnaCttParserLogFile );
try
{
mfw.write(message);
}
catch ( IOException e )
{
// There's not much we can do with this. It will be called by a bash script
// and we are inside the logging message, so dump to screen in case this
// is being run manually.
e.printStackTrace();
}
mfw.close();
}
}
......@@ -6,16 +6,12 @@ package parser;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import java.io.*;
import java.util.HashMap;
import java.util.Vector;
......@@ -49,16 +45,25 @@ public class ExtractUPnPResults
public static void main ( String[] args )
{
if ( args.length != 1 )
{
System.out.println ( "Number of args was not 1. Need 1 argument as branch name." );
System.exit ( SharedConstants.failValue );
}
int exitValue = SharedConstants.successValue;
ExtractUPnPResults ex = new ExtractUPnPResults();
try
{
ex.execute();
ex.execute ( args[0] );
}
catch ( Exception e )
{
e.printStackTrace ();
exitValue = SharedConstants.failValue;
}
......@@ -69,56 +74,29 @@ public class ExtractUPnPResults
/*
* Process the result file
*/
public void execute()
public void execute ( String branch )
throws Exception
{
Utilities ut = new Utilities();
File file = new File ( SharedConstants.upnpCttParserLogFile );
file.delete();
File inputFile = new File ( SharedConstants.upnpInputResultsFile );
// Determine file names
String summaryFileName = SharedConstants.upnpBaseDir + branch + "_upnp_summary.txt";
String inputFileName = SharedConstants.upnpBaseDir + branch + "_upnp_ctt_results.trf";
String resultsFileName = SharedConstants.upnpBaseDir + branch + "_upnp_ctt_results_parsed.txt";
// Create file writers
MyFileWriter resultsFile = new MyFileWriter ( resultsFileName );
MyFileWriter summaryFile = new MyFileWriter ( summaryFileName );
// Parse XML results file
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
Document doc = null;
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = null;
try
{
dBuilder = dbFactory.newDocumentBuilder();
}
catch ( ParserConfigurationException e )
{
e.printStackTrace();
log ( "Parser Configuration Exception\r\n" + ut.getExceptionString(e) );
throw new Exception();
}
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
try
{
doc = dBuilder.parse(inputFile);
}
catch ( SAXException e )
{
e.printStackTrace();
log ( "SAX Exception\r\n" + new Utilities().getExceptionString(e) );
throw new Exception();
}
catch ( IOException e )
{
e.printStackTrace();
log ( "IO Exception\r\n" + new Utilities().getExceptionString(e) );
throw new Exception();
}
Document doc = dBuilder.parse(inputFileName);
doc.getDocumentElement().normalize();
......@@ -148,59 +126,33 @@ public class ExtractUPnPResults
}
// Loop through all status types to count first
MyFileWriter countFile = new MyFileWriter ( ut.getCountFileName() );
MyFileWriter resultsFile = new MyFileWriter ( ut.getResultsFileName() );
int total = 0;
try
for ( String s : map.keySet() )
{
for ( String s : map.keySet() )
{
countFile.write ( s + "\t" + map.get(s).size() );
total += map.get(s).size();
}
summaryFile.write ( s + "\t" + map.get(s).size() );
countFile.write ( "-----------------------" );
countFile.write ( "Total\t" + total );
countFile.write ( "\r\n\r\nThese files are in SVN located at: \r\n" +
"https://community.cablelabs.com/svn/oc/ocap_ri/trunk/ri/QA/upnp_ctt/MarketDMS%20Automated%20Results" );
countFile.close();
}
catch ( IOException e )
{
e.printStackTrace();
log ( "IO Exception\r\n" + new Utilities().getExceptionString(e) );
throw new Exception();
total += map.get(s).size();
}
try
summaryFile.write ( "-----------------------" );
summaryFile.write ( "Total\t" + total );
summaryFile.write ( "\r\n\r\nThese files are in Bitbucket located at: \r\n" +
"https://community.cablelabs.com/svn/oc/ocap_ri/trunk/ri/QA/upnp_ctt/MarketDMS%20Automated%20Results" );
summaryFile.close();
// Now loop through again to display
for ( String s : map.keySet() )
{
// Now loop through again to display
for ( String s : map.keySet() )
for ( Rec r : map.get(s) )
{
for ( Rec r : map.get(s) )
{
resultsFile.write ( r.toString() );
}
resultsFile.write ( r.toString() );
}
resultsFile.close();
}
catch ( IOException e )
{
e.printStackTrace();
log ( "IO Exception\r\n" + new Utilities().getExceptionString(e) );
throw new Exception();
}
resultsFile.close();
}
......@@ -264,25 +216,5 @@ public class ExtractUPnPResults
results.add ( rec );
}
private void log ( String message )
{
MyFileWriter mfw = new MyFileWriter ( SharedConstants.dlnaCttParserLogFile );
try
{
mfw.write(message);
}
catch ( IOException e )
{
// There's not much we can do with this. It will be called by a bash script
// and we are inside the logging message, so dump to screen in case this
// is being run manually.
e.printStackTrace();
}
mfw.close();
}
}
......@@ -7,15 +7,11 @@ package parser;
public interface SharedConstants
{
// Log files
public static final String dlnaCttParserLogFile = "C:\\dlnaCttParserLog.txt";
public static final String upnpCttParserLogFile = "C:\\upnpCttParserLog.txt";
// Used to reference DLNA CTT results
public static final String dlnaInputResultsFile = "C:\\dlnaCttTestResults.trf";
public static final String upnpInputResultsFile = "C:\\upnpCttTestResults.uctt";
public static final String baseDir = "C:\\CTT Results Files\\";
public static final String dlnaBaseDir = baseDir + "DLNA\\";
public static final String upnpBaseDir = baseDir + "UPnP\\";
public static final String mcvtBaseDir = baseDir + "MCVT\\";
// Values used in System.exit() calls that signal the controlling
// bash script success or failure.
public static final int successValue = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment