diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /qadevOOo/tests/java/ifc/sdb | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
43 files changed, 6625 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/sdb/_DataAccessDescriptor.java b/qadevOOo/tests/java/ifc/sdb/_DataAccessDescriptor.java new file mode 100644 index 000000000..fda6ad192 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_DataAccessDescriptor.java @@ -0,0 +1,116 @@ +/* + * 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.sdb; + +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.uno.UnoRuntime; +import lib.MultiPropertyTest; + +public class _DataAccessDescriptor extends MultiPropertyTest { + + /** + * Tested with custom property tester. + */ + public void _ResultSet() { + String propName = "ResultSet"; + try{ + + log.println("try to get value from property..."); + UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName)); + + log.println("try to get value from object relation..."); + XResultSet newValue = UnoRuntime.queryInterface(XResultSet.class,tEnv.getObjRelation("DataAccessDescriptor.XResultSet")); + + log.println("set property to a new value..."); + oObj.setPropertyValue(propName, newValue); + + log.println("get the new value..."); + XResultSet getValue = UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName)); + + tRes.tested(propName, this.compare(newValue, getValue)); + } catch (com.sun.star.beans.PropertyVetoException e){ + log.println("could not set property '"+ propName +"' to a new value!"); + tRes.tested(propName, false); + } catch (com.sun.star.lang.IllegalArgumentException e){ + log.println("could not set property '"+ propName +"' to a new value!"); + tRes.tested(propName, false); + } catch (com.sun.star.beans.UnknownPropertyException e){ + if (this.isOptional(propName)){ + // skipping optional property test + log.println("Property '" + propName + + "' is optional and not supported"); + tRes.tested(propName,true); + + } else { + log.println("could not get property '"+ propName +"' from XPropertySet!"); + tRes.tested(propName, false); + } + } catch (com.sun.star.lang.WrappedTargetException e){ + log.println("could not get property '"+ propName +"' from XPropertySet!"); + tRes.tested(propName, false); + } + } + + /** + * Tested with custom property tester. + */ + public void _ActiveConnection() { + String propName = "ActiveConnection"; + try{ + + log.println("try to get value from property..."); + UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName)); + + log.println("try to get value from object relation..."); + XConnection newValue = UnoRuntime.queryInterface(XConnection.class,tEnv.getObjRelation("DataAccessDescriptor.XConnection")); + + log.println("set property to a new value..."); + oObj.setPropertyValue(propName, newValue); + + log.println("get the new value..."); + XConnection getValue = UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName)); + + tRes.tested(propName, this.compare(newValue, getValue)); + } catch (com.sun.star.beans.PropertyVetoException e){ + log.println("could not set property '"+ propName +"' to a new value! " + e.toString()); + tRes.tested(propName, false); + } catch (com.sun.star.lang.IllegalArgumentException e){ + log.println("could not set property '"+ propName +"' to a new value! " + e.toString()); + tRes.tested(propName, false); + } catch (com.sun.star.beans.UnknownPropertyException e){ + if (this.isOptional(propName)){ + // skipping optional property test + log.println("Property '" + propName + + "' is optional and not supported"); + tRes.tested(propName,true); + + } else { + log.println("could not get property '"+ propName +"' from XPropertySet!"); + tRes.tested(propName, false); + } + } catch (com.sun.star.lang.WrappedTargetException e){ + log.println("could not get property '"+ propName +"' from XPropertySet!"); + tRes.tested(propName, false); + } + } + +} + + diff --git a/qadevOOo/tests/java/ifc/sdb/_DataSource.java b/qadevOOo/tests/java/ifc/sdb/_DataSource.java new file mode 100644 index 000000000..e693d781a --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_DataSource.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.sdb; + +import lib.MultiPropertyTest; + +import com.sun.star.beans.PropertyValue; + +/** + * Testing <code>com.sun.star.sdb.DataSource</code> + * service properties : + * <ul> + * <li><code> Name</code></li> + * <li><code> URL</code></li> + * <li><code> Info</code></li> + * <li><code> User</code></li> + * <li><code> Password</code></li> + * <li><code> IsPasswordRequired</code></li> + * <li><code> SuppressVersionColumns</code></li> + * <li><code> IsReadOnly</code></li> + * <li><code> NumberFormatsSupplier</code></li> + * <li><code> TableFilter</code></li> + * <li><code> TableTypeFilter</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code> <p>. +* After this interface test <b>it's better to recreate</b> object tested. +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XPropertySetInfo +* @see com.sun.star.beans.Property +* @see com.sun.star.lang.XServiceInfo +*/ +public class _DataSource extends MultiPropertyTest { + + /** + * This property is an array of additional parameters for database + * connecting. Parameter is <code>PropertyValue</code> structure. + * The test just changes existing array onto array with a single + * element <code>("user", "API_QA_Tester")</code> <p> + * + * After testing old value is set for this property. <p> + * + * Result is OK: if property successfully changed with no exceptions. + * @see com.sun.star.beans.PropertyValue + */ + public void _Info() { + try { + Object oldInfo = oObj.getPropertyValue("Info") ; + + testProperty("Info", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + + PropertyValue propUsr = new PropertyValue(), + propPass = new PropertyValue() ; + + propUsr.Name = "user" ; + propUsr.Value = "API_QA_Tester" ; + propPass.Name = "password" ; + propPass.Value = "guest" ; + + return new PropertyValue[] { propUsr, propPass } ; + } + }) ; + + oObj.setPropertyValue("Info", oldInfo) ; + } catch(com.sun.star.beans.UnknownPropertyException e) {} + catch(com.sun.star.beans.PropertyVetoException e) {} + catch(com.sun.star.lang.IllegalArgumentException e) {} + catch(com.sun.star.lang.WrappedTargetException e) {} + } + + /** + * Property is tested by the common method, but after testing + * old value is set for this property. + */ + public void _URL() { + try { + Object oldURL = oObj.getPropertyValue("URL") ; + + testProperty("URL") ; + + oObj.setPropertyValue("URL", oldURL) ; + } catch(com.sun.star.beans.UnknownPropertyException e) {} + catch(com.sun.star.beans.PropertyVetoException e) {} + catch(com.sun.star.lang.IllegalArgumentException e) {} + catch(com.sun.star.lang.WrappedTargetException e) {} + } + + /** + * Property is tested by the common method, but after testing + * old value is set for this property. + */ + public void _User() { + try { + Object oldUser = oObj.getPropertyValue("User") ; + + testProperty("User") ; + + oObj.setPropertyValue("User", oldUser) ; + } catch(com.sun.star.beans.UnknownPropertyException e) {} + catch(com.sun.star.beans.PropertyVetoException e) {} + catch(com.sun.star.lang.IllegalArgumentException e) {} + catch(com.sun.star.lang.WrappedTargetException e) {} + } + + /** + * Property is tested by the common method, but after testing + * old value is set for this property. + */ + public void _Password() { + try { + Object oldPass = oObj.getPropertyValue("Password") ; + + testProperty("Password") ; + + oObj.setPropertyValue("Password", oldPass) ; + } catch(com.sun.star.beans.UnknownPropertyException e) {} + catch(com.sun.star.beans.PropertyVetoException e) {} + catch(com.sun.star.lang.IllegalArgumentException e) {} + catch(com.sun.star.lang.WrappedTargetException e) {} + } + + /** + * New value for the test is always <code>null</code>. + */ + public void _NumberFormatsSupplier() { + testProperty("NumberFormatsSupplier", new PropertyTester() { + @Override + protected Object getNewValue(String propName, Object oldValue) { + return null ; + } + }) ; + } + + /** + * If object test allows to recreate environment it is better to do it. + */ + @Override + public void after() { + try { + oObj.setPropertyValue("IsPasswordRequired",Boolean.FALSE); + } catch (Exception e) { + log.println("Couldn't set 'IsPasswordRequired' to false"); + } + } + +} // finish class _DataSource + + diff --git a/qadevOOo/tests/java/ifc/sdb/_DatasourceAdministrationDialog.java b/qadevOOo/tests/java/ifc/sdb/_DatasourceAdministrationDialog.java new file mode 100644 index 000000000..747ffe5d0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_DatasourceAdministrationDialog.java @@ -0,0 +1,36 @@ +/* + * 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.sdb; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.sdb.DatasourceAdministrationDialog</code> + * service properties : + * <ul> + * <li><code> Title</code></li> + * <li><code> ParentWindow</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.sdb.DatasourceAdministrationDialog + */ +public class _DatasourceAdministrationDialog extends MultiPropertyTest { + +} // EOF DatasourceAdministrationDialog + diff --git a/qadevOOo/tests/java/ifc/sdb/_ErrorMessageDialog.java b/qadevOOo/tests/java/ifc/sdb/_ErrorMessageDialog.java new file mode 100644 index 000000000..fcdc4f3f9 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_ErrorMessageDialog.java @@ -0,0 +1,60 @@ +/* + * 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.sdb; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.sdb.ErrorMessageDialog</code> + * service properties : + * <ul> + * <li><code> Title</code></li> + * <li><code> ParentWindow</code></li> + * <li><code> SQLException</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'ERR1', 'ERR2'</code> + * (of type <code>com.sun.star.sdbc.SQLException</code>): + * two objects which are used for changing 'SQLException' + * property. </li> + * <ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.sdb.ErrorMessageDialog + */ +public class _ErrorMessageDialog extends MultiPropertyTest { + + /** + * <code>SQLException</code> instances must be used as property + * value. + */ + public void _SQLException() { + log.println("Testing with custom Property tester") ; + testProperty("SQLException", tEnv.getObjRelation("ERR1"), + tEnv.getObjRelation("ERR2")) ; + } + + public void _ParentWindow(){ + log.println("Testing with custom Property tester"); + testProperty("ParentWindow", tEnv.getObjRelation("ERR_XWindow"), null); + } + +} // finish class _ErrorMessageDialog + + diff --git a/qadevOOo/tests/java/ifc/sdb/_QueryDefinition.java b/qadevOOo/tests/java/ifc/sdb/_QueryDefinition.java new file mode 100644 index 000000000..efd49829b --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_QueryDefinition.java @@ -0,0 +1,46 @@ +/* + * 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.sdb; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.sdb.QueryDefinition</code> + * service properties : + * <ul> + * <li><code> Name</code></li> + * <li><code> Command</code></li> + * <li><code> EscapeProcessing</code></li> + * <li><code> UpdateTableName</code></li> + * <li><code> UpdateCatalogName</code></li> + * <li><code> UpdateSchemaName</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.sdb.QueryDefinition + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XPropertySetInfo + * @see com.sun.star.beans.Property + * @see com.sun.star.lang.XServiceInfo + */ +public class _QueryDefinition extends MultiPropertyTest { + + +} // finish class _QueryDefinition + + diff --git a/qadevOOo/tests/java/ifc/sdb/_RowSet.java b/qadevOOo/tests/java/ifc/sdb/_RowSet.java new file mode 100644 index 000000000..9064a1411 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_RowSet.java @@ -0,0 +1,144 @@ +/* + * 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.sdb; + +import lib.MultiPropertyTest; +import lib.StatusException; + +import com.sun.star.sdbc.XConnection; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + +/** + * Testing <code>com.sun.star.sdb.RowSet</code> + * service properties : + * <ul> + * <li><code> ActiveConnection</code></li> + * <li><code> DataSourceName</code></li> + * <li><code> Command</code></li> + * <li><code> CommandType</code></li> + * <li><code> ActiveCommand</code></li> + * <li><code> IgnoreResult</code></li> + * <li><code> Filter</code></li> + * <li><code> ApplyFilter</code></li> + * <li><code> Order</code></li> + * <li><code> Privileges</code></li> + * <li><code> IsModified</code></li> + * <li><code> IsNew</code></li> + * <li><code> RowCount</code></li> + * <li><code> IsRowCountFinal</code></li> + * <li><code> UpdateTableName</code></li> + * <li><code> UpdateCatalogName</code></li> + * <li><code> UpdateSchemaName</code></li> + * </ul> <p> + * + * Properties are tested in a safe way, this means that old + * properties' values are restored to their previous values + * after testing. These values are meaningful for further + * testing. <p> + * + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.sdb.RowSet + */ +public class _RowSet extends MultiPropertyTest { + + /** + * The tester implementation which restores properties + * values after testing. + */ + protected class SafeTester extends PropertyTester { + Object oldValue = null ; + + @Override + protected Object getNewValue(String prop, Object old) { + log.println("Testing with SafeTester ...") ; + oldValue = old ; + return super.getNewValue(prop, old) ; + } + + @Override + protected void checkResult(String propName, Object oldValue, + Object newValue, Object resValue, Exception exception) + throws Exception { + + super.checkResult(propName, oldValue, newValue, resValue, exception); + + try { + oObj.setPropertyValue(propName, this.oldValue); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Exception while setting property to its old value '" + + this.oldValue + "' (ignoring) : " + e ); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Exception while setting property to its old value '" + + this.oldValue + "' (ignoring) : " + e ); + } catch (com.sun.star.beans.PropertyVetoException e) { + log.println("Exception while setting property to its old value '" + + this.oldValue + "' (ignoring) : " + e ); + } catch (com.sun.star.beans.UnknownPropertyException e) { + log.println("Exception while setting property to its old value '" + + this.oldValue + "' (ignoring) : " + e ); + } + + } + } + + /** + * Overridden method which tests all the properties + * with <code>SafeTester</code>. + * + * @see SafeTester + */ + @Override + protected void testProperty(String propName) { + testProperty(propName, new SafeTester()) ; + } + + public void _ActiveConnection() { + boolean result = false; + try { + XConnection the_connection = null; + + try { + the_connection = (XConnection) AnyConverter.toObject( + new Type(XConnection.class), + oObj.getPropertyValue("ActiveConnection")); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + throw new StatusException("couldn't convert Any",iae); + } + + result = (the_connection != null); + } catch (com.sun.star.beans.UnknownPropertyException e) { + log.println("the property is unknown"); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println(e.getMessage()); + } + + tRes.tested("ActiveConnection", result) ; + } + + /** + * Forces environment recreation. + */ + @Override + protected void after() { + disposeEnvironment(); + } + +} // EOF DatasourceAdministrationDialog + diff --git a/qadevOOo/tests/java/ifc/sdb/_SingleSelectQueryComposer.java b/qadevOOo/tests/java/ifc/sdb/_SingleSelectQueryComposer.java new file mode 100644 index 000000000..082bb7415 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_SingleSelectQueryComposer.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.sdb; + +import lib.MultiPropertyTest; + +/** + * Testing <code>com.sun.star.sdb.SingleSelectQueryComposer</code> + * service properties : + * <ul> + * <li><code> Original</code></li> + * </ul> <p> + * Properties testing is automated by <code>lib.MultiPropertyTest</code>. + * @see com.sun.star.sdb.SingleSelectQueryComposer + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XPropertySetInfo + * @see com.sun.star.beans.Property + * @see com.sun.star.lang.XServiceInfo + */ +public class _SingleSelectQueryComposer extends MultiPropertyTest { + + +} // finish class _SingleSelectQueryComposer + + diff --git a/qadevOOo/tests/java/ifc/sdb/_XBookmarksSupplier.java b/qadevOOo/tests/java/ifc/sdb/_XBookmarksSupplier.java new file mode 100644 index 000000000..a0ddfdd57 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XBookmarksSupplier.java @@ -0,0 +1,51 @@ +/* + * 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.sdb; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.sdb.XBookmarksSupplier; + + +/** + * Testing <code>com.sun.star.sdb.XBookmarksSupplier</code> + * interface methods : + * <ul> + * <li><code> getBookmarks()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.sdb.XBookmarksSupplier + */ +public class _XBookmarksSupplier extends MultiMethodTest { + + public XBookmarksSupplier oObj = null ; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getBookmarks() { + XNameAccess bookmarks = oObj.getBookmarks(); + tRes.tested("getBookmarks()",bookmarks != null); + } + +} // finish class _XBookmarksSupplier + diff --git a/qadevOOo/tests/java/ifc/sdb/_XCompletedConnection.java b/qadevOOo/tests/java/ifc/sdb/_XCompletedConnection.java new file mode 100644 index 000000000..12542edaa --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XCompletedConnection.java @@ -0,0 +1,75 @@ +/* + * 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.sdb; + +import lib.MultiMethodTest; +import lib.StatusException; + +import com.sun.star.sdb.XCompletedConnection; +import com.sun.star.sdbc.XConnection; +import com.sun.star.task.XInteractionHandler; + +/** + * Testing <code>com.sun.star.sdb.XCompletedConnection</code> + * interface methods : + * <ul> + * <li><code> connectWithCompletion()</code></li> + * </ul> <p> +* The following object relations required : +* <ul> +* <li> <code>'XCompletedConnection.Handler'</code> : passed as parameter +* to <code>connectWithCompletion</code> method. </li> +* </ul> +* @see com.sun.star.sdb.XCompletedConnection +* @see com.sun.star.task.XInteractionHandler +* @see com.sun.star.sdbc.XConnection +*/ +public class _XCompletedConnection extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XCompletedConnection oObj = null ; + + /** + * Test call the method with handler passed as object relation. + * Then value returned is checked.<p> + * Has OK status if not null value returned. < > + * FAILED if exception occurred, null value returned or object + * relation was not found. + */ + public void _connectWithCompletion() throws StatusException { + XInteractionHandler handler = (XInteractionHandler) + tEnv.getObjRelation("XCompletedConnection.Handler") ; + + if (handler == null) { + log.println("Required object relation not found !") ; + tRes.tested("connectWithCompletion()", false) ; + return ; + } + + XConnection con = null ; + try { + con = oObj.connectWithCompletion(handler) ; + } catch (com.sun.star.sdbc.SQLException e) { + throw new StatusException("Exception while method calling", e) ; + } + + tRes.tested("connectWithCompletion()", con != null) ; + } +} // finish class _XCompletedConnection + diff --git a/qadevOOo/tests/java/ifc/sdb/_XCompletedExecution.java b/qadevOOo/tests/java/ifc/sdb/_XCompletedExecution.java new file mode 100644 index 000000000..548b86c96 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XCompletedExecution.java @@ -0,0 +1,77 @@ +/* + * 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.sdb; + +import com.sun.star.sdb.XCompletedExecution; +import com.sun.star.task.XInteractionHandler; +import java.io.PrintWriter; +import lib.MultiMethodTest; +import lib.StatusException; + +/** + * + */ +public class _XCompletedExecution extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XCompletedExecution oObj = null ; + + private CheckInteractionHandler checkHandler = null; + /** + * Interface to implement so the call of the listener can be checked. + */ + public interface CheckInteractionHandler extends XInteractionHandler { + /** + * Set a log of the listener, so messages of the listener get printed + * into the file of the interface + */ + void setLog(PrintWriter log); + /** + * Return True, when the listener was called correctly. + */ + boolean checkInteractionHandler(); + } + + @Override + protected void before() { + checkHandler = (CheckInteractionHandler) + tEnv.getObjRelation("InteractionHandlerChecker"); + if (checkHandler == null) + throw new StatusException("Missing object relation 'InteractionHandlerChecker'", new Exception()); + checkHandler.setLog(log); + } + + + public void _executeWithCompletion() { + try { + oObj.executeWithCompletion(checkHandler); + } + catch(com.sun.star.sdbc.SQLException e) { + e.printStackTrace(log); + tRes.tested("executeWithCompletion()", false); + return; + } + + tRes.tested("executeWithCompletion()", checkHandler.checkInteractionHandler()); + } + + @Override + protected void after() { + disposeEnvironment(); + } +} diff --git a/qadevOOo/tests/java/ifc/sdb/_XFormDocumentsSupplier.java b/qadevOOo/tests/java/ifc/sdb/_XFormDocumentsSupplier.java new file mode 100644 index 000000000..3ca625281 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XFormDocumentsSupplier.java @@ -0,0 +1,55 @@ +/* + * 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.sdb; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.sdb.XFormDocumentsSupplier; + +/** +* <code>com.sun.star.sdb.XFormDocumentsSupplier</code> interface +* testing. +* @see com.sun.star.sdb.XFormDocumentsSupplier +*/ +public class _XFormDocumentsSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XFormDocumentsSupplier oObj = null ; + + /** + * Has OK status if not null returned. <p> + */ + public void _getFormDocuments() { + + XNameAccess docs = oObj.getFormDocuments() ; + + String[] docNames = docs.getElementNames() ; + if (docNames != null) { + log.println("Totally " + docNames.length + " documents :") ; + for (int i = 0; i < docNames.length; i++) + log.println(" " + docNames[i]) ; + } + + tRes.tested("getFormDocuments()", docNames != null) ; + } + +} // finish class _XFormDocumentsSupplier + + diff --git a/qadevOOo/tests/java/ifc/sdb/_XParametersSupplier.java b/qadevOOo/tests/java/ifc/sdb/_XParametersSupplier.java new file mode 100644 index 000000000..0c40f8547 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XParametersSupplier.java @@ -0,0 +1,52 @@ +/* + * 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.sdb; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.sdb.XParametersSupplier; +import lib.MultiMethodTest; + +/** +* Testing <code>com.sun.star.sdb.XParametersSupplier</code> +* interface methods : +* <ul> +* <li><code> getParameters()</code></li> +* </ul> <p> +* Test is multithread compliant. <p> +* @see com.sun.star.sdb.XParametersSupplier +*/ +public class _XParametersSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XParametersSupplier oObj = null ; + + /** + * checks of the return of <code>getParameters()</code> + * is not null + */ + public void _getParameters() { + + XIndexAccess the_Set = oObj.getParameters(); + if (the_Set == null) log.println("'getParameters()' returns NULL"); + tRes.tested("getParameters()",the_Set != null); + + } +} // finish class _XParametersSupplier + + diff --git a/qadevOOo/tests/java/ifc/sdb/_XQueryDefinitionsSupplier.java b/qadevOOo/tests/java/ifc/sdb/_XQueryDefinitionsSupplier.java new file mode 100644 index 000000000..a8d88983a --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XQueryDefinitionsSupplier.java @@ -0,0 +1,60 @@ +/* + * 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.sdb; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.sdb.XQueryDefinitionsSupplier; + +/** + * Testing <code>com.sun.star.sdb.XQueryDefinitionsSupplier</code> + * interface methods : + * <ul> + * <li><code> getQueryDefinitions()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.sdb.XQueryDefinitionsSupplier + */ +public class _XQueryDefinitionsSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XQueryDefinitionsSupplier oObj = null ; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getQueryDefinitions() { + + XNameAccess docs = oObj.getQueryDefinitions() ; + + String[] docNames = docs.getElementNames() ; + if (docNames != null) { + log.println("Totally " + docNames.length + " queries :") ; + for (int i = 0; i < docNames.length; i++) + log.println(" " + docNames[i]) ; + } + + tRes.tested("getQueryDefinitions()", docNames != null) ; + } + +} // finish class _XQueryDefinitionsSupplier + diff --git a/qadevOOo/tests/java/ifc/sdb/_XReportDocumentsSupplier.java b/qadevOOo/tests/java/ifc/sdb/_XReportDocumentsSupplier.java new file mode 100644 index 000000000..fe1b5f0b1 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XReportDocumentsSupplier.java @@ -0,0 +1,55 @@ +/* + * 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.sdb; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.sdb.XReportDocumentsSupplier; + +/** +* <code>com.sun.star.sdb.XReportDocumentsSupplier</code> interface +* testing. +* @see com.sun.star.sdb.XReportDocumentsSupplier +*/ +public class _XReportDocumentsSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XReportDocumentsSupplier oObj = null ; + + /** + * Has OK status if not null returned. <p> + */ + public void _getReportDocuments() { + + XNameAccess docs = oObj.getReportDocuments() ; + + String[] docNames = docs.getElementNames() ; + if (docNames != null) { + log.println("Totally " + docNames.length + " documents :") ; + for (int i = 0; i < docNames.length; i++) + log.println(" " + docNames[i]) ; + } + + tRes.tested("getReportDocuments()", docNames != null) ; + } + +} // finish class _XReportDocumentsSupplier + + diff --git a/qadevOOo/tests/java/ifc/sdb/_XResultSetAccess.java b/qadevOOo/tests/java/ifc/sdb/_XResultSetAccess.java new file mode 100644 index 000000000..f689c6cbf --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XResultSetAccess.java @@ -0,0 +1,60 @@ +/* + * 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.sdb; + +import lib.MultiMethodTest; + +import com.sun.star.sdb.XResultSetAccess; +import com.sun.star.sdbc.XResultSet; + +/** +* Testing <code>com.sun.star.sdb.XResultSetAccess</code> +* interface methods : +* <ul> +* <li><code> createResultSet()</code></li> +* </ul> <p> +* Test is multithread compliant. <p> +* @see com.sun.star.sdb.XResultSetAccess +*/ +public class _XResultSetAccess extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XResultSetAccess oObj = null ; + + /** + * tries to create a ResultSet for the Object</br> + * an XResultSet is returned.</br> + * The test is OK if a not null ResultSet is returned + */ + public void _createResultSet() { + + try { + XResultSet the_Set = oObj.createResultSet(); + if (the_Set == null) log.println("'createResulSet()' returns NULL"); + tRes.tested("createResultSet()",the_Set != null); + } catch (com.sun.star.sdbc.SQLException e) { + log.println("Exception while checking 'createResultSet()'"); + e.printStackTrace(log); + tRes.tested("createResultSet()",false); + } + + } +} // finish class _XResultSetAccess + + diff --git a/qadevOOo/tests/java/ifc/sdb/_XRowSetApproveBroadcaster.java b/qadevOOo/tests/java/ifc/sdb/_XRowSetApproveBroadcaster.java new file mode 100644 index 000000000..62911c851 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XRowSetApproveBroadcaster.java @@ -0,0 +1,207 @@ +/* + * 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.sdb; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.lang.EventObject; +import com.sun.star.sdb.RowChangeEvent; +import com.sun.star.sdb.XRowSetApproveBroadcaster; +import com.sun.star.sdb.XRowSetApproveListener; + +/** +* <code>com.sun.star.sdb.XRowSetApproveBroadcaster</code> interface test. <p> +* Required object relations : +* <ul> +* <li> <code>'XRowSetApproveBroadcaster.ApproveChecker'</code>: +* implementation of inner interface <code>RowSetApproveChecker</code> +* which can move cursor within a rowset, change row, and change the +* whole rowset. </li> +* </ul> <p> +* It is better to recreate the object after test, because of unknown +* actions made by <code>RowSetApproveChecker</code> interface implementation. +* +* @see com.sun.star.sdb.XRowSetApproveBroadcaster +* @see _XRowSetApproveBroadcaster.RowSetApproveChecker +*/ +public class _XRowSetApproveBroadcaster extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XRowSetApproveBroadcaster oObj = null ; + + /** + * The purpose of this interface is to pass to this test + * relation which can make some operations with row set + * on which <code>XRowSetApproveListener</code>s can react. + * @see com.sun.star.sdb.XRowSetApproveListener + */ + public interface RowSetApproveChecker { + /** + * Moves cursor within row set. Method <code>approveCursorMove</code> + * of <code>XRowSetApproveListener</code> must be called. + */ + void moveCursor() ; + /** + * Change rows in row set. Method <code>approveRowChange</code> + * of <code>XRowSetApproveListener</code> must be called. + * @return <code>RowChangeEvent</code> structure which contains + * what type of change was made and how many rows it affected. + * @see com.sun.star.sdb.RowChangeEvent + */ + RowChangeEvent changeRow() ; + /** + * Change the whole row set. Method <code>approveRowSetChange</code> + * of <code>XRowSetApproveListener</code> must be called. + */ + void changeRowSet() ; + } + + /** + * Implementation of <code>XRowSetApproveListener</code> interface + * which just detects and stores approve requirements. They are checked + * later. + */ + private static class TestListener implements XRowSetApproveListener { + public boolean approveRequests = true ; + public boolean approveCursorMoveCalled = false ; + public boolean approveRowChangeCalled = false ; + public RowChangeEvent approveRowChangeEvent = null ; + public boolean approveRowSetChangeCalled = false ; + + public TestListener(boolean approve) { + approveRequests = approve ; + } + + public void reset() { + approveCursorMoveCalled = false ; + approveRowChangeCalled = false ; + approveRowSetChangeCalled = false ; + } + public boolean approveCursorMove(EventObject ev) { + approveCursorMoveCalled = true ; + return approveRequests ; + } + public boolean approveRowChange(RowChangeEvent ev) { + approveRowChangeCalled = true ; + approveRowChangeEvent = ev ; + return approveRequests ; + } + public boolean approveRowSetChange(EventObject ev) { + approveRowSetChangeCalled = true ; + return approveRequests ; + } + public void disposing(EventObject ev) {} + } + private TestListener listener1 = null ; + + private RowSetApproveChecker checker = null ; + + /** + * Tries to retrieve object relation. + */ + @Override + public void before() { + checker = (RowSetApproveChecker) tEnv.getObjRelation + ("XRowSetApproveBroadcaster.ApproveChecker") ; + + if (checker == null) { + log.println("!!! Relation for test not found !!!") ; + throw new StatusException(Status.failed + ("!!! Relation for test not found !!!")) ; + } + } + + /** + * Creates and adds listener, then call <code>RowSetApproveChecker</code> + * methods for listener methods to be called. Then checks if + * listener methods were called on appropriate actions. <p> + * Has OK status : If and only if appropriate listener methods called, + * and listener <code>approveRowChange</code> method has write parameter, + * i.e. type and rows number expected. + */ + public void _addRowSetApproveListener() { + listener1 = new TestListener(true) ; + oObj.addRowSetApproveListener(listener1) ; + log.println("Listener added.") ; + + boolean result = true ; + + checker.moveCursor() ; + log.println("Cursor moved.") ; + result &= listener1.approveCursorMoveCalled ; + + listener1.reset() ; + RowChangeEvent actualEvent = checker.changeRow() ; + log.println("Row changed.") ; + + RowChangeEvent event = listener1.approveRowChangeEvent ; + result &= listener1.approveRowChangeCalled ; + + boolean eventOK = event.Action == actualEvent.Action && + event.Rows == actualEvent.Rows ; + + result &= eventOK ; + + listener1.reset() ; + checker.changeRowSet(); + log.println("Row set changed.") ; + result &= listener1.approveRowSetChangeCalled ; + + tRes.tested("addRowSetApproveListener()", result) ; + } + + /** + * Removes listener inserted before, then perform all actions + * on which listener must react. <p> + * Has OK status if no listener methods were called. <p> + * Methods required to pass before : + * <ul> + * <li> <code>_addRowSetApproveListener</code> </li> + * </ul> + */ + public void _removeRowSetApproveListener() { + requiredMethod("addRowSetApproveListener()") ; + + listener1.reset() ; + + oObj.removeRowSetApproveListener(listener1) ; + + checker.moveCursor() ; + checker.changeRow() ; + checker.changeRowSet() ; + + tRes.tested("removeRowSetApproveListener()", + !listener1.approveCursorMoveCalled && + !listener1.approveRowChangeCalled && + !listener1.approveRowSetChangeCalled) ; + } + + /** + * Disposes object environment. + */ + @Override + public void after() { + disposeEnvironment() ; + } + +} // finish class _XRowSetApproveBroadcaster + + diff --git a/qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster.java b/qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster.java new file mode 100644 index 000000000..ca2efa664 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster.java @@ -0,0 +1,29 @@ +/* + * 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.sdb; + +import com.sun.star.sdb.XSQLErrorBroadcaster; +import lib.MultiMethodTest; + +/** + * + */ +public class _XSQLErrorBroadcaster extends MultiMethodTest { + + public XSQLErrorBroadcaster oObj = null; +} diff --git a/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryAnalyzer.java b/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryAnalyzer.java new file mode 100644 index 000000000..39aabf688 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryAnalyzer.java @@ -0,0 +1,290 @@ +/* + * 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.sdb; + +import com.sun.star.sdb.XSingleSelectQueryAnalyzer; +import lib.MultiMethodTest; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.uno.UnoRuntime; +import lib.StatusException; +import lib.Status; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; + +/** +* Testing <code>com.sun.star.sdb.XSingleSelectQueryAnalyzer</code> +* interface methods : +* <ul> +* <li><code>getQuery()</code></li> +* <li><code>setQuery()</code></li> +* <li><code>getFilter()</code></li> +* <li><code>getStructuredFilter()</code></li> +* <li><code>getGroup()</code></li> +* <li><code>getGroupColumns()</code></li> +* <li><code>getHavingClause()</code></li> +* <li><code>getStructuredHavingClause()</code></li> +* <li><code>getOrder()</code></li> +* <li><code>getOrderColumns()</code></li> + +* </ul> <p> +* @see com.sun.star.sdb.XSingleSelectQueryAnalyzer +*/ +public class _XSingleSelectQueryAnalyzer extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XSingleSelectQueryAnalyzer oObj = null ; + + private static final String queryString = "SELECT * FROM \"biblio\""; + + private XSingleSelectQueryComposer xComposer = null; + + /** + * Receives the object relations: + * <ul> + * <li><code>XSingleSelectQueryComposer xCompoer</code></li> + * </ul> <p> + * @see com.sun.star.sdb.XSingleSelectQueryComposer + */ + @Override + protected void before() { + + xComposer = UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, + tEnv.getObjRelation("xComposer")); + + if (xComposer == null) { + throw new StatusException(Status.failed( + "Couldn't get object relation 'xComposer'. Test must be modified")); + + } + + } + /** + * call <code>setQuery()</code> once with valid query, once with invalid + * query. Has ok if only on second call <code>SQLException</code> was thrown + */ + public void _setQuery() { + + try{ + oObj.setQuery("This is an invalid SQL query"); + } catch (com.sun.star.sdbc.SQLException e){ + log.println("expected Exception. "); + } + + try{ + oObj.setQuery(queryString); + } catch (com.sun.star.sdbc.SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("setQuery()", false); + } + tRes.tested("setQuery()", true); + } + + /** + * checks of the returned value of <code>getQuery()</code> + * equals the string which was set by <code>setQuery()</code> + * <p> + * required methods: + *<ul> + * <li><code>setQuery</code></li> + *</ul> + */ + public void _getQuery() { + this.requiredMethod("setQuery()"); + + boolean res = false; + + res = oObj.getQuery().equals(queryString); + + tRes.tested("getQuery()", res); + } + + + /** + * Object relation <code>xComposer</code> set a filter. This filter + * must returned while calling <code>getFilter</code> + */ + public void _getFilter() { + try{ + String filter = "\"Identifier\" = 'BOR02b'"; + xComposer.setFilter(filter); + tRes.tested("getFilter()", oObj.getFilter().equals(filter)); + + } catch (com.sun.star.sdbc.SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getFilter()", false); + } + } + + /** + * Object relation <code>xComposer</code> set a complex filter with method + . <code>setFilter</code>. Then <code>getStructuredFilter</code> returns a + * sequence of <code>PropertyValue</code> which was set with method + * <code>setStructuredFilter</code> from <xComposer>. + * Then test has ok status if <getFilter> returns the complex filter. + * <p> + * required methods: + *<ul> + * <li><code>setQuery</code></li> + * <li><code>getFilter</code></li> + *</ul> + */ + public void _getStructuredFilter() { + requiredMethod("setQuery()"); + requiredMethod("getFilter()"); + try{ + oObj.setQuery("SELECT \"Identifier\", \"Type\", \"Address\" FROM \"biblio\" \"biblio\""); + String complexFilter = "( \"Identifier\" >= '1' AND \"Type\" <= '4' ) OR ( \"Identifier\" <> '2' AND \"Type\" = '5' ) OR ( \"Identifier\" < '3' AND \"Type\" > '6' AND \"Address\" = '7' ) OR ( \"Address\" >= '8' ) OR ( \"Type\" = '9' )"; + xComposer.setFilter(complexFilter); + PropertyValue[][] aStructuredFilter = oObj.getStructuredFilter(); + + xComposer.setFilter(""); + xComposer.setStructuredFilter(aStructuredFilter); + tRes.tested("getStructuredFilter()", oObj.getFilter().equals(complexFilter)); + + } catch (com.sun.star.sdbc.SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getStructuredFilter()", false); + } catch (com.sun.star.lang.IllegalArgumentException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getStructuredFilter()", false); + } + } + + /** + * Object relation <code>xComposer</code> set a goup. This group + * must returned while calling <code>getGroup</code> + */ + public void _getGroup() { + try{ + String group = "\"Identifier\""; + xComposer.setGroup(group); + tRes.tested("getGroup()", oObj.getGroup().equals(group)); + + } catch (com.sun.star.sdbc.SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getGroup()", false); + } + } + + /** + * Method <code>getGroupColumns</code> returns a <code>XIndexAccess</code> + * Test has ok status if returned value is a usable <code>XIndexAccess</code> + */ + public void _getGroupColumns() { + try{ + XIndexAccess xGroupColumns = oObj.getGroupColumns(); + + tRes.tested("getGroupColumns()", (xGroupColumns != null && + xGroupColumns.getCount() == 1 && + xGroupColumns.getByIndex(0) != null)); + + } catch (com.sun.star.lang.IndexOutOfBoundsException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getGroupColumns()", false); + } catch (com.sun.star.lang.WrappedTargetException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getGroupColumns()", false); + } + } + + /** + * Object relation <code>xComposer</code> set a clause. This clause + * must returned while calling <code>getHavingClause</code> + */ + public void _getHavingClause() { + try{ + String clause = "\"Identifier\" = 'BOR02b'"; + xComposer.setHavingClause(clause); + tRes.tested("getHavingClause()", oObj.getHavingClause().equals(clause)); + + } catch (com.sun.star.sdbc.SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getHavingClause()", false); + } + } + + /** + * Object relation <code>xComposer</code> set a clause. This clause + * must returned while calling <code>getHavingClause</code> + * <p> + * required methods: + *<ul> + * <li><code>setQuery</code></li> + * <li><code>getFilter</code></li> + * <li><code>getStructuredFilter</code></li> + *</ul> + */ + public void _getStructuredHavingClause() { + requiredMethod("setQuery()"); + requiredMethod("getFilter()"); + executeMethod("getStructuredFilter()"); + + String complexFilter = "( \"Identifier\" >= '1' AND \"Type\" <= '4' ) OR ( \"Identifier\" <> '2' AND \"Type\" = '5' ) OR ( \"Identifier\" < '3' AND \"Type\" > '6' AND \"Address\" = '7' ) OR ( \"Address\" >= '8' ) OR ( \"Type\" = '9' )"; + try{ + xComposer.setHavingClause(complexFilter); + PropertyValue[][] aStructuredHaving = oObj.getStructuredHavingClause(); + xComposer.setHavingClause(""); + xComposer.setStructuredHavingClause(aStructuredHaving); + tRes.tested("getStructuredHavingClause()", + oObj.getHavingClause().equals(complexFilter)); + + } catch (com.sun.star.sdbc.SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getStructuredHavingClause()", false); + } + } + + /** + * Object relation <code>xComposer</code> set an order. This order + * must returned while calling <code>getOrder</code> + */ + public void _getOrder() { + try{ + String order = "\"Identifier\""; + xComposer.setOrder(order); + tRes.tested("getOrder()", oObj.getOrder().equals(order)); + + } catch (com.sun.star.sdbc.SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getOrder()", false); + } + } + + /** + * Method <code>getGroupColumns</code> returns a <code>XIndexAccess</code> + * Test has ok status if returned value is a usable <code>XIndexAccess</code> + */ + public void _getOrderColumns() { + try{ + XIndexAccess xOrderColumns = oObj.getOrderColumns(); + tRes.tested("getOrderColumns()", (xOrderColumns != null && + xOrderColumns.getCount() == 1 && + xOrderColumns.getByIndex(0) != null)); + + } catch (com.sun.star.lang.IndexOutOfBoundsException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getOrderColumns()", false); + } catch (com.sun.star.lang.WrappedTargetException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("getOrderColumns()", false); + } + } + + +} // finish class _XSingleSelectQueryAnalyzer diff --git a/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer.java b/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer.java new file mode 100644 index 000000000..53b31f693 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer.java @@ -0,0 +1,521 @@ +/* + * 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.sdb; + +import com.sun.star.sdb.XSingleSelectQueryComposer; +import lib.MultiMethodTest; +import com.sun.star.sdb.XSingleSelectQueryAnalyzer; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import lib.StatusException; +import lib.Status; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.sdb.SQLFilterOperator; +import com.sun.star.sdbc.SQLException; + +/** +* Testing <code>com.sun.star.sdb.XSingleSelectQueryComposer</code> +* interface methods : +* <ul> +* <li><code>setFilter()</code></li> +* <li><code>setStructuredFilter()</code></li> +* <li><code>appendFilterByColumn()</code></li> +* <li><code>appendGroupByColumn()</code></li> +* <li><code>setGroup()</code></li> +* <li><code>setHavingClause()</code></li> +* <li><code>setStructuredHavingClause()</code></li> +* <li><code>appendHavingClauseByColumn()</code></li> +* <li><code>appendOrderByColumn()</code></li> +* <li><code>setOrder()</code></li> + +* </ul> <p> +* @see com.sun.star.sdb.XSingleSelectQueryComposer +*/ +public class _XSingleSelectQueryComposer extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XSingleSelectQueryComposer oObj = null ; + + private XSingleSelectQueryAnalyzer xQueryAna = null; + + private XPropertySet xProp = null; + + private String colName = null; + + private XResultSet xReSet = null; + + /** + * Retrieves the object relations: + * <ul> + * <li><code>XSingleSelectQueryAnalyzer xQueryAna</code></li> + * <li><code>XPropertySet xProp</code></li> + * <li><code>String colName</code></li> + * </ul> <p> + * @see com.sun.star.sdb.XSingleSelectQueryAnalyzer + * @see com.sun.star.beans.XPropertySet + */ + @Override + protected void before() /* throws Exception*/ { + + xQueryAna = UnoRuntime.queryInterface(XSingleSelectQueryAnalyzer.class, + tEnv.getObjRelation("xQueryAna")); + + if (xQueryAna == null) { + throw new StatusException(Status.failed( + "Couldn't get object relation 'xQueryAna'. Test must be modified")); + + } + + xProp = UnoRuntime.queryInterface(XPropertySet.class, + tEnv.getObjRelation("xProp")); + + if (xProp == null) { + throw new StatusException(Status.failed( + "Couldn't get object relation 'xProp'. Test must be modified")); + + } + + xReSet = UnoRuntime.queryInterface(XResultSet.class, + tEnv.getObjRelation("xResultSet")); + + if (xReSet == null) { + throw new StatusException(Status.failed( + "Couldn't get object relation 'xResultSet'. Test must be modified")); + + } + + try + { + colName = AnyConverter.toString(tEnv.getObjRelation("colName")); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + colName = null; + } + + if (colName == null) { + throw new StatusException(Status.failed( + "Couldn't get object relation 'colName'. Test must be modified")); + + } + + } + + + /** + * Object relation <code>xQueryAna</code> set a filter. This filter + * must returned while calling <code>getFilter</code> + */ + public void _setFilter() { + try{ + String filter = "\"Identifier\" = 'BOR02b'"; + oObj.setFilter(filter); + tRes.tested("setFilter()", xQueryAna.getFilter().equals(filter)); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("setFilter()", false); + } + } + + /** + * Object relation <code>xQueryAna</code> set a complex filter with method + . <code>setFilter</code>. Then <code>getStructuredFilter</code> returns a + * sequence of <code>PropertyValue</code> which was set with method + * <code>setStructuredFilter</code> from <code>xQueryAna</code>. + * Then test has ok status if <code>getFilter</code> returns the complex filter. + */ + public void _setStructuredFilter() { + requiredMethod("setFilter()"); + try{ + xQueryAna.setQuery("SELECT \"Identifier\", \"Type\", \"Address\" FROM \"biblio\" \"biblio\""); + String complexFilter = "( \"Identifier\" >= '1' AND \"Type\" <= '4' ) OR ( \"Identifier\" <> '2' AND \"Type\" = '5' ) OR ( \"Identifier\" < '3' AND \"Type\" > '6' AND \"Address\" = '7' ) OR ( \"Address\" >= '8' ) OR ( \"Type\" = '9' )"; + oObj.setFilter(complexFilter); + PropertyValue[][] aStructuredFilter = xQueryAna.getStructuredFilter(); + oObj.setFilter(""); + oObj.setStructuredFilter(aStructuredFilter); + tRes.tested("setStructuredFilter()", xQueryAna.getFilter().equals(complexFilter)); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("setStructuredFilter()", false); + } catch (com.sun.star.lang.IllegalArgumentException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("setStructuredFilter()", false); + } + } + + /** + * At first the object relation <code>xProp</code> was set as parameter. + * Relation <code>xQueryAna</code> was used to check if relation + * <code>colName</code> was found. + * Second an empty <code>XPropertySet</code> was used as parameter. A + * <code>SQLException</code> must be thrown. + */ + public void _appendFilterByColumn() { + boolean ok = true; + try + { + xReSet.beforeFirst(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + try + { + oObj.appendFilterByColumn(xProp, true,SQLFilterOperator.EQUAL); + log.println("expected Exception was not thrown"); + tRes.tested("appendFilterByColumn()", false); + ok = false; + } + catch (com.sun.star.uno.RuntimeException e) + { + log.println("expected Exception: " + e.toString()); + ok = ok && true; + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + + try + { + xReSet.first(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + try{ + + oObj.appendFilterByColumn(xProp, true,SQLFilterOperator.EQUAL); + log.println("appendFilterByColumn: " + xQueryAna.getFilter()); + ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + catch (com.sun.star.lang.WrappedTargetException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + + try{ + + oObj.appendFilterByColumn(xProp, false,SQLFilterOperator.EQUAL); + log.println("appendFilterByColumn: " + xQueryAna.getFilter()); + ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } catch (com.sun.star.lang.WrappedTargetException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + + try{ + XPropertySet dummy = null; + oObj.appendFilterByColumn(dummy, true,SQLFilterOperator.EQUAL); + log.println("expected Exception was not thrown"); + tRes.tested("appendFilterByColumn()", false); + + } catch (SQLException e){ + log.println("expected Exception"); + ok = ok && true; + } catch (com.sun.star.lang.WrappedTargetException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + + try + { + xReSet.beforeFirst(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + tRes.tested("appendFilterByColumn()", ok); + } + + /** + * At first the object relation <code>xProp</code> was used as parameter. + * Relation <code>xQueryAna</code> was used to check if relation + * <code>colName</code> was found. + * Second an empty <code>XPropertySet</code> was used as parameter. An + * <code>SQLException</code> must be thrown. + */ + public void _appendGroupByColumn() { + boolean ok = true; + try{ + + oObj.appendGroupByColumn(xProp); + log.println("appendGroupByColumn: " + xQueryAna.getFilter()); + ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendGroupByColumn()", false); + } + try{ + XPropertySet dummy = null; + oObj.appendGroupByColumn(dummy); + log.println("expected Exception was not thrown"); + tRes.tested("appendGroupByColumn()", false); + + } catch (SQLException e){ + log.println("expected Exception"); + ok = ok && true; + } + tRes.tested("appendGroupByColumn()", ok); + } + + /** + * The group which was set by <code>setGroup</code> must be returned + * while calling from object relation <code>XQueryAna</code> + * method <code>getGroup</code> + */ + public void _setGroup() { + try{ + String group = "\"Identifier\""; + oObj.setGroup(group); + tRes.tested("setGroup()", xQueryAna.getGroup().equals(group)); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("setGroup()", false); + } + } + + + /** + * The clause which was set by <code>setHavingClause</code> must be returned + * while calling from object relation <code>XQueryAna</code> + * method <code>getHavingClause</code> + */ + public void _setHavingClause() { + try{ + String clause = "\"Identifier\" = 'BOR02b'"; + oObj.setHavingClause(clause); + tRes.tested("setHavingClause()", + xQueryAna.getHavingClause().equals(clause)); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("setHavingClause()", false); + } + } + + /** + * At first <code>setHavingClause</code> sets a complex clause. + * Then method <code>getStructuredHavingClause</code> from object relation + * <code>xQueryAna</code> returns a valid <code>PropertyValue[][]</code> + * Method <code>setHavingClause</code> was called with an empty string to + * reset filter. Now <code>setStructuredHavingClause</code> with the valid + * <code>PropertyValue[][]</code> as parameter was called. + * Test is ok if <code>getHavingClause</code> from <code>xQueryAna</code> + * returns the complex clause from beginning. + * <p> + * required methods: + *<ul> + * <li><code>setHavingClause</code></li> + * <li><code>setStructuredFilter</code></li> + *</ul> + */ + public void _setStructuredHavingClause() { + requiredMethod("setHavingClause()"); + executeMethod("setStructuredFilter()"); + String complexFilter = "( \"Identifier\" >= '1' AND \"Type\" <= '4' ) OR ( \"Identifier\" <> '2' AND \"Type\" = '5' ) OR ( \"Identifier\" < '3' AND \"Type\" > '6' AND \"Address\" = '7' ) OR ( \"Address\" >= '8' ) OR ( \"Type\" = '9' )"; + try{ + oObj.setHavingClause(complexFilter); + PropertyValue[][] aStructuredHaving = + xQueryAna.getStructuredHavingClause(); + oObj.setHavingClause(""); + oObj.setStructuredHavingClause(aStructuredHaving); + tRes.tested("setStructuredHavingClause()", + xQueryAna.getHavingClause().equals(complexFilter)); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("setStructuredHavingClause()", false); + } + } + + /** + * First object relation <code>xProp</code> was used as parameter. Relation + * <code>xQueryAna</code> was used to check if relation <code>colName</code> + * was found. + * Second an empty <code>XPropertySet</code> was given as parameter. An + * <code>SQLException</code> must be thrown. + */ + public void _appendHavingClauseByColumn() { + boolean ok = true; + try + { + xReSet.beforeFirst(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } + try{ + + oObj.appendHavingClauseByColumn(xProp, true,SQLFilterOperator.EQUAL); + log.println("expected Exception was not thrown"); + tRes.tested("appendHavingClauseByColumn()", false); + ok = false; + + } + catch (com.sun.star.uno.RuntimeException e) + { + log.println("expected Exception: " + e.toString()); + ok = ok && true; + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } catch (com.sun.star.lang.WrappedTargetException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } + + try + { + xReSet.first(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } + try{ + + oObj.appendHavingClauseByColumn(xProp, true,SQLFilterOperator.EQUAL); + log.println("appendHavingClauseByColumn: " + xQueryAna.getFilter()); + ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } catch (com.sun.star.lang.WrappedTargetException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } + + try{ + XPropertySet dummy = null; + oObj.appendHavingClauseByColumn(dummy, true,SQLFilterOperator.EQUAL); + log.println("expected Exception was not thrown"); + tRes.tested("appendHavingClauseByColumn()", false); + + } catch (SQLException e){ + log.println("expected Exception"); + ok = ok && true; + } catch (com.sun.star.lang.WrappedTargetException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } + + // cleanup + try + { + xReSet.beforeFirst(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } + tRes.tested("appendHavingClauseByColumn()", ok); + } + + /** + * First object relation <code>xProp</code> was set as parameter. Relation + * <code>xQueryAna</code> was used to check if relation <code>colName</code> + * was found. + * Second an empty <code>XPropertySet</code> was given as parameter. An + * <code>SQLException</code> must be thrown. + */ + public void _appendOrderByColumn() { + boolean ok = true; + try{ + + oObj.appendOrderByColumn(xProp, true); + log.println("appendOrderByColumn: " + xQueryAna.getFilter()); + ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendOrderByColumn()", false); + } + try{ + XPropertySet dummy = null; + oObj.appendOrderByColumn(dummy, true); + log.println("expected Exception was not thrown"); + tRes.tested("appendOrderByColumn()", false); + + } catch (SQLException e){ + log.println("expected Exception"); + ok = ok && true; + } + tRes.tested("appendOrderByColumn()", ok); + } + + + /** + * Method <code>getOrder</code> from object relation <code>xQueryAna</code> + * checks the order which was set while calling <code>setOrder</code> + */ + public void _setOrder() { + try{ + String order = "\"Identifier\""; + oObj.setOrder(order); + tRes.tested("setOrder()", xQueryAna.getOrder().equals(order)); + + } catch (SQLException e){ + log.println("unexpected Exception: " + e.toString()); + tRes.tested("setOrder()", false); + } + } + + + +} // finish class _XSingleSelectQueryComposer diff --git a/qadevOOo/tests/java/ifc/sdbc/_ResultSet.java b/qadevOOo/tests/java/ifc/sdbc/_ResultSet.java new file mode 100644 index 000000000..56724524e --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_ResultSet.java @@ -0,0 +1,40 @@ +/* + * 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.sdbc; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sdbc.ResultSet</code> +* service properties : +* <ul> +* <li><code> CursorName</code></li> +* <li><code> ResultSetConcurrency</code></li> +* <li><code> ResultSetType</code></li> +* <li><code> FetchDirection</code></li> +* <li><code> FetchSize</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sdbc.ResultSet +*/ +public class _ResultSet extends MultiPropertyTest { + + +} // finish class _ResultSet + diff --git a/qadevOOo/tests/java/ifc/sdbc/_RowSet.java b/qadevOOo/tests/java/ifc/sdbc/_RowSet.java new file mode 100644 index 000000000..fae52a637 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_RowSet.java @@ -0,0 +1,72 @@ +/* + * 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.sdbc; + +import lib.MultiPropertyTest; + +import com.sun.star.uno.Any; + + +/** +* Testing <code>com.sun.star.sdbc.RowSet</code> +* service properties : +* <ul> +* <li><code> DataSourceName</code></li> +* <li><code> URL</code></li> +* <li><code> Command</code></li> +* <li><code> TransactionIsolation</code></li> +* <li><code> TypeMap</code></li> +* <li><code> EscapeProcessing</code></li> +* <li><code> QueryTimeOut</code></li> +* <li><code> MaxFieldSize</code></li> +* <li><code> MaxRows</code></li> +* <li><code> User</code></li> +* <li><code> Password</code></li> +* <li><code> ResultSetType</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sdbc.RowSet +*/ +public class _RowSet extends MultiPropertyTest { + + /** + * Redefined method returns object, that contains changed property value. + */ + public void _TypeMap() { + boolean result = false; + try { + Any TypeMap = (Any) oObj.getPropertyValue("TypeMap"); + String TypeName = TypeMap.getType().getTypeName(); + String expected = "com.sun.star.container.XNameAccess"; + result = TypeName.equals(expected); + if (! result ) { + log.println("Expected Type is "+expected); + log.println("but the returned is "+TypeName); + } + } catch(com.sun.star.lang.WrappedTargetException e) { + log.println("Exception " + e.getMessage()); + } catch(com.sun.star.beans.UnknownPropertyException e) { + log.println("Exception " + e.getMessage()); + } + + tRes.tested("TypeMap",result); + } + +} // finish class _RowSet + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XCloseable.java b/qadevOOo/tests/java/ifc/sdbc/_XCloseable.java new file mode 100644 index 000000000..efd39fd1f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XCloseable.java @@ -0,0 +1,85 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; +import lib.StatusException; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XCloseable; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sdbc.XCloseable</code> +* interface methods : +* <ul> +* <li><code> close()</code></li> +* </ul> <p> +* After test object must be recreated. +* @see com.sun.star.sdbc.XCloseable +*/ +public class _XCloseable extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XCloseable oObj = null ; + + /** + * Closes row set. If the component implements the interface + * <code>com.sun.star.sdbc.XResultSet</code> then tries to move + * the cursor to the first row in the result set. + * Has OK status if no exceptions were thrown during first call and + * if expected SQL exception was thrown during cursor moving. + */ + public void _close() throws StatusException { + boolean res = false; + try { + oObj.close(); + res = true; + } catch (SQLException e) { + log.println("Unexpected SQL Exception occurred:" + e) ; + res = false; + } + + XResultSet resSet = UnoRuntime.queryInterface(XResultSet.class, oObj); + + if (resSet != null) { + try { + resSet.first(); + log.println("Expected SQLException not occurred !"); + res = false; + } catch(SQLException e) { + log.println("Expected SQLException occurred"); + res = true; + } + } + + tRes.tested("close()", res); + } + + /** + * Forces environment recreation. + */ + @Override + public void after() { + disposeEnvironment() ; + } + +} // finish class _XCloseable + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XColumnLocate.java b/qadevOOo/tests/java/ifc/sdbc/_XColumnLocate.java new file mode 100644 index 000000000..f1d57c5b7 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XColumnLocate.java @@ -0,0 +1,76 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XColumnLocate; + +/** +/** +* Testing <code>com.sun.star.sdbc.XColumnLocate</code> +* interface methods : +* <ul> +* <li><code> findColumn()</code></li> +* </ul> <p> +* The test required the following relations : +* <ul> +* <li> <code> XColumnLocate.ColumnName </code> : The name of the first +* column. </li> +* </ul> +* @see com.sun.star.sdbc.XColumnLocate +*/ +public class _XColumnLocate extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XColumnLocate oObj = null ; + + /** + * Using column name from object relation trying to find out + * the index of this column. <p> + * Has OK status if column index returned by method equals to 1, + * FAILED otherwise. + */ + public void _findColumn() { + boolean result = false ; + String colName = (String) tEnv.getObjRelation("XColumnLocate.ColumnName") ; + + if (colName == null) { + throw new StatusException( + Status.failed("Object relation 'XColumnLocate.ColumnName' " + + "for this interface not found")); + } + + try { + int colIdx = oObj.findColumn(colName) ; + result = colIdx == 1 ; + } catch (SQLException e) { + log.println("Exception occurred:"); + e.printStackTrace(log); + result = false; + } + + tRes.tested("findColumn()", result); + } + +} // finish class _XColumnLocate + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XDataSource.java b/qadevOOo/tests/java/ifc/sdbc/_XDataSource.java new file mode 100644 index 000000000..304ea7ded --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XDataSource.java @@ -0,0 +1,105 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; + +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XDataSource; + +/** +* Testing <code>com.sun.star.sdbc.XDataSource</code> +* interface methods : +* <ul> +* <li><code>getConnection()</code></li> +* <li><code>setLoginTimeout()</code></li> +* <li><code>getLoginTimeout()</code></li> +* </ul> <p> +* @see com.sun.star.sdbc.XDataSource +*/ +public class _XDataSource extends MultiMethodTest { + // oObj filled by MultiMethodTest + public XDataSource oObj = null; + + /** + * Calls the method and checks returned value. + * Has OK status if exception wasn't thrown and + * if returned value isn't null. + */ + public void _getConnection() { + boolean res = true; + + try { + XConnection connection = oObj.getConnection("", ""); + res = connection != null; + } catch(com.sun.star.sdbc.SQLException e) { + log.println("Unexpected exception:"); + e.printStackTrace(log); + res = false; + } + + tRes.tested("getConnection()", res); + } + + /** + * Sets new timeout, compares with timeout returned by the method + * <code>getLoginTimeout()</code>. + * Has OK status if exception wasn't thrown and if timeout values are equal. + */ + public void _setLoginTimeout() { + requiredMethod("getLoginTimeout()"); + boolean res = true; + + try { + final int TO = 111; + log.println("setLoginTimeout(" + TO + ")"); + oObj.setLoginTimeout(TO); + int timeout = oObj.getLoginTimeout(); + res = timeout == TO; + log.println("getLoginTimeout(): " + timeout); + } catch(com.sun.star.sdbc.SQLException e) { + log.println("Unexpected exception:"); + e.printStackTrace(log); + res = false; + } + + tRes.tested("setLoginTimeout()", res); + } + + /** + * Calls the method and checks returned value. + * Has OK status if exception wasn't thrown and + * if returned value is equal to zero. + */ + public void _getLoginTimeout() { + boolean res = true; + + try { + int timeout = oObj.getLoginTimeout(); + log.println("getLoginTimeout(): " + timeout); + res = timeout == 0; + } catch(com.sun.star.sdbc.SQLException e) { + log.println("Unexpected exception:"); + e.printStackTrace(log); + res = false; + } + + tRes.tested("getLoginTimeout()", res); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sdbc/_XDriver.java b/qadevOOo/tests/java/ifc/sdbc/_XDriver.java new file mode 100644 index 000000000..4b0eb147f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XDriver.java @@ -0,0 +1,205 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.sdbc.DriverPropertyInfo; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XDriver; + +/** +* Testing <code>com.sun.star.sdbc.XDriver</code> +* interface methods : +* <ul> +* <li><code> connect()</code></li> +* <li><code> acceptsURL()</code></li> +* <li><code> getPropertyInfo()</code></li> +* <li><code> getMajorVersion()</code></li> +* <li><code> getMinorVersion()</code></li> +* </ul> <p> +* Required object relations : +* <ul> +* <li> <code>'XDriver.URL'</code>: +* is the URL of the database to which to connect</code></li> +* <li><code>'XDriver.UNSUITABLE_URL'</code>: +* the wrong kind of URL to connect using given driver</li> +* <li><code>'XDriver.INFO'</code>: +* a list of arbitrary string tag/value pairs as connection arguments</li> +* </ul> <p> +* @see com.sun.star.sdbc.XDriver +*/ +public class _XDriver extends MultiMethodTest { + // oObj filled by MultiMethodTest + public XDriver oObj = null; + String url = null; + String wrongUrl = null; + String nbu = null; + PropertyValue[] info = null; + + /** + * Retrieves relations. + * @throw StatusException If any relation not found. + */ + @Override + protected void before() { + nbu = (String) tEnv.getObjRelation("NoBadURL"); + url = (String)tEnv.getObjRelation("XDriver.URL"); + if (url == null) { + throw new StatusException(Status.failed( + "Couldn't get relation 'XDriver.URL'")); + } + wrongUrl = (String)tEnv.getObjRelation("XDriver.UNSUITABLE_URL"); + if (wrongUrl == null) { + throw new StatusException(Status.failed( + "Couldn't get relation 'XDriver.WRONG_URL'")); + } + info = (PropertyValue[])tEnv.getObjRelation("XDriver.INFO"); + if (info == null) { + throw new StatusException(Status.failed( + "Couldn't get relation 'XDriver.INFO'")); + } + } + + /** + * Connects to <code>'XDriver.URL'</code>, + * to <code>'XDriver.UNSUITABLE_URL'</code> and to wrong URL using + * <code>'XDriver.INFO'</code>. + * Has OK status if the method returns not null for <code>'XDriver.URL'</code>, + * null for <code>'XDriver.UNSUITABLE_URL'</code> and + * exception was thrown during the call with a wrong URL. + */ + public void _connect() { + boolean res = true; + + try { + log.println("Trying to connect to " + url); + XConnection connection = oObj.connect(url, info); + res = (connection != null); + log.println("Connected? " + res); + log.println("Trying to connect to " + wrongUrl); + connection = oObj.connect(wrongUrl, info); + res &= (connection == null); + log.println("Connected? " + !res); + } catch(SQLException e) { + log.println("Unexpected exception"); + res &= false; + } + + if (nbu==null) { + try { + String badUrl = url + "bla"; + log.println("Trying to connect to " + badUrl); + oObj.connect(badUrl, info); + res &= false; + log.println("Expected exception isn't thrown"); + } catch(SQLException e) { + log.println("Expected exception"); + res &= true; + } + } + + tRes.tested("connect()", res); + } + + /** + * Calls the method for <code>'XDriver.URL'</code> and + * for <code>'XDriver.UNSUITABLE_URL'</code>. + * Has OK status if the method returns true for <code>'XDriver.URL'</code> + * and false for <code>'XDriver.UNSUITABLE_URL'</code>. + */ + public void _acceptsURL() { + boolean res = false; + + try { + res = oObj.acceptsURL(url); + log.println("Accepts " + url + "? " + res); + res &= !oObj.acceptsURL(wrongUrl); + log.println("Accepts " + wrongUrl + "? " + !res); + } catch(SQLException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + res = false; + } + + tRes.tested("acceptsURL()", res); + } + + /** + * Calls the method with passed <code>'XDriver.URL'</code> and + * <code>'XDriver.INFO'</code>. Prints obtained driver properties info + * to log. + * Has OK status if returned value isn't null. + */ + public void _getPropertyInfo() { + requiredMethod("acceptsURL()"); + boolean res = false; + DriverPropertyInfo[] dpi = null; + try { + dpi = oObj.getPropertyInfo(url, info); + } catch(SQLException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + res = false; + } + + if (dpi != null) { + res = true; + log.println("Driver properties info:"); + for(int i = 0; i < dpi.length; i++) { + log.println("Property: " + dpi[i].Name); + log.println("Description: " + dpi[i].Description); + log.println("IsRequired? " + dpi[i].IsRequired); + log.println("Value: " + dpi[i].Value); + log.println("Choices: "); + for(int j = 0; j < dpi[i].Choices.length; j++) { + log.println("\t" + dpi[i].Choices[j]); + } + } + } + + tRes.tested("getPropertyInfo()", res); + } + + /** + * Calls the method. + * Has OK status if returned value is greater than or is equal to 1. + */ + public void _getMajorVersion() { + int majorVer = oObj.getMajorVersion(); + boolean res = majorVer >= 1; + log.println("Major version " + majorVer); + tRes.tested("getMajorVersion()", res); + } + + /** + * Calls the method. + * Has OK status if returned value is greater than or is equal to 0. + */ + public void _getMinorVersion() { + int minorVer = oObj.getMinorVersion(); + boolean res = minorVer >= 0; + log.println("Minor version " + minorVer); + tRes.tested("getMinorVersion()", res); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sdbc/_XDriverManager.java b/qadevOOo/tests/java/ifc/sdbc/_XDriverManager.java new file mode 100644 index 000000000..57477b4a7 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XDriverManager.java @@ -0,0 +1,152 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XDriverManager; + +/** +* Testing <code>com.sun.star.sdbc.XDriverManager</code> +* interface methods : +* <ul> +* <li><code> getConnection()</code></li> +* <li><code> getConnectionWithInfo()</code></li> +* <li><code> setLoginTimeout()</code></li> +* <li><code> getLoginTimeout()</code></li> +* </ul> <p> +* Required object relations : +* <ul> +* <li> <code>'SDBC.URL'</code>: +* is the URL of the database to which to connect using sdbc-driver +* </code></li> +* <li> <code>'JDBC.URL'</code>: +* is the URL of the database to which to connect using jdbc-driver +* </code></li> +* <li> <code>'JDBC.INFO'</code> of type <code>PropertyValue[]</code>: +* a list of arbitrary string tag/value pairs as connection arguments; +* normally at least a "user" and "password" property should be included +* </code></li> +* </ul> <p> +* @see com.sun.star.sdbc.XDriverManager +*/ +public class _XDriverManager extends MultiMethodTest { + // oObj filled by MultiMethodTest + public XDriverManager oObj = null; + String sdbcURL = null; + String jdbcURL = null; + PropertyValue[] jdbcINFO = null; + + /** + * Retrieves the required object relations. + */ + @Override + protected void before() { + sdbcURL = (String)tEnv.getObjRelation("SDBC.URL"); + if (sdbcURL == null) { + throw new StatusException( + Status.failed("Couldn't get relation 'SDBC.URL'")); + } + jdbcURL = (String)tEnv.getObjRelation("JDBC.URL"); + if (jdbcURL == null) { + throw new StatusException( + Status.failed("Couldn't get relation 'JDBC.URL'")); + } + jdbcINFO = (PropertyValue[])tEnv.getObjRelation("JDBC.INFO"); + if (jdbcINFO == null) { + throw new StatusException( + Status.failed("Couldn't get relation 'JDBC.INFO'")); + } + } + + /** + * Calls the method with the url received from the relation + * <code>SDBC.URL</code>. + * Has OK status if exception wasn't thrown and + * if returned value isn't null. + */ + public void _getConnection() { + boolean res = true; + + try { + log.println("getConnection(" + sdbcURL + ")"); + XConnection connection = oObj.getConnection(sdbcURL); + res = connection != null; + } catch(com.sun.star.sdbc.SQLException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + res = false; + } + + tRes.tested("getConnection()", res); + } + + /** + * Calls the method with the url received from the relation + * <code>JDBC.URL</code> and with info received from the relation + * <code>JDBC.INFO</code>. + * Has OK status if exception wasn't thrown and + * if returned value isn't null. + */ + public void _getConnectionWithInfo() { + boolean res = true; + + try { + log.println("getConnectionWithInfo(" + jdbcURL + ")"); + XConnection connection = + oObj.getConnectionWithInfo(jdbcURL, jdbcINFO); + res = connection != null; + } catch(com.sun.star.sdbc.SQLException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + res = false; + } + + tRes.tested("getConnectionWithInfo()", res); + } + + /** + * Calls the method and checks returned value. + * Has OK status if timeout that was set and timeout that was returned by + * the method <code>getLoginTimeout()</code> are equal. + */ + public void _setLoginTimeout() { + requiredMethod("getLoginTimeout()"); + final int TO = 111; + log.println("setLoginTimeout(" + TO + ")"); + oObj.setLoginTimeout(TO); + int timeout = oObj.getLoginTimeout(); + log.println("getLoginTimeout(): " + timeout); + tRes.tested("setLoginTimeout()", timeout == TO); + } + + /** + * Calls the method. + */ + public void _getLoginTimeout() { + int timeout = oObj.getLoginTimeout(); + log.println("getLoginTimeout(): " + timeout); + + tRes.tested("getLoginTimeout()", true); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sdbc/_XIsolatedConnection.java b/qadevOOo/tests/java/ifc/sdbc/_XIsolatedConnection.java new file mode 100644 index 000000000..64af7feb5 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XIsolatedConnection.java @@ -0,0 +1,111 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; +import lib.StatusException; + +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XIsolatedConnection; +import com.sun.star.task.XInteractionHandler; + +/** + * Testing <code>com.sun.star.sdb.XCompletedConnection</code> + * interface methods : + * <ul> + * <li><code> getIsolatedConnectionWithCompletion()</code></li> + * <li><code> getIsolatedConnection()</code></li> + * </ul> <p> +* The following object relations required : +* <ul> +* <li> <code>'XCompletedConnection.Handler'</code> : passed as parameter +* to <code>connectWithCompletion</code> method. </li> +* </ul> +* @see com.sun.star.sdb.XIsolatedConnection +* @see com.sun.star.task.XInteractionHandler +* @see com.sun.star.sdbc.XConnection +*/ +public class _XIsolatedConnection extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XIsolatedConnection oObj = null ; + + /** + * Test call the method with handler passed as object relation. + * Then value returned is checked.<p> + * Has OK status if not null value returned. < > + * FAILED if exception occurred, null value returned or object + * relation was not found. + */ + public void _getIsolatedConnectionWithCompletion() throws StatusException { + XInteractionHandler handler = (XInteractionHandler) + tEnv.getObjRelation("XCompletedConnection.Handler") ; + + if (handler == null) { + log.println("Required object relation not found !") ; + tRes.tested("getIsolatedConnectionWithCompletion()", false) ; + return ; + } + + XConnection con = null ; + try { + con = oObj.getIsolatedConnectionWithCompletion(handler) ; + } catch (com.sun.star.sdbc.SQLException e) { + throw new StatusException("Exception while method calling", e) ; + } + + tRes.tested("getIsolatedConnectionWithCompletion()", con != null) ; + } + + /** + * Test call the method with handler passed as object relation. + * Then value returned is checked.<p> + * Has OK status if not null value returned. < > + * FAILED if exception occurred, null value returned or object + * relation was not found. + */ + public void _getIsolatedConnection() throws StatusException { + String[] userSettings = (String[]) + tEnv.getObjRelation("UserAndPassword") ; + + String user = null; + String pwd = null; + + if (userSettings[0] != null) + user = userSettings[0].equals("")?"<empty>":userSettings[0]; + else + user = "<null>"; + if (userSettings[1] != null) + pwd = userSettings[1].equals("")?"<empty>":userSettings[1]; + else + pwd = "<null>"; + + log.println("Testing \"getIsolatedConnection('user', 'password')\"\n" + + "with user = '" + user + "'; password = '" + pwd + "'"); + XConnection con = null ; + try { + con = oObj.getIsolatedConnection(user, pwd) ; + } catch (com.sun.star.sdbc.SQLException e) { + throw new StatusException("Exception while method calling", e) ; + } + + tRes.tested("getIsolatedConnection()", con != null) ; + } +} // finish class _XIsolatedConnection + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XParameters.java b/qadevOOo/tests/java/ifc/sdbc/_XParameters.java new file mode 100644 index 000000000..4284931fe --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XParameters.java @@ -0,0 +1,564 @@ +/* + * 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.sdbc; + +import java.util.List; + +import lib.MultiMethodTest; +import lib.Status; + +import com.sun.star.io.XDataInputStream; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XTextInputStream; +import com.sun.star.sdbc.DataType; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XParameters; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; + +/** +/** +* Testing <code>com.sun.star.sdbc.XParameters</code> +* interface methods : +* <ul> +* <li><code> setNull()</code></li> +* <li><code> setObjectNull()</code></li> +* <li><code> setBoolean()</code></li> +* <li><code> setByte()</code></li> +* <li><code> setShort()</code></li> +* <li><code> setInt()</code></li> +* <li><code> setLong()</code></li> +* <li><code> setFloat()</code></li> +* <li><code> setDouble()</code></li> +* <li><code> setString()</code></li> +* <li><code> setBytes()</code></li> +* <li><code> setDate()</code></li> +* <li><code> setTime()</code></li> +* <li><code> setTimestamp()</code></li> +* <li><code> setBinaryStream()</code></li> +* <li><code> setCharacterStream()</code></li> +* <li><code> setObject()</code></li> +* <li><code> setObjectWithInfo()</code></li> +* <li><code> setRef()</code></li> +* <li><code> setBlob()</code></li> +* <li><code> setClob()</code></li> +* <li><code> setArray()</code></li> +* <li><code> clearParameters()</code></li> +* </ul> <p> +* Object relations required : +* <ul> +* <li> <code>'XParameters.ParamValues'</code> : is a +* <code>java.util.Vector</code> object +* that contains parameter types and values of the statement. Each +* element of vector corresponds to appropriate parameter (element +* with index 0 to parameter #1, 1 -> #2, etc.). <p> +* The following <code>XParameters</code> methods correspond to classes +* in Vector : +* <ul> +* <li> <code>setBinaryStream</code> - +* <code>com.sun.star.io.XDataInputStream</code> class. </li> +* <li> <code>setCharacterStream</code> - +* <code>com.sun.star.io.XTextInputStream</code> class. </li> +* <li> <code>setObject</code> - +* <code>java.lang.Object[]</code> class, the element with +* index 0 must be used. </li> +* </ul> +* Other methods uses types of their arguments (i.e. +* <code>String</code> +* for <code>setString</code> method, <code>com.sun.star.sdbc.XRef</code> +* for <code>setRef</code> method). +* </li> +* </ul> +* @see com.sun.star.sdbc.XParameters +*/ +public class _XParameters extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XParameters oObj = null ; + + private List<Object> data = null ; + + /** + * Gets object relation + */ + @Override + public void before() { + data = (List<Object>) tEnv.getObjRelation("XParameters.ParamValues") ; + if (data == null) { + log.println("!!! Relation not found !!!") ; + } + } + + /** + * Sets String parameter (if exists) to SQL NULL value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setNull() { + boolean result = true ; + int idx = findParamOfType(String.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setNull(idx, DataType.VARCHAR) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setNull()", result) ; + } + + public void _setObjectNull() { + /* + !!! TO DO !!! + */ + tRes.tested("setObjectNull()", Status.skipped(true)) ; + } + + /** + * Sets String parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setString() { + boolean result = true ; + int idx = findParamOfType(String.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setString(idx, "XParameters") ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setString()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setBoolean() { + boolean result = true ; + int idx = findParamOfType(Boolean.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setBoolean(idx, true) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setBoolean()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setByte() { + boolean result = true ; + int idx = findParamOfType(Byte.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setByte(idx, (byte)122) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setByte()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setShort() { + boolean result = true ; + int idx = findParamOfType(Short.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setShort(idx, (short)133) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setShort()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setInt() { + boolean result = true ; + int idx = findParamOfType(Integer.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setInt(idx, 13300) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setInt()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setLong() { + boolean result = true ; + int idx = findParamOfType(Long.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setLong(idx, 13362453) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setLong()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setFloat() { + boolean result = true ; + int idx = findParamOfType(Float.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setFloat(idx, (float)133.55) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setFloat()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setDouble() { + boolean result = true ; + int idx = findParamOfType(Double.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setDouble(idx, 133) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setDouble()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setBytes() { + boolean result = true ; + int idx = findParamOfType(byte[].class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setBytes(idx, new byte[] {5}) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setBytes()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setDate() { + boolean result = true ; + int idx = findParamOfType(Date.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setDate( + idx, new Date ((short)19, (short)1, (short)1979)) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setDate()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setTime() { + boolean result = true ; + int idx = findParamOfType(Time.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setTime( + idx, new Time((short)1,(short)2,(short)3,(short)44, false)); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setTime()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setTimestamp() { + boolean result = true ; + int idx = findParamOfType(DateTime.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.setTimestamp(idx, new DateTime((short)1,(short)2,(short)3, + (short)4, (short)19, (short)1, (short)1979, false)) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setTimestamp()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setBinaryStream() { + boolean result = true ; + int idx = findParamOfType(XDataInputStream.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + Object oStream = tParam.getMSF(). + createInstance("com.sun.star.io.DataInputStream") ; + XInputStream xStream = UnoRuntime.queryInterface + (XInputStream.class, oStream); + + oObj.setBinaryStream(idx, xStream, 2) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setBinaryStream()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setCharacterStream() { + boolean result = true ; + int idx = findParamOfType(XTextInputStream.class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + Object oStream = tParam.getMSF() + .createInstance("com.sun.star.io.TextInputStream") ; + XInputStream xStream = UnoRuntime.queryInterface + (XInputStream.class, oStream); + + oObj.setCharacterStream(idx, xStream, 2) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setCharacterStream()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setObject() { + boolean result = true ; + int idx = findParamOfType(Object[].class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + Object obj = tParam.getMSF(). + createInstance("com.sun.star.io.Pipe") ; + + oObj.setObject(idx, obj) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setObject()", result) ; + } + + /** + * Sets parameter (if exists) to new value. <p> + * Has OK status if no exceptions occurred. + */ + public void _setObjectWithInfo() { + boolean result = true ; + int idx = findParamOfType(Object[].class) ; + if (idx < 0) log.println("Type not found in relation: not tested"); + else { + try { + Object obj = tParam.getMSF(). + createInstance("com.sun.star.io.Pipe") ; + + oObj.setObjectWithInfo(idx, obj, DataType.OBJECT, 0) ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("setObjectWithInfo()", result) ; + } + + public void _setRef() { + /* + !!! TO DO !!! + */ + tRes.tested("setRef()", Status.skipped(true)) ; + } + public void _setBlob() { + /* + !!! TO DO !!! + */ + tRes.tested("setBlob()", Status.skipped(true)) ; + } + public void _setClob() { + /* + !!! TO DO !!! + */ + tRes.tested("setClob()", Status.skipped(true)) ; + } + public void _setArray() { + /* + !!! TO DO !!! + */ + tRes.tested("setArray()", Status.skipped(true)) ; + } + + /** + * Calls method. <p> + * Has OK status if no exceptions occurred. + */ + public void _clearParameters() { + boolean result = true ; + try { + oObj.clearParameters() ; + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + + tRes.tested("clearParameters()", result) ; + } + + + /** + * Finds in relation vector index of parameter of the appropriate + * type. + */ + private int findParamOfType(Class<?> clz) { + for (int i = 0; i < data.size(); i++) + if (clz.isInstance(data.get(i))) return i + 1 ; + return -1 ; + } + +} // finish class _XParameters + + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XResultSet.java b/qadevOOo/tests/java/ifc/sdbc/_XResultSet.java new file mode 100644 index 000000000..a2114d7d0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XResultSet.java @@ -0,0 +1,497 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbc.XRowUpdate; +import com.sun.star.uno.UnoRuntime; + +/** +/** +* Testing <code>com.sun.star.sdbc.XResultSet</code> +* interface methods : +* <ul> +* <li><code> next()</code></li> +* <li><code> isBeforeFirst()</code></li> +* <li><code> isAfterLast()</code></li> +* <li><code> isFirst()</code></li> +* <li><code> isLast()</code></li> +* <li><code> beforeFirst()</code></li> +* <li><code> afterLast()</code></li> +* <li><code> first()</code></li> +* <li><code> last()</code></li> +* <li><code> getRow()</code></li> +* <li><code> absolute()</code></li> +* <li><code> relative()</code></li> +* <li><code> previous()</code></li> +* <li><code> refreshRow()</code></li> +* <li><code> rowUpdated()</code></li> +* <li><code> rowInserted()</code></li> +* <li><code> rowDeleted()</code></li> +* <li><code> getStatement()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'XResultSet.hasStatement'</code> (<b>optional</b> of type +* <code>Object</code>): +* it the relation exists than <code>getStatement</code> method +* must not return <code>null</code> </li> +* <ul> <p> +* Test places DB cursor to different positions and then checks +* its current position. <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.sdbc.XResultSet +*/ +public class _XResultSet extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XResultSet oObj = null ; + + /** + * Positions the cursor to the first row. + * Forces method tests to be executed in definite order. + */ + @Override + public void before() { + try { + oObj.last() ; + log.println("Totally number of rows is " + oObj.getRow()) ; + oObj.first() ; + } catch (SQLException e) { + log.println("Ignored exception :") ; + e.printStackTrace(log); + } + + executeMethod("isBeforeFirst()") ; + executeMethod("isAfterLast()") ; + executeMethod("isLast()") ; + executeMethod("isFirst()") ; + executeMethod("next()") ; + executeMethod("previous()") ; + } + + /** + * Places the cursor before the first row. <p> + * Has <b>OK</b> status if no exceptions were thrown. + */ + public void _beforeFirst() { + try { + oObj.beforeFirst() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("beforeFirst()", false) ; + return ; + } + tRes.tested("beforeFirst()", true) ; + } + + /** + * The method is called immediately after <code>beforeFirst</code> + * method test. <p> + * Has <b>OK</b> status if method returns <code>true</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> beforeFirst </code> : to position cursor before + * the first row. </li> + * </ul> + */ + public void _isBeforeFirst() { + requiredMethod("beforeFirst()") ; + + boolean result = true ; + + try { + result = oObj.isBeforeFirst() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("isBeforeFirst()", result) ; + } + + /** + * Places the cursor after the last row. <p> + * Has <b>OK</b> status if no exceptions were thrown. + */ + public void _afterLast() { + try { + oObj.afterLast() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("afterLast()", false) ; + return ; + } + tRes.tested("afterLast()", true) ; + } + + /** + * The method is called immediately after <code>afterLast</code> + * method test. <p> + * Has <b>OK</b> status if method returns <code>true</code> <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> afterLast </code> : to position cursor after + * the last row. </li> + * </ul> + */ + public void _isAfterLast() { + requiredMethod("afterLast()") ; + + boolean result = true ; + + try { + result = oObj.isAfterLast() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("isAfterLast()", result) ; + } + + /** + * Places the cursor on the first row. <p> + * Has <b>OK</b> status if no exceptions were thrown. + */ + public void _first() { + try { + oObj.first() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("first()", false) ; + return ; + } + tRes.tested("first()", true) ; + } + + /** + * The method is called immediately after <code>first</code> + * method test. <p> + * Has <b>OK</b> status if method returns <code>true</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> first </code> : to position cursor on + * the first row. </li> + * </ul> + */ + public void _isFirst() { + requiredMethod("first()") ; + + boolean result = true ; + + try { + result = oObj.isFirst() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("isFirst()", result) ; + } + + /** + * Places the cursor on the last row. <p> + * Has <b>OK</b> status if no exceptions were thrown. + */ + public void _last() { + try { + oObj.last() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("last()", false) ; + return ; + } + tRes.tested("last()", true) ; + } + + /** + * The method is called immediately after <code>last</code> + * method test. <p> + * Has <b>OK</b> status if method returns <code>true</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> last </code> : to position cursor on + * the last row. </li> + * </ul> + */ + public void _isLast() { + requiredMethod("last()") ; + boolean result = true ; + + try { + result = oObj.isLast() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("isLast()", result) ; + } + + /** + * Places the cursor on the row number 1. <p> + * Has <b>OK</b> status if no exceptions were thrown. + */ + public void _absolute() { + boolean result = true ; + + try { + oObj.absolute(1) ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("absolute()", result) ; + } + + /** + * The method is called immediately after <code>absolute</code> + * method test. <p> + * Has <b>OK</b> status if method returns 1. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> absolute </code> : to position cursor on + * the row number 1. </li> + * </ul> + */ + public void _getRow() { + requiredMethod("absolute()"); + boolean result = true; + + try { + result &= oObj.getRow() == 1; + } catch (SQLException e) { + log.println("Exception occurred:"); + e.printStackTrace(log); + result = false; + } + + tRes.tested("getRow()", result); + } + + /** + * Positions the cursor to the next row. Current row + * number is retrieved before and after method call. <p> + * Has <b>OK</b> status if current row number increases + * by 1 after method call. + */ + public void _next() { + boolean result = true ; + + try { + int prevRow = oObj.getRow() ; + oObj.next() ; + + log.println("Row was : " + prevRow + ", row is : " + oObj.getRow()); + result &= prevRow + 1 == oObj.getRow() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("next()", result) ; + } + + /** + * Positions the cursor to the previous row. Current row + * number is retrieved before and after method call. <p> + * Has <b>OK</b> status if current row number decreases + * by 1 after method call. + */ + public void _previous() { + boolean result = true ; + + try { + int prevRow = oObj.getRow() ; + oObj.previous() ; + + log.println("Row was : " + prevRow + ", row is : " + oObj.getRow()); + result &= prevRow - 1 == oObj.getRow() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("previous()", result) ; + } + + /** + * Positions the cursor relatively by 2 rows forward. + * Current row number is retrieved before and after method call. <p> + * Has <b>OK</b> status if current row number increases + * by 2 after method call. + */ + public void _relative() { + boolean result = true ; + + try { + oObj.first() ; + int prevRow = oObj.getRow() ; + oObj.relative(2) ; + + log.println("Row was : " + prevRow + ", row is : " + oObj.getRow()); + + result &= prevRow + 2 == oObj.getRow() ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("relative()", result) ; + } + + /** + * If component supports XRow and XRowUpdate then: + * test saves current value of string field, updates string, + * calls refreshRow() and checks that value of + * string field was refetched from DB + * else: just calls method.<p> + * Has <b>OK</b> status if no exceptions were thrown and value after + * refreshRow() equals to saved value. + */ + public void _refreshRow() { + XRowUpdate xRowUpdate = UnoRuntime.queryInterface(XRowUpdate.class, oObj); + XRow xRow = UnoRuntime.queryInterface(XRow.class, oObj); + + if (xRowUpdate == null || xRow == null) { + log.println("Test must be modified because XRow or XRowUpdate is't supported"); + log.println("Only call method"); + try { + oObj.refreshRow() ; + tRes.tested("refreshRow()", true) ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("refreshRow()", false) ; + } + } else { + log.println("Testing of refreshRow()..."); + try { + String oldValue = xRow.getString(util.DBTools.TST_STRING); + log.println("Old value: " + oldValue); + xRowUpdate.updateString(util.DBTools.TST_STRING, + "Test method refreshRow"); + log.println("New value: " + + xRow.getString(util.DBTools.TST_STRING)); + oObj.refreshRow(); + String valAfterRefresh = + xRow.getString(util.DBTools.TST_STRING); + log.println("Value after refresh: " + valAfterRefresh); + tRes.tested("refreshRow()", valAfterRefresh.equals(oldValue)); + } catch(SQLException e) { + log.println("Exception occurred :"); + e.printStackTrace(log); + tRes.tested("refreshRow()", false); + } + } + } + + /** + * Just the method is called. <p> + * Has <b>OK</b> status if no exceptions were thrown. + */ + public void _rowUpdated() { + + try { + oObj.rowUpdated(); + tRes.tested("rowUpdated()", true) ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("rowUpdated()", false) ; + } + } + + /** + * Just the method is called. <p> + * Has <b>OK</b> status if no exceptions were thrown. + */ + public void _rowInserted() { + try { + oObj.rowInserted(); + tRes.tested("rowInserted()", true) ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("rowInserted()", false) ; + } + } + + /** + * Just the method is called. <p> + * Has <b>OK</b> status if no exceptions were thrown. + */ + public void _rowDeleted() { + try { + oObj.rowDeleted(); + tRes.tested("rowDeleted()", true) ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("rowDeleted()", false) ; + } + } + + /** + * Just the method is called. <p> + * Has <b>OK</b> status if the statement returned isn't null or + * the relation exists that informs that statement absent (e.g. for + * MetaData row set). + */ + public void _getStatement() { + try { + boolean hasStatement = + tEnv.getObjRelation("XResultSet.hasStatement") != null ; + Object res = oObj.getStatement() ; + tRes.tested("getStatement()", + (hasStatement && res != null) || !hasStatement) ; + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + tRes.tested("getStatement()", false) ; + } + } + + /** + * Moves the cursor to the first row to avoid affection to + * the following interfaces tests + */ + @Override + public void after() { + log.println("Finally moving cursor to the first row ..."); + try { + oObj.first(); + } catch (SQLException e) { + log.println("Exception occurred :") ; + e.printStackTrace(log) ; + } + } + +} // finish class _XResultSet + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XResultSetMetaDataSupplier.java b/qadevOOo/tests/java/ifc/sdbc/_XResultSetMetaDataSupplier.java new file mode 100644 index 000000000..0a721b368 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XResultSetMetaDataSupplier.java @@ -0,0 +1,60 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; + +import com.sun.star.sdbc.XResultSetMetaData; +import com.sun.star.sdbc.XResultSetMetaDataSupplier; + +/** +* Testing <code>com.sun.star.sdbc.XResultSetMetaDataSupplier</code> +* interface methods : +* <ul> +* <li><code> getMetaData()</code></li> +* </ul> <p> +* Test is multithread compliant. <p> +* @see com.sun.star.sdbc.XResultSetMetaDataSupplier +*/ +public class _XResultSetMetaDataSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XResultSetMetaDataSupplier oObj = null ; + + /** + * Tries to get the ResultSetMetaData of the Object</br> + * an XResultSetMetaData is returned.</br> + * The test is OK if a not null ResultSetMetaData is returned + */ + public void _getMetaData() { + + try { + XResultSetMetaData the_Meta = oObj.getMetaData(); + if (the_Meta == null) log.println("'getMetaData()' returns NULL"); + tRes.tested("getMetaData()",the_Meta != null); + } catch (com.sun.star.sdbc.SQLException e) { + log.println("Exception while checking 'createResultSet()'"); + e.printStackTrace(log); + tRes.tested("getMetaData()",false); + } + + } +} // finish class _XResultSetMetaDataSupplier + + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XResultSetUpdate.java b/qadevOOo/tests/java/ifc/sdbc/_XResultSetUpdate.java new file mode 100644 index 000000000..372373910 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XResultSetUpdate.java @@ -0,0 +1,255 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; +import lib.StatusException; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.sdbc.XRowUpdate; +import com.sun.star.uno.UnoRuntime; + +/** +/** +* Testing <code>com.sun.star.sdbc.XResultSetUpdate</code> +* interface methods : +* <ul> +* <li><code> insertRow()</code></li> +* <li><code> updateRow()</code></li> +* <li><code> deleteRow()</code></li> +* <li><code> cancelRowUpdates()</code></li> +* <li><code> moveToInsertRow()</code></li> +* <li><code> moveToCurrentRow()</code></li> +* </ul> <p> +* The test requires the following object relations : +* <ul> +* <li><code>'XResultSetUpdate.UpdateTester'</code> +* inner <code>UpdateTester</code> interface implementation : +* is used for checking test results. See interface +* documentation for more information.</li> +* </ul> +* The test is <b>not designed</b> for multithreaded testing. <p> +* After it's execution environment must be recreated. +* @see com.sun.star.sdbc.XResultSetUpdate +*/ +public class _XResultSetUpdate extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XResultSetUpdate oObj = null ; + + private UpdateTester tester = null ; + + /** + * Interface contains some methods for checking + * test results. It's implementation must be passed + * to this test. + */ + public interface UpdateTester { + /** + * @return Current number of rows. + */ + int rowCount() throws SQLException ; + /** + * Updates some data in the current row but doesn't commit + * changes to the source. + */ + void update() throws SQLException ; + /** + * Checks if updates made by method <code>update</code> was + * committed to the data source. + */ + boolean wasUpdated() throws SQLException ; + /** + * Returns current row number. Really it must returns value + * < 1 if the current position is on insert row. + */ + int currentRow() throws SQLException ; + } + + /** + * Retrieves relation. + * @throw StatusException If relation not found. + */ + @Override + public void before() throws StatusException { + tester = (UpdateTester)tEnv.getObjRelation + ("XResultSetUpdate.UpdateTester") ; + + if (tester == null) { + log.println("Required relation not found !!!") ; + throw new StatusException("Required relation not found !!!", + new NullPointerException()) ; + } + } + + /** + * Calls method when the cursor position is on existing row. + * Checks total number of rows before and after method call. <p> + * Executes <code>moveToCurrentRow</code> method test before to + * be sure that cursor is not on the insert row. <p> + * Has OK status if after method execution number of rows decreased + * by one. + */ + public void _deleteRow() { + executeMethod("moveToCurrentRow()") ; + + //temporary to avoid SOffice hanging + executeMethod("updateRow()") ; + executeMethod("cancelRowUpdates()") ; + + boolean result = true ; + try { + int rowsBefore = tester.rowCount() ; + oObj.deleteRow() ; + int rowsAfter = tester.rowCount() ; + + result = rowsBefore == rowsAfter + 1 ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("deleteRow()", result) ; + } + + /** + * Using relation methods first updates some data in the current + * row, then calls <code>updateRow</code> method to commit data. + * Then checks if the data changed was committed. <p> + * Executes <code>moveToCurrentRow</code> method test before to + * be sure that cursor is not on the insert row. <p> + * Has OK status if data in the source was changed. + */ + public void _updateRow() { + executeMethod("moveToCurrentRow()") ; + boolean result = true ; + try { + tester.update() ; + oObj.updateRow() ; + + result = tester.wasUpdated() ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("updateRow()", result) ; + } + + /** + * Using relation methods first updates some data in the current + * row, then calls <code>cancelRowUpdates</code> method. + * Then checks if the data changed was not committed. <p> + * Executes <code>moveToCurrentRow</code> method test before to + * be sure that cursor is not on the insert row. <p> + * Has OK status if data in the source was not changed. + */ + public void _cancelRowUpdates() { + executeMethod("moveToCurrentRow()") ; + boolean result = true ; + try { + tester.update() ; + oObj.cancelRowUpdates() ; + + result = !tester.wasUpdated() ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("cancelRowUpdates()", result) ; + } + + /** + * Tries to move cursor to insert row. Then checks current row + * number. It must be less than 1. (0 as I know) <p> + */ + public void _moveToInsertRow() { + boolean result = true ; + try { + oObj.moveToInsertRow() ; + + result = tester.currentRow() < 1 ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("moveToInsertRow()", result) ; + } + + /** + * Returns cursor from insert row back to previous row. <p> + * <code>moveToInsertRow</code> method test must be executed + * first for positioning cursor to insert row. <p> + * Has OK status if after method call current row number is + * above 0. + */ + public void _moveToCurrentRow() { + boolean result = true ; + try { + oObj.moveToCurrentRow() ; + + result = tester.currentRow() >= 1 ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + tRes.tested("moveToCurrentRow()", result) ; + } + + /** + * Moves cursor to the insert row, then calls the method + * <code>insertRow</code>. Before and after call stores + * total number of rows. <p> + * Has OK status if after method call rows number increases + * by one. + */ + public void _insertRow() { + executeMethod("moveToInsertRow()") ; + boolean result = true ; + try { + oObj.moveToCurrentRow(); + int rowsBefore = tester.rowCount() ; + oObj.moveToInsertRow() ; + XRowUpdate rowU = UnoRuntime.queryInterface(XRowUpdate.class, oObj); + rowU.updateString(1,"open"); + rowU.updateInt(2,5); + rowU.updateDouble(5,3.4); + rowU.updateBoolean(10,true); + oObj.insertRow() ; + oObj.moveToCurrentRow(); + int rowsAfter = tester.rowCount() ; + result = rowsBefore + 1 == rowsAfter ; + } catch (SQLException e) { + e.printStackTrace(log) ; + log.println("******"+e.getMessage()); + result = false ; + } + tRes.tested("insertRow()", result) ; + } + + /** + * Forces environment to be recreated. + */ + @Override + public void after() { + //disposeEnvironment() ; + } +} // finish class _XResultSetUpdate + + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XRow.java b/qadevOOo/tests/java/ifc/sdbc/_XRow.java new file mode 100644 index 000000000..70a60b0cf --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XRow.java @@ -0,0 +1,527 @@ +/* + * 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.sdbc; + +import java.util.List; + +import lib.MultiMethodTest; + +import com.sun.star.io.XDataInputStream; +import com.sun.star.io.XTextInputStream; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XArray; +import com.sun.star.sdbc.XBlob; +import com.sun.star.sdbc.XClob; +import com.sun.star.sdbc.XRef; +import com.sun.star.sdbc.XRow; +import com.sun.star.util.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; + +/** +* Testing <code>com.sun.star.sdbc.XRow</code> +* interface methods : +* <ul> +* <li><code> wasNull()</code></li> +* <li><code> getString()</code></li> +* <li><code> getBoolean()</code></li> +* <li><code> getByte()</code></li> +* <li><code> getShort()</code></li> +* <li><code> getInt()</code></li> +* <li><code> getLong()</code></li> +* <li><code> getFloat()</code></li> +* <li><code> getDouble()</code></li> +* <li><code> getBytes()</code></li> +* <li><code> getDate()</code></li> +* <li><code> getTime()</code></li> +* <li><code> getTimestamp()</code></li> +* <li><code> getBinaryStream()</code></li> +* <li><code> getCharacterStream()</code></li> +* <li><code> getObject()</code></li> +* <li><code> getRef()</code></li> +* <li><code> getBlob()</code></li> +* <li><code> getClob()</code></li> +* <li><code> getArray()</code></li> +* </ul> <p> +* +* This interface is full tested in XRowUpdate interface test. Here +* only exceptions checked. +* <p> +* +* Object relations required : +* <ul> +* <li> <code>'CurrentRowData'</code> : (may be used in other +* interface tests) is a <code>java.util.Vector</code> object +* that contains column types and values in current row. Each +* element of vector corresponds to appropriate column (element +* with index 0 to column 1, 1 -> 2, etc.). <p> +* The following <code>XRow</code> methods correspond to classes +* in Vector : +* <ul> +* <li> <code>getBinaryStream</code> - +* <code>com.sun.star.io.XDataInputStream</code> class. </li> +* <li> <code>getCharacterStream</code> - +* <code>com.sun.star.io.XTextInputStream</code> class. </li> +* <li> <code>getObject</code> - +* <code>java.lang.Object[]</code> class, the element with +* index 0 must be used. </li> +* </ul> +* Other methods uses types they return (i.e. <code>String</code> +* for <code>getString</code> method, <code>com.sun.star.sdbc.XRef</code> +* for <code>getRef</code> method). +* </li> +* </ul> +* @see com.sun.star.sdbc.XRaw +* @see ifc.sdbc._XRowUpdate +*/ +public class _XRow extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XRow oObj = null ; + private List<Object> data = null ; + private static final boolean notNullRes = true; + + /** + * Retrieves object relation first. + */ + @Override + public void before() { + data = (List<Object>) tEnv.getObjRelation("CurrentRowData") ; + } + + /** + * Always has <b>OK</b> status. + */ + public void _wasNull() { + executeMethod("getString()") ; + executeMethod("getBoolean()") ; + executeMethod("getByte()") ; + executeMethod("getShort()") ; + executeMethod("getInt()") ; + executeMethod("getLong()") ; + executeMethod("getFloat()") ; + executeMethod("getDouble()") ; + executeMethod("getBytes()") ; + executeMethod("getDate()") ; + executeMethod("getTime()") ; + executeMethod("getTimestamp()") ; + executeMethod("getBinaryStream()") ; + executeMethod("getCharacterStream()") ; + executeMethod("getObject()") ; + executeMethod("getRef()") ; + executeMethod("getBlob()") ; + executeMethod("getClob()") ; + executeMethod("getArray()") ; + + tRes.tested("wasNull()", notNullRes) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getString() { + boolean result = true ; + int col = findColumnOfType(String.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getString(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getString()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getBoolean() { + boolean result = true ; + int col = findColumnOfType(Boolean.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getBoolean(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getBoolean()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getByte() { + boolean result = true ; + int col = findColumnOfType(Byte.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getByte(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getByte()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getShort() { + boolean result = true ; + int col = findColumnOfType(Short.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getShort(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getShort()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getInt() { + boolean result = true ; + int col = findColumnOfType(Integer.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getInt(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getInt()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getLong() { + boolean result = true ; + int col = findColumnOfType(Long.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getLong(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getLong()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getFloat() { + boolean result = true ; + int col = findColumnOfType(Float.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getFloat(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getFloat()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getDouble() { + boolean result = true ; + int col = findColumnOfType(Double.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getDouble(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getDouble()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getBytes() { + boolean result = true ; + int col = findColumnOfType(byte[].class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getBytes(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getBytes()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getDate() { + boolean result = true ; + int col = findColumnOfType(Date.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getDate(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getDate()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getTime() { + boolean result = true ; + int col = findColumnOfType(Time.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getTime(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getTime()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getTimestamp() { + boolean result = true ; + int col = findColumnOfType(DateTime.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getTimestamp(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getTimestamp()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getBinaryStream() { + boolean result = true ; + int col = findColumnOfType(XDataInputStream.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getBinaryStream(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getBinaryStream()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getCharacterStream() { + boolean result = true ; + int col = findColumnOfType(XTextInputStream.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getCharacterStream(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getCharacterStream()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getObject() { + boolean result = true ; + int col = findColumnOfType(Object[].class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getObject(col, null); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getObject()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getRef() { + boolean result = true ; + int col = findColumnOfType(XRef.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getRef(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getRef()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getBlob() { + boolean result = true ; + int col = findColumnOfType(XBlob.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getBlob(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getBlob()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getClob() { + boolean result = true ; + int col = findColumnOfType(XClob.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getClob(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getClob()", result) ; + } + + /** + * Has <b>OK</b> status if no exceptions occurred in method call. + */ + public void _getArray() { + boolean result = true ; + int col = findColumnOfType(XArray.class) ; + if (col < 0) log.println("Type not found in relation: not tested"); + else { + try { + oObj.getArray(col); + } catch (SQLException e) { + log.println("Unexpected SQL exception:") ; + log.println(e) ; + result = false ; + } + } + + tRes.tested("getArray()", result) ; + } + + /** + * Finds in relation vector index of column of the appropriate + * type. + */ + protected int findColumnOfType(Class<?> clz) { + + for (int i = 0; i < data.size(); i++) + if (clz.isInstance(data.get(i))) return i + 1 ; + return -1 ; + } +} // finish class _XRow + + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XRowSet.java b/qadevOOo/tests/java/ifc/sdbc/_XRowSet.java new file mode 100644 index 000000000..cda9da30b --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XRowSet.java @@ -0,0 +1,192 @@ +/* + * 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.sdbc; + +import ifc.sdb._XRowSetApproveBroadcaster; +import lib.MultiMethodTest; +import lib.StatusException; + +import com.sun.star.lang.EventObject; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XRowSet; +import com.sun.star.sdbc.XRowSetListener; + +/** +* Testing <code>com.sun.star.sdbc.XRowSet</code> +* interface methods : +* <ul> +* <li><code> execute()</code></li> +* <li><code> addRowSetListener()</code></li> +* <li><code> removeRowSetListener()</code></li> +* </ul> <p> +* Required object relations : +* <ul> +* <li> <code>'XRowSetApproveBroadcaster.ApproveChecker'</code>: +* implementation of inner interface +* <code>ifs.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker</code> +* which can move cursor within a rowset, change row, and change the +* whole rowset. </li> +* </ul> <p> +* It is better to recreate the object after test, because of unknown +* actions made by <code>RowSetApproveChecker</code> interface implementation. +* @see com.sun.star.sdbc.XRowSet +* @see ifc.sdb._XRowSetApproveBroadcaster +*/ +public class _XRowSet extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XRowSet oObj = null ; + private _XRowSetApproveBroadcaster.RowSetApproveChecker checker = null ; + private final TestListener listener = new TestListener() ; + + private static class TestListener implements XRowSetListener { + public boolean cursorMoved = false ; + public boolean rowChanged = false ; + public boolean rowSetChanged = false ; + + public void reset() { + cursorMoved = false ; + rowChanged = false ; + rowSetChanged = false ; + } + public void cursorMoved(EventObject ev) { + cursorMoved = true ; + } + public void rowChanged(EventObject ev) { + rowChanged = true ; + } + public void rowSetChanged(EventObject ev) { + rowSetChanged = true ; + } + public void disposing(EventObject ev) {} + } + + /** + * Retrieves relation. + * @throw StatusException If relation not found. + */ + @Override + public void before() throws StatusException { + checker = (_XRowSetApproveBroadcaster.RowSetApproveChecker) + tEnv.getObjRelation("XRowSetApproveBroadcaster.ApproveChecker") ; + + if (checker == null) { + log.println("Required relation not found !!!") ; + throw new StatusException("Required relation not found !!!", + new NullPointerException()) ; + } + } + + /** + * Reexecutes the RowSet and checks that listener was called. <p> + * Has OK status if no exceptions were raised and listener was called. + */ + public void _execute() { + requiredMethod("addRowSetListener()"); + listener.reset(); + try { + oObj.execute() ; + } catch (SQLException e) { + log.println("Exception occurred :" + e) ; + } + + tRes.tested("execute()", listener.rowSetChanged); + } + + /** + * Adds listener and calls methods moveCursor, changeRow, + * changeRowSet of the relation and then checks if appropriate + * methods of the listener were called. <p> + * Has OK status if all listener methods were called. + */ + public void _addRowSetListener() { + boolean result = true ; + + oObj.addRowSetListener(listener) ; + + checker.moveCursor() ; + result &= listener.cursorMoved ; + if (!listener.cursorMoved) + log.println("cursorMoved event wasn't called") ; + listener.reset() ; + + checker.changeRow() ; + result &= listener.rowChanged ; + if (!listener.rowChanged) + log.println("rowChanged event wasn't called") ; + listener.reset() ; + + checker.changeRowSet() ; + result &= listener.rowSetChanged ; + if (!listener.rowSetChanged) + log.println("rowSetChanged event wasn't called") ; + listener.reset() ; + + tRes.tested("addRowSetListener()", result) ; + } + + /* + * Removes listener added before, and checks for no listener + * methods were called on response to rowSet manipulations. <p> + * Methods to be successfully completed before : + * <ul> + * <li> <code>addRowSetListener()</code> </li> + * </ul> <p> + * Has OK status if no listeners methods were called. + */ + public void _removeRowSetListener() { + requiredMethod("addRowSetListener()") ; + + boolean result = true ; + + oObj.removeRowSetListener(listener) ; + + checker.moveCursor() ; + if (listener.cursorMoved) { + log.println("cursorMoved is erroneously set"); + result = false; + } + listener.reset() ; + + checker.changeRow() ; + if (listener.rowChanged) { + log.println("rowChanged is erroneously set"); + result = false; + } + listener.reset() ; + + checker.changeRowSet() ; + if (listener.rowSetChanged) { + log.println("rowSetChanged is erroneously set"); + result = false; + } + + tRes.tested("removeRowSetListener()", result) ; + } + + /** + * Disposes test environment. + */ + @Override + public void after() { + disposeEnvironment() ; + } + +} // finish class _XRowSet + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XRowUpdate.java b/qadevOOo/tests/java/ifc/sdbc/_XRowUpdate.java new file mode 100644 index 000000000..e57b2f062 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XRowUpdate.java @@ -0,0 +1,683 @@ +/* + * 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.sdbc; + +import java.util.List; + +import lib.MultiMethodTest; +import lib.Status; +import util.utils; +import util.ValueComparer; + +import com.sun.star.io.XDataInputStream; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XTextInputStream; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbc.XRowUpdate; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; + +/** +* Testing <code>com.sun.star.sdbc.XRowUpdate</code> +* interface methods : +* <ul> +* <li><code> updateNull()</code></li> +* <li><code> updateBoolean()</code></li> +* <li><code> updateByte()</code></li> +* <li><code> updateShort()</code></li> +* <li><code> updateInt()</code></li> +* <li><code> updateLong()</code></li> +* <li><code> updateFloat()</code></li> +* <li><code> updateDouble()</code></li> +* <li><code> updateString()</code></li> +* <li><code> updateBytes()</code></li> +* <li><code> updateDate()</code></li> +* <li><code> updateTime()</code></li> +* <li><code> updateTimestamp()</code></li> +* <li><code> updateBinaryStream()</code></li> +* <li><code> updateCharacterStream()</code></li> +* <li><code> updateObject()</code></li> +* <li><code> updateNumericObject()</code></li> +* </ul> <p> +* Object relations required : +* <ul> +* <li> <code>'CurrentRowData'</code> : (may be used in other +* interface tests) is a <code>java.util.Vector</code> object +* that contains column types and values in current row. Each +* element of vector corresponds to appropriate column (element +* with index 0 to column 1, 1 -> 2, etc.). <p> +* The following <code>XRowUpdate</code> methods correspond to classes +* in Vector : +* <ul> +* <li> <code>setBinaryStream</code> - +* <code>com.sun.star.io.XDataInputStream</code> class. </li> +* <li> <code>setCharacterStream</code> - +* <code>com.sun.star.io.XTextInputStream</code> class. </li> +* <li> <code>setObject</code> - +* <code>java.lang.Object[]</code> class, the element with +* index 0 must be used. </li> +* </ul> +* Other methods uses types they return (i.e. <code>String</code> +* for <code>setString</code> method, <code>com.sun.star.sdbc.XRef</code> +* for <code>setRef</code> method). +* </li> +* <li> <code>'XRowUpdate.XRow'</code> : implementation of <code> +* com.sun.star.sdbc.XRow</code> interface for checking updated data. +* </li> +* </ul> <p> +* The test <b>damages</b> the object, so it is recreated finally. +* @see com.sun.star.sdbc.XRowUpdate +* @see com.sun.star.sdbc.XRow +*/ +public class _XRowUpdate extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XRowUpdate oObj = null ; + + private List<Object> rowData = null ; + private XRow row = null ; + + /** + * Gets relations. + */ + @Override + public void before() { + rowData = (List<Object>) tEnv.getObjRelation("CurrentRowData") ; + if (rowData == null) { + log.println("!!! 'CurrentRowData' relation not found !!!") ; + } + row = (XRow) tEnv.getObjRelation("XRowUpdate.XRow") ; + if (rowData == null) { + log.println("!!! 'XRowUpdate.XRow' relation not found !!!") ; + } + } + + /** + * Try to set NULL value for each column. Then using <code>XRow</code> + * relation check if NULL was really set. <p> + * Has OK status if for every column NULL value was successfully set. + * @see com.sun.star.sdbc.XRow + */ + public void _updateNull() { + boolean result = true ; + for (int i = 0; i < rowData.size(); i++) { + if (rowData.get(i) == null) continue ; + log.print(" Setting NULL at column #" + (i+1) + " ...") ; + try { + oObj.updateNull(i + 1) ; + + if (rowData.get(i) instanceof String) row.getString(i + 1) ; + if (rowData.get(i) instanceof Boolean) row.getBoolean(i + 1) ; + if (rowData.get(i) instanceof Byte) row.getByte(i + 1) ; + if (rowData.get(i) instanceof Short) row.getShort(i + 1) ; + if (rowData.get(i) instanceof Integer) row.getInt(i + 1) ; + if (rowData.get(i) instanceof Long) row.getLong(i + 1) ; + if (rowData.get(i) instanceof Float) row.getFloat(i + 1) ; + if (rowData.get(i) instanceof Double) row.getDouble(i + 1) ; + if (rowData.get(i) instanceof byte[]) row.getBytes(i + 1) ; + if (rowData.get(i) instanceof Date) row.getDate(i + 1) ; + if (rowData.get(i) instanceof Time) row.getTime(i + 1) ; + if (rowData.get(i) instanceof DateTime) + row.getTimestamp(i + 1) ; + if (rowData.get(i) instanceof XDataInputStream) + row.getBinaryStream(i + 1) ; + if (rowData.get(i) instanceof XTextInputStream) + row.getCharacterStream(i + 1) ; + + if (!row.wasNull()) { + log.println("FAILED") ; + log.println("Not NULL was returned !!!") ; + result = false ; + } else { + log.println("OK") ; + } + } catch (SQLException e) { + log.println("FAILED") ; + e.printStackTrace(log) ; + result = false ; + } + } + + tRes.tested("updateNull()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateBoolean() { + boolean result = true ; + int idx = findColumnOfType(Boolean.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateBoolean()", Status.skipped(true)) ; + return ; + } + + try { + boolean newVal = !row.getBoolean(idx) ; + oObj.updateBoolean(idx, newVal) ; + boolean getVal = row.getBoolean(idx) ; + result = newVal == getVal ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateBoolean()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateByte() { + boolean result = true ; + int idx = findColumnOfType(Byte.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateByte()", Status.skipped(true)) ; + return ; + } + + try { + byte newVal = (byte) (row.getByte(idx) + 1) ; + oObj.updateByte(idx, newVal) ; + byte getVal = row.getByte(idx) ; + result = newVal == getVal ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateByte()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateShort() { + boolean result = true ; + int idx = findColumnOfType(Short.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateShort()", Status.skipped(true)) ; + return ; + } + + try { + short newVal = (short) (row.getShort(idx) + 1) ; + oObj.updateShort(idx, newVal) ; + short getVal = row.getShort(idx) ; + result = newVal == getVal ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateShort()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateInt() { + boolean result = true ; + int idx = findColumnOfType(Integer.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateInt()", Status.skipped(true)) ; + return ; + } + + try { + int newVal = 1 + row.getInt(idx) ; + oObj.updateInt(idx, newVal) ; + int getVal = row.getInt(idx) ; + result = newVal == getVal ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateInt()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateLong() { + boolean result = true ; + int idx = findColumnOfType(Long.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateLong()", Status.skipped(true)) ; + return ; + } + + try { + long newVal = 1 + row.getLong(idx) ; + oObj.updateLong(idx, newVal) ; + long getVal = row.getLong(idx) ; + result = newVal == getVal ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateLong()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateFloat() { + boolean result = true ; + int idx = findColumnOfType(Float.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateFloat()", Status.skipped(true)) ; + return ; + } + + try { + float newVal = (float) (1.1 + row.getFloat(idx)); + oObj.updateFloat(idx, newVal) ; + float getVal = row.getFloat(idx) ; + result = newVal == getVal ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateFloat()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateDouble() { + boolean result = true ; + int idx = findColumnOfType(Double.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateDouble()", Status.skipped(true)) ; + return ; + } + + try { + double newVal = 1.1 + row.getDouble(idx) ; + oObj.updateDouble(idx, newVal) ; + double getVal = row.getDouble(idx) ; + result = utils.approxEqual(newVal, getVal); + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateDouble()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateString() { + boolean result = true ; + int idx = findColumnOfType(String.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateString()", Status.skipped(true)) ; + return ; + } + + try { + String newVal = "_" + row.getString(idx) ; + oObj.updateString(idx, newVal) ; + String getVal = row.getString(idx) ; + result = newVal.equals(getVal) ; + log.println("New value = '" + newVal + "', get value = '" + + getVal + "'") ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateString()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateBytes() { + boolean result = true ; + int idx = findColumnOfType(byte[].class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateBytes()", Status.skipped(true)) ; + return ; + } + + try { + byte[] newVal = row.getBytes(idx) ; + if (newVal == null || newVal.length == 0) { + newVal = new byte[] {34, 111, 98} ; + } else { + newVal = new byte[] {(byte) (newVal[0] + 1), 111, 98} ; + } + oObj.updateBytes(idx, newVal) ; + byte[] getVal = row.getBytes(idx) ; + result = ValueComparer.equalValue(newVal, getVal) ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateBytes()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateDate() { + boolean result = true ; + int idx = findColumnOfType(Date.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateDate()", Status.skipped(true)) ; + return ; + } + + try { + Date newVal = row.getDate(idx) ; + newVal.Year ++ ; + oObj.updateDate(idx, newVal) ; + Date getVal = row.getDate(idx) ; + result = ValueComparer.equalValue(newVal, getVal) ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateDate()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateTime() { + boolean result = true ; + int idx = findColumnOfType(Time.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateTime()", Status.skipped(true)) ; + return ; + } + + try { + Time newVal = row.getTime(idx) ; + newVal.Seconds ++ ; + oObj.updateTime(idx, newVal) ; + Time getVal = row.getTime(idx) ; + result = ValueComparer.equalValue(newVal, getVal) ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateTime()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateTimestamp() { + boolean result = true ; + int idx = findColumnOfType(DateTime.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateTimestamp()", Status.skipped(true)) ; + return ; + } + + try { + DateTime newVal = row.getTimestamp(idx) ; + newVal.Year ++ ; + oObj.updateTimestamp(idx, newVal) ; + DateTime getVal = row.getTimestamp(idx) ; + result = ValueComparer.equalValue(newVal, getVal) ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateTimestamp()", result) ; + } + + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateBinaryStream() { + boolean result = true ; + int idx = findColumnOfType(XDataInputStream.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateBinaryStream()", Status.skipped(true)) ; + return ; + } + + try { + Object oStream = tParam.getMSF(). + createInstance("com.sun.star.io.DataInputStream") ; + XInputStream newVal = UnoRuntime.queryInterface + (XInputStream.class, oStream); + + oObj.updateBinaryStream(idx, newVal, 0) ; + XInputStream getVal = row.getBinaryStream(idx) ; + result = UnoRuntime.areSame(newVal, getVal) ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected exception:") ; + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateBinaryStream()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateCharacterStream() { + boolean result = true ; + int idx = findColumnOfType(XTextInputStream.class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateCharacterStream()", Status.skipped(true)) ; + return ; + } + + try { + Object oStream = tParam.getMSF(). + createInstance("com.sun.star.io.TextInputStream") ; + XInputStream newVal = UnoRuntime.queryInterface + (XInputStream.class, oStream); + + oObj.updateCharacterStream(idx, newVal, 0) ; + XInputStream getVal = row.getCharacterStream(idx) ; + result = UnoRuntime.areSame(newVal, getVal) ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected exception:") ; + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateCharacterStream()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateObject() { + boolean result = true ; + int idx = findColumnOfType(Object[].class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateObject()", Status.skipped(true)) ; + return ; + } + + try { + Object newVal = tParam.getMSF(). + createInstance("com.sun.star.io.Pipe") ; + + oObj.updateObject(idx, newVal) ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected exception:") ; + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateObject()", result) ; + } + + /** + * Updates column with the appropriate type (if exists) and then + * checks result with interface <code>XRow</code>.<p> + * Has OK status if column successfully updated, ahd the same + * result returned. + */ + public void _updateNumericObject() { + boolean result = true ; + int idx = findColumnOfType(Object[].class) ; + + if (idx < 0) { + log.println("Required type not found") ; + tRes.tested("updateNumericObject()", Status.skipped(true)) ; + return ; + } + + try { + Object newVal = tParam.getMSF(). + createInstance("com.sun.star.io.Pipe") ; + + oObj.updateNumericObject(idx, newVal, 0) ; + } catch (SQLException e) { + e.printStackTrace(log) ; + result = false ; + } catch (com.sun.star.uno.Exception e) { + log.println("Unexpected exception:") ; + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("updateNumericObject()", result) ; + } + + /** + * Finds in relation vector index of column of the appropriate + * type. + */ + protected int findColumnOfType(Class<?> clz) { + + for (int i = 0; i < rowData.size(); i++) + if (clz.isInstance(rowData.get(i))) return i + 1 ; + return -1 ; + } + + /** + * Disposes environment. + */ + @Override + public void after() { + disposeEnvironment() ; + } + +} // finish class _XRow + + diff --git a/qadevOOo/tests/java/ifc/sdbc/_XWarningsSupplier.java b/qadevOOo/tests/java/ifc/sdbc/_XWarningsSupplier.java new file mode 100644 index 000000000..1758ccb1b --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbc/_XWarningsSupplier.java @@ -0,0 +1,130 @@ +/* + * 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.sdbc; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.DBTools; +import util.utils; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbc.XRowUpdate; +import com.sun.star.sdbc.XWarningsSupplier; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sdbc.XWarningsSupplier</code> +* interface methods : +* <ul> +* <li><code> getWarnings()</code></li> +* <li><code> clearWarnings()</code></li> +* </ul> <p> +* @see com.sun.star.sdbc.XWarningsSupplier +*/ +public class _XWarningsSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XWarningsSupplier oObj = null ; + + /** + * Updates value of int column by value '9999999999999999'. + * Calls method and checks returned value. <p> + * Has OK status if the method return not empty value. + */ + public void _getWarnings() { + final XRowUpdate rowUpdate = UnoRuntime.queryInterface(XRowUpdate.class, oObj); + final XResultSetUpdate resultSetUpdate = UnoRuntime.queryInterface(XResultSetUpdate.class, rowUpdate); + final XRow row = UnoRuntime.queryInterface(XRow.class, resultSetUpdate); + if ( row == null) + throw new StatusException(Status.failed("Test must be modified")); + + // not sure what the below test was intended to test, but it actually fails with an SQLException (which is + // correct for what is done there), and thus makes the complete interface test fail (which is not correct) + // So, for the moment, just let the test succeed all the time - until issue #i84235# is fixed + + if ( false ) + { + int oldVal = 0, newVal = 0; + String valToSet = "9999999999999999"; + try + { + oldVal = row.getInt(DBTools.TST_INT); + rowUpdate.updateString(DBTools.TST_INT, valToSet); + resultSetUpdate.updateRow(); + newVal = row.getInt(DBTools.TST_INT); + } + catch(com.sun.star.sdbc.SQLException e) + { + log.println("Unexpected SQL exception"); + e.printStackTrace(log); + tRes.tested("getWarnings()", false); + return; + } + + log.println("Old INT value: " + oldVal); + log.println("Value that was set: " + valToSet); + log.println("New INT value: " + newVal); + + boolean res = false; + + try + { + Object warns = oObj.getWarnings(); + res = (!utils.isVoid(warns)); + } + catch (SQLException e) + { + log.println("Exception occurred :"); + e.printStackTrace(log); + tRes.tested("getWarnings()", res); + return; + } + tRes.tested("getWarnings()", res); + } + else + tRes.tested( "getWarnings()", true ); + } + + /** + * Calls method and checks value returned by the method + * <code>getWarnings()</code>. <p> + * Has OK status if the method <code>getWarnings()</code> return void value. + */ + public void _clearWarnings() { + executeMethod("getWarnings()"); + boolean res = false; + + try { + oObj.clearWarnings(); + Object warns = oObj.getWarnings(); + res = utils.isVoid(warns); + } catch (SQLException e) { + log.println("Exception occurred :"); + e.printStackTrace(log); + tRes.tested("clearWarnings()", res); + return; + } + + tRes.tested("clearWarnings()", res); + } + +} diff --git a/qadevOOo/tests/java/ifc/sdbcx/_ResultSet.java b/qadevOOo/tests/java/ifc/sdbcx/_ResultSet.java new file mode 100644 index 000000000..bdbf0a9a5 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbcx/_ResultSet.java @@ -0,0 +1,36 @@ +/* + * 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.sdbcx; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sdbcx.ResultSet</code> +* service properties : +* <ul> +* <li><code> IsBookmarkable</code></li> +* <li><code> CanUpdateInsertedRows</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sdbcx.ResultSet +*/ +public class _ResultSet extends MultiPropertyTest { + +} + diff --git a/qadevOOo/tests/java/ifc/sdbcx/_XColumnsSupplier.java b/qadevOOo/tests/java/ifc/sdbcx/_XColumnsSupplier.java new file mode 100644 index 000000000..02dce1d4f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbcx/_XColumnsSupplier.java @@ -0,0 +1,70 @@ +/* + * 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.sdbcx; + +import lib.MultiMethodTest; + +import com.sun.star.container.XNameAccess; +import com.sun.star.sdbcx.XColumnsSupplier; + +/** +* Testing <code>com.sun.star.sdbcx.XColumnsSupplier</code> +* interface methods : +* <ul> +* <li><code> getColumns()</code></li> +* </ul> <p> +* @see com.sun.star.sdbcx.XColumnsSupplier +*/ +public class _XColumnsSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XColumnsSupplier oObj = null ; + + /** + * Has OK status if method returns not null + * <code>XNameAccess</code> object, FAILED otherwise. + */ + public void _getColumns() { + + XNameAccess cols = oObj.getColumns() ; + + /* + String[] colNames = cols.getElementNames() ; + + log.println("Column names:") ; + for (int i =0 ; i < colNames.length; i++) { + log.println(" " + colNames[i]) ; + } + + XServiceInfo info = null ; + try { + info = (XServiceInfo) UnoRuntime.queryInterface + (XServiceInfo.class, cols.getByName("colNames[0]")) ; + } catch (com.sun.star.uno.Exception e) {} + + log.println("Support : " + + info.supportsService("com.sun.star.sdbcx.Column")) ; + */ + + tRes.tested("getColumns()", cols != null) ; + } + +} // finish class _XColumnsSupplier + + diff --git a/qadevOOo/tests/java/ifc/sdbcx/_XCreateCatalog.java b/qadevOOo/tests/java/ifc/sdbcx/_XCreateCatalog.java new file mode 100644 index 000000000..15c09694a --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbcx/_XCreateCatalog.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.sdbcx; + +import lib.MultiMethodTest; +import lib.Status; + +import com.sun.star.sdbcx.XCreateCatalog; + +/** +* Testing <code>com.sun.star.sdbcx.XCreateCatalog</code> +* interface methods : +* <ul> +* <li><code>createCatalog()</code></li> +* </ul> <p> +* @see com.sun.star.sdbcx.XCreateCatalog +*/ +public class _XCreateCatalog extends MultiMethodTest { + // oObj filled by MultiMethodTest + public XCreateCatalog oObj = null; + + public void _createCatalog() { + tRes.tested("createCatalog()", Status.skipped(false)); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sdbcx/_XDataDefinitionSupplier.java b/qadevOOo/tests/java/ifc/sdbcx/_XDataDefinitionSupplier.java new file mode 100644 index 000000000..a05310c50 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbcx/_XDataDefinitionSupplier.java @@ -0,0 +1,163 @@ +/* + * 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.sdbcx; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XDriver; +import com.sun.star.sdbcx.XDataDefinitionSupplier; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sdbcx.XDataDefinitionSupplier</code> +* interface methods : +* <ul> +* <li><code> getDataDefinitionByConnection()</code></li> +* <li><code> getDataDefinitionByURL()</code></li> +* </ul> <p> +* Required object relations : +* <ul> +* <li> <code>'XDriver.URL'</code>: +* is the URL of the database to which to connect</code></li> +* <li><code>'XDriver.UNSUITABLE_URL'</code>: +* the wrong kind of URL to connect using given driver</li> +* <li><code>'XDriver.INFO'</code>: +* a list of arbitrary string tag/value pairs as connection arguments</li> +* </ul> <p> +* @see com.sun.star.sdbcx.XDataDefinitionSupplier +*/ +public class _XDataDefinitionSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XDataDefinitionSupplier oObj = null ; + + String url = null; + String wrongUrl = null; + PropertyValue[] info = null; + + /** + * Retrieves relations. + * @throw StatusException If any relation not found. + */ + @Override + protected void before() { + url = (String)tEnv.getObjRelation("XDriver.URL"); + if (url == null) { + throw new StatusException(Status.failed( + "Couldn't get relation 'XDriver.URL'")); + } + wrongUrl = (String)tEnv.getObjRelation("XDriver.UNSUITABLE_URL"); + if (wrongUrl == null) { + throw new StatusException(Status.failed( + "Couldn't get relation 'XDriver.WRONG_URL'")); + } + info = (PropertyValue[])tEnv.getObjRelation("XDriver.INFO"); + if (info == null) { + throw new StatusException(Status.failed( + "Couldn't get relation 'XDriver.INFO'")); + } + } + + XConnection connection = null; + + /** + * Obtains the connection to url(relation <code>'XDriver.URL'</code>) + * with info(relation <code>'XDriver.INFO'</code>). + * Calls the method with obtained connection and checks that returned value + * isn't null. + */ + public void _getDataDefinitionByConnection() { + boolean bRes = true; + XDriver xDriver = UnoRuntime.queryInterface(XDriver.class, oObj); + if (xDriver == null) { + log.println("The XDriver interface isn't supported"); + tRes.tested("getDataDefinitionByConnection()", + Status.skipped(false)); + return; + } + try { + connection = xDriver.connect(url, info); + } catch(com.sun.star.sdbc.SQLException e) { + e.printStackTrace(log); + bRes = false; + } + if (connection == null) { + log.println("Couldn't get connection to specified url using " + + "specified info"); + tRes.tested("getDataDefinitionByConnection()", + Status.skipped(false)); + return; + } + XTablesSupplier xTS = null; + try { + log.println("getDataDefinitionByConnection(connection)"); + xTS = oObj.getDataDefinitionByConnection(connection); + bRes = xTS != null; + } catch(com.sun.star.sdbc.SQLException e) { + log.println("Unexpected exception: " + e); + bRes = false; + } + + try { + log.println("getDataDefinitionByConnection(null)"); + xTS = oObj.getDataDefinitionByConnection(null); + bRes = xTS == null; + } catch(com.sun.star.sdbc.SQLException e) { + log.println("Exception: " + e); + bRes = true; + } + + tRes.tested("getDataDefinitionByConnection()", bRes); + } + + /** + * Calls the method with url and info obtained from the relations + * <code>XDriver.URL</code> and <code>XDriver.INFO</code>. + * Checks that returned value isn't null. + * Then calls the method with the unsuitable url obtained from the relation + * <code>XDriver.UNSUITABLE_URL</code> and checks that SQLException + * exception was thrown. + */ + public void _getDataDefinitionByURL() { + try { + log.println("getDataDefinitionByURL('" + url + "')"); + oObj.getDataDefinitionByURL(url, info); + } catch (com.sun.star.sdbc.SQLException e) { + log.println("Unexpected exception: " + e); + } + + try { + log.println("getDataDefinitionByURL('" + wrongUrl + "')"); + oObj.getDataDefinitionByURL(wrongUrl, info); + log.println("Exception was expected"); + } catch (com.sun.star.sdbc.SQLException e) { + log.println("Expected exception"); + } + + tRes.tested("getDataDefinitionByURL()", true); + + } +} // finish class _XDataDefinitionSupplier + + diff --git a/qadevOOo/tests/java/ifc/sdbcx/_XDeleteRows.java b/qadevOOo/tests/java/ifc/sdbcx/_XDeleteRows.java new file mode 100644 index 000000000..af79864a5 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbcx/_XDeleteRows.java @@ -0,0 +1,84 @@ +/* + * 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.sdbcx; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbcx.XDeleteRows; +import com.sun.star.sdbcx.XRowLocate; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sdbcx.XDeleteRows</code> +* interface methods : +* <ul> +* <li><code> deleteRows()</code></li> +* </ul> <p> +* @see com.sun.star.sdbcx.XDeleteRows +*/ +public class _XDeleteRows extends MultiMethodTest { + // oObj filled by MultiMethodTest + public XDeleteRows oObj = null ; + + /** + * Retrieves bookmark using XRowLocate and deletes + * row pointed by this bookmark. <p> + * Has OK status if number of rows after deleting is less than before + * and no exception rises while method call, FAILED otherwise. <p> + */ + public void _deleteRows() { + XRowLocate xRowLocate = UnoRuntime.queryInterface(XRowLocate.class, oObj); + XResultSet xResultSet = UnoRuntime.queryInterface(XResultSet.class, oObj); + if (xRowLocate == null || xResultSet == null) { + log.println("The test must be modified according to "+ + "component testcase"); + throw new StatusException(Status.failed( + "The component doesn't support one of the "+ + "required interfaces")); + } + + int rowsBefore = 0, rowsAfter = 0; + Object bkmrk = null; + try { + xResultSet.last(); + rowsBefore = xResultSet.getRow(); + xResultSet.first(); + bkmrk = xRowLocate.getBookmark(); + oObj.deleteRows(new Object[] {bkmrk}); + xResultSet.last(); + rowsAfter = xResultSet.getRow(); + } catch(com.sun.star.sdbc.SQLException e) { + log.println("SQLException:" + e); + tRes.tested("deleteRows()", false); + return; + } + + log.println("Rows before: " + rowsBefore + ", after: " + rowsAfter); + tRes.tested("deleteRows()", rowsBefore - 1 == rowsAfter); + } + + @Override + protected void after() { + disposeEnvironment(); + } +} // finish class _XDeleteRows + diff --git a/qadevOOo/tests/java/ifc/sdbcx/_XDropCatalog.java b/qadevOOo/tests/java/ifc/sdbcx/_XDropCatalog.java new file mode 100644 index 000000000..e697f8394 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbcx/_XDropCatalog.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.sdbcx; + +import lib.MultiMethodTest; +import lib.Status; + +import com.sun.star.sdbcx.XDropCatalog; + +/** +* Testing <code>com.sun.star.sdbcx.XDropCatalog</code> +* interface methods : +* <ul> +* <li><code>dropCatalog()</code></li> +* </ul> <p> +* @see com.sun.star.sdbcx.XDropCatalog +*/ +public class _XDropCatalog extends MultiMethodTest { + // oObj filled by MultiMethodTest + public XDropCatalog oObj = null; + + public void _dropCatalog() { + tRes.tested("dropCatalog()", Status.skipped(false)); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sdbcx/_XRowLocate.java b/qadevOOo/tests/java/ifc/sdbcx/_XRowLocate.java new file mode 100644 index 000000000..9a1726932 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbcx/_XRowLocate.java @@ -0,0 +1,225 @@ +/* + * 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.sdbcx; + +import lib.MultiMethodTest; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbcx.XRowLocate; + +/** +* Testing <code>com.sun.star.sdbcx.XRowLocate</code> +* interface methods : +* <ul> +* <li><code> getBookmark()</code></li> +* <li><code> moveToBookmark()</code></li> +* <li><code> moveRelativeToBookmark()</code></li> +* <li><code> compareBookmarks()</code></li> +* <li><code> hasOrderedBookmarks()</code></li> +* <li><code> hashBookmark()</code></li> +* </ul> <p> +* Object relations needed : +* <ul> +* <li> <code>XRowLocate.HasOrderedBookmarks</code> <b>(optional)</b>: +* <code>Boolean</code> type. If information about bookmark ordering +* of object tested exists it placed in this relation.</li> +* </ul> <p> +* @see com.sun.star.sdbcx.XRowLocate +*/ +public class _XRowLocate extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XRowLocate oObj = null ; + + private Object bookmark1 = null, bookmark2 = null ; + + /** + * Gets the bookmark of the current cursor position and + * stores it for other methods use. + * Has OK status if method returns not null + * <code>XNameAccess</code> object, FAILED otherwise. + */ + public void _getBookmark() { + + try { + bookmark1 = oObj.getBookmark() ; + } catch (SQLException e) { + log.println("Exception occurred :" + e) ; + } + + tRes.tested("getBookmark()", bookmark1 != null) ; + } + + /** + * Moves to bookmark previously created by method <code>_getBookmark</code> + * then creates new bookmark and compare it to the first one. The + * row difference must be equal to 0. <p> + * Method tests to be completed successfully before : + * <ul> + * <li> <code>getBookmark()</code> : to have a bookmark to move to.</li> + * </ul> + * Method tests to be executed before : + * <ul> + * <li> <code>moveRelativeToBookmark()</code> : to move the cursor from + * the initial position, to check if it returns back.</li> + * </ul> <p> + * Has OK status difference between positions of bookmarks (where + * cursor was moved to and created new one) equals to 0 and no + * exceptions occurred, FAILED otherwise. + */ + public void _moveToBookmark() { + requiredMethod("getBookmark()") ; + executeMethod("moveRelativeToBookmark()") ; + + int comparison = -1 ; + Object tmpBookmark = null ; + try { + synchronized(oObj) { + oObj.moveToBookmark(bookmark1) ; + tmpBookmark = oObj.getBookmark() ; + } + comparison = oObj.compareBookmarks(bookmark1, tmpBookmark) ; + } catch (SQLException e) { + log.println("Exception occurred :" + e) ; + } + + tRes.tested("moveToBookmark()", comparison == 0) ; + } + + /** + * Moves the cursor to the position with offset 2 from the + * bookmark created by <code>_getBookmark()</code> method and + * then creates a bookmark of new position. <p> + * Method tests to be completed successfully before : + * <ul> + * <li> <code>getBookmark()</code> : to have a bookmark to move to.</li> + * </ul> <p> + * Has OK status if no exceptions occurred while method call. + */ + public void _moveRelativeToBookmark() { + requiredMethod("getBookmark()") ; + + boolean result = true ; + try { + synchronized (oObj) { + oObj.moveRelativeToBookmark(bookmark1, 1) ; + bookmark2 = oObj.getBookmark() ; + } + } catch (SQLException e) { + log.println("Exception occurred :" + e) ; + result = false ; + } + + tRes.tested("moveRelativeToBookmark()", result) ; + } + + /** + * Compares bookmarks created in <code>getBookmark()</code> and + * <code>moveRelativeToBokkmark()</code> methods. + * Method tests to be completed successfully before : + * <ul> + * <li> <code>getBookmark()</code> : to have first bookmark to compare.</li> + * <li> <code>moveRelativeToBookmark()</code> : to have second + * bookmark to compare.</li> + * </ul> <p> + * Has OK status if difference in bookmark positions equals to 2. + */ + public void _compareBookmarks() { + requiredMethod("getBookmark()") ; + requiredMethod("moveRelativeToBookmark()") ; + + int comparison = 0 ; + int comparison1 = 0 ; + try { + comparison = oObj.compareBookmarks(bookmark1, bookmark2) ; + comparison1 = oObj.compareBookmarks(bookmark1, bookmark1) ; + } catch (SQLException e) { + log.println("Exception occurred :" + e) ; + } + + if (comparison != -1) { + log.println("! Wrong compare number :" + comparison) ; + } + + tRes.tested("compareBookmarks()", comparison == -1 && comparison1 == 0) ; + } + + /** + * Calls method. If relation is not found, returned result is not + * checked. <p> + * Has OK status if method returned right value (in case if relation + * and value to compare to exist), or just successfully returned + * (in case of no relation). + */ + public void _hasOrderedBookmarks() { + boolean result = true ; + boolean res = true ; + + // Optional relation + Boolean has = (Boolean) tEnv.getObjRelation + ("XRowLocate.HasOrderedBookmarks") ; + + try { + res = oObj.hasOrderedBookmarks() ; + } catch (SQLException e) { + log.println("Exception occurred :" + e) ; + result = false ; + } + + if (has == null) { + log.println("Optional relation not found - result not checked") ; + } else { + result &= res == has.booleanValue() ; + } + + tRes.tested("hasOrderedBookmarks()", result) ; + } + + /** + * Gets hash values of two previously created bookmarks of different + * cursor positions and compares them. <p> + * Method tests to be completed successfully before : + * <ul> + * <li> <code>getBookmark()</code> : to have first bookmark.</li> + * <li> <code>moveRelativeToBookmark()</code> : to have second + * bookmark.</li> + * </ul> <p> + * Has OK status if hash values of two bookmarks are different. + */ + public void _hashBookmark() { + requiredMethod("getBookmark()") ; + requiredMethod("moveRelativeToBookmark()") ; + + boolean result = true ; + try { + int hash1 = oObj.hashBookmark(bookmark1) ; + int hash2 = oObj.hashBookmark(bookmark2) ; + log.println("1st hash = " + hash1 + ", 2nd = " + hash2) ; + + result = hash1 != hash2 ; + } catch (SQLException e) { + log.println("Exception occurred :" + e) ; + result = false ; + } + + tRes.tested("hashBookmark()", result) ; + } + +} // finish class _XRowLocate + diff --git a/qadevOOo/tests/java/ifc/sdbcx/_XTablesSupplier.java b/qadevOOo/tests/java/ifc/sdbcx/_XTablesSupplier.java new file mode 100644 index 000000000..5c48e44e1 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sdbcx/_XTablesSupplier.java @@ -0,0 +1,71 @@ +/* + * 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.sdbcx; + +import com.sun.star.container.XNameAccess; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.uno.UnoRuntime; +import lib.MultiMethodTest; + +/** +* Testing <code>com.sun.star.sdbcx.XTablesSupplier</code> +* interface methods : +* <ul> +* <li><code> getTables()</code></li> +* </ul> <p> +* @see com.sun.star.sdbcx.XTablesSupplier +*/ +public class _XTablesSupplier extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XTablesSupplier oObj = null ; + + /** + * Has OK status if method returns not null + * <code>XNameAccess</code> object, FAILED otherwise. + */ + public void _getTables() { + XNameAccess tabs = oObj.getTables() ; + + + String[] tabNames = tabs.getElementNames() ; + + log.println("Table names:") ; + for (int i =0 ; i < tabNames.length; i++) { + log.println(" " + tabNames[i]) ; + } + + XServiceInfo info = null ; + try { + info = UnoRuntime.queryInterface + (XServiceInfo.class, tabs.getByName(tabNames[0])) ; + } catch (com.sun.star.uno.Exception e) {} + + if (info != null) { + log.println("Support : " + + info.supportsService("com.sun.star.sdbcx.Table")) ; + } + + tRes.tested("getTables()", info != null) ; + } + +} // finish class _XTablesSupplier + + |