bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _MailMerge.java
blob98b2ec3cac0e468e529471d69e81fe183201a174
1 /*
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 .
19 package ifc.text;
21 import lib.MultiPropertyTest;
23 import com.sun.star.lang.XMultiServiceFactory;
24 import com.sun.star.sdbc.XConnection;
25 import com.sun.star.sdbc.XResultSet;
26 import com.sun.star.uno.UnoRuntime;
28 public class _MailMerge extends MultiPropertyTest {
30 /**
31 * Custom tester for properties which contains URLs.
32 * Switches between two valid folders
34 protected PropertyTester URLTester = new PropertyTester() {
35 protected Object getNewValue(String propName, Object oldValue) {
36 if (oldValue.equals(util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF())))
37 return util.utils.getFullTestURL(""); else
38 return util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF());
40 } ;
42 /**
43 * Custom tester for properties which contains document URLs.
44 * Switches between two document URLs.
46 protected PropertyTester DocumentURLTester = new PropertyTester() {
47 protected Object getNewValue(String propName, Object oldValue) {
48 if (oldValue.equals(util.utils.getFullTestURL("MailMerge.sxw")))
49 return util.utils.getFullTestURL("sForm.sxw"); else
50 return util.utils.getFullTestURL("MailMerge.sxw");
52 } ;
53 /**
54 * Tested with custom property tester.
56 public void _ResultSet() {
57 String propName = "ResultSet";
58 try{
60 log.println("try to get value from property...");
61 UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName));
63 log.println("try to get value from object relation...");
64 XResultSet newValue = UnoRuntime.queryInterface(XResultSet.class,tEnv.getObjRelation("MailMerge.XResultSet"));
66 log.println("set property to a new value...");
67 oObj.setPropertyValue(propName, newValue);
69 log.println("get the new value...");
70 XResultSet getValue = UnoRuntime.queryInterface(XResultSet.class,oObj.getPropertyValue(propName));
72 tRes.tested(propName, this.compare(newValue, getValue));
73 } catch (com.sun.star.beans.PropertyVetoException e){
74 log.println("could not set property '"+ propName +"' to a new value!");
75 tRes.tested(propName, false);
76 } catch (com.sun.star.lang.IllegalArgumentException e){
77 log.println("could not set property '"+ propName +"' to a new value!");
78 tRes.tested(propName, false);
79 } catch (com.sun.star.beans.UnknownPropertyException e){
80 if (this.isOptional(propName)){
81 // skipping optional property test
82 log.println("Property '" + propName
83 + "' is optional and not supported");
84 tRes.tested(propName,true);
86 } else {
87 log.println("could not get property '"+ propName +"' from XPropertySet!");
88 tRes.tested(propName, false);
90 } catch (com.sun.star.lang.WrappedTargetException e){
91 log.println("could not get property '"+ propName +"' from XPropertySet!");
92 tRes.tested(propName, false);
96 /**
97 * Tested with custom property tester.
100 public void _ActiveConnection() {
101 String propName = "ActiveConnection";
102 try{
104 log.println("try to get value from property...");
105 UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName));
107 log.println("try to get value from object relation...");
108 XConnection newValue = UnoRuntime.queryInterface(XConnection.class,tEnv.getObjRelation("MailMerge.XConnection"));
110 log.println("set property to a new value...");
111 oObj.setPropertyValue(propName, newValue);
113 log.println("get the new value...");
114 XConnection getValue = UnoRuntime.queryInterface(XConnection.class,oObj.getPropertyValue(propName));
116 tRes.tested(propName, this.compare(newValue, getValue));
117 } catch (com.sun.star.beans.PropertyVetoException e){
118 log.println("could not set property '"+ propName +"' to a new value! " + e.toString());
119 tRes.tested(propName, false);
120 } catch (com.sun.star.lang.IllegalArgumentException e){
121 log.println("could not set property '"+ propName +"' to a new value! " + e.toString());
122 tRes.tested(propName, false);
123 } catch (com.sun.star.beans.UnknownPropertyException e){
124 if (this.isOptional(propName)){
125 // skipping optional property test
126 log.println("Property '" + propName
127 + "' is optional and not supported");
128 tRes.tested(propName,true);
130 } else {
131 log.println("could not get property '"+ propName +"' from XPropertySet!");
132 tRes.tested(propName, false);
134 } catch (com.sun.star.lang.WrappedTargetException e){
135 log.println("could not get property '"+ propName +"' from XPropertySet!");
136 tRes.tested(propName, false);
141 * Tested with custom property tester.
143 public void _DocumentURL() {
144 log.println("Testing with custom Property tester") ;
145 testProperty("DocumentURL", DocumentURLTester) ;
149 * Tested with custom property tester.
151 public void _OutputURL() {
152 log.println("Testing with custom Property tester") ;
153 testProperty("OutputURL", URLTester) ;
157 * Forces environment recreation.
159 protected void after() {
160 disposeEnvironment();
164 } //finish class _MailMerge