01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.impl.wsdl.submit.filters;
14:
15: import junit.framework.TestCase;
16:
17: import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
18:
19: public class PropertyExpansionTestCase extends TestCase {
20: public void testExpansion() throws Exception {
21: WsdlSubmitContext context = new WsdlSubmitContext(null);
22:
23: context.setProperty("test", "value");
24:
25: assertEquals("value", PropertyExpansionRequestFilter
26: .expandProperties(context, "${test}"));
27: assertEquals("value", PropertyExpansionRequestFilter
28: .expandProperties(context, "${#test}"));
29: assertEquals(" value ", PropertyExpansionRequestFilter
30: .expandProperties(context, " ${test} "));
31: assertEquals("${testa}", PropertyExpansionRequestFilter
32: .expandProperties(context, "${testa}"));
33: assertEquals("valuevalue", PropertyExpansionRequestFilter
34: .expandProperties(context, "${test}${test}"));
35:
36: context.setProperty("testa", "");
37: assertEquals("", PropertyExpansionRequestFilter
38: .expandProperties(context, "${testa}"));
39: }
40:
41: public void testRecursiveExpansion() throws Exception {
42: WsdlSubmitContext context = new WsdlSubmitContext(null);
43:
44: context.setProperty("test", "value");
45: context.setProperty("testexp", "${test}");
46:
47: assertEquals("value", PropertyExpansionRequestFilter
48: .expandProperties(context, "${testexp}"));
49:
50: context.setProperty("exp", "${exp}");
51: assertEquals("${exp}", PropertyExpansionRequestFilter
52: .expandProperties(context, "${exp}"));
53: }
54:
55: public void testNestedExpansion() throws Exception {
56: WsdlSubmitContext context = new WsdlSubmitContext(null);
57:
58: context.setProperty("test", "value");
59: context.setProperty("testexp", "${test}");
60: context.setProperty("exp", "exp");
61:
62: assertEquals("value", PropertyExpansionRequestFilter
63: .expandProperties(context, "${test${exp}}"));
64:
65: context.setProperty("id", "123");
66: context.setProperty("testxml",
67: "<test><value id=\"123\">hello</value></test>");
68: assertEquals("hello", PropertyExpansionRequestFilter
69: .expandProperties(context,
70: "${#testxml#//value[@id=${id}]/text()}"));
71:
72: context.setProperty("testxpath", "//value[@id=${id}]/text()");
73: assertEquals("hello", PropertyExpansionRequestFilter
74: .expandProperties(context, "${#testxml#${testxpath}}"));
75: }
76:
77: public void testXPathExpansion() throws Exception {
78: WsdlSubmitContext context = new WsdlSubmitContext(null);
79:
80: context
81: .setProperty("test",
82: "<test><value>hello</value></test>");
83: assertEquals("hello", PropertyExpansionRequestFilter
84: .expandProperties(context, "${#test#//value/text()}"));
85: }
86: }
|