1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _MailMerge.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiPropertyTest
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.sdbc
.XConnection
;
37 import com
.sun
.star
.sdbc
.XResultSet
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
40 public class _MailMerge
extends MultiPropertyTest
{
43 * Custom tester for properties which contains URLs.
44 * Switches between two valid folders
46 protected PropertyTester URLTester
= new PropertyTester() {
47 protected Object
getNewValue(String propName
, Object oldValue
) {
48 if (oldValue
.equals(util
.utils
.getOfficeTemp((XMultiServiceFactory
)tParam
.getMSF())))
49 return util
.utils
.getFullTestURL(""); else
50 return util
.utils
.getOfficeTemp((XMultiServiceFactory
)tParam
.getMSF());
55 * Custom tester for properties which contains document URLs.
56 * Switches between two document URLs.
58 protected PropertyTester DocumentURLTester
= new PropertyTester() {
59 protected Object
getNewValue(String propName
, Object oldValue
) {
60 if (oldValue
.equals(util
.utils
.getFullTestURL("MailMerge.sxw")))
61 return util
.utils
.getFullTestURL("sForm.sxw"); else
62 return util
.utils
.getFullTestURL("MailMerge.sxw");
66 * Tested with custom property tester.
68 public void _ResultSet() {
69 String propName
= "ResultSet";
72 log
.println("try to get value from property...");
73 XResultSet oldValue
= (XResultSet
) UnoRuntime
.queryInterface(XResultSet
.class,oObj
.getPropertyValue(propName
));
75 log
.println("try to get value from object relation...");
76 XResultSet newValue
= (XResultSet
) UnoRuntime
.queryInterface(XResultSet
.class,tEnv
.getObjRelation("MailMerge.XResultSet"));
78 log
.println("set property to a new value...");
79 oObj
.setPropertyValue(propName
, newValue
);
81 log
.println("get the new value...");
82 XResultSet getValue
= (XResultSet
) UnoRuntime
.queryInterface(XResultSet
.class,oObj
.getPropertyValue(propName
));
84 tRes
.tested(propName
, this.compare(newValue
, getValue
));
85 } catch (com
.sun
.star
.beans
.PropertyVetoException e
){
86 log
.println("could not set property '"+ propName
+"' to a new value!");
87 tRes
.tested(propName
, false);
88 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
){
89 log
.println("could not set property '"+ propName
+"' to a new value!");
90 tRes
.tested(propName
, false);
91 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
92 if (this.isOptional(propName
)){
93 // skipping optional property test
94 log
.println("Property '" + propName
95 + "' is optional and not supported");
96 tRes
.tested(propName
,true);
99 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
100 tRes
.tested(propName
, false);
102 } catch (com
.sun
.star
.lang
.WrappedTargetException e
){
103 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
104 tRes
.tested(propName
, false);
109 * Tested with custom property tester.
112 public void _ActiveConnection() {
113 String propName
= "ActiveConnection";
116 log
.println("try to get value from property...");
117 XConnection oldValue
= (XConnection
) UnoRuntime
.queryInterface(XConnection
.class,oObj
.getPropertyValue(propName
));
119 log
.println("try to get value from object relation...");
120 XConnection newValue
= (XConnection
) UnoRuntime
.queryInterface(XConnection
.class,tEnv
.getObjRelation("MailMerge.XConnection"));
122 log
.println("set property to a new value...");
123 oObj
.setPropertyValue(propName
, newValue
);
125 log
.println("get the new value...");
126 XConnection getValue
= (XConnection
) UnoRuntime
.queryInterface(XConnection
.class,oObj
.getPropertyValue(propName
));
128 tRes
.tested(propName
, this.compare(newValue
, getValue
));
129 } catch (com
.sun
.star
.beans
.PropertyVetoException 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
.lang
.IllegalArgumentException e
){
133 log
.println("could not set property '"+ propName
+"' to a new value! " + e
.toString());
134 tRes
.tested(propName
, false);
135 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
136 if (this.isOptional(propName
)){
137 // skipping optional property test
138 log
.println("Property '" + propName
139 + "' is optional and not supported");
140 tRes
.tested(propName
,true);
143 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
144 tRes
.tested(propName
, false);
146 } catch (com
.sun
.star
.lang
.WrappedTargetException e
){
147 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
148 tRes
.tested(propName
, false);
153 * Tested with custom property tester.
155 public void _DocumentURL() {
156 log
.println("Testing with custom Property tester") ;
157 testProperty("DocumentURL", DocumentURLTester
) ;
161 * Tested with custom property tester.
163 public void _OutputURL() {
164 log
.println("Testing with custom Property tester") ;
165 testProperty("OutputURL", URLTester
) ;
169 * Forces environment recreation.
171 protected void after() {
172 disposeEnvironment();
176 } //finish class _MailMerge