Kaydet (Commit) 0f2007b1 authored tarafından Noel Grandin's avatar Noel Grandin

more exception handling cleanup in Java unit tests

Change-Id: I8a826c1b31f99e8d1592f284094ff921ddac74ad
üst cc190ef2
...@@ -73,10 +73,6 @@ public class BridgeFactory extends TestCase { ...@@ -73,10 +73,6 @@ public class BridgeFactory extends TestCase {
XInterface oObj = (XInterface) Param.getMSF().createInstance XInterface oObj = (XInterface) Param.getMSF().createInstance
("com.sun.star.bridge.BridgeFactory") ; ("com.sun.star.bridge.BridgeFactory") ;
if (oObj == null)
throw new StatusException("Can't create service",
new NullPointerException());
TestEnvironment tEnv = new TestEnvironment(oObj) ; TestEnvironment tEnv = new TestEnvironment(oObj) ;
// select the port // select the port
......
...@@ -71,10 +71,6 @@ public class BridgeFactory extends TestCase { ...@@ -71,10 +71,6 @@ public class BridgeFactory extends TestCase {
Param.getMSF().createInstance Param.getMSF().createInstance
("com.sun.star.bridge.BridgeFactory") ; ("com.sun.star.bridge.BridgeFactory") ;
if (oObj == null)
throw new StatusException("Can't create service",
new NullPointerException());
TestEnvironment tEnv = new TestEnvironment(oObj) ; TestEnvironment tEnv = new TestEnvironment(oObj) ;
// select the port // select the port
......
...@@ -125,14 +125,9 @@ public class CachedContentResultSetFactory extends TestCase { ...@@ -125,14 +125,9 @@ public class CachedContentResultSetFactory extends TestCase {
(OpenMode.ALL, 10000, null, new Property[] {prop}, (OpenMode.ALL, 10000, null, new Property[] {prop},
new NumberedSortingInfo[0])) ; new NumberedSortingInfo[0])) ;
XDynamicResultSet dynResSet = null; XDynamicResultSet dynResSet = (XDynamicResultSet)
try { AnyConverter.toObject(new Type(XDynamicResultSet.class),
dynResSet = (XDynamicResultSet) cmdProc.execute(cmd, 0, null));
AnyConverter.toObject(new Type(XDynamicResultSet.class),
cmdProc.execute(cmd, 0, null));
} catch (com.sun.star.lang.IllegalArgumentException iae) {
throw new StatusException("Couldn't convert Any ",iae);
}
XResultSet resSet = dynResSet.getStaticResultSet() ; XResultSet resSet = dynResSet.getStaticResultSet() ;
......
...@@ -124,14 +124,9 @@ public class CachedContentResultSetStubFactory extends TestCase { ...@@ -124,14 +124,9 @@ public class CachedContentResultSetStubFactory extends TestCase {
(OpenMode.ALL, 10000, null, new Property[] {prop}, (OpenMode.ALL, 10000, null, new Property[] {prop},
new NumberedSortingInfo[0])) ; new NumberedSortingInfo[0])) ;
XDynamicResultSet dynResSet = null; XDynamicResultSet dynResSet = (XDynamicResultSet)
try { AnyConverter.toObject(new Type(XDynamicResultSet.class),
dynResSet = (XDynamicResultSet) cmdProc.execute(cmd, 0, null));
AnyConverter.toObject(new Type(XDynamicResultSet.class),
cmdProc.execute(cmd, 0, null));
} catch (com.sun.star.lang.IllegalArgumentException iae) {
throw new StatusException("Couldn't convert Any ",iae);
}
resSet = dynResSet.getStaticResultSet() ; resSet = dynResSet.getStaticResultSet() ;
......
...@@ -179,55 +179,34 @@ public class OQueryDesign extends TestCase { ...@@ -179,55 +179,34 @@ public class OQueryDesign extends TestCase {
} // finish method getTestEnvironment } // finish method getTestEnvironment
private XInitialization getUnititializedObj(TestParameters Param){ private XInitialization getUnititializedObj(TestParameters Param) throws Exception {
// creating an object which ist not initialized // creating an object which ist not initialized
// get a model of a DataSource // get a model of a DataSource
Object oDBC = null; Object oDBC = null;
XMultiServiceFactory xMSF; XMultiServiceFactory xMSF;
try { xMSF = Param.getMSF();
xMSF = Param.getMSF(); oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" );
oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" );
}
catch( com.sun.star.uno.Exception e ) {
throw new StatusException("Could not instantiate DatabaseContext", e) ;
}
Object oDataSource = null; Object oDataSource = null;
try{ XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oDBC);
XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oDBC); oDataSource = xNA.getByName(sDataSourceName);
oDataSource = xNA.getByName(sDataSourceName);
} catch ( com.sun.star.container.NoSuchElementException e){
throw new StatusException("could not get '" + sDataSourceName + "'" , e) ;
} catch ( com.sun.star.lang.WrappedTargetException e){
throw new StatusException("could not get '" + sDataSourceName + "'" , e) ;
}
XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource);
XModel xMod = UnoRuntime.queryInterface(XModel.class, xDDS.getDatabaseDocument ()); XModel xMod = UnoRuntime.queryInterface(XModel.class, xDDS.getDatabaseDocument ());
// get an intaces of QueryDesign // get an intaces of QueryDesign
Object oQueryDesign = null; Object oQueryDesign = xMSF.createInstance("com.sun.star.sdb.QueryDesign");
try{
oQueryDesign = xMSF.createInstance("com.sun.star.sdb.QueryDesign");
}catch( com.sun.star.uno.Exception e ) {
throw new StatusException("Could not instantiate QueryDesign", e) ;
}
XController xCont = UnoRuntime.queryInterface(XController.class, oQueryDesign); XController xCont = UnoRuntime.queryInterface(XController.class, oQueryDesign);
// marry them all // marry them all
xCont.attachModel(xMod); xCont.attachModel(xMod);
xMod.connectController(xCont); xMod.connectController(xCont);
try{ xMod.setCurrentController(xCont);
xMod.setCurrentController(xCont);
} catch (com.sun.star.container.NoSuchElementException e){
throw new StatusException("Could not set controller", e) ;
}
return UnoRuntime.queryInterface(XInitialization.class, oQueryDesign); return UnoRuntime.queryInterface(XInitialization.class, oQueryDesign);
} }
@Override @Override
......
...@@ -395,7 +395,7 @@ public class SbaXGridControl extends TestCase { ...@@ -395,7 +395,7 @@ public class SbaXGridControl extends TestCase {
} // finish method getTestEnvironment } // finish method getTestEnvironment
public static XControlShape createGrid(XComponent oDoc, int height, public static XControlShape createGrid(XComponent oDoc, int height,
int width, int x, int y) { int width, int x, int y) throws Exception {
Size size = new Size(); Size size = new Size();
Point position = new Point(); Point position = new Point();
XControlShape oCShape = null; XControlShape oCShape = null;
...@@ -406,30 +406,24 @@ public class SbaXGridControl extends TestCase { ...@@ -406,30 +406,24 @@ public class SbaXGridControl extends TestCase {
XMultiServiceFactory.class, XMultiServiceFactory.class,
oDoc); oDoc);
try { Object oInt = oDocMSF.createInstance(
Object oInt = oDocMSF.createInstance( "com.sun.star.drawing.ControlShape");
"com.sun.star.drawing.ControlShape"); Object aCon = oDocMSF.createInstance(
Object aCon = oDocMSF.createInstance( "com.sun.star.form.component.GridControl");
"com.sun.star.form.component.GridControl"); XPropertySet model_props = UnoRuntime.queryInterface(
XPropertySet model_props = UnoRuntime.queryInterface( XPropertySet.class, aCon);
XPropertySet.class, aCon); model_props.setPropertyValue("DefaultControl",
model_props.setPropertyValue("DefaultControl", "com.sun.star.form.control.InteractionGridControl");
"com.sun.star.form.control.InteractionGridControl"); aControl = UnoRuntime.queryInterface(
aControl = UnoRuntime.queryInterface( XControlModel.class, aCon);
XControlModel.class, aCon); oCShape = UnoRuntime.queryInterface(
oCShape = UnoRuntime.queryInterface( XControlShape.class, oInt);
XControlShape.class, oInt); size.Height = height;
size.Height = height; size.Width = width;
size.Width = width; position.X = x;
position.X = x; position.Y = y;
position.Y = y; oCShape.setSize(size);
oCShape.setSize(size); oCShape.setPosition(position);
oCShape.setPosition(position);
} catch (com.sun.star.uno.Exception e) {
// Some exception occurs.FAILED
System.out.println("Couldn't create Grid" + e);
throw new StatusException("Couldn't create Grid", e);
}
oCShape.setControl(aControl); oCShape.setControl(aControl);
......
...@@ -132,7 +132,7 @@ public class NestedRegistry extends TestCase { ...@@ -132,7 +132,7 @@ public class NestedRegistry extends TestCase {
@Override @Override
public TestEnvironment createTestEnvironment( TestParameters Param, public TestEnvironment createTestEnvironment( TestParameters Param,
PrintWriter log ) PrintWriter log )
throws StatusException { throws Exception {
XInterface oObj = null; XInterface oObj = null;
Object oInterface = null; Object oInterface = null;
...@@ -144,15 +144,9 @@ public class NestedRegistry extends TestCase { ...@@ -144,15 +144,9 @@ public class NestedRegistry extends TestCase {
uniq++ ; uniq++ ;
log.println("creating copies of the registry for XSimpleRegistry"); log.println("creating copies of the registry for XSimpleRegistry");
try { String source = utils.getFullTestDocName("XSimpleRegistry.rdb");
String source = utils.getFullTestDocName("XSimpleRegistry.rdb"); copyFile(source, openF, log) ;
copyFile(source, openF, log) ; copyFile(source, mergeF, log) ;
copyFile(source, mergeF, log) ;
} catch (java.io.IOException e) {
log.println("Exception occurred while copying files");
e.printStackTrace(log);
throw new StatusException("Exception occurred while copying files", e);
}
try { try {
XMultiServiceFactory xMSF = Param.getMSF(); XMultiServiceFactory xMSF = Param.getMSF();
......
...@@ -481,13 +481,7 @@ public class ODatabaseForm extends TestCase { ...@@ -481,13 +481,7 @@ public class ODatabaseForm extends TestCase {
XResultSet the_set = UnoRuntime.queryInterface( XResultSet the_set = UnoRuntime.queryInterface(
XResultSet.class, oObj); XResultSet.class, oObj);
try { the_set.first();
the_set.first();
} catch (SQLException e) {
log.println("Cann't move cursor to the first row.");
e.printStackTrace();
throw new StatusException("Can't move cursor to the first row.", e);
}
tEnv.addObjRelation("Model1", shape1.getControl()); tEnv.addObjRelation("Model1", shape1.getControl());
tEnv.addObjRelation("Model2", shape2.getControl()); tEnv.addObjRelation("Model2", shape2.getControl());
......
...@@ -67,11 +67,6 @@ public class ContentHandlerFactory extends TestCase { ...@@ -67,11 +67,6 @@ public class ContentHandlerFactory extends TestCase {
oInterface = Param.getMSF().createInstance oInterface = Param.getMSF().createInstance
("com.sun.star.frame.ContentHandlerFactory") ; ("com.sun.star.frame.ContentHandlerFactory") ;
if (oInterface == null) {
log.println("Service wasn't created") ;
throw new StatusException(Status.failed("Service wasn't created")) ;
}
oObj = (XInterface) oInterface ; oObj = (XInterface) oInterface ;
log.println("ImplName: "+utils.getImplName(oObj)); log.println("ImplName: "+utils.getImplName(oObj));
......
...@@ -67,17 +67,10 @@ public class Thesaurus extends TestCase { ...@@ -67,17 +67,10 @@ public class Thesaurus extends TestCase {
*/ */
@Override @Override
protected TestEnvironment createTestEnvironment protected TestEnvironment createTestEnvironment
(TestParameters tParam, PrintWriter log) { (TestParameters tParam, PrintWriter log) throws Exception {
XMultiServiceFactory xMSF = tParam.getMSF(); XMultiServiceFactory xMSF = tParam.getMSF();
XInterface oObj = null; XInterface oObj = (XInterface)xMSF.createInstance
try {
oObj = (XInterface)xMSF.createInstance
("com.sun.star.linguistic2.Thesaurus"); ("com.sun.star.linguistic2.Thesaurus");
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log);
throw new StatusException("Unexpected exception", e);
}
String Iname = util.utils.getImplName(oObj); String Iname = util.utils.getImplName(oObj);
log.println("Implementation Name: "+Iname); log.println("Implementation Name: "+Iname);
......
...@@ -115,13 +115,8 @@ public class ScAccessibleCell extends TestCase { ...@@ -115,13 +115,8 @@ public class ScAccessibleCell extends TestCase {
try { try {
XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ;
XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
XSpreadsheet oSheet = null; XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
try { new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
oSheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
} catch (com.sun.star.lang.IllegalArgumentException iae) {
throw new StatusException("couldn't get sheet",iae);
}
xCell = oSheet.getCellByPosition(1, 0) ; xCell = oSheet.getCellByPosition(1, 0) ;
xCell.setFormula(text); xCell.setFormula(text);
XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, oSheet); XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, oSheet);
......
...@@ -95,13 +95,8 @@ public class ScAccessiblePageHeader extends TestCase { ...@@ -95,13 +95,8 @@ public class ScAccessiblePageHeader extends TestCase {
try { try {
XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ;
XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
XSpreadsheet oSheet = null; XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
try { new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
oSheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
} catch (com.sun.star.lang.IllegalArgumentException iae) {
throw new StatusException("couldn't get sheet",iae);
}
xCell = oSheet.getCellByPosition(0, 0) ; xCell = oSheet.getCellByPosition(0, 0) ;
xCell.setFormula("ScAccessiblePageHeader"); xCell.setFormula("ScAccessiblePageHeader");
} catch(com.sun.star.lang.WrappedTargetException e) { } catch(com.sun.star.lang.WrappedTargetException e) {
......
...@@ -106,45 +106,39 @@ public class ScAutoFormatsObj extends TestCase{ ...@@ -106,45 +106,39 @@ public class ScAutoFormatsObj extends TestCase{
@Override @Override
public TestEnvironment createTestEnvironment public TestEnvironment createTestEnvironment
(TestParameters Param, PrintWriter log ) (TestParameters Param, PrintWriter log )
throws StatusException { throws Exception {
XInterface oObj = null; XInterface oObj = null;
try { // creation of testobject here
// creation of testobject here // get AutoFormats
// get AutoFormats XComponent xComp = UnoRuntime.queryInterface
XComponent xComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc);
(XComponent.class, xSheetDoc); oObj = (XInterface) AnyConverter.toObject(
oObj = (XInterface) AnyConverter.toObject( new Type(XInterface.class),Param.getMSF().createInstance
new Type(XInterface.class),Param.getMSF().createInstance ("com.sun.star.sheet.TableAutoFormats"));
("com.sun.star.sheet.TableAutoFormats")); Object secondInstance = SOF.createInstance
Object secondInstance = SOF.createInstance (xComp, "com.sun.star.sheet.TableAutoFormat");
(xComp, "com.sun.star.sheet.TableAutoFormat");
TestEnvironment tEnv = new TestEnvironment(oObj) ;
TestEnvironment tEnv = new TestEnvironment(oObj) ;
//adding ObjRelation for XNameContainer
//adding ObjRelation for XNameContainer tEnv.addObjRelation("SecondInstance",secondInstance);
tEnv.addObjRelation("SecondInstance",secondInstance);
// INSTANCEn : _XNameContainer; _XNameReplace
// INSTANCEn : _XNameContainer; _XNameReplace log.println( "adding INSTANCEn as mod relation to environment" );
log.println( "adding INSTANCEn as mod relation to environment" ); int THRCNT = 1;
int THRCNT = 1; if ((String)Param.get("THRCNT") != null) {
if ((String)Param.get("THRCNT") != null) { Integer.parseInt((String)Param.get("THRCNT"));
Integer.parseInt((String)Param.get("THRCNT")); }
} for (int n = 1; n < (THRCNT+1) ;n++ ) {
for (int n = 1; n < (THRCNT+1) ;n++ ) { log.println( "adding INSTANCE" + n
log.println( "adding INSTANCE" + n +" as mod relation to environment" );
+" as mod relation to environment" ); tEnv.addObjRelation("INSTANCE" + n, SOF.createInstance(xComp,
tEnv.addObjRelation("INSTANCE" + n, SOF.createInstance(xComp, "com.sun.star.sheet.TableAutoFormat"));
"com.sun.star.sheet.TableAutoFormat"));
}
return tEnv;
} catch (com.sun.star.uno.Exception e) {
log.println ("Exception occurred while creating test Object.");
e.printStackTrace(log);
throw new StatusException("Couldn't create test object", e);
} }
return tEnv;
} }
} // finish class ScAutoFormatsObj } // finish class ScAutoFormatsObj
......
...@@ -201,27 +201,12 @@ public class ScChartObj extends TestCase { ...@@ -201,27 +201,12 @@ public class ScChartObj extends TestCase {
// get the TableChart // get the TableChart
XTableChart oChart = null; XTableChart oChart = null;
try { XNameAccess names = (XNameAccess) AnyConverter.toObject(
XNameAccess names = (XNameAccess) AnyConverter.toObject( new Type(XNameAccess.class),UnoRuntime.queryInterface(
new Type(XNameAccess.class),UnoRuntime.queryInterface( XNameAccess.class, oCharts));
XNameAccess.class, oCharts));
oChart = (XTableChart) AnyConverter.toObject(
oChart = (XTableChart) AnyConverter.toObject( new Type(XTableChart.class),names.getByName("ScChartObj"));
new Type(XTableChart.class),names.getByName("ScChartObj"));
} catch (com.sun.star.lang.WrappedTargetException e) {
log.println("Couldn't get TableChart");
e.printStackTrace(log);
throw new StatusException("Couldn't get TableChart", e);
} catch (com.sun.star.container.NoSuchElementException e) {
log.println("Couldn't get TableChart");
e.printStackTrace(log);
throw new StatusException("Couldn't get TableChart", e);
} catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("Couldn't get TableChart");
e.printStackTrace(log);
throw new StatusException("Couldn't get TableChart", e);
}
log.println("creating a new environment for object"); log.println("creating a new environment for object");
TestEnvironment tEnv = new TestEnvironment(oChart); TestEnvironment tEnv = new TestEnvironment(oChart);
......
...@@ -40,6 +40,7 @@ import com.sun.star.sheet.XSpreadsheets; ...@@ -40,6 +40,7 @@ import com.sun.star.sheet.XSpreadsheets;
import com.sun.star.table.CellAddress; import com.sun.star.table.CellAddress;
import com.sun.star.table.CellRangeAddress; import com.sun.star.table.CellRangeAddress;
import com.sun.star.uno.AnyConverter; import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Exception;
import com.sun.star.uno.Type; import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
...@@ -229,7 +230,7 @@ public class ScDataPilotTableObj extends TestCase { ...@@ -229,7 +230,7 @@ public class ScDataPilotTableObj extends TestCase {
* @param srcRange source range * @param srcRange source range
* @param tEnv test environment instance * @param tEnv test environment instance
*/ */
private void createTable2(XSpreadsheet oSheet, CellRangeAddress srcRange, TestEnvironment tEnv) private void createTable2(XSpreadsheet oSheet, CellRangeAddress srcRange, TestEnvironment tEnv) throws Exception
{ {
XDataPilotTablesSupplier DPTS = UnoRuntime.queryInterface(XDataPilotTablesSupplier.class, oSheet); XDataPilotTablesSupplier DPTS = UnoRuntime.queryInterface(XDataPilotTablesSupplier.class, oSheet);
log.println("Creating test table object"); log.println("Creating test table object");
...@@ -239,53 +240,45 @@ public class ScDataPilotTableObj extends TestCase { ...@@ -239,53 +240,45 @@ public class ScDataPilotTableObj extends TestCase {
XIndexAccess xIA = DPDsc.getDataPilotFields(); XIndexAccess xIA = DPDsc.getDataPilotFields();
int fieldCount = xIA.getCount() - 1; // skip the last field because it's always hidden. int fieldCount = xIA.getCount() - 1; // skip the last field because it's always hidden.
try for (int i = 0; i < fieldCount; ++i)
{ {
for (int i = 0; i < fieldCount; ++i) Object o = xIA.getByIndex(i);
XPropertySet fieldPropSet = UnoRuntime.queryInterface(
XPropertySet.class, o);
if (i == fieldCount - 1)
{
// last field
fieldPropSet.setPropertyValue(
"Function", com.sun.star.sheet.GeneralFunction.SUM);
fieldPropSet.setPropertyValue(
"Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA);
}
else if (i%2 == 0)
{
// even number fields
fieldPropSet.setPropertyValue(
"Orientation", com.sun.star.sheet.DataPilotFieldOrientation.COLUMN);
}
else if (i%2 == 1)
{ {
Object o = xIA.getByIndex(i); // odd number fields
XPropertySet fieldPropSet = UnoRuntime.queryInterface( fieldPropSet.setPropertyValue(
XPropertySet.class, o); "Orientation", com.sun.star.sheet.DataPilotFieldOrientation.ROW);
if (i == fieldCount - 1)
{
// last field
fieldPropSet.setPropertyValue(
"Function", com.sun.star.sheet.GeneralFunction.SUM);
fieldPropSet.setPropertyValue(
"Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA);
}
else if (i%2 == 0)
{
// even number fields
fieldPropSet.setPropertyValue(
"Orientation", com.sun.star.sheet.DataPilotFieldOrientation.COLUMN);
}
else if (i%2 == 1)
{
// odd number fields
fieldPropSet.setPropertyValue(
"Orientation", com.sun.star.sheet.DataPilotFieldOrientation.ROW);
}
} }
}
if (DPT.hasByName("DataPilotTable2")) if (DPT.hasByName("DataPilotTable2"))
DPT.removeByName("DataPilotTable2"); DPT.removeByName("DataPilotTable2");
CellAddress destAddr = new CellAddress(); CellAddress destAddr = new CellAddress();
destAddr.Sheet = 0; destAddr.Sheet = 0;
destAddr.Column = 0; destAddr.Column = 0;
destAddr.Row = 14; destAddr.Row = 14;
DPT.insertNewByName("DataPilotTable2", destAddr, DPDsc); DPT.insertNewByName("DataPilotTable2", destAddr, DPDsc);
Object o = DPT.getByName("DataPilotTable2"); Object o = DPT.getByName("DataPilotTable2");
tEnv.addObjRelation("DATAPILOTTABLE2", o); tEnv.addObjRelation("DATAPILOTTABLE2", o);
}
catch (com.sun.star.uno.Exception e)
{
e.printStackTrace(log);
throw new StatusException("Couldn't create a test environment", e);
}
} }
} }
......
...@@ -33,6 +33,7 @@ import com.sun.star.sheet.XDatabaseRanges; ...@@ -33,6 +33,7 @@ import com.sun.star.sheet.XDatabaseRanges;
import com.sun.star.sheet.XSpreadsheetDocument; import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.table.CellRangeAddress; import com.sun.star.table.CellRangeAddress;
import com.sun.star.uno.AnyConverter; import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Exception;
import com.sun.star.uno.Type; import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
...@@ -70,7 +71,7 @@ public class ScIndexEnumeration_DatabaseRangesEnumeration extends TestCase { ...@@ -70,7 +71,7 @@ public class ScIndexEnumeration_DatabaseRangesEnumeration extends TestCase {
} }
@Override @Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
XInterface oObj = null; XInterface oObj = null;
...@@ -81,24 +82,9 @@ public class ScIndexEnumeration_DatabaseRangesEnumeration extends TestCase { ...@@ -81,24 +82,9 @@ public class ScIndexEnumeration_DatabaseRangesEnumeration extends TestCase {
log.println("Getting test object ") ; log.println("Getting test object ") ;
XPropertySet docProps = UnoRuntime.queryInterface(XPropertySet.class, xSheetDoc); XPropertySet docProps = UnoRuntime.queryInterface(XPropertySet.class, xSheetDoc);
XDatabaseRanges dbRanges = null; XDatabaseRanges dbRanges = (XDatabaseRanges) AnyConverter.toObject(
try { new Type(XDatabaseRanges.class),
dbRanges = (XDatabaseRanges) AnyConverter.toObject( docProps.getPropertyValue("DatabaseRanges"));
new Type(XDatabaseRanges.class),
docProps.getPropertyValue("DatabaseRanges"));
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log) ;
throw new StatusException(
"Error getting test object from spreadsheet document",e) ;
} catch (com.sun.star.beans.UnknownPropertyException e) {
e.printStackTrace(log) ;
throw new StatusException(
"Error getting test object from spreadsheet document",e) ;
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log) ;
throw new StatusException(
"Error getting test object from spreadsheet document",e) ;
}
log.println("Adding at least one element for ElementAccess interface"); log.println("Adding at least one element for ElementAccess interface");
CellRangeAddress aRange = new CellRangeAddress((short)0, 2, 4, 5, 6); CellRangeAddress aRange = new CellRangeAddress((short)0, 2, 4, 5, 6);
......
...@@ -67,11 +67,6 @@ public class AppDispatchProvider extends TestCase { ...@@ -67,11 +67,6 @@ public class AppDispatchProvider extends TestCase {
oInterface = Param.getMSF().createInstance oInterface = Param.getMSF().createInstance
("com.sun.star.comp.sfx2.AppDispatchProvider") ; ("com.sun.star.comp.sfx2.AppDispatchProvider") ;
if (oInterface == null) {
log.println("Service wasn't created") ;
throw new StatusException(Status.failed("Service wasn't created")) ;
}
oObj = (XInterface) oInterface ; oObj = (XInterface) oInterface ;
System.out.println("ImplName: "+utils.getImplName(oObj)); System.out.println("ImplName: "+utils.getImplName(oObj));
dbg.printInterfaces(oObj); dbg.printInterfaces(oObj);
......
...@@ -33,6 +33,7 @@ import com.sun.star.ucb.XContentIdentifier; ...@@ -33,6 +33,7 @@ import com.sun.star.ucb.XContentIdentifier;
import com.sun.star.ucb.XContentIdentifierFactory; import com.sun.star.ucb.XContentIdentifierFactory;
import com.sun.star.ucb.XContentProvider; import com.sun.star.ucb.XContentProvider;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import util.WriterTools; import util.WriterTools;
import org.junit.After; import org.junit.After;
...@@ -41,6 +42,7 @@ import org.junit.Before; ...@@ -41,6 +42,7 @@ import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection; import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
...@@ -145,7 +147,7 @@ public class CheckContentProvider { ...@@ -145,7 +147,7 @@ public class CheckContentProvider {
/** /**
* Check the interfaces of the root. * Check the interfaces of the root.
*/ */
@Test public void checkTDOCRootInterfaces() { @Test public void checkTDOCRootInterfaces() throws Exception {
checkInterfaces(false); checkInterfaces(false);
} }
...@@ -179,7 +181,7 @@ public class CheckContentProvider { ...@@ -179,7 +181,7 @@ public class CheckContentProvider {
/** /**
* Check the interfaces on the document. * Check the interfaces on the document.
*/ */
@Test public void checkTDOCDocumentInterfaces() { @Test public void checkTDOCDocumentInterfaces() throws Exception {
checkInterfaces(true); checkInterfaces(true);
} }
...@@ -214,7 +216,7 @@ public class CheckContentProvider { ...@@ -214,7 +216,7 @@ public class CheckContentProvider {
/** /**
* Check the interfaces on the folder. * Check the interfaces on the folder.
*/ */
@Test public void checkTDOCFolderInterfaces() { @Test public void checkTDOCFolderInterfaces() throws Exception {
checkInterfaces(true); checkInterfaces(true);
} }
...@@ -249,7 +251,7 @@ public class CheckContentProvider { ...@@ -249,7 +251,7 @@ public class CheckContentProvider {
/** /**
* Check the interfaces on the stream. * Check the interfaces on the stream.
*/ */
@Test public void checkTDOCStreamInterfaces() { @Test public void checkTDOCStreamInterfaces() throws Exception {
checkInterfaces(true); checkInterfaces(true);
} }
...@@ -272,7 +274,7 @@ public class CheckContentProvider { ...@@ -272,7 +274,7 @@ public class CheckContentProvider {
* @param hasParent True, if the tested content type does have a parent: * @param hasParent True, if the tested content type does have a parent:
* only the root has not. Used in the XChild interface test. * only the root has not. Used in the XChild interface test.
*/ */
private void checkInterfaces(boolean hasParent) { private void checkInterfaces(boolean hasParent) throws Exception {
// check the XTypeProvider interface // check the XTypeProvider interface
_XTypeProvider xTypeProvider = new _XTypeProvider(); _XTypeProvider xTypeProvider = new _XTypeProvider();
_XTypeProvider.oObj = UnoRuntime.queryInterface(XTypeProvider.class, xContent); _XTypeProvider.oObj = UnoRuntime.queryInterface(XTypeProvider.class, xContent);
......
...@@ -108,13 +108,13 @@ public class _XCommandProcessor { ...@@ -108,13 +108,13 @@ public class _XCommandProcessor {
/** /**
* First executes 'geCommandInfo' command and examines returned * First executes 'geCommandInfo' command and examines returned
* command info information. Second tries to execute inproper * command info information. Second tries to execute in proper
* command. <p> * command. <p>
* Has <b> OK </b> status if in the first case returned information * Has <b> OK </b> status if in the first case returned information
* contains info about 'getCommandInfo' command and in the second * contains info about 'getCommandInfo' command and in the second
* case an exception is thrown. <p> * case an exception is thrown. <p>
*/ */
public boolean _execute() { public boolean _execute() throws Exception {
String[]commands = new String[] {"getCommandInfo", "getPropertySetInfo"}; String[]commands = new String[] {"getCommandInfo", "getPropertySetInfo"};
boolean returnVal = true; boolean returnVal = true;
for (int j=0; j<commands.length; j++) { for (int j=0; j<commands.length; j++) {
...@@ -124,17 +124,7 @@ public class _XCommandProcessor { ...@@ -124,17 +124,7 @@ public class _XCommandProcessor {
Object result; Object result;
log.println("executing command " + commandName); log.println("executing command " + commandName);
try { result = oObj.execute(command, 0, null);
result = oObj.execute(command, 0, null);
} catch (CommandAbortedException e) {
log.println("The command aborted " + e.getMessage());
e.printStackTrace((java.io.PrintWriter)log);
throw new StatusException("Unexpected exception", e);
} catch (Exception e) {
log.println("Unexpected exception " + e.getMessage());
e.printStackTrace((java.io.PrintWriter)log);
throw new StatusException("Unexpected exception", e);
}
boolean found = false; boolean found = false;
......
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