Kaydet (Commit) 049d8555 authored tarafından Lars Langhans's avatar Lars Langhans

gfxcmp02: #159601# cleanups

üst e07e9218
...@@ -93,7 +93,7 @@ public class BuildID ...@@ -93,7 +93,7 @@ public class BuildID
} }
else else
{ {
GlobalLogWriter.get().println("soffice executable not found."); GlobalLogWriter.println("soffice executable not found.");
} }
// int dummy = 0; // int dummy = 0;
...@@ -119,7 +119,7 @@ public class BuildID ...@@ -119,7 +119,7 @@ public class BuildID
} }
else else
{ {
GlobalLogWriter.get().println("Property Build, can't open file '" + sOfficePath + "', please check."); GlobalLogWriter.println("Property Build, can't open file '" + sOfficePath + "', please check.");
} }
return sBuildID; return sBuildID;
} }
...@@ -144,7 +144,7 @@ public class BuildID ...@@ -144,7 +144,7 @@ public class BuildID
} }
else else
{ {
GlobalLogWriter.get().println("Property Build, can't open file '" + sOfficePath + "', please check."); GlobalLogWriter.println("Property Build, can't open file '" + sOfficePath + "', please check.");
} }
return sBuildID; return sBuildID;
} }
......
...@@ -38,7 +38,7 @@ import java.util.ArrayList; ...@@ -38,7 +38,7 @@ import java.util.ArrayList;
*/ */
public class DirectoryHelper public class DirectoryHelper
{ {
ArrayList m_aFileList = new ArrayList(); ArrayList<String> m_aFileList = new ArrayList<String>();
boolean m_bRecursiveIsAllowed = true; boolean m_bRecursiveIsAllowed = true;
void setRecursiveIsAllowed(boolean _bValue) void setRecursiveIsAllowed(boolean _bValue)
...@@ -73,6 +73,10 @@ public class DirectoryHelper ...@@ -73,6 +73,10 @@ public class DirectoryHelper
* System.out.println(aEntry); * System.out.println(aEntry);
* } * }
* *
* @param _sDirectory
* @param _aFileFilter
* @param _bRecursiveIsAllowed
* @return list of directories
*/ */
public static Object[] traverse( String _sDirectory, FileFilter _aFileFilter, boolean _bRecursiveIsAllowed ) public static Object[] traverse( String _sDirectory, FileFilter _aFileFilter, boolean _bRecursiveIsAllowed )
{ {
......
...@@ -44,8 +44,8 @@ abstract public class EnhancedComplexTestCase extends ComplexTestCase implements ...@@ -44,8 +44,8 @@ abstract public class EnhancedComplexTestCase extends ComplexTestCase implements
private void callEntry(String _sEntry, ParameterHelper _aParam) private void callEntry(String _sEntry, ParameterHelper _aParam)
{ {
log.println("- next file is: ------------------------------"); // log.println("- next file is: ------------------------------");
log.println(_sEntry); log.println("File: " + _sEntry);
// TODO: check if 'sEntry' is a guilty document. // TODO: check if 'sEntry' is a guilty document.
File aFile = new File(_aParam.getInputPath()); File aFile = new File(_aParam.getInputPath());
String sPath = _aParam.getInputPath(); String sPath = _aParam.getInputPath();
...@@ -79,7 +79,8 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) ...@@ -79,7 +79,8 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
// sNewDiffPath = FileHelper.appendPath(sNewDiffPath, sNewSubDir); // sNewDiffPath = FileHelper.appendPath(sNewDiffPath, sNewSubDir);
// } // }
} }
log.println("sEntry: " + _sEntry + " " /* + sNewReferencePath + " " */ + sNewOutputPath); // log.println("sEntry: " + _sEntry + " " /* + sNewReferencePath + " " */ + sNewOutputPath);
log.println("Outputpath: " + sNewOutputPath);
// call interface with parameters // call interface with parameters
...@@ -187,12 +188,34 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) ...@@ -187,12 +188,34 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
} }
else else
{ {
String sPath = FileHelper.getPath(sInputPath); String sInputPathWithPDF = sInputPath + ".pdf";
String sBasename = FileHelper.getBasename(sInputPath); File aInputPathWithPDF = new File(sInputPathWithPDF);
// there exist an index file, therefore we assume the given if (aInputPathWithPDF.exists() &&
// file is already converted to postscript or pdf _aParam.getReferenceType().toLowerCase().equals("pdf"))
runThroughEveryReportInIndex(sPath, sBasename, _aParam); {
// create PDF only if a pdf file exists and creatortype is set to PDF
callEntry(sInputPathWithPDF, _aParam);
}
else
{
String sInputPathWithPS = sInputPath + ".ps";
File aInputPathWithPS = new File(sInputPathWithPS);
if (aInputPathWithPS.exists())
{
callEntry(sInputPathWithPS, _aParam);
}
else
{
String sPath = FileHelper.getPath(sInputPath);
String sBasename = FileHelper.getBasename(sInputPath);
// there exist an index file, therefore we assume the given
// file is already converted to postscript or pdf
runThroughEveryReportInIndex(sPath, sBasename, _aParam);
}
}
} }
} }
} }
...@@ -210,7 +233,7 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) ...@@ -210,7 +233,7 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
{ {
// special case for odb files // special case for odb files
int nFileCount = aIniFile.getIntValue(_sBasename, "reportcount", 0); int nFileCount = aIniFile.getIntValue(_sBasename, "reportcount", 0);
ArrayList aList = new ArrayList(); ArrayList<String> aList = new ArrayList<String>();
for (int i=0;i<nFileCount;i++) for (int i=0;i<nFileCount;i++)
{ {
String sValue = aIniFile.getValue(_sBasename, "report" + i); String sValue = aIniFile.getValue(_sBasename, "report" + i);
...@@ -230,7 +253,7 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) ...@@ -230,7 +253,7 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
// get the bad status and store it into the // get the bad status and store it into the
for (int i=0;i<aList.size();i++) for (int i=0;i<aList.size();i++)
{ {
String sEntry = (String)aList.get(i); String sEntry = aList.get(i);
callEntry(sEntry, _aParam); callEntry(sEntry, _aParam);
// we want to know the current status of the run through // we want to know the current status of the run through
...@@ -265,7 +288,12 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) ...@@ -265,7 +288,12 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
} }
} }
} }
else
{
assure("File '" + sIndexFile + "' doesn't exists.", aIndexFile.exists(), true);
}
} }
private String getPSorPDFNameFromIniFile(IniFile _aIniFile, String _sName) private String getPSorPDFNameFromIniFile(IniFile _aIniFile, String _sName)
{ {
boolean bHasPostscriptOrPDF = false; boolean bHasPostscriptOrPDF = false;
...@@ -419,7 +447,7 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) ...@@ -419,7 +447,7 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
{ {
// special case for odb files // special case for odb files
int nFileCount = aIniFile.getIntValue(sBasename, "reportcount", 0); int nFileCount = aIniFile.getIntValue(sBasename, "reportcount", 0);
ArrayList aList = new ArrayList(); ArrayList<String> aList = new ArrayList<String>();
for (int i=0;i<nFileCount;i++) for (int i=0;i<nFileCount;i++)
{ {
String sValue = aIniFile.getValue(sBasename, "report" + i); String sValue = aIniFile.getValue(sBasename, "report" + i);
...@@ -439,7 +467,7 @@ private void callEntry(String _sEntry, ParameterHelper _aParam) ...@@ -439,7 +467,7 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
for (int i=0;i<aList.size();i++) for (int i=0;i<aList.size();i++)
{ {
String sPSFile = (String)aList.get(i); String sPSFile = aList.get(i);
// TODO: this information has to come out of the ini files // TODO: this information has to come out of the ini files
String sStatusRunThrough = ""; String sStatusRunThrough = "";
......
...@@ -50,9 +50,9 @@ public class FileHelper ...@@ -50,9 +50,9 @@ public class FileHelper
String sOSArch = System.getProperty("os.arch"); String sOSArch = System.getProperty("os.arch");
String sOSVersion = System.getProperty("os.version"); String sOSVersion = System.getProperty("os.version");
GlobalLogWriter.get().println(sOSName); GlobalLogWriter.println(sOSName);
GlobalLogWriter.get().println(sOSArch); GlobalLogWriter.println(sOSArch);
GlobalLogWriter.get().println(sOSVersion); GlobalLogWriter.println(sOSVersion);
} }
...@@ -110,7 +110,7 @@ public class FileHelper ...@@ -110,7 +110,7 @@ public class FileHelper
} }
catch (NullPointerException e) catch (NullPointerException e)
{ {
GlobalLogWriter.get().println("Exception caught. FileHelper.isDir('" + _sDir + "')"); GlobalLogWriter.println("Exception caught. FileHelper.isDir('" + _sDir + "')");
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
...@@ -258,7 +258,7 @@ public class FileHelper ...@@ -258,7 +258,7 @@ public class FileHelper
} }
catch (java.io.IOException e) catch (java.io.IOException e)
{ {
GlobalLogWriter.get().println("Exception caught. FileHelper.makeDirectories('" + new_dir.getAbsolutePath() + "')"); GlobalLogWriter.println("Exception caught. FileHelper.makeDirectories('" + new_dir.getAbsolutePath() + "')");
} }
} }
} }
...@@ -361,9 +361,9 @@ public class FileHelper ...@@ -361,9 +361,9 @@ public class FileHelper
{ {
if (m_bDebugTextShown == false) if (m_bDebugTextShown == false)
{ {
GlobalLogWriter.get().println("Found file: " + sName); GlobalLogWriter.println("Found file: " + sName);
GlobalLogWriter.get().println("Activate debug mode."); GlobalLogWriter.println("Activate debug mode.");
GlobalLogWriter.get().println("If debug mode is no longer necessary, remove the above file."); GlobalLogWriter.println("If debug mode is no longer necessary, remove the above file.");
m_bDebugTextShown = true; m_bDebugTextShown = true;
} }
bDebug = true; bDebug = true;
...@@ -463,6 +463,16 @@ public class FileHelper ...@@ -463,6 +463,16 @@ public class FileHelper
{ {
return false; return false;
} }
// leave out files starts with '.~lock.' these are OpenOffice.org lock files
if (pathname.getName().startsWith(".~lock."))
{
return false;
}
// leave out files ends with '#' these could be temp files
if (pathname.getName().endsWith("#"))
{
return false;
}
if (pathname.getName().endsWith(".prn")) if (pathname.getName().endsWith(".prn"))
{ {
return false; return false;
...@@ -592,7 +602,7 @@ public class FileHelper ...@@ -592,7 +602,7 @@ public class FileHelper
if (_sFile.startsWith("file://")) if (_sFile.startsWith("file://"))
{ {
sFilename = FileHelper.getSystemPathFromFileURL(_sFile); sFilename = FileHelper.getSystemPathFromFileURL(_sFile);
GlobalLogWriter.get().println("CreateInfoFile: '" + sFilename + "'" ); GlobalLogWriter.println("CreateInfoFile: '" + sFilename + "'" );
} }
else else
{ {
...@@ -682,7 +692,7 @@ public class FileHelper ...@@ -682,7 +692,7 @@ public class FileHelper
} }
catch (java.io.IOException e) catch (java.io.IOException e)
{ {
GlobalLogWriter.get().println("can't create Info file."); GlobalLogWriter.println("can't create Info file.");
e.printStackTrace(); e.printStackTrace();
} }
aIniFile.close(); aIniFile.close();
......
...@@ -33,11 +33,22 @@ import stats.SimpleLogWriter; ...@@ -33,11 +33,22 @@ import stats.SimpleLogWriter;
public class GlobalLogWriter public class GlobalLogWriter
{ {
private static LogWriter m_aGlobalLogWriter = null; private static LogWriter m_aGlobalLogWriter = null;
public static synchronized void println(String _sMsg)
/**
* This is just a helper to get clearer code.
* use this GlobalLogWriter.println(...)
* @param _sMsg
*/
protected static synchronized void println(String _sMsg)
{ {
get().println(_sMsg); get().println(_sMsg);
} }
public static synchronized LogWriter get()
/**
* @deprecated use GlobalLogWriter.println(...) direct
* @return
*/
protected static synchronized LogWriter get()
{ {
if (m_aGlobalLogWriter == null) if (m_aGlobalLogWriter == null)
{ {
...@@ -52,7 +63,7 @@ public class GlobalLogWriter ...@@ -52,7 +63,7 @@ public class GlobalLogWriter
// get().initialize(null, true); // get().initialize(null, true);
// } // }
public static synchronized void set(LogWriter _aLog) protected static synchronized void set(LogWriter _aLog)
{ {
m_aGlobalLogWriter = _aLog; m_aGlobalLogWriter = _aLog;
} }
......
...@@ -59,7 +59,7 @@ public class HTMLResult ...@@ -59,7 +59,7 @@ public class HTMLResult
catch (java.io.IOException e) catch (java.io.IOException e)
{ {
e.printStackTrace(); e.printStackTrace();
GlobalLogWriter.get().println("ERROR: Can't create HTML Outputter"); GlobalLogWriter.println("ERROR: Can't create HTML Outputter");
// return null; // return null;
} }
// m_sFilename = sFilename; // m_sFilename = sFilename;
......
...@@ -40,7 +40,7 @@ public interface IDocument ...@@ -40,7 +40,7 @@ public interface IDocument
* @param _sDocument * @param _sDocument
* @param _sResult * @param _sResult
* @param _aParams * @param _aParams
* @throws graphical.DocumentLoaderException * @throws OfficeException
*/ */
public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException; public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException;
} }
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
************************************************************************/ ************************************************************************/
package graphical; package graphical;
import java.io.BufferedReader; // import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -44,7 +44,7 @@ public class IniFile implements Enumeration ...@@ -44,7 +44,7 @@ public class IniFile implements Enumeration
* Problem, if ini file changed why other write something difference, we don't realise this. * Problem, if ini file changed why other write something difference, we don't realise this.
*/ */
private String m_sFilename; private String m_sFilename;
private ArrayList m_aList; private ArrayList<String> m_aList;
boolean m_bListContainUnsavedChanges = false; boolean m_bListContainUnsavedChanges = false;
private int m_aEnumerationPos = 0; private int m_aEnumerationPos = 0;
...@@ -76,13 +76,13 @@ public class IniFile implements Enumeration ...@@ -76,13 +76,13 @@ public class IniFile implements Enumeration
} }
} }
private ArrayList loadLines() private ArrayList<String> loadLines()
{ {
File aFile = new File(m_sFilename); File aFile = new File(m_sFilename);
ArrayList aLines = new ArrayList(); ArrayList<String> aLines = new ArrayList<String>();
if (!aFile.exists()) if (!aFile.exists())
{ {
GlobalLogWriter.get().println("couldn't find file '" + m_sFilename + "', will be created."); // GlobalLogWriter.println("couldn't find file '" + m_sFilename + "', will be created.");
// DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, ""); // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
// m_bListContainUnsavedChanges = false; // m_bListContainUnsavedChanges = false;
return aLines; return aLines;
...@@ -104,14 +104,14 @@ public class IniFile implements Enumeration ...@@ -104,14 +104,14 @@ public class IniFile implements Enumeration
} }
catch (java.io.FileNotFoundException fne) catch (java.io.FileNotFoundException fne)
{ {
GlobalLogWriter.get().println("couldn't open file " + m_sFilename); GlobalLogWriter.println("couldn't open file " + m_sFilename);
GlobalLogWriter.get().println("Message: " + fne.getMessage()); GlobalLogWriter.println("Message: " + fne.getMessage());
// DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, ""); // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
} }
catch (java.io.IOException ie) catch (java.io.IOException ie)
{ {
GlobalLogWriter.get().println("Exception occurs while reading from file " + m_sFilename); GlobalLogWriter.println("Exception occurs while reading from file " + m_sFilename);
GlobalLogWriter.get().println("Message: " + ie.getMessage()); GlobalLogWriter.println("Message: " + ie.getMessage());
// DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage()); // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
} }
try try
...@@ -120,8 +120,8 @@ public class IniFile implements Enumeration ...@@ -120,8 +120,8 @@ public class IniFile implements Enumeration
} }
catch (java.io.IOException ie) catch (java.io.IOException ie)
{ {
GlobalLogWriter.get().println("Couldn't close file " + m_sFilename); GlobalLogWriter.println("Couldn't close file " + m_sFilename);
GlobalLogWriter.get().println("Message: " + ie.getMessage()); GlobalLogWriter.println("Message: " + ie.getMessage());
// DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage()); // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
} }
return aLines; return aLines;
...@@ -165,7 +165,7 @@ public class IniFile implements Enumeration ...@@ -165,7 +165,7 @@ public class IniFile implements Enumeration
private String getItem(int i) private String getItem(int i)
{ {
return (String) m_aList.get(i); return m_aList.get(i);
} }
private String buildSectionName(String _sSectionName) private String buildSectionName(String _sSectionName)
...@@ -380,7 +380,7 @@ public class IniFile implements Enumeration ...@@ -380,7 +380,7 @@ public class IniFile implements Enumeration
} }
catch (java.lang.NumberFormatException e) catch (java.lang.NumberFormatException e)
{ {
GlobalLogWriter.get().println("IniFile.getIntValue(): Caught a number format exception, return the default value."); GlobalLogWriter.println("IniFile.getIntValue(): Caught a number format exception, return the default value.");
} }
} }
return nValue; return nValue;
...@@ -395,6 +395,8 @@ public class IniFile implements Enumeration ...@@ -395,6 +395,8 @@ public class IniFile implements Enumeration
write back the ini file to the disk, only if there exist changes write back the ini file to the disk, only if there exist changes
* @deprecated use close() instead! * @deprecated use close() instead!
*/ */
// TODO: make private
public void store() public void store()
{ {
if (m_bListContainUnsavedChanges == false) if (m_bListContainUnsavedChanges == false)
...@@ -411,7 +413,7 @@ public class IniFile implements Enumeration ...@@ -411,7 +413,7 @@ public class IniFile implements Enumeration
aFile.delete(); aFile.delete();
if (aFile.exists()) if (aFile.exists())
{ {
GlobalLogWriter.get().println("Couldn't delete the file " + m_sFilename); GlobalLogWriter.println("Couldn't delete the file " + m_sFilename);
return; return;
// DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, "Couldn't delete the file " + m_sFilename); // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, "Couldn't delete the file " + m_sFilename);
} }
...@@ -439,14 +441,14 @@ public class IniFile implements Enumeration ...@@ -439,14 +441,14 @@ public class IniFile implements Enumeration
} }
catch (java.io.FileNotFoundException fne) catch (java.io.FileNotFoundException fne)
{ {
GlobalLogWriter.get().println("couldn't open file for writing " + m_sFilename); GlobalLogWriter.println("couldn't open file for writing " + m_sFilename);
GlobalLogWriter.get().println("Message: " + fne.getMessage()); GlobalLogWriter.println("Message: " + fne.getMessage());
// DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, ""); // DebugHelper.exception(BasicErrorCode.SbERR_FILE_NOT_FOUND, "");
} }
catch (java.io.IOException ie) catch (java.io.IOException ie)
{ {
GlobalLogWriter.get().println("Exception occurs while writing to file " + m_sFilename); GlobalLogWriter.println("Exception occurs while writing to file " + m_sFilename);
GlobalLogWriter.get().println("Message: " + ie.getMessage()); GlobalLogWriter.println("Message: " + ie.getMessage());
// DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage()); // DebugHelper.exception(BasicErrorCode.SbERR_INTERNAL_ERROR, ie.getMessage());
} }
} }
...@@ -467,7 +469,10 @@ public class IniFile implements Enumeration ...@@ -467,7 +469,10 @@ public class IniFile implements Enumeration
1. section doesn't exist, goto end and insert a new section, insert a new key value pair 1. section doesn't exist, goto end and insert a new section, insert a new key value pair
2. section exist but key not, search section, search key, if key is -1 get last known key position and insert new key value pair there 2. section exist but key not, search section, search key, if key is -1 get last known key position and insert new key value pair there
3. section exist and key exist, remove the old key and insert the key value pair at the same position 3. section exist and key exist, remove the old key and insert the key value pair at the same position
*/ * @param _sSection
* @param _sKey
* @param _sValue
*/
public void insertValue(String _sSection, String _sKey, String _sValue) public void insertValue(String _sSection, String _sKey, String _sValue)
{ {
int i = findSection(_sSection); int i = findSection(_sSection);
...@@ -637,7 +642,7 @@ public class IniFile implements Enumeration ...@@ -637,7 +642,7 @@ public class IniFile implements Enumeration
{ {
while (i < m_aList.size()) while (i < m_aList.size())
{ {
String sLine = (String) m_aList.get(i); String sLine = m_aList.get(i);
if (sLine.startsWith("[")) if (sLine.startsWith("["))
{ {
return i; return i;
...@@ -657,7 +662,7 @@ public class IniFile implements Enumeration ...@@ -657,7 +662,7 @@ public class IniFile implements Enumeration
int nLineWithSection = findNextSection(m_aEnumerationPos); int nLineWithSection = findNextSection(m_aEnumerationPos);
if (nLineWithSection != -1) if (nLineWithSection != -1)
{ {
String sSection = (String) m_aList.get(nLineWithSection); String sSection = m_aList.get(nLineWithSection);
m_aEnumerationPos = findNextSection(nLineWithSection + 1); m_aEnumerationPos = findNextSection(nLineWithSection + 1);
sSection = sectionToString(sSection); sSection = sectionToString(sSection);
return sSection; return sSection;
......
...@@ -75,18 +75,35 @@ public class JPEGCreator extends EnhancedComplexTestCase ...@@ -75,18 +75,35 @@ public class JPEGCreator extends EnhancedComplexTestCase
{ {
createSmallPictures(sJPEGNameSchema); createSmallPictures(sJPEGNameSchema);
// read out tolerance file
String sFileDir = FileHelper.getPath(_sDocumentName);
String sBasename = FileHelper.getBasename(_sDocumentName);
int nTolerance = 0;
String sToleranceFile = FileHelper.appendPath(sFileDir, "tolerance.ini");
File aToleranceFile = new File(sToleranceFile);
if (aToleranceFile.exists())
{
IniFile aIniFile = new IniFile(sToleranceFile);
nTolerance = aIniFile.getIntValue(sBasename, "accept", 0); // default for all pages
aIniFile.close();
}
String sIndexFile = FileHelper.appendPath(_sResult, "index.ini"); String sIndexFile = FileHelper.appendPath(_sResult, "index.ini");
File aIndexFile = new File(sIndexFile); File aIndexFile = new File(sIndexFile);
if (aIndexFile.exists()) if (aIndexFile.exists())
{ {
// store only if an index file exists // store only if an index file exists
IniFile aIniFile = new IniFile(sIndexFile); IniFile aIniFile = new IniFile(sIndexFile);
String sBasename = FileHelper.getBasename(_sDocumentName);
aIniFile.insertValue(sBasename, "jpegschema", sJPEGNameSchema); aIniFile.insertValue(sBasename, "jpegschema", sJPEGNameSchema);
aIniFile.insertValue(sBasename, "pages", nPages); aIniFile.insertValue(sBasename, "pages", nPages);
aIniFile.insertValue(sBasename, "tolerance", nTolerance);
aIniFile.close(); aIniFile.close();
} }
} }
else
{
assure("There are no pages in document:'" + _sDocumentName + "', maybe document currupt?", false, true);
}
} }
/** /**
...@@ -96,6 +113,12 @@ public class JPEGCreator extends EnhancedComplexTestCase ...@@ -96,6 +113,12 @@ public class JPEGCreator extends EnhancedComplexTestCase
*/ */
public void createSmallPictures(String _sJPEGSchema) public void createSmallPictures(String _sJPEGSchema)
{ {
ParameterHelper aParam = new ParameterHelper(param);
if (! aParam.createSmallPictures())
{
return;
}
int nPages = 0; int nPages = 0;
if (_sJPEGSchema.length() > 0) if (_sJPEGSchema.length() > 0)
{ {
...@@ -124,6 +147,11 @@ public class JPEGCreator extends EnhancedComplexTestCase ...@@ -124,6 +147,11 @@ public class JPEGCreator extends EnhancedComplexTestCase
*/ */
public static void convertToNearSameFileWithWidth340(String _sJPEGFilename) public static void convertToNearSameFileWithWidth340(String _sJPEGFilename)
{ {
ParameterHelper aParam = new ParameterHelper(param);
if (! aParam.createSmallPictures())
{
return;
}
String sJPEGFilename = _sJPEGFilename.replaceAll("\\\\", "/"); String sJPEGFilename = _sJPEGFilename.replaceAll("\\\\", "/");
// if (OSHelper.isWindows()) // if (OSHelper.isWindows())
// { // {
...@@ -160,7 +188,13 @@ private static void convertToWidth340(String _sFrom, String _To) ...@@ -160,7 +188,13 @@ private static void convertToWidth340(String _sFrom, String _To)
{ {
// TODO! // TODO!
// HACK Hard coded! // HACK Hard coded!
sConvertEXE = "C:\\Programme\\ImageMagick-6.0.3-q8\\convert.exe"; // sConvertEXE = "C:\\Programme\\ImageMagick-6.0.3-q8\\convert.exe";
sConvertEXE = "convert.exe";
String sConvertPath = (String)param.get("imagemagick.path");
if (sConvertPath != null)
{
sConvertEXE = FileHelper.appendPath(sConvertPath, sConvertEXE);
}
} }
String[] sCommandArray = String[] sCommandArray =
...@@ -178,7 +212,7 @@ private static void convertToWidth340(String _sFrom, String _To) ...@@ -178,7 +212,7 @@ private static void convertToWidth340(String _sFrom, String _To)
String sBack = aHandler.getOutputText(); String sBack = aHandler.getOutputText();
if (sBack.length() > 0) if (sBack.length() > 0)
{ {
GlobalLogWriter.get().println("'" + sBack + "'"); GlobalLogWriter.println("'" + sBack + "'");
} }
// try to interpret the result, which we get as a String // try to interpret the result, which we get as a String
// try // try
...@@ -223,7 +257,7 @@ private static void convertToWidth340(String _sFrom, String _To) ...@@ -223,7 +257,7 @@ private static void convertToWidth340(String _sFrom, String _To)
} }
else else
{ {
GlobalLogWriter.get().println("File: '" + _sFile + "' doesn't exist."); GlobalLogWriter.println("File: '" + _sFile + "' doesn't exist.");
return ""; return "";
} }
String sFileDir = FileHelper.getPath(_sFile); String sFileDir = FileHelper.getPath(_sFile);
...@@ -291,6 +325,16 @@ private static void convertToWidth340(String _sFrom, String _To) ...@@ -291,6 +325,16 @@ private static void convertToWidth340(String _sFrom, String _To)
if (OSHelper.isWindows()) if (OSHelper.isWindows())
{ {
sGhostscriptEXE = "gswin32c.exe"; sGhostscriptEXE = "gswin32c.exe";
String sGhostscriptEXE2 = (String)param.get("gs.exe");
if (sGhostscriptEXE2 != null)
{
sGhostscriptEXE = sGhostscriptEXE2;
}
String sGhostscriptPath = (String)param.get("gs.path");
if (sGhostscriptPath != null)
{
sGhostscriptEXE = FileHelper.appendPath(sGhostscriptPath, sGhostscriptEXE);
}
} }
// String sCommand = sGhostscriptEXE + " -dNOPROMPT -dBATCH -sDEVICE=jpeg -r" + String.valueOf(_nResolutionInDPI) + " -dNOPAUSE -sOutputFile=" + StringHelper.doubleQuoteIfNeed(sJPGFilename) + " " + StringHelper.doubleQuoteIfNeed(sOriginalFile); // String sCommand = sGhostscriptEXE + " -dNOPROMPT -dBATCH -sDEVICE=jpeg -r" + String.valueOf(_nResolutionInDPI) + " -dNOPAUSE -sOutputFile=" + StringHelper.doubleQuoteIfNeed(sJPGFilename) + " " + StringHelper.doubleQuoteIfNeed(sOriginalFile);
...@@ -333,6 +377,7 @@ private static void convertToWidth340(String _sFrom, String _To) ...@@ -333,6 +377,7 @@ private static void convertToWidth340(String _sFrom, String _To)
{ {
// return only a valid schema name if there at least one page. // return only a valid schema name if there at least one page.
sJPEGNameSchema = ""; sJPEGNameSchema = "";
assure("Document '" + sPostscriptOrPDFFile + "' doesn't create pages.", false, true);
} }
} }
else else
......
...@@ -48,6 +48,7 @@ public class Office implements IOffice ...@@ -48,6 +48,7 @@ public class Office implements IOffice
m_sResult = _sResult; m_sResult = _sResult;
if (_aParam.getReferenceType().toLowerCase().equals("ooo") || if (_aParam.getReferenceType().toLowerCase().equals("ooo") ||
_aParam.getReferenceType().toLowerCase().equals("ps") ||
_aParam.getReferenceType().toLowerCase().equals("pdf")) _aParam.getReferenceType().toLowerCase().equals("pdf"))
{ {
m_aOffice = new OpenOfficePostscriptCreator(_aParam, m_sResult); m_aOffice = new OpenOfficePostscriptCreator(_aParam, m_sResult);
......
...@@ -193,7 +193,7 @@ public class ParameterHelper ...@@ -193,7 +193,7 @@ public class ParameterHelper
String sReferenceType = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_REFERENCE_TYPE ); String sReferenceType = (String)getTestParameters().get( PropertyName.DOC_COMPARATOR_REFERENCE_TYPE );
if (sReferenceType == null || sReferenceType.length() == 0) if (sReferenceType == null || sReferenceType.length() == 0)
{ {
m_sReferenceType = "OOo"; m_sReferenceType = "ps";
} }
else else
{ {
...@@ -241,6 +241,7 @@ public class ParameterHelper ...@@ -241,6 +241,7 @@ public class ParameterHelper
/** /**
* Helper function to get the buildid of the current used OpenOffice.org * Helper function to get the buildid of the current used OpenOffice.org
* out of the AppExecutionCommand the build ID * out of the AppExecutionCommand the build ID
* @return
*/ */
public String getBuildID() public String getBuildID()
{ {
...@@ -265,11 +266,12 @@ public class ParameterHelper ...@@ -265,11 +266,12 @@ public class ParameterHelper
// check if MultiServiceFactory is given // check if MultiServiceFactory is given
if (getReferenceType().toLowerCase().equals("pdf") || if (getReferenceType().toLowerCase().equals("pdf") ||
getReferenceType().toLowerCase().equals("ps") ||
getReferenceType().toLowerCase().equals("ooo")) getReferenceType().toLowerCase().equals("ooo"))
{ {
if (xMSF == null) if (xMSF == null)
{ {
GlobalLogWriter.get().println("ERROR! MultiServiceFactory not given."); GlobalLogWriter.println("ERROR! MultiServiceFactory not given.");
} }
} }
return xMSF; return xMSF;
...@@ -417,5 +419,15 @@ public class ParameterHelper ...@@ -417,5 +419,15 @@ public class ParameterHelper
return m_sHTMLPrefix; return m_sHTMLPrefix;
} }
public boolean createSmallPictures()
{
// boolean bCreateSmallPictures = true;
boolean bNoSmallPictures = m_aCurrentParams.getBool( PropertyName.NO_SMALL_PICTURES);
if (bNoSmallPictures == true)
{
return false;
}
return true;
}
} }
...@@ -59,7 +59,7 @@ public class PerformanceContainer /* extends *//* implements */ { ...@@ -59,7 +59,7 @@ public class PerformanceContainer /* extends *//* implements */ {
{ {
if (_nCurrentTimer == 0) if (_nCurrentTimer == 0)
{ {
GlobalLogWriter.get().println("Forgotten to initialise a start timer."); GlobalLogWriter.println("Forgotten to initialise a start timer.");
return 0; return 0;
} }
long nMeanTime = System.currentTimeMillis(); long nMeanTime = System.currentTimeMillis();
...@@ -160,7 +160,7 @@ public class PerformanceContainer /* extends *//* implements */ { ...@@ -160,7 +160,7 @@ public class PerformanceContainer /* extends *//* implements */ {
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
GlobalLogWriter.get().println("Can't convert string to double " + _sStr); GlobalLogWriter.println("Can't convert string to double " + _sStr);
} }
return nValue; return nValue;
} }
...@@ -185,7 +185,7 @@ public class PerformanceContainer /* extends *//* implements */ { ...@@ -185,7 +185,7 @@ public class PerformanceContainer /* extends *//* implements */ {
File aFile = new File(sFilename); File aFile = new File(sFilename);
if (! aFile.exists()) if (! aFile.exists())
{ {
GlobalLogWriter.get().println("couldn't find file " + sFilename); GlobalLogWriter.println("couldn't find file " + sFilename);
return; return;
} }
...@@ -236,13 +236,13 @@ public class PerformanceContainer /* extends *//* implements */ { ...@@ -236,13 +236,13 @@ public class PerformanceContainer /* extends *//* implements */ {
} }
catch (java.io.FileNotFoundException fne) catch (java.io.FileNotFoundException fne)
{ {
GlobalLogWriter.get().println("couldn't open file " + sFilename); GlobalLogWriter.println("couldn't open file " + sFilename);
GlobalLogWriter.get().println("Message: " + fne.getMessage()); GlobalLogWriter.println("Message: " + fne.getMessage());
} }
catch (java.io.IOException ie) catch (java.io.IOException ie)
{ {
GlobalLogWriter.get().println("Exception while reading file " + sFilename); GlobalLogWriter.println("Exception while reading file " + sFilename);
GlobalLogWriter.get().println("Message: " + ie.getMessage()); GlobalLogWriter.println("Message: " + ie.getMessage());
} }
try try
{ {
...@@ -250,8 +250,8 @@ public class PerformanceContainer /* extends *//* implements */ { ...@@ -250,8 +250,8 @@ public class PerformanceContainer /* extends *//* implements */ {
} }
catch (java.io.IOException ie) catch (java.io.IOException ie)
{ {
GlobalLogWriter.get().println("Couldn't close file " + sFilename); GlobalLogWriter.println("Couldn't close file " + sFilename);
GlobalLogWriter.get().println("Message: " + ie.getMessage()); GlobalLogWriter.println("Message: " + ie.getMessage());
} }
} }
......
...@@ -69,5 +69,5 @@ public interface PropertyName ...@@ -69,5 +69,5 @@ public interface PropertyName
// final public static String DB_CONNECTION_STRING = "DB_CONNECTION_STRING"; // final public static String DB_CONNECTION_STRING = "DB_CONNECTION_STRING";
// final public static String CHECK_NEED_TOOLS = "CHECK_NEED_TOOLS"; // final public static String CHECK_NEED_TOOLS = "CHECK_NEED_TOOLS";
// final public static String CREATE_DEFAULT = "CREATE_DEFAULT_REFERENCE"; // final public static String CREATE_DEFAULT = "CREATE_DEFAULT_REFERENCE";
final public static String NO_SMALL_PICTURES = "NoSmallPictures";
} }
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
package graphical; package graphical;
import java.util.Calendar;
/** /**
* *
* @author ll93751 * @author ll93751
...@@ -42,9 +44,48 @@ public class TimeHelper ...@@ -42,9 +44,48 @@ public class TimeHelper
*/ */
static void waitInSeconds(int _nSeconds, String _sReason) static void waitInSeconds(int _nSeconds, String _sReason)
{ {
GlobalLogWriter.get().println("Wait " + String.valueOf(_nSeconds) + " sec. Reason: " + _sReason); GlobalLogWriter.println("Wait 0.25 * " + String.valueOf(_nSeconds) + " sec. Reason: " + _sReason);
try { try {
java.lang.Thread.sleep(_nSeconds * 1000); java.lang.Thread.sleep(_nSeconds * 250);
} catch (java.lang.InterruptedException e2) {} } catch (java.lang.InterruptedException e2) {}
} }
private int m_nSeconds;
private int m_nMilliSeconds;
private long m_nRealMilliSeconds;
private boolean m_bIsStopped = false;
public TimeHelper()
{}
public void start()
{
m_bIsStopped = false;
Calendar cal = Calendar.getInstance();
m_nSeconds = cal.get(Calendar.SECOND);
m_nMilliSeconds = cal.get(Calendar.MILLISECOND);
}
public void stop()
{
Calendar cal = Calendar.getInstance();
m_bIsStopped = true;
int nSeconds = cal.get(Calendar.SECOND);
m_nSeconds = nSeconds - m_nSeconds;
if (m_nSeconds < 0)
{
// add a minute
m_nSeconds += 60;
}
int nMilliSeconds = cal.get(Calendar.MILLISECOND);
m_nMilliSeconds = nMilliSeconds - m_nMilliSeconds;
m_nRealMilliSeconds = m_nSeconds * 1000 + m_nMilliSeconds;
}
public String getTime()
{
return String.valueOf(m_nRealMilliSeconds);
}
} }
...@@ -64,7 +64,8 @@ PostscriptCreator.java \ ...@@ -64,7 +64,8 @@ PostscriptCreator.java \
PropertyName.java \ PropertyName.java \
TimeHelper.java \ TimeHelper.java \
WrongEnvironmentException.java \ WrongEnvironmentException.java \
WrongSuffixException.java WrongSuffixException.java \
Tolerance.java
# GraphicalComparator.java # GraphicalComparator.java
......
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