001: package org.objectweb.celtix.tools.processors.wsdl2;
002:
003: //import java.io.File;
004: //import java.io.FileReader;
005: ////import java.io.FileReader;
006: //
007: //import org.objectweb.celtix.tools.WSDLToJava;
008: import org.objectweb.celtix.tools.common.ToolConstants; //import org.objectweb.celtix.tools.common.toolspec.ToolException;
009: import org.objectweb.celtix.tools.processors.ProcessorTestBase;
010:
011: public class WSDLToJavaMIMETest extends ProcessorTestBase {
012:
013: public void setUp() throws Exception {
014: super .setUp();
015: env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
016: }
017:
018: // public void testHelloWorld() throws Exception {
019: // String[] args = new String[] {"-d", output.getCanonicalPath(),
020: // getLocation("/wsdl/binary_attachment.wsdl")};
021: // WSDLToJava.main(args);
022: // assertNotNull(output);
023: // File org = new File(output, "org");
024: // assertTrue(org.exists());
025: // File objectweb = new File(org, "objectweb");
026: // assertTrue(objectweb.exists());
027: // File helloworldsoaphttp = new File(objectweb, "binary_attachment");
028: // assertTrue(helloworldsoaphttp.exists());
029: // File outputFile = new File(helloworldsoaphttp, "BinaryAttachmentPortType.java");
030: // assertTrue("PortType file is not generated", outputFile.exists());
031: // FileReader fileReader = new FileReader(outputFile);
032: // char[] chars = new char[100];
033: // int size = 0;
034: // StringBuffer sb = new StringBuffer();
035: // while (size < outputFile.length()) {
036: // int readLen = fileReader.read(chars);
037: // sb.append(chars, 0, readLen);
038: // size = size + readLen;
039: // }
040: // String serviceString = new String(sb);
041: // int position1 = serviceString.indexOf("public byte[] echoImage(");
042: // int position2 = serviceString.indexOf("byte[] para0");
043: // int position3 = serviceString.indexOf("java.awt.Image para1,");
044: // int position4 = serviceString
045: // .indexOf("javax.xml.ws.Holder<javax.activation.DataHandler> retn1");
046: // assertTrue(position1 > 0 && position2 > 0 && position3 > 0 && position4 > 0);
047: // assertTrue(position1 < position2 && position2 < position3 && position3 < position4);
048: // }
049: //
050: // public void testWithExternalBindingSwitch() throws Exception {
051: // String[] args = new String[] {"-d", output.getCanonicalPath(), "-b",
052: // getLocation("/wsdl/mime_binding.wsdl"),
053: // getLocation("/wsdl/binary_attachment.wsdl")};
054: // WSDLToJava.main(args);
055: // assertNotNull(output);
056: // File org = new File(output, "org");
057: // assertTrue(org.exists());
058: // File objectweb = new File(org, "objectweb");
059: // assertTrue(objectweb.exists());
060: // File helloworldsoaphttp = new File(objectweb, "binary_attachment");
061: // assertTrue(helloworldsoaphttp.exists());
062: // File outputFile = new File(helloworldsoaphttp, "BinaryAttachmentPortType.java");
063: // assertTrue("PortType file is not generated", outputFile.exists());
064: // FileReader fileReader = new FileReader(outputFile);
065: // char[] chars = new char[100];
066: // int size = 0;
067: // StringBuffer sb = new StringBuffer();
068: // while (size < outputFile.length()) {
069: // int readLen = fileReader.read(chars);
070: // sb.append(chars, 0, readLen);
071: // size = size + readLen;
072: // }
073: // String serviceString = new String(sb);
074: // int position1 = serviceString.indexOf("public java.awt.Image echoImage(");
075: // int position2 = serviceString.indexOf("java.awt.Image para0");
076: // int position3 = serviceString.indexOf("public void echoMultipleImage(");
077: // int position4 = serviceString.indexOf("java.awt.Image para1,");
078: // int position5 = serviceString
079: // .indexOf("javax.xml.ws.Holder<javax.activation.DataHandler> retn1");
080: //// System.out.println("position1=" + position1 + "; position2=" + position2 + "; position3="
081: //// + position3 + "; position4=" + position4 + "; position5=" + position5);
082: // assertTrue(position1 > 0 && position2 > 0 && position3 > 0 && position4 > 0
083: // && position5 > 0);
084: // assertTrue(position1 < position2 && position2 < position3 && position3 < position4
085: // && position4 < position5);
086: // }
087: //
088: // public void testMIMEValidationUniqueRoot() throws Exception {
089: // WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
090: // env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
091: // env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/mime_fail_unique_root.wsdl"));
092: // processor.setEnvironment(env);
093: // try {
094: // processor.process();
095: // fail("Do not catch expected tool exception for MIME unique root validation failure!");
096: // } catch (Exception e) {
097: // if (!(e instanceof ToolException && e.toString()
098: // .indexOf("There's more than one soap body mime part in its binding input") >= 0)) {
099: // fail("Do not catch expected tool exception for MIME unique root validation failure,"
100: // + " catch other unexpected exception!");
101: // }
102: // }
103: // }
104: //
105: // public void testMIMEValidationDiffParts() throws Exception {
106: // WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
107: // env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
108: // env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/mime_fail_diff_parts.wsdl"));
109: // processor.setEnvironment(env);
110: // try {
111: // processor.process();
112: // fail("Do not catch expected tool exception for MIME different parts validation failure!");
113: // } catch (Exception e) {
114: // if (!(e instanceof ToolException && e.toString()
115: // .indexOf("Part attribute value for meme:content elements are different") >= 0)) {
116: // fail("Do not catch expected tool exception for MIME different parts validation failure,"
117: // + " catch other unexpected exception!");
118: // }
119: // }
120: // }
121:
122: // private String getLocation(String wsdlFile) {
123: // return WSDLToJavaMIMETest.class.getResource(wsdlFile).getFile();
124: // }
125:
126: public void testDummy() {
127: System.out.print("");
128: }
129:
130: }
|