01: package org.objectweb.celtix.tools.processors.wsdl2;
02:
03: import org.objectweb.celtix.tools.common.ToolConstants;
04: import org.objectweb.celtix.tools.common.ToolException;
05: import org.objectweb.celtix.tools.processors.ProcessorTestBase;
06:
07: public class WSDLToJavaXMLFormatTest extends ProcessorTestBase {
08:
09: public void setUp() throws Exception {
10: super .setUp();
11: env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
12: }
13:
14: public void testXMLFormatRootNodeValidationFail() throws Exception {
15: WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
16: env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
17: env.put(ToolConstants.CFG_WSDLURL,
18: getLocation("/wsdl/xml_format_fail.wsdl"));
19: env.put(ToolConstants.CFG_VALIDATE_WSDL,
20: ToolConstants.CFG_VALIDATE_WSDL);
21: System.setProperty(ToolConstants.CELTIX_SCHEMA_DIR,
22: getLocation("/schemas"));
23: processor.setEnvironment(env);
24: try {
25: processor.process();
26: fail("Do not catch expected tool exception for xml format binding!");
27: } catch (Exception e) {
28: if (!(e instanceof ToolException && e.toString().indexOf(
29: "missing xml format body element") >= 0)) {
30: fail("Do not catch expected tool exception for xml format binding,"
31: + " catch other unexpected exception!");
32: }
33: }
34: }
35:
36: public void testXMLFormatRootNodeValidationPass() throws Exception {
37: WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
38: env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
39: env.put(ToolConstants.CFG_WSDLURL,
40: getLocation("/wsdl/xml_format_pass.wsdl"));
41: processor.setEnvironment(env);
42: processor.process();
43: }
44:
45: private String getLocation(String wsdlFile) {
46: return WSDLToJavaXMLFormatTest.class.getResource(wsdlFile)
47: .getFile();
48: }
49: }
|