From 5cba8d44cabc3cbb18648efc9d8658d471b257e7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 16 Oct 2014 12:16:51 +0200 Subject: java: when rethrowing, store the original exception Change-Id: Idfca83a2a646acab90886c0ef9c30dd7d2fc8b53 --- qadevOOo/runner/complexlib/Assurance.java | 3 + .../runner/convwatch/ConvWatchCancelException.java | 5 + qadevOOo/runner/convwatch/ConvWatchException.java | 5 + .../runner/convwatch/GraphicalDifferenceCheck.java | 2 +- qadevOOo/runner/convwatch/MSOfficePrint.java | 2 +- qadevOOo/runner/convwatch/OfficePrint.java | 5 +- qadevOOo/runner/convwatch/ReportDesignerTest.java | 2 +- .../graphical/MSOfficePostscriptCreator.java | 7 +- qadevOOo/runner/graphical/OfficeException.java | 5 + .../graphical/WrongEnvironmentException.java | 4 + qadevOOo/runner/helper/ConfigHelper.java | 26 +++--- qadevOOo/runner/helper/StreamSimulator.java | 2 +- qadevOOo/runner/util/BasicMacroTools.java | 101 ++++++++------------- qadevOOo/runner/util/CalcTools.java | 77 ++++++---------- qadevOOo/runner/util/DesktopTools.java | 6 +- qadevOOo/runner/util/DrawTools.java | 4 +- qadevOOo/runner/util/FormTools.java | 2 +- qadevOOo/runner/util/SOfficeFactory.java | 3 +- qadevOOo/runner/util/UITools.java | 8 +- qadevOOo/runner/util/WriterTools.java | 2 +- .../runner/util/compare/GraphicalComparator.java | 12 ++- .../backend/org/openoffice/JavaSystemBackend.java | 2 +- .../java/ifc/beans/_XMultiPropertyStates.java | 4 +- .../tests/java/ifc/beans/_XPropertyWithState.java | 3 +- qadevOOo/tests/java/ifc/document/_Settings.java | 4 +- .../tests/java/ifc/io/_XActiveDataControl.java | 9 +- qadevOOo/tests/java/ifc/sheet/_XFormulaQuery.java | 3 +- qadevOOo/tests/java/ifc/sheet/_XSheetAuditing.java | 2 +- qadevOOo/tests/java/mod/_adabas/ODriver.java | 3 +- qadevOOo/tests/java/mod/_ado/ODriver.java | 3 +- .../mod/_dbaccess/ConnectionLineAccessibility.java | 48 ++++------ .../java/mod/_dbaccess/JoinViewAccessibility.java | 56 ++++-------- qadevOOo/tests/java/mod/_dbaccess/ORowSet.java | 5 +- .../mod/_dbaccess/TableWindowAccessibility.java | 53 +++-------- .../tests/java/mod/_dbpool/OConnectionPool.java | 3 +- qadevOOo/tests/java/mod/_file/calc/ODriver.java | 3 +- qadevOOo/tests/java/mod/_file/dbase/ODriver.java | 3 +- qadevOOo/tests/java/mod/_file/flat/ODriver.java | 3 +- qadevOOo/tests/java/mod/_forms/ODatabaseForm.java | 5 +- .../tests/java/mod/_forms/OFileControlModel.java | 8 +- qadevOOo/tests/java/mod/_fwk/Desktop.java | 8 +- .../java/mod/_fwk/DispatchRecorderSupplier.java | 4 +- qadevOOo/tests/java/mod/_fwk/JobExecutor.java | 4 +- qadevOOo/tests/java/mod/_fwk/JobHandler.java | 4 +- qadevOOo/tests/java/mod/_fwk/MailToDispatcher.java | 4 +- qadevOOo/tests/java/mod/_fwk/ModuleManager.java | 4 +- qadevOOo/tests/java/mod/_fwk/ServiceHandler.java | 4 +- qadevOOo/tests/java/mod/_fwk/SoundHandler.java | 4 +- qadevOOo/tests/java/mod/_fwk/URLTransformer.java | 4 +- qadevOOo/tests/java/mod/_fwl/FilterFactory.java | 6 +- qadevOOo/tests/java/mod/_fwl/TypeDetection.java | 6 +- qadevOOo/tests/java/mod/_jdbc/JDBCDriver.java | 3 +- qadevOOo/tests/java/mod/_mozab/MozabDriver.java | 2 +- qadevOOo/tests/java/mod/_odbc/ODBCDriver.java | 3 +- .../AccessibleEditableTextPara_PreviewCell.java | 2 +- .../mod/_sc/ScAccessibleDocumentPagePreview.java | 3 +- .../tests/java/mod/_sc/ScAccessiblePageHeader.java | 3 +- .../java/mod/_sc/ScAccessiblePageHeaderArea.java | 3 +- .../java/mod/_sc/ScAccessiblePreviewCell.java | 3 +- .../mod/_sc/ScAccessiblePreviewHeaderCell.java | 21 ++--- .../java/mod/_sc/ScAccessiblePreviewTable.java | 3 +- .../java/mod/_sd/DrawController_DrawView.java | 3 +- .../java/mod/_sd/DrawController_HandoutView.java | 3 +- .../java/mod/_sd/DrawController_NotesView.java | 3 +- .../java/mod/_sd/DrawController_OutlineView.java | 3 +- .../mod/_sd/DrawController_PresentationView.java | 3 +- .../java/mod/_sw/SwAccessibleDocumentPageView.java | 3 +- .../tests/java/mod/_sw/SwAccessiblePageView.java | 3 +- .../tests/java/mod/_toolkit/MutableTreeNode.java | 2 +- 69 files changed, 237 insertions(+), 387 deletions(-) (limited to 'qadevOOo') diff --git a/qadevOOo/runner/complexlib/Assurance.java b/qadevOOo/runner/complexlib/Assurance.java index 3b4d03a64602..53d287e9dc48 100644 --- a/qadevOOo/runner/complexlib/Assurance.java +++ b/qadevOOo/runner/complexlib/Assurance.java @@ -173,5 +173,8 @@ public class Assurance public AssureException(String msg) { super(msg); } + public AssureException(Throwable cause) { + super(cause); + } } } diff --git a/qadevOOo/runner/convwatch/ConvWatchCancelException.java b/qadevOOo/runner/convwatch/ConvWatchCancelException.java index ad37c2da2a8b..f360293e18f3 100644 --- a/qadevOOo/runner/convwatch/ConvWatchCancelException.java +++ b/qadevOOo/runner/convwatch/ConvWatchCancelException.java @@ -24,4 +24,9 @@ public class ConvWatchCancelException extends ConvWatchException { super(_aMessage); } + + public ConvWatchCancelException(String _aMessage, Throwable cause) + { + super(_aMessage, cause); + } } diff --git a/qadevOOo/runner/convwatch/ConvWatchException.java b/qadevOOo/runner/convwatch/ConvWatchException.java index 28b15121131a..efd1e67e3dc9 100644 --- a/qadevOOo/runner/convwatch/ConvWatchException.java +++ b/qadevOOo/runner/convwatch/ConvWatchException.java @@ -24,5 +24,10 @@ public class ConvWatchException extends Exception { super(_aMessage); } + + public ConvWatchException(String _aMessage, Throwable cause) + { + super(_aMessage, cause); + } } diff --git a/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java b/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java index 2d59022c527d..f9d1e29edbc4 100644 --- a/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java +++ b/qadevOOo/runner/convwatch/GraphicalDifferenceCheck.java @@ -279,7 +279,7 @@ public class GraphicalDifferenceCheck catch (com.sun.star.io.IOException e) { // wrap IOException - throw new ConvWatchCancelException("Wrap IOException caught, " + e.getMessage()); + throw new ConvWatchCancelException("Wrap IOException caught", e); } GlobalLogWriter.get().println("Saving XComponent as " + resultURL); diff --git a/qadevOOo/runner/convwatch/MSOfficePrint.java b/qadevOOo/runner/convwatch/MSOfficePrint.java index ba65b5bcf80e..9ed3b4b60727 100644 --- a/qadevOOo/runner/convwatch/MSOfficePrint.java +++ b/qadevOOo/runner/convwatch/MSOfficePrint.java @@ -251,7 +251,7 @@ public class MSOfficePrint } catch (IndexOutOfBoundsException e) { - throw new ConvWatchCancelException/*WrongEnvironmentException*/("Given list is too short."); + throw new ConvWatchCancelException/*WrongEnvironmentException*/("Given list is too short.", e); } // return aHandler.getExitCode(); diff --git a/qadevOOo/runner/convwatch/OfficePrint.java b/qadevOOo/runner/convwatch/OfficePrint.java index cc7867db015e..432620005573 100644 --- a/qadevOOo/runner/convwatch/OfficePrint.java +++ b/qadevOOo/runner/convwatch/OfficePrint.java @@ -767,14 +767,13 @@ public class OfficePrint { } catch(ConvWatchCancelException e) { - e.printStackTrace(); GlobalLogWriter.get().println(e.getMessage()); - throw new ConvWatchCancelException("Exception caught. Problem with MSOffice printer methods."); + throw new ConvWatchCancelException("Exception caught. Problem with MSOffice printer methods.", e); } catch(java.io.IOException e) { GlobalLogWriter.get().println(e.getMessage()); - throw new ConvWatchCancelException("IOException caught. Problem with MSOffice printer methods."); + throw new ConvWatchCancelException("IOException caught. Problem with MSOffice printer methods.", e); } bBack = true; } diff --git a/qadevOOo/runner/convwatch/ReportDesignerTest.java b/qadevOOo/runner/convwatch/ReportDesignerTest.java index 6dd5001c3441..204f8d9c70f3 100644 --- a/qadevOOo/runner/convwatch/ReportDesignerTest.java +++ b/qadevOOo/runner/convwatch/ReportDesignerTest.java @@ -285,7 +285,7 @@ public class ReportDesignerTest extends ComplexTestCase { catch (AssureException e) { stopOffice(); - throw new AssureException(e.getMessage()); + throw new AssureException(e); } // ------------------------------ Office shutdown ------------------------------ diff --git a/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java b/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java index 6133094ece6d..a5c1667e7eb1 100644 --- a/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java +++ b/qadevOOo/runner/graphical/MSOfficePostscriptCreator.java @@ -89,14 +89,13 @@ public class MSOfficePostscriptCreator implements IOffice } catch(OfficeException e) { - e.printStackTrace(); GlobalLogWriter.println(e.getMessage()); - throw new OfficeException("Exception caught. Problem with MSOffice printer methods."); + throw new OfficeException("Exception caught. Problem with MSOffice printer methods.", e); } catch(java.io.IOException e) { GlobalLogWriter.println(e.getMessage()); - throw new OfficeException("IOException caught. Problem with MSOffice printer methods."); + throw new OfficeException("IOException caught. Problem with MSOffice printer methods.", e); } } @@ -258,7 +257,7 @@ public class MSOfficePostscriptCreator implements IOffice } catch (IndexOutOfBoundsException e) { - throw new WrongEnvironmentException("Given list is too short."); + throw new WrongEnvironmentException("Given list is too short.", e); } } diff --git a/qadevOOo/runner/graphical/OfficeException.java b/qadevOOo/runner/graphical/OfficeException.java index 1241c1b2db0d..94c0d3ae942c 100644 --- a/qadevOOo/runner/graphical/OfficeException.java +++ b/qadevOOo/runner/graphical/OfficeException.java @@ -28,4 +28,9 @@ public class OfficeException extends Exception { super(_aMessage); } + + public OfficeException(String _aMessage, Throwable cause) + { + super(_aMessage, cause); + } } diff --git a/qadevOOo/runner/graphical/WrongEnvironmentException.java b/qadevOOo/runner/graphical/WrongEnvironmentException.java index 922ee8c6e8e3..fe60de560f27 100644 --- a/qadevOOo/runner/graphical/WrongEnvironmentException.java +++ b/qadevOOo/runner/graphical/WrongEnvironmentException.java @@ -24,4 +24,8 @@ public class WrongEnvironmentException extends OfficeException { super(_aMessage); } + public WrongEnvironmentException(String _aMessage, Throwable cause) + { + super(_aMessage, cause); + } } diff --git a/qadevOOo/runner/helper/ConfigHelper.java b/qadevOOo/runner/helper/ConfigHelper.java index da873a59b97c..cfa61a3bf15a 100644 --- a/qadevOOo/runner/helper/ConfigHelper.java +++ b/qadevOOo/runner/helper/ConfigHelper.java @@ -212,18 +212,18 @@ public class ConfigHelper xProp = UnoRuntime.queryInterface( XPropertySet.class, xSetCont.getByName(groupName)); - } catch (com.sun.star.container.NoSuchElementException e){ - throw new com.sun.star.uno.Exception( + } catch (com.sun.star.container.NoSuchElementException ex){ + throw new com.sun.star.uno.Exception(ex, "could not get group '" + groupName + - "' from set '"+ setName +"':\n" + e.toString()); + "' from set '"+ setName +"'"); } try{ xProp.setPropertyValue(propName, propValue); - } catch (com.sun.star.uno.Exception e) { - throw new com.sun.star.uno.Exception( + } catch (com.sun.star.uno.Exception ex) { + throw new com.sun.star.uno.Exception(ex, "could not set property '" + propName + "' from group '"+ groupName + - "' from set '"+ setName +"':\n" + e.toString()); + "' from set '"+ setName +"'"); } } @@ -255,28 +255,28 @@ public class ConfigHelper Object xGroup=xSetCont.getByName(group); xGroupAccess = UnoRuntime.queryInterface( XNameReplace.class,xGroup); - } catch(com.sun.star.container.NoSuchElementException e) { - throw new com.sun.star.uno.Exception( + } catch(com.sun.star.container.NoSuchElementException ex) { + throw new com.sun.star.uno.Exception(ex, "could not get group '" + group + - "' from set '"+ setName +"':\n" + e.toString()); + "' from set '"+ setName +"'"); } try { Object xGroup=xGroupAccess.getByName(extGroup); xExtGroupCont = UnoRuntime.queryInterface( XNameContainer.class,xGroup); - } catch(com.sun.star.container.NoSuchElementException e) { - throw new com.sun.star.uno.Exception( + } catch(com.sun.star.container.NoSuchElementException ex) { + throw new com.sun.star.uno.Exception(ex, "could not get extensilbe group '"+extGroup+ "' from group '"+ group + - "' from set '"+ setName +"':\n" + e.toString()); + "' from set '"+ setName +"'"); } try { xExtGroupCont.insertByName(propName, propValue); } catch(com.sun.star.container.ElementExistException e) { - xExtGroupCont .replaceByName(propName, propValue); + xExtGroupCont.replaceByName(propName, propValue); } } diff --git a/qadevOOo/runner/helper/StreamSimulator.java b/qadevOOo/runner/helper/StreamSimulator.java index 1b53d4a9a492..7571ce6864cf 100644 --- a/qadevOOo/runner/helper/StreamSimulator.java +++ b/qadevOOo/runner/helper/StreamSimulator.java @@ -106,7 +106,7 @@ public class StreamSimulator implements com.sun.star.io.XInputStream , } catch(com.sun.star.uno.Exception exUno) { - throw new com.sun.star.io.NotConnectedException("Could not open the file."); + throw new com.sun.star.io.NotConnectedException(exUno); } } diff --git a/qadevOOo/runner/util/BasicMacroTools.java b/qadevOOo/runner/util/BasicMacroTools.java index 34407cac336d..0a2a856f774f 100644 --- a/qadevOOo/runner/util/BasicMacroTools.java +++ b/qadevOOo/runner/util/BasicMacroTools.java @@ -47,32 +47,26 @@ public class BasicMacroTools { */ public BasicMacroTools(XMultiServiceFactory msf, XModel xModel, XComponent xDoc) throws java.lang.Exception { - try { - mMSF = msf; - mDispProv = makeDispatchProvider(xModel); - mParser = makeParser(mMSF); + mMSF = msf; + mDispProv = makeDispatchProvider(xModel); + mParser = makeParser(mMSF); - Object DocLibCont = null; + Object DocLibCont = null; - try { - XPropertySet xDocProps = UnoRuntime.queryInterface( - XPropertySet.class, xDoc); - DocLibCont = xDocProps.getPropertyValue("BasicLibraries"); - } catch (com.sun.star.uno.Exception e) { - throw new Exception( - "Couldn't get BasicLibraries-Container from document: " + e.toString()); - } - - mLCxNA = UnoRuntime.queryInterface(XNameAccess.class, - DocLibCont); + try { + XPropertySet xDocProps = UnoRuntime.queryInterface( + XPropertySet.class, xDoc); + DocLibCont = xDocProps.getPropertyValue("BasicLibraries"); + } catch (com.sun.star.uno.Exception e) { + throw new Exception( + "Couldn't get BasicLibraries-Container from document", e); + } - mLCxLC = UnoRuntime.queryInterface( - XLibraryContainer.class, DocLibCont); + mLCxNA = UnoRuntime.queryInterface(XNameAccess.class, + DocLibCont); - } catch (Exception e) { - throw new Exception("could not initialize BasicMacros " + - e.toString()); - } + mLCxLC = UnoRuntime.queryInterface( + XLibraryContainer.class, DocLibCont); } /* @@ -80,31 +74,24 @@ public class BasicMacroTools { */ public BasicMacroTools(XMultiServiceFactory msf, XModel xModel) throws java.lang.Exception { - try { - mMSF = msf; - mDispProv = makeDispatchProvider(xModel); - mParser = makeParser(mMSF); + mMSF = msf; + mDispProv = makeDispatchProvider(xModel); + mParser = makeParser(mMSF); - Object ASLC = null; + Object ASLC = null; - try { - ASLC = mMSF.createInstance( - "com.sun.star.script.ApplicationScriptLibraryContainer"); - } catch (com.sun.star.uno.Exception e) { - throw new Exception( - "Couldn't create ApplicationScriptLibraryContainer" + e.toString()); - } - - mLCxNA = UnoRuntime.queryInterface(XNameAccess.class, - ASLC); + try { + ASLC = mMSF.createInstance( + "com.sun.star.script.ApplicationScriptLibraryContainer"); + } catch (com.sun.star.uno.Exception e) { + throw new Exception("Couldn't create ApplicationScriptLibraryContainer", e); + } - mLCxLC = UnoRuntime.queryInterface( - XLibraryContainer.class, ASLC); + mLCxNA = UnoRuntime.queryInterface(XNameAccess.class, + ASLC); - } catch (Exception e) { - throw new Exception("could not initialize BasicMacros " + - e.toString()); - } + mLCxLC = UnoRuntime.queryInterface( + XLibraryContainer.class, ASLC); } private static XDispatchProvider makeDispatchProvider(XModel aModel) @@ -137,21 +124,15 @@ public class BasicMacroTools { try { appendLibrary(LibraryName, LibraryURL); } catch (java.lang.Exception e) { - e.printStackTrace(); - throw new Exception("ERROR: Could not append Library " + - LibraryName + e.toString()); + throw new Exception("Could not append Library " + LibraryName, e); } try { mLCxLC.loadLibrary(LibraryName); } catch (com.sun.star.container.NoSuchElementException e) { - e.printStackTrace(); - throw new Exception("ERROR: Could not load Library " + - LibraryName + e.toString()); + throw new Exception("Could not load Library " + LibraryName, e); } catch (com.sun.star.lang.WrappedTargetException e) { - e.printStackTrace(); - throw new Exception("ERROR: Could not load Library " + - LibraryName + e.toString()); + throw new Exception("Could not load Library " + LibraryName, e); } } @@ -165,13 +146,9 @@ public class BasicMacroTools { try { mLCxLC.createLibraryLink(LibraryName, LibraryURL, false); } catch (com.sun.star.container.ElementExistException e) { - e.printStackTrace(); - throw new Exception("ERROR: Library " + LibraryName + - "already exist." + e.toString()); + throw new Exception("Library " + LibraryName + "already exists.", e); } catch (com.sun.star.lang.IllegalArgumentException e) { - e.printStackTrace(); - throw new Exception("Could not link Basic library:" + - LibraryName + e.toString()); + throw new Exception("Could not link Basic library " + LibraryName, e); } } @@ -180,13 +157,9 @@ public class BasicMacroTools { try { mLCxLC.removeLibrary(LibraryName); } catch (com.sun.star.container.NoSuchElementException e) { - e.printStackTrace(); - throw new Exception("Could not remove Basic library:" + - LibraryName + ": Library does not exist" + e.toString()); + throw new Exception("Could not remove Basic library " + LibraryName + ", Library does not exist", e); } catch (com.sun.star.lang.WrappedTargetException e) { - e.printStackTrace(); - throw new Exception("Could not remove Basic library:" + - LibraryName + e.toString()); + throw new Exception("Could not remove Basic library " + LibraryName, e); } } } diff --git a/qadevOOo/runner/util/CalcTools.java b/qadevOOo/runner/util/CalcTools.java index dd6defab8050..73f11ba81cf0 100644 --- a/qadevOOo/runner/util/CalcTools.java +++ b/qadevOOo/runner/util/CalcTools.java @@ -34,7 +34,7 @@ import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; /** - * This class contains some useful mathods to handle Calc documents + * This class contains some useful methods to handle Calc documents * and its sheets. */ public class CalcTools { @@ -42,7 +42,7 @@ public class CalcTools { /** * fills a range of a calc sheet with computed data of type * Double. - * @param xSheetDoc the Clac documents which should be filled + * @param xSheetDoc the Calc documents which should be filled * @param sheetNumber the number of the sheet of xSheetDoc * @param startCellX the cell number of the X start point (row) of the range to fill * @param startCellY the cell number of the Y start point (column) of the range to fill @@ -53,15 +53,9 @@ public class CalcTools { public static void fillCalcSheetWithContent(XComponent xSheetDoc, int sheetNumber, int startCellX, int startCellY, int rangeLengthX, int rangeLengthY) throws java.lang.Exception { - try{ - XSpreadsheet xSheet = getSpreadSheetFromSheetDoc(xSheetDoc, sheetNumber); - - fillCalcSheetWithContent(xSheet, startCellX, startCellY, rangeLengthX, rangeLengthY); + XSpreadsheet xSheet = getSpreadSheetFromSheetDoc(xSheetDoc, sheetNumber); - } catch (Exception e){ - throw new Exception( - "Couldn't fill CalcSheet with content: " + e.toString()); - } + fillCalcSheetWithContent(xSheet, startCellX, startCellY, rangeLengthX, rangeLengthY); } /** @@ -77,31 +71,24 @@ public class CalcTools { public static void fillCalcSheetWithContent(XSpreadsheet xSheet, int startCellX, int startCellY, int rangeLengthX, int rangeLengthY) throws java.lang.Exception { - - try{ - // create a range with content - Object[][] newData = new Object[rangeLengthY][rangeLengthX]; - for (int i=0; i