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 ************************************************************************/
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() {
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);
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.");
60 tRes
.tested("getSubstituteVariableValue()",res
);
63 public void _substituteVariables() {
66 log
.println("try to get a valid variable...");
67 String toCheck
= "$(user)";
68 String eString
= oObj
.substituteVariables(toCheck
, false);
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);
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.");
87 tRes
.tested("substituteVariables()",res
);
90 public void _reSubstituteVariables() {
92 log
.println("try to get a valid variable...");
93 String toCheck
= "file:///";
94 String eString
= oObj
.reSubstituteVariables(toCheck
);
96 res
= eString
.startsWith("file:///");
98 tRes
.tested("reSubstituteVariables()",res
);