Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _MailMerge.java
blobf16eaefd12db1f2fb0fdabe30fe24255ca4e3523
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.text;
30 import lib.MultiPropertyTest;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.sdbc.XConnection;
34 import com.sun.star.sdbc.XResultSet;
35 import com.sun.star.uno.UnoRuntime;
37 public class _MailMerge extends MultiPropertyTest {
39 /**
40 * Custom tester for properties which contains URLs.
41 * Switches between two valid folders
43 protected PropertyTester URLTester = new PropertyTester() {
44 protected Object getNewValue(String propName, Object oldValue) {
45 if (oldValue.equals(util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF())))
46 return util.utils.getFullTestURL(""); else
47 return util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF());
49 } ;
51 /**
52 * Custom tester for properties which contains document URLs.
53 * Switches between two document URLs.
55 protected PropertyTester DocumentURLTester = new PropertyTester() {
56 protected Object getNewValue(String propName, Object oldValue) {
57 if (oldValue.equals(util.utils.getFullTestURL("MailMerge.sxw")))
58 return util.utils.getFullTestURL("sForm.sxw"); else
59 return util.utils.getFullTestURL("MailMerge.sxw");
61 } ;
62 /**
63 * Tested with custom property tester.
65 public void _ResultSet() {
66 String propName = "ResultSet";
67 try{
69 log.println("try to get value from property...");
70 XResultSet oldValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName));
72 log.println("try to get value from object relation...");
73 XResultSet newValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,tEnv.getObjRelation("MailMerge.XResultSet"));
75 log.println("set property to a new value...");
76 oObj.setPropertyValue(propName, newValue);
78 log.println("get the new value...");
79 XResultSet getValue = (XResultSet) UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName));
81 tRes.tested(propName, this.compare(newValue, getValue));
82 } catch (com.sun.star.beans.PropertyVetoException e){
83 log.println("could not set property '"+ propName +"' to a new value!");
84 tRes.tested(propName, false);
85 } catch (com.sun.star.lang.IllegalArgumentException e){
86 log.println("could not set property '"+ propName +"' to a new value!");
87 tRes.tested(propName, false);
88 } catch (com.sun.star.beans.UnknownPropertyException e){
89 if (this.isOptional(propName)){
90 // skipping optional property test
91 log.println("Property '" + propName
92 + "' is optional and not supported");
93 tRes.tested(propName,true);
95 } else {
96 log.println("could not get property '"+ propName +"' from XPropertySet!");
97 tRes.tested(propName, false);
99 } catch (com.sun.star.lang.WrappedTargetException e){
100 log.println("could not get property '"+ propName +"' from XPropertySet!");
101 tRes.tested(propName, false);
106 * Tested with custom property tester.
109 public void _ActiveConnection() {
110 String propName = "ActiveConnection";
111 try{
113 log.println("try to get value from property...");
114 XConnection oldValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName));
116 log.println("try to get value from object relation...");
117 XConnection newValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,tEnv.getObjRelation("MailMerge.XConnection"));
119 log.println("set property to a new value...");
120 oObj.setPropertyValue(propName, newValue);
122 log.println("get the new value...");
123 XConnection getValue = (XConnection) UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName));
125 tRes.tested(propName, this.compare(newValue, getValue));
126 } catch (com.sun.star.beans.PropertyVetoException e){
127 log.println("could not set property '"+ propName +"' to a new value! " + e.toString());
128 tRes.tested(propName, false);
129 } catch (com.sun.star.lang.IllegalArgumentException e){
130 log.println("could not set property '"+ propName +"' to a new value! " + e.toString());
131 tRes.tested(propName, false);
132 } catch (com.sun.star.beans.UnknownPropertyException e){
133 if (this.isOptional(propName)){
134 // skipping optional property test
135 log.println("Property '" + propName
136 + "' is optional and not supported");
137 tRes.tested(propName,true);
139 } else {
140 log.println("could not get property '"+ propName +"' from XPropertySet!");
141 tRes.tested(propName, false);
143 } catch (com.sun.star.lang.WrappedTargetException e){
144 log.println("could not get property '"+ propName +"' from XPropertySet!");
145 tRes.tested(propName, false);
150 * Tested with custom property tester.
152 public void _DocumentURL() {
153 log.println("Testing with custom Property tester") ;
154 testProperty("DocumentURL", DocumentURLTester) ;
158 * Tested with custom property tester.
160 public void _OutputURL() {
161 log.println("Testing with custom Property tester") ;
162 testProperty("OutputURL", URLTester) ;
166 * Forces environment recreation.
168 protected void after() {
169 disposeEnvironment();
173 } //finish class _MailMerge