Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / util / _XStringSubstitution.java
blobaed62619f41e8cd09f0cd427114798ef1ccce977
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.util;
30 import com.sun.star.util.XStringSubstitution;
31 import lib.MultiMethodTest;
33 public class _XStringSubstitution extends MultiMethodTest {
35 public XStringSubstitution oObj;
37 public void _getSubstituteVariableValue() {
38 boolean res = true;
39 try {
40 log.println("try to get the valid variable $(user) ...");
41 String toCheck = "$(user)";
42 String eString = oObj.getSubstituteVariableValue(toCheck);
43 res = eString.startsWith("file:///");
44 } catch (com.sun.star.container.NoSuchElementException e) {
45 log.println("$(user) does not exist");
46 tRes.tested("getSubstituteVariableValue()",false);
48 try {
49 log.println("try to get a invalid variable...");
50 String toCheck = "$(ThisVariableShouldNoExist)";
51 String eString = oObj.getSubstituteVariableValue(toCheck);
52 log.println("$(ThisVariableShouldNoExist) should not exist");
53 tRes.tested("getSubstituteVariableValue()",false);
55 } catch (com.sun.star.container.NoSuchElementException e) {
56 log.println("expected exception was thrown.");
57 res &= true;
60 tRes.tested("getSubstituteVariableValue()",res);
63 public void _substituteVariables() {
64 boolean res = true;
65 try {
66 log.println("try to get a valid variable...");
67 String toCheck = "$(user)";
68 String eString = oObj.substituteVariables(toCheck, false);
69 log.println(eString);
70 res = eString.startsWith("file:///");
71 } catch (com.sun.star.container.NoSuchElementException e) {
72 log.println("$(user) does not exist");
73 tRes.tested("substituteVariables()",false);
75 try {
76 log.println("try to get a invalid variable...");
77 String toCheck = "$(ThisVariableShouldNoExist)";
78 String eString = oObj.substituteVariables(toCheck,true);
79 log.println("$(ThisVariableShouldNoExist) should not exist");
80 tRes.tested("substituteVariables()",false);
82 } catch (com.sun.star.container.NoSuchElementException e) {
83 log.println("expected exception was thrown.");
84 res &= true;
87 tRes.tested("substituteVariables()",res);
90 public void _reSubstituteVariables() {
91 boolean res = true;
92 log.println("try to get a valid variable...");
93 String toCheck = "file:///";
94 String eString = oObj.reSubstituteVariables(toCheck);
95 log.println(eString);
96 res = eString.startsWith("file:///");
98 tRes.tested("reSubstituteVariables()",res);