1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  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  {
21     public void testExpansion() throws Exception
22     {
23     	WsdlSubmitContext context = new WsdlSubmitContext( null );
24     	
25     	context.setProperty( "test", "value" );
26     	
27     	assertEquals( "value", PropertyExpansionRequestFilter.expandProperties( context, "${test}" ));
28     	assertEquals( "value", PropertyExpansionRequestFilter.expandProperties( context, "${#test}" ));
29     	assertEquals( " value ", PropertyExpansionRequestFilter.expandProperties( context, " ${test} " ));
30     	assertEquals( "${testa}", PropertyExpansionRequestFilter.expandProperties( context, "${testa}" ));
31     	assertEquals( "valuevalue", PropertyExpansionRequestFilter.expandProperties( context, "${test}${test}" ));
32     	assertEquals( "${testvalue}", PropertyExpansionRequestFilter.expandProperties( context, "${test${test}}" ));
33     }
34     
35     public void testXPathExpansion() throws Exception 
36     {
37     	WsdlSubmitContext context = new WsdlSubmitContext( null );
38     	
39     	context.setProperty( "test", "<test><value>hello</value></test>" );
40     	assertEquals( "hello", PropertyExpansionRequestFilter.expandProperties( context, "${#test#//value/text()}" ));
41     }
42  }