2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiPropertyTest
;
23 import com
.sun
.star
.sdbc
.XConnection
;
24 import com
.sun
.star
.sdbc
.XResultSet
;
25 import com
.sun
.star
.uno
.UnoRuntime
;
27 public class _MailMerge
extends MultiPropertyTest
{
30 * Custom tester for properties which contains URLs.
31 * Switches between two valid folders
33 protected PropertyTester URLTester
= new PropertyTester() {
35 protected Object
getNewValue(String propName
, Object oldValue
) {
36 if (oldValue
.equals(util
.utils
.getOfficeTemp(tParam
.getMSF())))
37 return util
.utils
.getFullTestURL(""); else
38 return util
.utils
.getOfficeTemp(tParam
.getMSF());
43 * Custom tester for properties which contains document URLs.
44 * Switches between two document URLs.
46 protected PropertyTester DocumentURLTester
= new PropertyTester() {
48 protected Object
getNewValue(String propName
, Object oldValue
) {
49 if (oldValue
.equals(util
.utils
.getFullTestURL("MailMerge.sxw")))
50 return util
.utils
.getFullTestURL("sForm.sxw"); else
51 return util
.utils
.getFullTestURL("MailMerge.sxw");
55 * Tested with custom property tester.
57 public void _ResultSet() {
58 String propName
= "ResultSet";
61 log
.println("try to get value from property...");
62 UnoRuntime
.queryInterface(XResultSet
.class,oObj
.getPropertyValue(propName
));
64 log
.println("try to get value from object relation...");
65 XResultSet newValue
= UnoRuntime
.queryInterface(XResultSet
.class,tEnv
.getObjRelation("MailMerge.XResultSet"));
67 log
.println("set property to a new value...");
68 oObj
.setPropertyValue(propName
, newValue
);
70 log
.println("get the new value...");
71 XResultSet getValue
= UnoRuntime
.queryInterface(XResultSet
.class,oObj
.getPropertyValue(propName
));
73 tRes
.tested(propName
, this.compare(newValue
, getValue
));
74 } catch (com
.sun
.star
.beans
.PropertyVetoException e
){
75 log
.println("could not set property '"+ propName
+"' to a new value!");
76 tRes
.tested(propName
, false);
77 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
){
78 log
.println("could not set property '"+ propName
+"' to a new value!");
79 tRes
.tested(propName
, false);
80 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
81 if (this.isOptional(propName
)){
82 // skipping optional property test
83 log
.println("Property '" + propName
84 + "' is optional and not supported");
85 tRes
.tested(propName
,true);
88 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
89 tRes
.tested(propName
, false);
91 } catch (com
.sun
.star
.lang
.WrappedTargetException e
){
92 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
93 tRes
.tested(propName
, false);
98 * Tested with custom property tester.
101 public void _ActiveConnection() {
102 String propName
= "ActiveConnection";
105 log
.println("try to get value from property...");
106 UnoRuntime
.queryInterface(XConnection
.class,oObj
.getPropertyValue(propName
));
108 log
.println("try to get value from object relation...");
109 XConnection newValue
= UnoRuntime
.queryInterface(XConnection
.class,tEnv
.getObjRelation("MailMerge.XConnection"));
111 log
.println("set property to a new value...");
112 oObj
.setPropertyValue(propName
, newValue
);
114 log
.println("get the new value...");
115 XConnection getValue
= UnoRuntime
.queryInterface(XConnection
.class,oObj
.getPropertyValue(propName
));
117 tRes
.tested(propName
, this.compare(newValue
, getValue
));
118 } catch (com
.sun
.star
.beans
.PropertyVetoException e
){
119 log
.println("could not set property '"+ propName
+"' to a new value! " + e
.toString());
120 tRes
.tested(propName
, false);
121 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
){
122 log
.println("could not set property '"+ propName
+"' to a new value! " + e
.toString());
123 tRes
.tested(propName
, false);
124 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
){
125 if (this.isOptional(propName
)){
126 // skipping optional property test
127 log
.println("Property '" + propName
128 + "' is optional and not supported");
129 tRes
.tested(propName
,true);
132 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
133 tRes
.tested(propName
, false);
135 } catch (com
.sun
.star
.lang
.WrappedTargetException e
){
136 log
.println("could not get property '"+ propName
+"' from XPropertySet!");
137 tRes
.tested(propName
, false);
142 * Tested with custom property tester.
144 public void _DocumentURL() {
145 log
.println("Testing with custom Property tester") ;
146 testProperty("DocumentURL", DocumentURLTester
) ;
150 * Tested with custom property tester.
152 public void _OutputURL() {
153 log
.println("Testing with custom Property tester") ;
154 testProperty("OutputURL", URLTester
) ;
158 * Forces environment recreation.
161 protected void after() {
162 disposeEnvironment();
166 } //finish class _MailMerge