diff options
Diffstat (limited to 'qadevOOo/tests/java/ifc/configuration')
12 files changed, 2049 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/configuration/_XTemplateContainer.java b/qadevOOo/tests/java/ifc/configuration/_XTemplateContainer.java new file mode 100644 index 000000000..6c000f23f --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/_XTemplateContainer.java @@ -0,0 +1,41 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.configuration; + +import com.sun.star.configuration.XTemplateContainer; +import lib.MultiMethodTest; + + +public class _XTemplateContainer extends MultiMethodTest { + + public XTemplateContainer oObj; + + public void _getElementTemplateName() { + String tName = (String) tEnv.getObjRelation("TemplateName"); + String oTName = oObj.getElementTemplateName(); + log.println("TemplateName: "+oTName); + boolean res = oTName.equals(tName); + if (!res) { + log.println("Expected: "+tName); + log.println("Gained: "+oTName); + } + tRes.tested("getElementTemplateName()", res); + } + +} diff --git a/qadevOOo/tests/java/ifc/configuration/_XTemplateInstance.java b/qadevOOo/tests/java/ifc/configuration/_XTemplateInstance.java new file mode 100644 index 000000000..fac45c493 --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/_XTemplateInstance.java @@ -0,0 +1,41 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.configuration; + +import com.sun.star.configuration.XTemplateInstance; +import lib.MultiMethodTest; + + +public class _XTemplateInstance extends MultiMethodTest { + + public XTemplateInstance oObj; + + + public void _getTemplateName() { + String expected = (String) tEnv.getObjRelation("TemplateInstance"); + String getting = oObj.getTemplateName(); + boolean res = getting.equals(expected); + if (!res) { + log.println("Expected: "+expected); + log.println("Getting: "+getting); + } + tRes.tested("getTemplateName()",res); + } + +} diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XBackend.java b/qadevOOo/tests/java/ifc/configuration/backend/_XBackend.java new file mode 100644 index 000000000..eb8a09cc6 --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XBackend.java @@ -0,0 +1,250 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XBackend; +import com.sun.star.configuration.backend.XLayer; +import com.sun.star.configuration.backend.XUpdateHandler; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XStringSubstitution; + +import lib.MultiMethodTest; + +import util.XLayerHandlerImpl; + + +public class _XBackend extends MultiMethodTest { + public XBackend oObj; + + public void _getOwnUpdateHandler() { + boolean res = true; + + String noUpdate = (String) tEnv.getObjRelation("noUpdate"); + + if (noUpdate != null) { + log.println(noUpdate); + tRes.tested("getOwnUpdateHandler()", res); + + return; + } + + try { + XUpdateHandler aHandler = oObj.getOwnUpdateHandler( + "org.openoffice.Office.Linguistic"); + res &= (aHandler != null); + + if (aHandler == null) { + log.println("\treturned Layer is NULL -- FAILED"); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } + + tRes.tested("getOwnUpdateHandler()", res); + } + + public void _getUpdateHandler() { + boolean res = true; + + String noUpdate = (String) tEnv.getObjRelation("noUpdate"); + + if (noUpdate != null) { + log.println(noUpdate); + tRes.tested("getUpdateHandler()", res); + + return; + } + + try { + oObj.getUpdateHandler( + "org.openoffice.Office.TypeDetection", + "illegal"); + log.println("Exception expected -- FAILED"); + res = false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("expected Exception -- OK"); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } + + try { + XStringSubstitution sts = createStringSubstitution( + tParam.getMSF()); + String ent = sts.getSubstituteVariableValue("$(inst)") + + "/share/registry"; + XUpdateHandler aHandler = oObj.getUpdateHandler( + "org.openoffice.Office.Jobs", + ent); + + if (aHandler == null) { + log.println("\treturned Layer is NULL -- FAILED"); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.uno.Exception e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } + + tRes.tested("getUpdateHandler()", res); + } + + public void _listLayers() { + boolean res = true; + + try { + XStringSubstitution sts = createStringSubstitution(tParam.getMSF()); + String ent = sts.getSubstituteVariableValue("$(inst)") + + "/share/registry"; + XLayer[] Layers = oObj.listLayers( + "org.openoffice.Office.Linguistic", ent); + + for (int i = 0; i < Layers.length; i++) { + log.println("Checking Layer " + i); + res &= checkLayer(Layers[i]); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.uno.Exception e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } + + tRes.tested("listLayers()", res); + } + + public void _listOwnLayers() { + boolean res = true; + + try { + XLayer[] Layers = oObj.listOwnLayers( + "org.openoffice.Office.Common"); + + for (int i = 0; i < Layers.length; i++) { + log.println("Checking Layer " + i); + res &= checkLayer(Layers[i]); + } + if (Layers.length==0) { + System.out.println("No Layers found -- FAILED"); + res &= false; + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } + + tRes.tested("listOwnLayers()", res); + } + + protected boolean checkLayer(XLayer aLayer) { + boolean res = false; + + log.println("Checking for Exception in case of null argument"); + + try { + aLayer.readData(null); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } + + log.println("checking read data with own XLayerHandler implementation"); + + try { + XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl(); + aLayer.readData(xLayerHandler); + + String implCalled = xLayerHandler.getCalls(); + log.println(implCalled); + + int sl = implCalled.indexOf("startLayer"); + + if (sl < 0) { + log.println("startLayer wasn't called -- FAILED"); + res &= false; + } else { + log.println("startLayer was called -- OK"); + res &= true; + } + + int el = implCalled.indexOf("endLayer"); + + if (el < 0) { + log.println("endLayer wasn't called -- FAILED"); + res &= false; + } else { + log.println("endLayer was called -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + return res; + } + + public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF) throws com.sun.star.uno.Exception + { + Object xPathSubst = xMSF.createInstance( + "com.sun.star.util.PathSubstitution"); + return UnoRuntime.queryInterface(XStringSubstitution.class, xPathSubst); + } +} diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XBackendEntities.java b/qadevOOo/tests/java/ifc/configuration/backend/_XBackendEntities.java new file mode 100644 index 000000000..5ed64c292 --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XBackendEntities.java @@ -0,0 +1,173 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XBackendEntities; + +import lib.MultiMethodTest; + + +public class _XBackendEntities extends MultiMethodTest { + String AdminEntity = ""; + String OwnerEntity = ""; + String adm = ""; + public XBackendEntities oObj; + + @Override + public void before() { + adm = (String) tEnv.getObjRelation("NoAdmin"); + } + + public void _getAdminEntity() { + if (adm != null) { + AdminEntity = adm; + log.println( + "This component doesn't have an AdminEntity, setting it to default"); + tRes.tested("getAdminEntity()", true); + + return; + } + + AdminEntity = oObj.getAdminEntity(); + + boolean res = AdminEntity.endsWith("/share/registry"); + + if (!res) { + log.println("Expected the Entity to end with /share/registry"); + log.println("getting: " + AdminEntity + " -- FAILED"); + } + + tRes.tested("getAdminEntity()", res); + } + + public void _getOwnerEntity() { + OwnerEntity = oObj.getOwnerEntity(); + + boolean res = OwnerEntity.endsWith("/user/registry"); + + if (!res) { + log.println("Expected the Entity to end with /user/registry"); + log.println("getting: " + OwnerEntity + " -- FAILED"); + } + + tRes.tested("getOwnerEntity()", res); + } + + public void _isEqualEntity() { + boolean res = true; + boolean localRes = true; + + try { + localRes = oObj.isEqualEntity("", ""); + log.println( + "No Exception thrown for isEqualEntity(\"\",\"\") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected Exception (" + e + ") -- OK"); + res &= true; + } + + try { + localRes = oObj.isEqualEntity(AdminEntity, AdminEntity); + + if (!localRes) { + log.println( + "isEqualEntity(AdminEntity,AdminEntity) returns false -- FAILED"); + } + + res &= localRes; + + localRes = oObj.isEqualEntity(OwnerEntity, OwnerEntity); + + if (!localRes) { + log.println( + "isEqualEntity(OwnerEntity,OwnerEntity) returns false -- FAILED"); + } + + res &= localRes; + + localRes = !oObj.isEqualEntity(AdminEntity, OwnerEntity); + + if (!localRes) { + log.println( + "isEqualEntity(AdminEntity,OwnerEntity) returns true -- FAILED"); + } + + res &= localRes; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + tRes.tested("isEqualEntity()", res); + } + + public void _supportsEntity() { + boolean res = true; + boolean localRes = true; + + try { + localRes = oObj.supportsEntity("illegal"); + log.println( + "No Exception thrown for supportsEntity(\"\") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("Expected Exception (" + e + ") -- OK"); + res &= true; + } + + try { + localRes = oObj.supportsEntity(AdminEntity); + + if (adm != null) { + Object msb = tEnv.getObjRelation("MSB") ; + if (msb == null){ + localRes = !localRes; + log.println("This Component doesn't support the AdminEntity"); + } + } + + if (!localRes) { + log.println( + "supportsEntity(AdminEntity) returns false -- FAILED"); + } + + res &= localRes; + + localRes = oObj.supportsEntity(OwnerEntity); + + if (!localRes) { + log.println( + "supportsEntity(OwnerEntity) returns false -- FAILED"); + } + + res &= localRes; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + tRes.tested("supportsEntity()", res); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XLayer.java b/qadevOOo/tests/java/ifc/configuration/backend/_XLayer.java new file mode 100644 index 000000000..879a3113e --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XLayer.java @@ -0,0 +1,81 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XLayer; +import lib.MultiMethodTest; +import util.XLayerHandlerImpl; + +public class _XLayer extends MultiMethodTest { + + public XLayer oObj; + + public void _readData() { + boolean res = false; + + log.println("Checking for Exception in case of nul argument"); + + try { + oObj.readData(null); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception ("+e+") -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception ("+e+") -- FAILED"); + } + + log.println("checking read data with own XLayerHandler implementation"); + try { + XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl(); + oObj.readData(xLayerHandler); + String implCalled = xLayerHandler.getCalls(); + log.println(implCalled); + int sl = implCalled.indexOf("startLayer"); + if (sl < 0) { + log.println("startLayer wasn't called -- FAILED"); + res &= false; + } else { + log.println("startLayer was called -- OK"); + res &= true; + } + int el = implCalled.indexOf("endLayer"); + if (el < 0) { + log.println("endLayer wasn't called -- FAILED"); + res &= false; + } else { + log.println("endLayer was called -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception ("+e+") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception ("+e+") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception ("+e+") -- FAILED"); + res &= false; + } + + tRes.tested("readData()",res); + } + +} diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XLayerHandler.java b/qadevOOo/tests/java/ifc/configuration/backend/_XLayerHandler.java new file mode 100644 index 000000000..609d1c9a8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XLayerHandler.java @@ -0,0 +1,242 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XLayer; +import com.sun.star.configuration.backend.XLayerHandler; +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XInputStream; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiMethodTest; + +import util.XLayerHandlerImpl; + + +public class _XLayerHandler extends MultiMethodTest { + public XLayerHandler oObj = null; + + /** this method contains the logic for all test methods + * the others will be passed OK if this one is + */ + public void _endLayer() { + boolean res = false; + + try { + oObj.startLayer(); + oObj.overrideNode("org.openoffice.Setup", (short) 0, false); + oObj.overrideNode("Office", (short) 0, false); + oObj.overrideProperty("ooSetupInstCompleted", (short) 0, + new Type(String.class), false); + oObj.setPropertyValue(Boolean.FALSE); + oObj.endProperty(); + oObj.overrideNode("Factories", (short) 0, false); + oObj.addOrReplaceNode("com.sun.star.chart.ChartDocument", + (short) 0); + oObj.overrideProperty("ooSetupFactoryEmptyDocumentURL", (short) 0, + new Type(String.class), false); + oObj.setPropertyValue("private:factory/schart"); + oObj.endProperty(); + oObj.overrideProperty("ooSetupFactoryIcon", (short) 0, + new Type(java.lang.Long.class), false); + oObj.setPropertyValue(Integer.valueOf(13)); + oObj.endProperty(); + oObj.overrideProperty("ooSetupFactoryShortName", (short) 0, + new Type(String.class), false); + oObj.setPropertyValue("schart"); + oObj.setPropertyValueForLocale("TemplateFile", "en-US"); + oObj.endProperty(); + oObj.overrideProperty("ooSetupFactoryTemplateFile", (short) 0, + new Type(String.class), false); + oObj.setPropertyValue("empty"); + oObj.endProperty(); + oObj.addProperty("ooSetupFactoryTemplateFile", (short) 0, + new Type(String.class)); + oObj.addPropertyWithValue("ooSetupFactoryTemplateFile", (short) 0, + "TemplateFile"); + oObj.endNode(); + + oObj.addOrReplaceNode("dropme", (short) 0); + oObj.overrideProperty("anyway", (short) 0, + new Type(String.class), false); + oObj.setPropertyValue("nice"); + oObj.endProperty(); + oObj.dropNode("dropme"); + oObj.endNode(); + + oObj.addOrReplaceNodeFromTemplate("FromTemplate", + new com.sun.star.configuration.backend.TemplateIdentifier( + "org.openoffice.Setup", + "Setup"), (short) 0); + oObj.endNode(); + + oObj.endNode(); + oObj.endNode(); + oObj.endNode(); + oObj.endLayer(); + + Object LayerParser = tParam.getMSF().createInstance( + "com.sun.star.comp.configuration.backend.xml.LayerParser"); + + XActiveDataSink xSink = UnoRuntime.queryInterface( + XActiveDataSink.class, LayerParser); + Object fileacc = tParam.getMSF().createInstance( + "com.sun.star.comp.ucb.SimpleFileAccess"); + XSimpleFileAccess simpleAccess = UnoRuntime.queryInterface( + XSimpleFileAccess.class, + fileacc); + + String filename = util.utils.getOfficeTemp( + tParam.getMSF()) + + "LayerWriter.xcu"; + log.println("Going to parse: " + filename); + + XInputStream xStream = simpleAccess.openFileRead(filename); + + xSink.setInputStream(xStream); + + XLayer xLayer = UnoRuntime.queryInterface(XLayer.class, + LayerParser); + + XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl(); + + xLayer.readData(xLayerHandler); + + res = xLayerHandler.getCalls().equals(getExpected()); + + if (!res) { + log.println("#### Getting: "); + log.println(xLayerHandler.getCalls()); + log.println("#### Expected: "); + log.println(getExpected()); + } + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception " + e); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception " + e); + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected Exception " + e); + } + + tRes.tested("endLayer()", res); + } + + public void _addOrReplaceNode() { + requiredMethod("endLayer()"); + tRes.tested("addOrReplaceNode()", true); + } + + public void _addOrReplaceNodeFromTemplate() { + requiredMethod("endLayer()"); + tRes.tested("addOrReplaceNodeFromTemplate()", true); + } + + public void _addProperty() { + requiredMethod("endLayer()"); + tRes.tested("addProperty()", true); + } + + public void _addPropertyWithValue() { + requiredMethod("endLayer()"); + tRes.tested("addPropertyWithValue()", true); + } + + public void _dropNode() { + requiredMethod("endLayer()"); + tRes.tested("dropNode()", true); + } + + public void _endNode() { + requiredMethod("endLayer()"); + tRes.tested("endNode()", true); + } + + public void _endProperty() { + requiredMethod("endLayer()"); + tRes.tested("endProperty()", true); + } + + public void _overrideNode() { + requiredMethod("endLayer()"); + tRes.tested("overrideNode()", true); + } + + public void _overrideProperty() { + requiredMethod("endLayer()"); + tRes.tested("overrideProperty()", true); + } + + public void _setPropertyValue() { + requiredMethod("endLayer()"); + tRes.tested("setPropertyValue()", true); + } + + public void _setPropertyValueForLocale() { + requiredMethod("endLayer()"); + tRes.tested("setPropertyValueForLocale()", true); + } + + public void _startLayer() { + requiredMethod("endLayer()"); + tRes.tested("startLayer()", true); + } + + protected String getExpected() { + String ls = System.getProperty("line.separator"); + String expected = "startLayer();" + ls; + expected += ("overrideNode(org.openoffice.Setup,0,false);" + ls); + expected += ("overrideNode(Office,0,false);" + ls); + expected += ("overrideProperty(ooSetupInstCompleted,0,Type[string],false);" + ls); + expected += ("setPropertyValue(false);" + ls); + expected += ("endProperty();" + ls); + expected += ("overrideNode(Factories,0,false);" + ls); + expected += ("addOrReplace(com.sun.star.chart.ChartDocument,0);" + ls); + expected += ("overrideProperty(ooSetupFactoryEmptyDocumentURL,0,Type[string],false);" + ls); + expected += ("setPropertyValue(private:factory/schart);" + ls); + expected += ("endProperty();" + ls); + expected += ("overrideProperty(ooSetupFactoryIcon,0,Type[hyper],false);" + ls); + expected += ("setPropertyValue(13);" + ls); + expected += ("endProperty();" + ls); + expected += ("overrideProperty(ooSetupFactoryShortName,0,Type[string],false);" + ls); + expected += ("setPropertyValue(schart);" + ls); + expected += ("setPropertyValueForLocale(TemplateFile,en-US);" + ls); + expected += ("endProperty();" + ls); + expected += ("overrideProperty(ooSetupFactoryTemplateFile,0,Type[string],false);" + ls); + expected += ("setPropertyValue(empty);" + ls); + expected += ("endProperty();" + ls); + expected += ("addProperty(ooSetupFactoryTemplateFile,0,Type[string]);" + ls); + expected += ("addPropertyWithValue(ooSetupFactoryTemplateFile,0,TemplateFile);" + ls); + expected += ("endNode();" + ls); + expected += ("addOrReplace(dropme,0);" + ls); + expected += ("overrideProperty(anyway,0,Type[string],false);" + ls); + expected += ("setPropertyValue(nice);" + ls); + expected += ("endProperty();" + ls); + expected += ("dropNode(dropme);" + ls); + expected += ("endNode();" + ls); + expected += ("addOrReplace(FromTemplate,0);" + ls); + expected += ("endNode();" + ls); + expected += ("endNode();" + ls); + expected += ("endNode();" + ls); + expected += ("endNode();" + ls); + expected += ("endLayer();" + ls); + + return expected; + } +} diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XLayerImporter.java b/qadevOOo/tests/java/ifc/configuration/backend/_XLayerImporter.java new file mode 100644 index 000000000..0e42ec526 --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XLayerImporter.java @@ -0,0 +1,157 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XBackend; +import com.sun.star.configuration.backend.XLayerImporter; +import lib.MultiMethodTest; + +public class _XLayerImporter extends MultiMethodTest { + + public XLayerImporter oObj; + public XBackend xBackend = null; + + public void _getTargetBackend() { + xBackend = oObj.getTargetBackend(); + tRes.tested("getTargetBackend()", xBackend != null); + } + + public void _importLayer() { + boolean res = false; + log.println("checking for exception is argument null is given"); + try { + oObj.importLayer(null); + log.println("\tException expected -- FAILED"); + } catch (com.sun.star.lang.NullPointerException ne) { + res = true; + log.println("\tExpected exception was thrown -- OK"); + } catch (com.sun.star.configuration.backend.MalformedDataException mde) { + res = false; + log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED"); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + res = false; + log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED"); + } catch (com.sun.star.lang.WrappedTargetException wte) { + res = false; + log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED"); + } + + log.println("checking own implementation of XLayer"); + try { + util.XLayerImpl xLayer = new util.XLayerImpl(); + oObj.importLayer(xLayer); + if (! xLayer.hasBeenCalled()) { + log.println("\tXLayer hasn't been imported -- FAILED"); + res &= false; + } else { + log.println("\tXLayer has been imported -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException ne) { + res &= false; + log.println("\tExpected exception "+ne+" was thrown -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException mde) { + res &= false; + log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED"); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + res &= false; + log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED"); + } catch (com.sun.star.lang.WrappedTargetException wte) { + res &= false; + log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED"); + } + + tRes.tested("importLayer()",res); + } + + public void _importLayerForEntity() { + boolean res = false; + log.println("checking for exception for argument (null,\"\")"); + try { + oObj.importLayerForEntity(null,""); + log.println("\tException expected -- FAILED"); + } catch (com.sun.star.lang.NullPointerException ne) { + res = true; + log.println("\tExpected exception was thrown -- OK"); + } catch (com.sun.star.configuration.backend.MalformedDataException mde) { + res = false; + log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED"); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + res = false; + log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED"); + } catch (com.sun.star.lang.WrappedTargetException wte) { + res = false; + log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED"); + } + + log.println("checking own implementation of XLayer"); + try { + util.XLayerImpl xLayer = new util.XLayerImpl(); + oObj.importLayerForEntity(xLayer,""); + if (! xLayer.hasBeenCalled()) { + log.println("\tXLayer hasn't been imported -- FAILED"); + res &= false; + } else { + log.println("\tXLayer has been imported -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException ne) { + res &= false; + log.println("\tExpected exception "+ne+" was thrown -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException mde) { + res &= false; + log.println("\tWrong Expected "+mde+" exception was thrown -- FAILED"); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + res &= false; + log.println("\tWrong Expected "+iae+" exception was thrown -- FAILED"); + } catch (com.sun.star.lang.WrappedTargetException wte) { + res &= false; + log.println("\tWrong Expected "+wte+" exception was thrown -- FAILED"); + } + + tRes.tested("importLayerForEntity()",res); + } + + public void _setTargetBackend() { + requiredMethod("getTargetBackend()"); + boolean res = false; + log.println("checking for exception if argument null is given"); + try { + oObj.setTargetBackend(null); + log.println("\tException expected -- FAILED"); + } catch (com.sun.star.lang.NullPointerException ne) { + res = true; + log.println("\tExpected exception was thrown -- OK"); + } + + log.println("checking argument previously gained by getTargetBackend"); + try { + oObj.setTargetBackend(xBackend); + log.println("\t No Exception thrown -- OK"); + res &= true; + } catch (com.sun.star.lang.NullPointerException ne) { + res &= false; + log.println("\tException was thrown -- FAILED"); + } + + tRes.tested("setTargetBackend()",res); + + } + +} diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XMultiLayerStratum.java b/qadevOOo/tests/java/ifc/configuration/backend/_XMultiLayerStratum.java new file mode 100644 index 000000000..c0b7c438c --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XMultiLayerStratum.java @@ -0,0 +1,303 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XLayer; +import com.sun.star.configuration.backend.XMultiLayerStratum; +import com.sun.star.configuration.backend.XUpdatableLayer; +import lib.MultiMethodTest; + +import util.XLayerHandlerImpl; + + +public class _XMultiLayerStratum extends MultiMethodTest { + public XMultiLayerStratum oObj; + protected String aLayerID; + + public void _getLayer() { + boolean res = true; + + try { + oObj.getLayer("", ""); + log.println("Exception expected -- FAILED"); + res = false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("expected Exception -- OK"); + } + + try { + XLayer aLayer = oObj.getLayer(aLayerID, ""); + res &= (aLayer != null); + + if (aLayer == null) { + log.println("\treturned Layer is NULL -- FAILED"); + } else { + res &= checkLayer(aLayer); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + tRes.tested("getLayer()", res); + } + + public void _getLayers() { + boolean res = true; + + try { + String[] LayerIds = new String[] { + "1 /org/openoffice/Office/Jobs.xcu", + "2 /org/openoffice/Office/Linguistic.xcu" }; + + XLayer[] Layers = oObj.getLayers(LayerIds, ""); + res = Layers.length == 2; + log.println("Getting two XLayers -- OK"); + log.println("Checking first on "+LayerIds[0]); + res &= checkLayer(Layers[0]); + log.println("Checking second on "+LayerIds[1]); + res &= checkLayer(Layers[1]); + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + tRes.tested("getLayers()", res); + } + + public void _getMultipleLayers() { + boolean res = true; + + try { + String[] LayerIds = new String[] { + "1 /org/openoffice/Office/Jobs.xcu", + "2 /org/openoffice/Office/Linguistic.xcu" }; + String[] Times = new String[] { "", "" }; + + XLayer[] Layers = oObj.getMultipleLayers(LayerIds, Times); + res = Layers.length == 2; + log.println("Getting two XLayers -- OK"); + log.println("Checking first on "+LayerIds[0]); + res &= checkLayer(Layers[0]); + log.println("Checking second on "+LayerIds[1]); + res &= checkLayer(Layers[1]); + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + tRes.tested("getMultipleLayers()", res); + } + + public void _getUpdatableLayer() { + boolean res = true; + + try { + oObj.getUpdatableLayer(""); + log.println("Exception expected -- FAILED"); + res = false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("expected Exception -- OK"); + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + try { + XUpdatableLayer aLayer = oObj.getUpdatableLayer(aLayerID); + res &= (aLayer != null); + + if (aLayer == null) { + log.println("\treturned Layer is NULL -- FAILED"); + } else { + res &= checkLayer(aLayer); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + tRes.tested("getUpdatableLayer()", res); + } + + public void _getUpdateLayerId() throws com.sun.star.uno.Exception { + boolean res = true; + + try { + oObj.getUpdateLayerId( + "org.openoffice.Office.TypeDetection", + "illegal"); + log.println("Exception expected -- FAILED"); + res = false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("expected Exception -- OK"); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + try { + String ent = util.utils.getOfficeURL( + tParam.getMSF()) + + "/../share/registry"; + String UpdateLayerID = oObj.getUpdateLayerId( + "org.openoffice.Office.Linguistic", ent); + res &= UpdateLayerID.endsWith("Linguistic.xcu"); + + if (!UpdateLayerID.endsWith("Linguistic.xcu")) { + log.println("\tExpected the id to end with Linguistic.xcu"); + log.println("\tBut got " + UpdateLayerID); + log.println("\t=> FAILED"); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception "+e+" -- FAILED"); + res = false; + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + tRes.tested("getUpdateLayerId()", res); + } + + public void _listLayerIds() throws com.sun.star.uno.Exception { + boolean res = true; + + try { + oObj.listLayerIds( + "org.openoffice.Office.TypeDetection", + "illegal"); + log.println("Exception expected -- FAILED"); + res = false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("expected Exception -- OK"); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + try { + String ent = util.utils.getOfficeURL( + tParam.getMSF()) + + "/../share/registry"; + String[] LayerIDs = oObj.listLayerIds("org.openoffice.Office.Jobs", + ent); + res &= LayerIDs[0].endsWith("Jobs.xcu"); + aLayerID = LayerIDs[0]; + + if (!LayerIDs[0].endsWith("Jobs.xcu")) { + log.println("\tExpected the id to end with Jobs.xcu"); + log.println("\tBut got " + LayerIDs[0]); + log.println("\t=> FAILED"); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + tRes.tested("listLayerIds()", res); + } + + protected boolean checkLayer(XLayer aLayer) { + boolean res = false; + + log.println("Checking for Exception in case of null argument"); + + try { + aLayer.readData(null); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } + + log.println("checking read data with own XLayerHandler implementation"); + + try { + XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl(); + aLayer.readData(xLayerHandler); + + String implCalled = xLayerHandler.getCalls(); + log.println(implCalled); + + int sl = implCalled.indexOf("startLayer"); + + if (sl < 0) { + log.println("startLayer wasn't called -- FAILED"); + res &= false; + } else { + log.println("startLayer was called -- OK"); + res &= true; + } + + int el = implCalled.indexOf("endLayer"); + + if (el < 0) { + log.println("endLayer wasn't called -- FAILED"); + res &= false; + } else { + log.println("endLayer was called -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + return res; + } +} diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XSchema.java b/qadevOOo/tests/java/ifc/configuration/backend/_XSchema.java new file mode 100644 index 000000000..597d245ef --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XSchema.java @@ -0,0 +1,253 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XSchema; +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XInputStream; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiMethodTest; + +import util.XSchemaHandlerImpl; + +public class _XSchema extends MultiMethodTest { + public XSchema oObj; + XSchemaHandlerImpl xSchemaHandlerImpl = new XSchemaHandlerImpl(); + String filename = null; + + @Override + protected void before() { + filename = (String)tEnv.getObjRelation("ParsedFileName"); + } + + public void _readComponent() { + requiredMethod("readTemplates()"); + boolean res = false; + + log.println("Checking for Exception in case of null argument"); + + try { + oObj.readComponent(null); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } + + log.println( + "checking readComponent with own XSchemeHandler implementation"); + + try { + xSchemaHandlerImpl.cleanCalls(); + oObj.readComponent(xSchemaHandlerImpl); + + String implCalled = xSchemaHandlerImpl.getCalls(); + + System.out.println(implCalled); + + int sc = implCalled.indexOf("startComponent"); + + if (sc < 0) { + log.println("startComponent wasn't called -- FAILED"); + res &= false; + } else { + log.println("startComponent was called -- OK"); + res &= true; + } + + int ec = implCalled.indexOf("endComponent"); + + if (ec < 0) { + log.println("endComponent wasn't called -- FAILED"); + res &= false; + } else { + log.println("endComponent was called -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + tRes.tested("readComponent()", res); + reopenFile(); + } + + public void _readSchema() { + requiredMethod("readComponent()"); + boolean res = false; + + log.println("Checking for Exception in case of null argument"); + + try { + xSchemaHandlerImpl.cleanCalls(); + oObj.readSchema(null); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } + + log.println( + "checking read data with own XSchemeHandler implementation"); + + try { + xSchemaHandlerImpl.cleanCalls(); + oObj.readSchema(xSchemaHandlerImpl); + + String implCalled = xSchemaHandlerImpl.getCalls(); + + int sc = implCalled.indexOf("startSchema"); + + if (sc < 0) { + log.println("startSchema wasn't called -- FAILED"); + res &= false; + } else { + log.println("startSchema was called -- OK"); + res &= true; + } + + int ec = implCalled.indexOf("endSchema"); + + if (ec < 0) { + log.println("endSchema wasn't called -- FAILED"); + res &= false; + } else { + log.println("endSchema was called -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + // check for the wrapped target exception + try { + xSchemaHandlerImpl.cleanCalls(); + oObj.readSchema(xSchemaHandlerImpl); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } + + tRes.tested("readSchema()", res); + reopenFile(); + } + + public void _readTemplates() { + boolean res = false; + + log.println("Checking for Exception in case of null argument"); + + try { + oObj.readTemplates(null); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } + + log.println( + "checking readComponent with own XSchemeHandler implementation"); + + try { + xSchemaHandlerImpl.cleanCalls(); + oObj.readComponent(xSchemaHandlerImpl); + + String implCalled = xSchemaHandlerImpl.getCalls(); + + int sc = implCalled.indexOf("startGroup"); + + if (sc < 0) { + log.println("startGroup wasn't called -- FAILED"); + res &= false; + } else { + log.println("startGroup was called -- OK"); + res &= true; + } + + int ec = implCalled.indexOf("endNode"); + + if (ec < 0) { + log.println("endNode wasn't called -- FAILED"); + res &= false; + } else { + log.println("endNode was called -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + tRes.tested("readTemplates()", res); + reopenFile(); + } + + /** + * reopen the parsed file again, to avoid the wrapped target exception. + */ + private void reopenFile() { + XSimpleFileAccess simpleAccess = null; + XInputStream xStream = null; + try { + Object fileacc = tParam.getMSF().createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + simpleAccess = UnoRuntime.queryInterface(XSimpleFileAccess.class,fileacc); + log.println("Going to parse: "+filename); + xStream = simpleAccess.openFileRead(filename); + } catch (com.sun.star.uno.Exception e) { + } + + XActiveDataSink xSink = UnoRuntime.queryInterface(XActiveDataSink.class, oObj); + xSink.setInputStream(xStream); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XSchemaSupplier.java b/qadevOOo/tests/java/ifc/configuration/backend/_XSchemaSupplier.java new file mode 100644 index 000000000..aee858b6a --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XSchemaSupplier.java @@ -0,0 +1,109 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XSchema; +import com.sun.star.configuration.backend.XSchemaSupplier; + +import lib.MultiMethodTest; +import util.XSchemaHandlerImpl; + +public class _XSchemaSupplier extends MultiMethodTest { + public XSchemaSupplier oObj; + + public void _getComponentSchema() { + boolean res = true; + XSchema aSchema = null; + + try { + aSchema = oObj.getComponentSchema("org.openoffice.Office.Linguistic"); + res &= (aSchema != null); + + if (aSchema == null) { + log.println("\treturned Layer is NULL -- FAILED"); + } else { + res &= checkSchema(aSchema); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + tRes.tested("getComponentSchema()",res); + } + + protected boolean checkSchema(XSchema aSchema) { + boolean res = false; + XSchemaHandlerImpl xSchemaHandlerImpl = new XSchemaHandlerImpl(); + log.println("Checking for Exception in case of null argument"); + + try { + aSchema.readTemplates(null); + log.println("NoException thrown for null argument -- FAILED"); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } + + log.println( + "checking readComponent with own XSchemaHandler implementation"); + + try { + aSchema.readComponent(xSchemaHandlerImpl); + + String implCalled = xSchemaHandlerImpl.getCalls(); + int sc = implCalled.indexOf("startComponent"); + + if (sc < 0) { + log.println("startComponent wasn't called -- FAILED"); + res &= false; + } else { + log.println("startComponent was called -- OK"); + res &= true; + } + + int ec = implCalled.indexOf("endComponent"); + + if (ec < 0) { + log.println("endComponent wasn't called -- FAILED"); + res &= false; + } else { + log.println("endComponent was called -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + return res; + + } +} diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XSingleLayerStratum.java b/qadevOOo/tests/java/ifc/configuration/backend/_XSingleLayerStratum.java new file mode 100644 index 000000000..33eb0cfa8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XSingleLayerStratum.java @@ -0,0 +1,165 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.XLayer; +import com.sun.star.configuration.backend.XSingleLayerStratum; +import com.sun.star.configuration.backend.XUpdatableLayer; + +import lib.MultiMethodTest; + +import util.XLayerHandlerImpl; + + +public class _XSingleLayerStratum extends MultiMethodTest { + public XSingleLayerStratum oObj; + + public void _getLayer() { + String aLayerID = "org.openoffice.Office.Common"; + boolean res = true; + + try { + oObj.getLayer("", ""); + log.println("Exception expected -- FAILED"); + res = false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("expected Exception -- OK"); + } + + try { + XLayer aLayer = oObj.getLayer(aLayerID, ""); + res &= (aLayer != null); + + if (aLayer == null) { + log.println("\treturned Layer is NULL -- FAILED"); + } else { + res &= checkLayer(aLayer); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + tRes.tested("getLayer()", res); + } + + public void _getUpdatableLayer() { + String aLayerID = "org.openoffice.Office.Common"; + boolean res = true; + + try { + oObj.getUpdatableLayer(""); + log.println("Exception expected -- FAILED"); + res = false; + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception " + e + " -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("expected Exception -- OK"); + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + try { + XUpdatableLayer aLayer = oObj.getUpdatableLayer(aLayerID); + res &= (aLayer != null); + + if (aLayer == null) { + log.println("\treturned Layer is NULL -- FAILED"); + } else { + res &= checkLayer(aLayer); + } + } catch (com.sun.star.configuration.backend.BackendAccessException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } catch (com.sun.star.lang.NoSupportException e) { + log.println("unexpected Exception -- FAILED"); + res = false; + } + + tRes.tested("getUpdatableLayer()", res); + } + + protected boolean checkLayer(XLayer aLayer) { + boolean res = false; + + log.println("Checking for Exception in case of null argument"); + + try { + aLayer.readData(null); + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Expected Exception -- OK"); + res = true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + } + + log.println("checking read data with own XLayerHandler implementation"); + + try { + XLayerHandlerImpl xLayerHandler = new XLayerHandlerImpl(); + aLayer.readData(xLayerHandler); + + String implCalled = xLayerHandler.getCalls(); + log.println(implCalled); + + int sl = implCalled.indexOf("startLayer"); + + if (sl < 0) { + log.println("startLayer wasn't called -- FAILED"); + res &= false; + } else { + log.println("startLayer was called -- OK"); + res &= true; + } + + int el = implCalled.indexOf("endLayer"); + + if (el < 0) { + log.println("endLayer wasn't called -- FAILED"); + res &= false; + } else { + log.println("endLayer was called -- OK"); + res &= true; + } + } catch (com.sun.star.lang.NullPointerException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception (" + e + ") -- FAILED"); + res &= false; + } + + return res; + } +} diff --git a/qadevOOo/tests/java/ifc/configuration/backend/_XUpdateHandler.java b/qadevOOo/tests/java/ifc/configuration/backend/_XUpdateHandler.java new file mode 100644 index 000000000..4c35cc70d --- /dev/null +++ b/qadevOOo/tests/java/ifc/configuration/backend/_XUpdateHandler.java @@ -0,0 +1,234 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.configuration.backend; + +import com.sun.star.configuration.backend.TemplateIdentifier; +import com.sun.star.configuration.backend.XUpdateHandler; +import com.sun.star.uno.Type; + +import lib.MultiMethodTest; + +import util.XLayerHandlerImpl; +import util.XLayerImpl; + +public class _XUpdateHandler extends MultiMethodTest { + public XUpdateHandler oObj; + protected XLayerHandlerImpl xLayerHandler = null; + + @Override + public void before() { + xLayerHandler = (XLayerHandlerImpl) tEnv.getObjRelation("LayerHandler"); + + try { + xLayerHandler.startLayer(); + xLayerHandler.overrideNode("org.openoffice.Setup", (short) 0, + false); + xLayerHandler.overrideNode("Office", (short) 0, false); + xLayerHandler.overrideProperty("ooSetupInstCompleted", (short) 0, + new Type(String.class), + false); + xLayerHandler.setPropertyValue(Boolean.FALSE); + xLayerHandler.endProperty(); + xLayerHandler.overrideNode("Factories", (short) 0, false); + xLayerHandler.addOrReplaceNode("com.sun.star.chart.ChartDocument", + (short) 0); + xLayerHandler.overrideProperty("ooSetupFactoryEmptyDocumentURL", + (short) 0, + new Type(String.class), + false); + xLayerHandler.setPropertyValue("private:factory/schart"); + xLayerHandler.endProperty(); + xLayerHandler.overrideProperty("ooSetupFactoryIcon", (short) 0, + new Type(java.lang.Long.class), + false); + xLayerHandler.setPropertyValue(Integer.valueOf(13)); + xLayerHandler.endProperty(); + xLayerHandler.overrideProperty("ooSetupFactoryShortName", + (short) 0, + new Type(String.class), + false); + xLayerHandler.setPropertyValue("schart"); + xLayerHandler.setPropertyValueForLocale("TemplateFile", "en-US"); + xLayerHandler.endProperty(); + xLayerHandler.overrideProperty("ooSetupFactoryTemplateFile", + (short) 0, + new Type(String.class), + false); + xLayerHandler.setPropertyValue("empty"); + xLayerHandler.endProperty(); + xLayerHandler.addProperty("ooSetupFactoryTemplateFile", (short) 0, + new Type(String.class)); + xLayerHandler.addPropertyWithValue("ooSetupFactoryTemplateFile", + (short) 0, "TemplateFile"); + xLayerHandler.endNode(); + + xLayerHandler.addOrReplaceNode("dropme", (short) 0); + xLayerHandler.overrideProperty("anyway", (short) 0, + new Type(String.class), + false); + xLayerHandler.setPropertyValue("nice"); + xLayerHandler.endProperty(); + xLayerHandler.dropNode("dropme"); + xLayerHandler.endNode(); + + xLayerHandler.addOrReplaceNodeFromTemplate("FromTemplate", + new com.sun.star.configuration.backend.TemplateIdentifier( + "org.openoffice.Setup", + "Setup"), + (short) 0); + xLayerHandler.endNode(); + + xLayerHandler.endNode(); + xLayerHandler.endNode(); + xLayerHandler.endNode(); + xLayerHandler.endLayer(); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected Exception " + e); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception " + e); + } + } + + public void _addOrReplaceNode() { + requiredMethod("startUpdate()"); + tRes.tested("addOrReplaceNode()", true); + } + + public void _addOrReplaceNodeFromTemplate() { + requiredMethod("startUpdate()"); + tRes.tested("addOrReplaceNodeFromTemplate()", true); + } + + public void _addOrReplaceProperty() { + requiredMethod("startUpdate()"); + tRes.tested("addOrReplaceProperty()", true); + } + + public void _addOrReplacePropertyWithValue() { + requiredMethod("startUpdate()"); + tRes.tested("addOrReplacePropertyWithValue()", true); + } + + public void _endNode() { + requiredMethod("startUpdate()"); + tRes.tested("endNode()", true); + } + + public void _endProperty() { + requiredMethod("startUpdate()"); + tRes.tested("endProperty()", true); + } + + public void _endUpdate() { + requiredMethod("startUpdate()"); + tRes.tested("endUpdate()", true); + } + + public void _modifyNode() { + requiredMethod("startUpdate()"); + tRes.tested("modifyNode()", true); + } + + public void _modifyProperty() { + requiredMethod("startUpdate()"); + tRes.tested("modifyProperty()", true); + } + + public void _removeNode() { + requiredMethod("startUpdate()"); + tRes.tested("removeNode()", true); + } + + public void _removeProperty() { + requiredMethod("startUpdate()"); + tRes.tested("removeProperty()", true); + } + + public void _resetProperty() { + requiredMethod("startUpdate()"); + tRes.tested("resetProperty()", true); + } + + public void _resetPropertyValue() { + requiredMethod("startUpdate()"); + tRes.tested("resetPropertyValue()", true); + } + + public void _resetPropertyValueForLocale() { + requiredMethod("startUpdate()"); + tRes.tested("resetPropertyValueForLocale()", true); + } + + public void _setPropertyValue() { + requiredMethod("startUpdate()"); + tRes.tested("setPropertyValue()", true); + } + + public void _setPropertyValueForLocale() { + requiredMethod("startUpdate()"); + tRes.tested("setPropertyValueForLocale()", true); + } + + public void _startUpdate() { + boolean res = true; + + try { + XLayerImpl xLayer = (XLayerImpl) tEnv.getObjRelation("Layer"); + log.println("Layer called (before): " + xLayer.hasBeenCalled()); + oObj.startUpdate(); + oObj.addOrReplaceNode("whatever", (short) 0); + oObj.addOrReplaceNodeFromTemplate("Office", (short) 0, + new TemplateIdentifier()); + oObj.addOrReplaceProperty("prop", (short) 0, + new Type(String.class)); + oObj.addOrReplacePropertyWithValue("prop2", (short) 0, "this"); + oObj.modifyProperty("ooSetupFactoryIcon", (short) 0, (short) 0, + new Type(String.class)); + oObj.resetPropertyValue(); + oObj.resetPropertyValueForLocale("en-US"); + oObj.endProperty(); + oObj.modifyProperty("ooSetupFactoryEmptyDocumentURL", (short) 0, + (short) 0, new Type(String.class)); + oObj.setPropertyValue("newValue"); + oObj.setPropertyValueForLocale("newValue-US", "de-DE"); + oObj.endProperty(); + oObj.modifyNode("org.openoffice.Setup", (short) 0, (short) 0, true); + oObj.removeNode("whatever"); + oObj.resetProperty("prop"); + oObj.endNode(); + oObj.endNode(); + oObj.endNode(); + oObj.endUpdate(); + + log.println("Layer called (after): " + xLayer.hasBeenCalled()); + + res = xLayer.hasBeenCalled(); + } catch (com.sun.star.configuration.backend.MalformedDataException e) { + log.println("Unexpected exception " + e.getMessage()); + res = false; + } catch (com.sun.star.lang.IllegalAccessException e) { + log.println("Unexpected exception " + e.getMessage()); + res = false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected exception " + e.getMessage()); + res = false; + } + + tRes.tested("startUpdate()", res); + } +} |