Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / util / _XStringSubstitution.java
blobfac10a3bcd15f1771276c61dc254c67a3687fce8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XStringSubstitution.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.util;
33 import com.sun.star.util.XStringSubstitution;
34 import lib.MultiMethodTest;
36 public class _XStringSubstitution extends MultiMethodTest {
38 public XStringSubstitution oObj;
40 public void _getSubstituteVariableValue() {
41 boolean res = true;
42 try {
43 log.println("try to get the valid variable $(user) ...");
44 String toCheck = "$(user)";
45 String eString = oObj.getSubstituteVariableValue(toCheck);
46 res = eString.startsWith("file:///");
47 } catch (com.sun.star.container.NoSuchElementException e) {
48 log.println("$(user) does not exist");
49 tRes.tested("getSubstituteVariableValue()",false);
51 try {
52 log.println("try to get a invalid variable...");
53 String toCheck = "$(ThisVariableShouldNoExist)";
54 String eString = oObj.getSubstituteVariableValue(toCheck);
55 log.println("$(ThisVariableShouldNoExist) should not exist");
56 tRes.tested("getSubstituteVariableValue()",false);
58 } catch (com.sun.star.container.NoSuchElementException e) {
59 log.println("expected exception was thrown.");
60 res &= true;
63 tRes.tested("getSubstituteVariableValue()",res);
66 public void _substituteVariables() {
67 boolean res = true;
68 try {
69 log.println("try to get a valid variable...");
70 String toCheck = "$(user)";
71 String eString = oObj.substituteVariables(toCheck, false);
72 log.println(eString);
73 res = eString.startsWith("file:///");
74 } catch (com.sun.star.container.NoSuchElementException e) {
75 log.println("$(user) does not exist");
76 tRes.tested("substituteVariables()",false);
78 try {
79 log.println("try to get a invalid variable...");
80 String toCheck = "$(ThisVariableShouldNoExist)";
81 String eString = oObj.substituteVariables(toCheck,true);
82 log.println("$(ThisVariableShouldNoExist) should not exist");
83 tRes.tested("substituteVariables()",false);
85 } catch (com.sun.star.container.NoSuchElementException e) {
86 log.println("expected exception was thrown.");
87 res &= true;
90 tRes.tested("substituteVariables()",res);
93 public void _reSubstituteVariables() {
94 boolean res = true;
95 log.println("try to get a valid variable...");
96 String toCheck = "file:///";
97 String eString = oObj.reSubstituteVariables(toCheck);
98 log.println(eString);
99 res = eString.startsWith("file:///");
101 tRes.tested("reSubstituteVariables()",res);