From 2a0dda3dfb37f0cb69842f7d569c253d82f53713 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 9 Jun 2015 08:52:12 +0200 Subject: 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 --- .../tests/java/mod/_cnt/ChaosContentProvider.java | 20 +++-------- .../tests/java/mod/_cnt/CntUnoDataContainer.java | 39 ++++++++-------------- .../java/mod/_cnt/PropertyMatcherFactory.java | 21 +++--------- 3 files changed, 22 insertions(+), 58 deletions(-) (limited to 'qadevOOo/tests/java/mod/_cnt') diff --git a/qadevOOo/tests/java/mod/_cnt/ChaosContentProvider.java b/qadevOOo/tests/java/mod/_cnt/ChaosContentProvider.java index b2f60ed1e265..3d8338077452 100644 --- a/qadevOOo/tests/java/mod/_cnt/ChaosContentProvider.java +++ b/qadevOOo/tests/java/mod/_cnt/ChaosContentProvider.java @@ -20,7 +20,6 @@ package mod._cnt; import java.io.PrintWriter; -import lib.StatusException; import lib.TestCase; import lib.TestEnvironment; import lib.TestParameters; @@ -66,24 +65,13 @@ public class ChaosContentProvider extends TestCase { @Override public TestEnvironment createTestEnvironment( TestParameters Param, PrintWriter log ) - throws StatusException { - XInterface oObj = null; - Object oInterface = null; + throws Exception { XMultiServiceFactory xMSF = Param.getMSF(); - Object cntFactory = null ; - - try { - oInterface = xMSF.createInstance + Object oInterface = xMSF.createInstance ( "com.sun.star.ucb.ChaosContentProvider" ); - cntFactory = xMSF.createInstance + Object cntFactory = xMSF.createInstance ( "com.sun.star.comp.ucb.UniversalContentBroker" ); - } - catch( com.sun.star.uno.Exception e ) { - log.println("Can't create an object." ); - throw new StatusException( "Can't create an object", e ); - } - - oObj = (XInterface) oInterface; + XInterface oObj = (XInterface) oInterface; TestEnvironment tEnv = new TestEnvironment( oObj ); diff --git a/qadevOOo/tests/java/mod/_cnt/CntUnoDataContainer.java b/qadevOOo/tests/java/mod/_cnt/CntUnoDataContainer.java index ee7aebf4e19b..8fc8cd0d9143 100644 --- a/qadevOOo/tests/java/mod/_cnt/CntUnoDataContainer.java +++ b/qadevOOo/tests/java/mod/_cnt/CntUnoDataContainer.java @@ -20,7 +20,6 @@ package mod._cnt; import java.io.PrintWriter; -import lib.StatusException; import lib.TestCase; import lib.TestEnvironment; import lib.TestParameters; @@ -79,37 +78,27 @@ public class CntUnoDataContainer extends TestCase { */ @Override protected TestEnvironment createTestEnvironment( - TestParameters Param, PrintWriter log) { - XInterface oObj = null; - Object oInterface = null; + TestParameters Param, PrintWriter log) throws Exception { XMultiServiceFactory xMSF = Param.getMSF(); - Object relationContainer = null ; - Object xIn = null; - try { - oInterface = xMSF.createInstance - ( "com.sun.star.ucb.DataContainer" ); + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.DataContainer" ); - // adding one child container - XIndexContainer xIC = UnoRuntime.queryInterface - (XIndexContainer.class, oInterface) ; + // adding one child container + XIndexContainer xIC = UnoRuntime.queryInterface + (XIndexContainer.class, oInterface) ; - Object child = xMSF.createInstance - ( "com.sun.star.ucb.DataContainer" ); - xIC.insertByIndex(0, child) ; + Object child = xMSF.createInstance + ( "com.sun.star.ucb.DataContainer" ); + xIC.insertByIndex(0, child) ; - relationContainer = xMSF.createInstance - ( "com.sun.star.ucb.DataContainer" ); + Object relationContainer = xMSF.createInstance + ( "com.sun.star.ucb.DataContainer" ); - xIn = xMSF.createInstance - ( "com.sun.star.io.DataInputStream" ); - } - catch( com.sun.star.uno.Exception e ) { - log.println("Can't create an object." ); - throw new StatusException( "Can't create an object", e ); - } + Object xIn = xMSF.createInstance + ( "com.sun.star.io.DataInputStream" ); - oObj = (XInterface) oInterface; + XInterface oObj = (XInterface) oInterface; TestEnvironment tEnv = new TestEnvironment( oObj ); diff --git a/qadevOOo/tests/java/mod/_cnt/PropertyMatcherFactory.java b/qadevOOo/tests/java/mod/_cnt/PropertyMatcherFactory.java index 61ada8c2acd5..93807fe5f486 100644 --- a/qadevOOo/tests/java/mod/_cnt/PropertyMatcherFactory.java +++ b/qadevOOo/tests/java/mod/_cnt/PropertyMatcherFactory.java @@ -20,7 +20,6 @@ package mod._cnt; import java.io.PrintWriter; -import lib.StatusException; import lib.TestCase; import lib.TestEnvironment; import lib.TestParameters; @@ -51,23 +50,11 @@ public class PropertyMatcherFactory extends TestCase { @Override public TestEnvironment createTestEnvironment( TestParameters Param, PrintWriter log ) - throws StatusException { - XInterface oObj = null; - Object oInterface = null; + throws Exception { XMultiServiceFactory xMSF = Param.getMSF(); - - - try { - oInterface = xMSF.createInstance - ( "com.sun.star.ucb.PropertyMatcherFactory" ); - - } - catch( com.sun.star.uno.Exception e ) { - log.println("Can't create an object." ); - throw new StatusException( "Can't create an object", e ); - } - - oObj = (XInterface) oInterface; + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.PropertyMatcherFactory" ); + XInterface oObj = (XInterface) oInterface; TestEnvironment tEnv = new TestEnvironment( oObj ); -- cgit