diff options
author | Noel Grandin <noel@peralex.com> | 2015-06-05 10:24:36 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-06-05 13:17:50 +0000 |
commit | 275f0c7b250d448a8e2658ee2f26d4010628237b (patch) | |
tree | 9537d17adfe0f098a27f84c0f0710b6ba2592aeb /framework/qa | |
parent | 9eb1bfcbb164a8d029d7ba92947e0c9caf8e0826 (diff) |
Let JUnit take care of exceptions
Inspired by commit
4dd0ac62855c5b9382cac004c7eebb9bed983a2b
Change-Id: I6ca29aecde357a3cb5852acfc9b5443761052960
Reviewed-on: https://gerrit.libreoffice.org/16094
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'framework/qa')
5 files changed, 182 insertions, 322 deletions
diff --git a/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java b/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java index 916e57032def..6516d27d7f4c 100644 --- a/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java +++ b/framework/qa/complex/contextMenuInterceptor/CheckContextMenuInterceptor.java @@ -31,7 +31,6 @@ import com.sun.star.beans.XPropertySet; import com.sun.star.drawing.XShape; import com.sun.star.frame.XFrame; import com.sun.star.frame.XModel; -import com.sun.star.lang.IndexOutOfBoundsException; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.ui.XContextMenuInterception; import com.sun.star.ui.XContextMenuInterceptor; @@ -79,7 +78,7 @@ public class CheckContextMenuInterceptor } @After - public void after() + public void after() throws Exception { System.out.println("release the popup menu"); try @@ -98,116 +97,97 @@ public class CheckContextMenuInterceptor XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xFrame); - try - { - xClose.close(true); - } - catch (com.sun.star.util.CloseVetoException exVeto) - { - fail("Test frame couldn't be closed successfully."); - } + xClose.close(true); xFrame = null; - } @Test - public void checkContextMenuInterceptor() + public void checkContextMenuInterceptor() throws Exception { System.out.println(" **** Context Menu Interceptor *** "); - try - { - // intialize the test document - xDrawDoc = DrawTools.createDrawDoc(xMSF); + // intialize the test document + xDrawDoc = DrawTools.createDrawDoc(xMSF); - SOfficeFactory SOF = SOfficeFactory.getFactory(xMSF); - XShape oShape = SOF.createShape(xDrawDoc, 5000, 5000, 1500, 1000, "GraphicObject"); - DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc, 0)).add(oShape); + SOfficeFactory SOF = SOfficeFactory.getFactory(xMSF); + XShape oShape = SOF.createShape(xDrawDoc, 5000, 5000, 1500, 1000, "GraphicObject"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc, 0)).add(oShape); - com.sun.star.frame.XModel xModel = - UnoRuntime.queryInterface(com.sun.star.frame.XModel.class, xDrawDoc); + com.sun.star.frame.XModel xModel = + UnoRuntime.queryInterface(com.sun.star.frame.XModel.class, xDrawDoc); - // get the frame for later usage - xFrame = xModel.getCurrentController().getFrame(); + // get the frame for later usage + xFrame = xModel.getCurrentController().getFrame(); - // ensure that the document content is optimal visible - DesktopTools.zoomToEntirePage(xDrawDoc); + // ensure that the document content is optimal visible + DesktopTools.zoomToEntirePage(xDrawDoc); - XBitmap xBitmap = null; + XBitmap xBitmap = null; - // adding graphic as ObjRelation for GraphicObjectShape - XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class, oShape); - System.out.println("Inserting a shape into the document"); + // adding graphic as ObjRelation for GraphicObjectShape + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class, oShape); + System.out.println("Inserting a shape into the document"); - try - { - String sFile = OfficeFileUrl.getAbsolute(new File("space-metal.jpg")); - oShapeProps.setPropertyValue("GraphicURL", sFile); - Object oProp = oShapeProps.getPropertyValue("GraphicObjectFillBitmap"); - xBitmap = (XBitmap) AnyConverter.toObject(new Type(XBitmap.class), oProp); - } - catch (com.sun.star.lang.WrappedTargetException e) - { - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - } - catch (com.sun.star.beans.PropertyVetoException e) - { - } - catch (com.sun.star.beans.UnknownPropertyException e) - { - } + try + { + String sFile = OfficeFileUrl.getAbsolute(new File("space-metal.jpg")); + oShapeProps.setPropertyValue("GraphicURL", sFile); + Object oProp = oShapeProps.getPropertyValue("GraphicObjectFillBitmap"); + xBitmap = (XBitmap) AnyConverter.toObject(new Type(XBitmap.class), oProp); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + } + catch (com.sun.star.beans.PropertyVetoException e) + { + } + catch (com.sun.star.beans.UnknownPropertyException e) + { + } - // reuse the frame - com.sun.star.frame.XController xController = xFrame.getController(); - XContextMenuInterception xContextMenuInterception = null; - XContextMenuInterceptor xContextMenuInterceptor = null; + // reuse the frame + com.sun.star.frame.XController xController = xFrame.getController(); + XContextMenuInterception xContextMenuInterception = null; + XContextMenuInterceptor xContextMenuInterceptor = null; - if (xController != null) - { - System.out.println("Creating context menu interceptor"); + if (xController != null) + { + System.out.println("Creating context menu interceptor"); - // add our context menu interceptor - xContextMenuInterception = - UnoRuntime.queryInterface(XContextMenuInterception.class, xController); + // add our context menu interceptor + xContextMenuInterception = + UnoRuntime.queryInterface(XContextMenuInterception.class, xController); - if (xContextMenuInterception != null) - { - ContextMenuInterceptor aContextMenuInterceptor = new ContextMenuInterceptor(xBitmap); - xContextMenuInterceptor = - UnoRuntime.queryInterface(XContextMenuInterceptor.class, aContextMenuInterceptor); + if (xContextMenuInterception != null) + { + ContextMenuInterceptor aContextMenuInterceptor = new ContextMenuInterceptor(xBitmap); + xContextMenuInterceptor = + UnoRuntime.queryInterface(XContextMenuInterceptor.class, aContextMenuInterceptor); - System.out.println("Register context menu interceptor"); - xContextMenuInterception.registerContextMenuInterceptor(xContextMenuInterceptor); - } + System.out.println("Register context menu interceptor"); + xContextMenuInterception.registerContextMenuInterceptor(xContextMenuInterceptor); } + } - openContextMenu(UnoRuntime.queryInterface(XModel.class, xDrawDoc)); + openContextMenu(UnoRuntime.queryInterface(XModel.class, xDrawDoc)); - checkHelpEntry(); + checkHelpEntry(); - // remove our context menu interceptor - if (xContextMenuInterception != null - && xContextMenuInterceptor != null) - { - System.out.println("Release context menu interceptor"); - xContextMenuInterception.releaseContextMenuInterceptor( - xContextMenuInterceptor); - } - } - catch (com.sun.star.uno.RuntimeException ex) + // remove our context menu interceptor + if (xContextMenuInterception != null + && xContextMenuInterceptor != null) { - fail("Runtime exception caught!" + ex.getMessage()); - } - catch (java.lang.Exception ex) - { - fail("Java lang exception caught!" + ex.getMessage()); + System.out.println("Release context menu interceptor"); + xContextMenuInterception.releaseContextMenuInterceptor( + xContextMenuInterceptor); } } - private void checkHelpEntry() + private void checkHelpEntry() throws Exception { XInterface toolkit = null; @@ -240,24 +220,14 @@ public class CheckContextMenuInterceptor System.out.println("ImplementationName: " + util.utils.getImplName(oPopMenu)); XAccessible xHelp = null; - try - { - System.out.println("Try to get first entry of context menu..."); - xHelp = oPopMenu.getAccessibleChild(0); - - } - catch (IndexOutOfBoundsException e) - { - fail("Not possible to get first entry of context menu"); - } - + System.out.println("Try to get first entry of context menu..."); + xHelp = oPopMenu.getAccessibleChild(0); if (xHelp == null) { fail("first entry of context menu is NULL"); } XAccessibleContext xHelpCont = xHelp.getAccessibleContext(); - if (xHelpCont == null) { fail("No able to retrieve accessible context from first entry of context menu"); @@ -270,16 +240,8 @@ public class CheckContextMenuInterceptor fail("First entry of context menu is not from context menu interceptor"); } - try - { - System.out.println("try to get first children of Help context..."); - xHelpCont.getAccessibleChild(0); - } - catch (IndexOutOfBoundsException e) - { - fail("not possible to get first children of Help context"); - } - + System.out.println("try to get first children of Help context..."); + xHelpCont.getAccessibleChild(0); } private void openContextMenu(XModel aModel) diff --git a/framework/qa/complex/dispatches/checkdispatchapi.java b/framework/qa/complex/dispatches/checkdispatchapi.java index c227be25e9bb..febef2bc3048 100644 --- a/framework/qa/complex/dispatches/checkdispatchapi.java +++ b/framework/qa/complex/dispatches/checkdispatchapi.java @@ -68,30 +68,23 @@ public class checkdispatchapi @descr create an empty test frame, where we can load different components inside. */ - @Before public void before() + @Before public void before() throws Exception { - try - { - // get uno service manager from global test environment - m_xMSF = getMSF(); + // get uno service manager from global test environment + m_xMSF = getMSF(); - db = new connectivity.tools.HsqlDatabase(m_xMSF); + db = new connectivity.tools.HsqlDatabase(m_xMSF); - // create desktop - m_xDesktop = UnoRuntime.queryInterface(XFrame.class, m_xMSF.createInstance("com.sun.star.frame.Desktop")); + // create desktop + m_xDesktop = UnoRuntime.queryInterface(XFrame.class, m_xMSF.createInstance("com.sun.star.frame.Desktop")); - m_xFrame = impl_createNewFrame(); - } - catch (java.lang.Throwable ex) - { - fail("Can't initialize test environment."); - } + m_xFrame = impl_createNewFrame(); } /** @short close the environment. */ - @After public void after() + @After public void after() throws Exception { db.close(); impl_closeFrame(m_xFrame); @@ -99,49 +92,49 @@ public class checkdispatchapi } - @Test public void checkDispatchInfoOfWriter() + @Test public void checkDispatchInfoOfWriter() throws Exception { impl_checkDispatchInfoOfXXX("private:factory/swriter"); } - @Test public void checkDispatchInfoOfCalc() + @Test public void checkDispatchInfoOfCalc() throws Exception { impl_checkDispatchInfoOfXXX("private:factory/scalc"); } - @Test public void checkDispatchInfoOfDraw() + @Test public void checkDispatchInfoOfDraw() throws Exception { impl_checkDispatchInfoOfXXX("private:factory/sdraw"); } - @Test public void checkDispatchInfoOfImpress() + @Test public void checkDispatchInfoOfImpress() throws Exception { impl_checkDispatchInfoOfXXX("private:factory/simpress"); } - @Test public void checkDispatchInfoOfChart() + @Test public void checkDispatchInfoOfChart() throws Exception { impl_checkDispatchInfoOfXXX("private:factory/schart"); } - @Test public void checkDispatchInfoOfMath() + @Test public void checkDispatchInfoOfMath() throws Exception { impl_checkDispatchInfoOfXXX("private:factory/smath"); } - @Test public void checkDispatchInfoOfDataBase() + @Test public void checkDispatchInfoOfDataBase() throws Exception { impl_checkDispatchInfoOfXXX("private:factory/sdatabase"); } - @Test public void checkDispatchInfoOfBibliography() + @Test public void checkDispatchInfoOfBibliography() throws Exception { impl_checkDispatchInfoOfXXX(".component:Bibliography/View1"); } @@ -153,19 +146,19 @@ public class checkdispatchapi } - @Test public void checkDispatchInfoOfTableDesign() + @Test public void checkDispatchInfoOfTableDesign() throws Exception { callDatabaseDispatch(".component:DB/TableDesign"); } - @Test public void checkDispatchInfoOfFormGridView() + @Test public void checkDispatchInfoOfFormGridView() throws Exception { impl_checkDispatchInfoOfXXX(".component:DB/FormGridView"); } - @Test public void checkDispatchInfoOfDataSourceBrowser() + @Test public void checkDispatchInfoOfDataSourceBrowser() throws Exception { impl_checkDispatchInfoOfXXX(".component:DB/DataSourceBrowser"); } @@ -200,21 +193,21 @@ public class checkdispatchapi } - @Test public void checkDispatchInfoOfBasic() + @Test public void checkDispatchInfoOfBasic() throws Exception { Object aComponent = impl_createUNOComponent("com.sun.star.script.BasicIDE"); impl_checkDispatchInfo(aComponent); } - @Test public void checkDispatchInfoOfStartModule() + @Test public void checkDispatchInfoOfStartModule() throws Exception { Object aComponent = impl_createUNOComponent("com.sun.star.frame.StartModule"); impl_checkDispatchInfo(aComponent); } - public void checkInterceptorLifeTime() + public void checkInterceptorLifeTime() throws Exception { // Note: It's important for the following test, that aInterceptor will be hold alive by the uno reference // xInterceptor. Otherwhise we can't check some internal states of aInterceptor at the end of this method, because @@ -249,7 +242,7 @@ public class checkdispatchapi } - public void checkInterception() + public void checkInterception() throws Exception { String[] lDisabledURLs = new String[] { ".uno:Open" }; @@ -273,7 +266,7 @@ public class checkdispatchapi } - private void impl_checkDispatchInfoOfXXX(String sXXX) + private void impl_checkDispatchInfoOfXXX(String sXXX) throws Exception { XFrame xFrame = impl_createNewFrame(); impl_loadIntoFrame(xFrame, sXXX, null); @@ -284,7 +277,7 @@ public class checkdispatchapi /** @short load an URL into the current test frame. */ - private void impl_loadIntoFrame(XFrame xFrame, String sURL, PropertyValue args[]) + private void impl_loadIntoFrame(XFrame xFrame, String sURL, PropertyValue args[]) throws Exception { XComponentLoader xLoader = UnoRuntime.queryInterface(XComponentLoader.class, xFrame); if (xLoader == null) @@ -292,15 +285,7 @@ public class checkdispatchapi fail("Frame does not provide required interface XComponentLoader."); } - XComponent xDoc = null; - try - { - xDoc = xLoader.loadComponentFromURL(sURL, "_self", 0, args); - } - catch (java.lang.Throwable ex) - { - xDoc = null; - } + XComponent xDoc = xLoader.loadComponentFromURL(sURL, "_self", 0, args); if (xDoc == null) { @@ -334,7 +319,7 @@ public class checkdispatchapi /** @short check the interface XDispatchInformationProvider at the specified component. */ - private void impl_checkDispatchInfo(Object aComponent) + private void impl_checkDispatchInfo(Object aComponent) throws Exception { XDispatchInformationProvider xInfoProvider = UnoRuntime.queryInterface(XDispatchInformationProvider.class, aComponent); if (xInfoProvider == null) @@ -344,86 +329,62 @@ public class checkdispatchapi return; } - try + short[] lGroups = xInfoProvider.getSupportedCommandGroups(); + int c1 = lGroups.length; + int i1 = 0; + for (i1 = 0; i1 < c1; ++i1) { - short[] lGroups = xInfoProvider.getSupportedCommandGroups(); - int c1 = lGroups.length; - int i1 = 0; - for (i1 = 0; i1 < c1; ++i1) + short nGroup = lGroups[i1]; + DispatchInformation[] lInfos = xInfoProvider.getConfigurableDispatchInformation(nGroup); + int c2 = lInfos.length; + int i2 = 0; + + // check for empty lists + // Warning + if (lInfos.length < 1) { - short nGroup = lGroups[i1]; - DispatchInformation[] lInfos = xInfoProvider.getConfigurableDispatchInformation(nGroup); - int c2 = lInfos.length; - int i2 = 0; - - // check for empty lists - // Warning - if (lInfos.length < 1) + System.out.println("Warning:\tCould not get any DispatchInformation for group [" + nGroup + "]."); + } + + // check for duplicates (and by the way, if the info item match the requested group) + HashMap<String, String> aCheckMap = new HashMap<String, String>(c2); + for (i2 = 0; i2 < c2; ++i2) + { + DispatchInformation aInfo = lInfos[i2]; + if (aInfo.GroupId != nGroup) { - System.out.println("Warning:\tCould not get any DispatchInformation for group [" + nGroup + "]."); + // Error + fail("At least one DispatchInformation item does not match the requested group.\n\trequested group=[" + nGroup + + "] returned groupd=[" + aInfo.GroupId + "] command=\"" + aInfo.Command + "\""); // true => dont break this test + continue; } - // check for duplicates (and by the way, if the info item match the requested group) - HashMap<String, String> aCheckMap = new HashMap<String, String>(c2); - for (i2 = 0; i2 < c2; ++i2) + if (aCheckMap.containsKey(aInfo.Command)) { - DispatchInformation aInfo = lInfos[i2]; - if (aInfo.GroupId != nGroup) - { - // Error - fail("At least one DispatchInformation item does not match the requested group.\n\trequested group=[" + nGroup - + "] returned groupd=[" + aInfo.GroupId + "] command=\"" + aInfo.Command + "\""); // true => dont break this test - continue; - } - - if (aCheckMap.containsKey(aInfo.Command)) - { - // Error - fail("Found a duplicate item: group=[" + aInfo.GroupId + "] command=\"" + aInfo.Command + "\""); // true => dont break this test - continue; - } - - aCheckMap.put(aInfo.Command, aInfo.Command); - System.out.println("\t[" + aInfo.GroupId + "] \"" + aInfo.Command + "\""); + // Error + fail("Found a duplicate item: group=[" + aInfo.GroupId + "] command=\"" + aInfo.Command + "\""); // true => dont break this test + continue; } + + aCheckMap.put(aInfo.Command, aInfo.Command); + System.out.println("\t[" + aInfo.GroupId + "] \"" + aInfo.Command + "\""); } } - catch (java.lang.Throwable ex) - { - fail("Exception caught during using XDispatchInformationProvider."); - } } private synchronized XFrame impl_createNewFrame() { - XFrame xFrame = null; - - try - { - xFrame = m_xDesktop.findFrame("_blank", 0); - xFrame.getContainerWindow().setVisible(true); - } - catch (java.lang.Throwable ex) - { - fail("Could not create the frame instance."); - } - + XFrame xFrame = m_xDesktop.findFrame("_blank", 0); + xFrame.getContainerWindow().setVisible(true); return xFrame; } - private synchronized void impl_closeFrame(XFrame xFrame) + private synchronized void impl_closeFrame(XFrame xFrame) throws Exception { XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xFrame); - try - { - xClose.close(false); - } - catch (com.sun.star.util.CloseVetoException exVeto) - { - fail("Test frame couldn't be closed successfully."); - } + xClose.close(false); } private XMultiServiceFactory getMSF() diff --git a/framework/qa/complex/disposing/GetServiceWhileDisposingOffice.java b/framework/qa/complex/disposing/GetServiceWhileDisposingOffice.java index f55662787ceb..fd7fffcb3ddb 100644 --- a/framework/qa/complex/disposing/GetServiceWhileDisposingOffice.java +++ b/framework/qa/complex/disposing/GetServiceWhileDisposingOffice.java @@ -25,7 +25,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.openoffice.test.OfficeConnection; -import static org.junit.Assert.*; /** @@ -36,19 +35,12 @@ import static org.junit.Assert.*; public class GetServiceWhileDisposingOffice { - @Test public void checkServiceWhileDisposing() + @Test public void checkServiceWhileDisposing() throws Exception { XMultiServiceFactory xMSF = getMSF(); XDesktop xDesktop = null; - try - { - xDesktop = UnoRuntime.queryInterface(XDesktop.class, xMSF.createInstance("com.sun.star.frame.Desktop")); - } - catch (com.sun.star.uno.Exception e) - { - fail("Could not create a desktop instance."); - } + xDesktop = UnoRuntime.queryInterface(XDesktop.class, xMSF.createInstance("com.sun.star.frame.Desktop")); int step = 0; try { @@ -63,11 +55,6 @@ public class GetServiceWhileDisposingOffice { System.out.println("DisposedException in step: " + step); } - catch (Exception e) - { - fail(e.getMessage()); - } - } diff --git a/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java b/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java index da3b57a1c096..c41388b70b36 100644 --- a/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java +++ b/framework/qa/complex/loadAllDocuments/CheckXComponentLoader.java @@ -114,33 +114,18 @@ public class CheckXComponentLoader @descr Use either a component loader from desktop or from frame */ - @Before public void before() + @Before public void before() throws Exception { // get uno service manager from global test environment /* points to the global uno service manager. */ XMultiServiceFactory xMSF = getMSF(); // create stream provider - try - { - m_xStreamProvider = UnoRuntime.queryInterface(XSimpleFileAccess.class, xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess")); - } - catch(java.lang.Throwable ex) - { - fail("Could not create a stream provider instance."); - } + m_xStreamProvider = UnoRuntime.queryInterface(XSimpleFileAccess.class, xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess")); // create desktop instance /* provides XComponentLoader interface. */ - XFrame xDesktop = null; - try - { - xDesktop = UnoRuntime.queryInterface(XFrame.class, xMSF.createInstance("com.sun.star.frame.Desktop")); - } - catch(java.lang.Throwable ex) - { - fail("Could not create the desktop instance."); - } + XFrame xDesktop = UnoRuntime.queryInterface(XFrame.class, xMSF.createInstance("com.sun.star.frame.Desktop")); // create frame instance m_xFrame = xDesktop.findFrame("testFrame_componentLoader", @@ -162,49 +147,37 @@ public class CheckXComponentLoader m_lTestFiles = new ArrayList<String>(); final String sTestDocURL = OfficeFileUrl.getAbsolute(new File("testdocuments")); m_sTestDocPath = graphical.FileHelper.getSystemPathFromFileURL(sTestDocURL); - try + File aBaseDir = new File(m_sTestDocPath); + List<File> lDirContent = URLHelper.getSystemFilesFromDir(aBaseDir.getPath()); + Iterator<File> lList = lDirContent.iterator(); + int nBasePathLength = m_sTestDocPath.length(); + while(lList.hasNext()) { - File aBaseDir = new File(m_sTestDocPath); - List<File> lDirContent = URLHelper.getSystemFilesFromDir(aBaseDir.getPath()); - Iterator<File> lList = lDirContent.iterator(); - int nBasePathLength = m_sTestDocPath.length(); - while(lList.hasNext()) - { - File aFile = lList.next(); + File aFile = lList.next(); - // ignore broken links and directories at all - if ( - (!aFile.exists()) || - (!aFile.isFile()) - ) - { - continue; - } + // ignore broken links and directories at all + if ( + (!aFile.exists()) || + (!aFile.isFile()) + ) + { + continue; + } - String sCompletePath = aFile.getAbsolutePath(); - String sSubPath = sCompletePath.substring(nBasePathLength); + String sCompletePath = aFile.getAbsolutePath(); + String sSubPath = sCompletePath.substring(nBasePathLength); - m_lTestFiles.add(sSubPath); - } - } - catch(java.lang.Throwable ex) - { - fail("Couldn't find test documents."); + m_lTestFiles.add(sSubPath); } } /** @short close the environment. */ - @After public void after() + @After public void after() throws Exception { XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, m_xFrame); - try - { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException exVeto) - { fail("Test frame couldn't be closed successfully."); } + xClose.close(false); m_xFrame = null; m_xLoader = null; @@ -281,7 +254,7 @@ public class CheckXComponentLoader String sSourceURL, String sTargetURL, String sFilter , - String sPassword ) + String sPassword ) throws Exception { PropertyValue[] lLoadProps = new PropertyValue[1]; @@ -304,24 +277,17 @@ public class CheckXComponentLoader lSaveProps[2].Value = Boolean.TRUE; XComponent xDoc = null; - try - { - // load it - xDoc = xLoader.loadComponentFromURL(sSourceURL, "_blank", 0, lLoadProps); - assertNotNull("Could create office document, which should be saved as temp one.", xDoc); + // load it + xDoc = xLoader.loadComponentFromURL(sSourceURL, "_blank", 0, lLoadProps); + assertNotNull("Could create office document, which should be saved as temp one.", xDoc); - // save it as temp file - XStorable xStore = UnoRuntime.queryInterface(XStorable.class, xDoc); - xStore.storeAsURL(sTargetURL, lSaveProps); + // save it as temp file + XStorable xStore = UnoRuntime.queryInterface(XStorable.class, xDoc); + xStore.storeAsURL(sTargetURL, lSaveProps); - // Dont forget to close this file. Otherwise the temp file is locked! - XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xDoc); - xClose.close(false); - } - catch(java.lang.Throwable ex) - { - fail("Could not create temp office document."); - } + // Dont forget to close this file. Otherwise the temp file is locked! + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xDoc); + xClose.close(false); } @@ -331,7 +297,7 @@ public class CheckXComponentLoader as password for the ftp connection, or - if none given a default one. */ - @Test public void checkLoadingWithPassword() + @Test public void checkLoadingWithPassword() throws Exception { String sTempFile = impl_getTempFileName(m_sTempPath, SUFFIX_PASSWORD_TEMPFILE, PREFIX_PASSWORD_TEMPFILE); File aTestFile = new File(sTempFile); @@ -363,7 +329,7 @@ public class CheckXComponentLoader * Check URL encoding. The first filename that matches "*.sxw" * is used as source for several encodings. */ - @Test public void checkURLEncoding() { + @Test public void checkURLEncoding() throws Exception { PropertyValue[] lProps = new PropertyValue[1]; lProps[0] = new PropertyValue(); @@ -409,28 +375,23 @@ public class CheckXComponentLoader }; for (int i = 0; i < sEncoding.length; i = i + 2) { - try { - String encURL = new String(baURL, sEncoding[i]); - System.out.println("ENC[" + sEncoding[i] + "]"); - - if (sEncoding[i + 1].equals("TRUE")) { - loadURL(m_xLoader, RESULT_VALID_DOC, encURL, "_blank", 0, - lProps); - } else { - //with cws_loadenv01 changed to IllegalArgumentException - loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, encURL, "_blank", 0, - lProps); - } - } catch (java.io.UnsupportedEncodingException e) { - fail("Unsopported Encoding: " + sEncoding[i] + - "\n Not able to test encoding on this platform."); + String encURL = new String(baURL, sEncoding[i]); + System.out.println("ENC[" + sEncoding[i] + "]"); + + if (sEncoding[i + 1].equals("TRUE")) { + loadURL(m_xLoader, RESULT_VALID_DOC, encURL, "_blank", 0, + lProps); + } else { + //with cws_loadenv01 changed to IllegalArgumentException + loadURL(m_xLoader, RESULT_ILLEGALARGUMENTEXCEPTION, encURL, "_blank", 0, + lProps); } } } /** TODo document me */ - @Test public void checkStreamLoading() + @Test public void checkStreamLoading() throws Exception { PropertyValue[] lProps = new PropertyValue[2]; @@ -447,19 +408,12 @@ public class CheckXComponentLoader File aFile = new File(m_sTestDocPath, aSnapshot.next()); String sURL = URLHelper.getFileURLFromSystemPath(aFile); - try - { - XInputStream xStream = m_xStreamProvider.openFileRead(sURL); - lProps[1].Value = xStream; - } - catch(com.sun.star.uno.Exception e) - { - fail("Could not open test file \""+sURL+"\" for stream test."); - } + XInputStream xStream = m_xStreamProvider.openFileRead(sURL); + lProps[1].Value = xStream; // check different version of "private:stream" URL! loadURL(m_xLoader, RESULT_VALID_DOC, "private:stream" , "_blank", 0, lProps); - } + } } /** diff --git a/framework/qa/complex/path_settings/PathSettingsTest.java b/framework/qa/complex/path_settings/PathSettingsTest.java index a34375806a34..d3aa875689bd 100644 --- a/framework/qa/complex/path_settings/PathSettingsTest.java +++ b/framework/qa/complex/path_settings/PathSettingsTest.java @@ -95,7 +95,7 @@ public class PathSettingsTest * This methods sets the 'aPathSettings' and 'xPropertyInfoOfPathSettings' variables. */ @Before - public void before() + public void before() throws Exception { try { @@ -127,10 +127,6 @@ public class PathSettingsTest System.out.println(e.getClass().getName()); System.out.println("Message: " + e.getMessage()); } - catch (Exception e) - { - fail("What exception?"); - } } private String convertToString(Object o) |