1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XStringSubstitution.java,v $
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 ************************************************************************/
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() {
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);
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.");
63 tRes
.tested("getSubstituteVariableValue()",res
);
66 public void _substituteVariables() {
69 log
.println("try to get a valid variable...");
70 String toCheck
= "$(user)";
71 String eString
= oObj
.substituteVariables(toCheck
, false);
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);
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.");
90 tRes
.tested("substituteVariables()",res
);
93 public void _reSubstituteVariables() {
95 log
.println("try to get a valid variable...");
96 String toCheck
= "file:///";
97 String eString
= oObj
.reSubstituteVariables(toCheck
);
99 res
= eString
.startsWith("file:///");
101 tRes
.tested("reSubstituteVariables()",res
);