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 com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
16: import com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpRequestTransport;
17:
18: import junit.framework.TestCase;
19:
20: public class RemoveEmptyContentRequestFilterTestCase extends TestCase {
21: public void testRemoval() throws Exception {
22: doRemoval("<test><testing/></test>", "<test/>");
23: doRemoval("<test><testing test=\"\"/></test>", "<test/>");
24:
25: doRemoval("<test><testing> </testing></test>", "<test/>");
26: doRemoval(
27: "<test><testing> <testar test=\"\"></testar> </testing></test>",
28: "<test><testing> </testing></test>");
29:
30: doRemoval(
31: "<test><testing>\n <testar test=\"\"></testar>\n </testing></test>",
32: "<test><testing>\n \n </testing></test>");
33:
34: doRemoval("<test></test>", "<test></test>");
35:
36: doRemoval("<test><testing></test>", "<test><testing></test>");
37: }
38:
39: public void doRemoval(String request, String expected)
40: throws Exception {
41: RemoveEmptyContentRequestFilter filter = new RemoveEmptyContentRequestFilter();
42: WsdlSubmitContext context = new WsdlSubmitContext();
43:
44: context.setProperty(BaseHttpRequestTransport.REQUEST_CONTENT,
45: request);
46:
47: filter.filterRequest(context, null);
48:
49: assertEquals(expected, context
50: .getProperty(BaseHttpRequestTransport.REQUEST_CONTENT));
51: }
52: }
|