diff options
author | Noel Grandin <noel@peralex.com> | 2015-06-09 08:52:12 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-06-09 11:34:31 +0200 |
commit | 2a0dda3dfb37f0cb69842f7d569c253d82f53713 (patch) | |
tree | 7a762c2fa22651cefb68021250a3fad8811e0f06 /qadevOOo/tests/java/mod/_xmloff/Impress | |
parent | 60f8dd78fa3f19e8bed867f7f5926fcf9a8d8e67 (diff) |
remove some unnecessary exception wrapping in the Java tests
Modify createTestEnvironment so that it throws Exception. This
is appropriate for unit testing.
The wrapping adds no value and the calling method already has
a catch(Exception) to handle anything.
Change-Id: I430a414f63d2cbfc3b65ecfde0285509265e5192
Diffstat (limited to 'qadevOOo/tests/java/mod/_xmloff/Impress')
10 files changed, 91 insertions, 154 deletions
diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java index c5997f057d84..5738566cb496 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java @@ -116,7 +116,7 @@ public class XMLContentExporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam, PrintWriter log ) throws StatusException { + (TestParameters tParam, PrintWriter log ) throws Exception { XMultiServiceFactory xMSF = tParam.getMSF() ; XInterface oObj = null; @@ -125,24 +125,19 @@ public class XMLContentExporter extends TestCase { FilterChecker filter = new FilterChecker(log); Any arg = new Any(new Type(XDocumentHandler.class),filter); - try { - oObj = (XInterface) xMSF.createInstanceWithArguments( - "com.sun.star.comp.Impress.XMLContentExporter", - new Object[] {arg}); - XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); - xEx.setSourceDocument(xImpressDoc); - - // assigning a draw page a new name - XDrawPagesSupplier xPagesSup = UnoRuntime.queryInterface - (XDrawPagesSupplier.class, xImpressDoc) ; - XDrawPages xPages = xPagesSup.getDrawPages() ; - XNamed xPageName = UnoRuntime.queryInterface - (XNamed.class, xPages.getByIndex(0)) ; - xPageName.setName(expPageName) ; - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLContentExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // assigning a draw page a new name + XDrawPagesSupplier xPagesSup = UnoRuntime.queryInterface + (XDrawPagesSupplier.class, xImpressDoc) ; + XDrawPages xPages = xPagesSup.getDrawPages() ; + XNamed xPageName = UnoRuntime.queryInterface + (XNamed.class, xPages.getByIndex(0)) ; + xPageName.setName(expPageName) ; // adding tags required to be in XML data exported. filter.addTag(new XMLTools.Tag("office:document-content")) ; diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java index 01cd9372e387..7b816c529a32 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java @@ -111,7 +111,7 @@ public class XMLContentImporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam,PrintWriter log) throws StatusException { + (TestParameters tParam,PrintWriter log) throws Exception { XInterface oObj = null; Object oInt = null ; @@ -123,14 +123,8 @@ public class XMLContentImporter extends TestCase { XMultiServiceFactory xMSF = tParam.getMSF() ; - try { - oInt = xMSF.createInstance - ("com.sun.star.comp.Impress.XMLContentImporter") ; - - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLContentImporter") ; oObj = (XInterface) oInt ; diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.java index ed9968f50012..87a4f891e4aa 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.java @@ -117,7 +117,7 @@ public class XMLExporter extends TestCase { */ @Override protected synchronized TestEnvironment createTestEnvironment - (TestParameters tParam, PrintWriter log) { + (TestParameters tParam, PrintWriter log) throws Exception { XMultiServiceFactory xMSF = tParam.getMSF() ; XInterface oObj = null; @@ -127,25 +127,19 @@ public class XMLExporter extends TestCase { final String NAME = "XMLExporter"; - try { - oObj = (XInterface) xMSF.createInstanceWithArguments( - "com.sun.star.comp.Impress.XMLExporter", new Object[] {arg}); - - //get draw pages - XDrawPagesSupplier drawPagesSupplier = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); - XDrawPages drawPages = drawPagesSupplier.getDrawPages(); - //insert new draw page - XDrawPage newDrawPage = drawPages.insertNewByIndex(0); - //set specific test name - XNamed newPageNamed = UnoRuntime.queryInterface(XNamed.class, newDrawPage); - newPageNamed.setName(NAME); - XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); - xEx.setSourceDocument(xImpressDoc); - - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLExporter", new Object[] {arg}); + + //get draw pages + XDrawPagesSupplier drawPagesSupplier = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); + XDrawPages drawPages = drawPagesSupplier.getDrawPages(); + //insert new draw page + XDrawPage newDrawPage = drawPages.insertNewByIndex(0); + //set specific test name + XNamed newPageNamed = UnoRuntime.queryInterface(XNamed.class, newDrawPage); + newPageNamed.setName(NAME); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); // adding tags which must be contained in XML output Filter.addTag( new XMLTools.Tag("office:document") ); diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java index 06f104445cb1..5b76b9622cef 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java @@ -111,7 +111,7 @@ public class XMLImporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam, PrintWriter log) throws StatusException { + (TestParameters tParam, PrintWriter log) throws Exception { XInterface oObj = null; Object oInt = null ; @@ -122,13 +122,8 @@ public class XMLImporter extends TestCase { XMultiServiceFactory xMSF = tParam.getMSF() ; - try { - oInt = xMSF.createInstance - ("com.sun.star.comp.Impress.XMLImporter") ; - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLImporter") ; oObj = (XInterface) oInt ; diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java index faa13c1a45ab..9b010e69b3bd 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java @@ -115,7 +115,7 @@ public class XMLMetaExporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam, PrintWriter log) throws StatusException { + (TestParameters tParam, PrintWriter log) throws Exception { XMultiServiceFactory xMSF = tParam.getMSF() ; XInterface oObj = null; @@ -124,23 +124,17 @@ public class XMLMetaExporter extends TestCase { Any arg = new Any(new Type(XDocumentHandler.class), filter); final String NAME = "XMLMetaExporter"; - try { - oObj = (XInterface) xMSF.createInstanceWithArguments( - "com.sun.star.comp.Impress.XMLMetaExporter", - new Object[]{arg}); - XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); - xEx.setSourceDocument(xImpressDoc); - - // change title name - XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface - (XDocumentPropertiesSupplier.class, xImpressDoc); - final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); - xDocProps.setTitle(NAME); - - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLMetaExporter", + new Object[]{arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // change title name + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xImpressDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle(NAME); // Checking tags existence and changed property value filter.addTag(new XMLTools.Tag ("office:document-meta")); diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java index caaa7090339b..a9d840f3efd0 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java @@ -110,7 +110,7 @@ public class XMLMetaImporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam,PrintWriter log ) throws StatusException { + (TestParameters tParam,PrintWriter log ) throws Exception { XInterface oObj = null; Object oInt = null ; @@ -122,14 +122,8 @@ public class XMLMetaImporter extends TestCase { XMultiServiceFactory xMSF = tParam.getMSF() ; - try { - oInt = xMSF.createInstance - ("com.sun.star.comp.Impress.XMLMetaImporter") ; - - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLMetaImporter") ; oObj = (XInterface) oInt ; diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java index a317be770c9d..bab90b342d6c 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java @@ -113,7 +113,7 @@ public class XMLSettingsExporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam, PrintWriter log ) throws StatusException { + (TestParameters tParam, PrintWriter log ) throws Exception { XMultiServiceFactory xMSF = tParam.getMSF(); XInterface oObj = null; @@ -121,27 +121,21 @@ public class XMLSettingsExporter extends TestCase { Any arg = new Any(new Type(XDocumentHandler.class),filter); final boolean NewDataValue; - try { - oObj = (XInterface) xMSF.createInstanceWithArguments( - "com.sun.star.comp.Impress.XMLSettingsExporter", - new Object[] {arg}); - XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); - xEx.setSourceDocument(xImpressDoc); - - //set some settings - XModel xImpressModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); - XController xController = xImpressModel.getCurrentController(); - XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); - NewDataValue = ! ((Boolean) xPropSet.getPropertyValue - ("IsLayerMode")).booleanValue(); - xPropSet.setPropertyValue("IsLayerMode", - Boolean.valueOf(NewDataValue)); - - - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLSettingsExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + //set some settings + XModel xImpressModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + XController xController = xImpressModel.getCurrentController(); + XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + NewDataValue = ! ((Boolean) xPropSet.getPropertyValue + ("IsLayerMode")).booleanValue(); + xPropSet.setPropertyValue("IsLayerMode", + Boolean.valueOf(NewDataValue)); + // Adding tags for checking existence of head tag and other tags filter.addTagEnclosed(new XMLTools.Tag("office:settings"), diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java index a048a1a6bcfd..e370eb1a23a3 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java @@ -112,7 +112,7 @@ public class XMLSettingsImporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam, PrintWriter log ) throws StatusException { + (TestParameters tParam, PrintWriter log ) throws Exception { XInterface oObj = null; Object oInt = null ; @@ -123,14 +123,8 @@ public class XMLSettingsImporter extends TestCase { XMultiServiceFactory xMSF = tParam.getMSF() ; - try { - oInt = xMSF.createInstance - ("com.sun.star.comp.Impress.XMLSettingsImporter") ; - - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLSettingsImporter") ; oObj = (XInterface) oInt ; @@ -169,13 +163,8 @@ public class XMLSettingsImporter extends TestCase { XModel xImpressModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); XController xController = xImpressModel.getCurrentController(); final XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); - try { - log.println("Property \"IsLayerMode\" before import is " + - xPropSet.getPropertyValue("IsLayerMode")); - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log); - throw new StatusException("Can't create component.", e); - } + log.println("Property \"IsLayerMode\" before import is " + + xPropSet.getPropertyValue("IsLayerMode")); final PrintWriter logF = log; tEnv.addObjRelation("XDocumentHandler.ImportChecker", new ifc.xml.sax._XDocumentHandler.ImportChecker() { diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java index 5360e5dfc50e..803c7f431ae7 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java @@ -118,7 +118,7 @@ public class XMLStylesExporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam, PrintWriter log) throws StatusException { + (TestParameters tParam, PrintWriter log) throws Exception { SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); XMultiServiceFactory xMSF = tParam.getMSF() ; @@ -132,29 +132,23 @@ public class XMLStylesExporter extends TestCase { filter.addTag(new XMLTools.Tag("office:styles")); filter.addTag(new XMLTools.Tag("style:style","style:name", newName)); - try { - oObj = (XInterface) xMSF.createInstanceWithArguments( - "com.sun.star.comp.Impress.XMLStylesExporter", - new Object[] {arg}); - XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); - xEx.setSourceDocument(xImpressDoc); - - // Obtaining and changing property values - XStyleFamiliesSupplier styleSup = UnoRuntime.queryInterface - (XStyleFamiliesSupplier.class, xImpressDoc) ; - XNameAccess styleFamilies = styleSup.getStyleFamilies(); - String[] styleFamiliesNames = styleFamilies.getElementNames(); - XNameContainer StyleFamilyName = UnoRuntime.queryInterface(XNameContainer.class, - styleFamilies.getByName(styleFamiliesNames[0])); - Object SC = SOF.createInstance - (xImpressDoc, "com.sun.star.style.Style"); - XStyle StylePage = UnoRuntime.queryInterface(XStyle.class,SC); - StyleFamilyName.insertByName(newName, StylePage); - - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLStylesExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // Obtaining and changing property values + XStyleFamiliesSupplier styleSup = UnoRuntime.queryInterface + (XStyleFamiliesSupplier.class, xImpressDoc) ; + XNameAccess styleFamilies = styleSup.getStyleFamilies(); + String[] styleFamiliesNames = styleFamilies.getElementNames(); + XNameContainer StyleFamilyName = UnoRuntime.queryInterface(XNameContainer.class, + styleFamilies.getByName(styleFamiliesNames[0])); + Object SC = SOF.createInstance + (xImpressDoc, "com.sun.star.style.Style"); + XStyle StylePage = UnoRuntime.queryInterface(XStyle.class,SC); + StyleFamilyName.insertByName(newName, StylePage); // create testobject here log.println( "creating a new environment" ); diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java index 8cd1ff917fb1..d4f48b276a84 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java @@ -111,7 +111,7 @@ public class XMLStylesImporter extends TestCase { */ @Override public synchronized TestEnvironment createTestEnvironment - (TestParameters tParam, PrintWriter log ) throws StatusException { + (TestParameters tParam, PrintWriter log ) throws Exception { XInterface oObj = null; Object oInt = null ; @@ -123,14 +123,8 @@ public class XMLStylesImporter extends TestCase { XMultiServiceFactory xMSF = tParam.getMSF() ; - try { - oInt = xMSF.createInstance - ("com.sun.star.comp.Impress.XMLStylesImporter") ; - - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(log) ; - throw new StatusException("Can't create component.", e) ; - } + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLStylesImporter") ; oObj = (XInterface) oInt ; |