01: package org.objectweb.celtix.tools.processors.wsdl2;
02:
03: import java.io.File;
04: import java.io.FileReader;
05:
06: import org.objectweb.celtix.tools.common.ToolConstants;
07: import org.objectweb.celtix.tools.processors.ProcessorTestBase;
08:
09: public class WSDLTOJavaEOLStyleTest extends ProcessorTestBase {
10:
11: private WSDLToJavaProcessor processor = new WSDLToJavaProcessor();
12:
13: public void setUp() throws Exception {
14: super .setUp();
15: env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
16: }
17:
18: public void tearDown() {
19: super .tearDown();
20: processor = null;
21: }
22:
23: public void testHelloWorld() throws Exception {
24: env.put(ToolConstants.CFG_WSDLURL,
25: getLocation("/wsdl/hello_world.wsdl"));
26: processor.setEnvironment(env);
27: processor.process();
28: File seiFile = new File(output.getCanonicalPath()
29: + "/org/objectweb/hello_world_soap_http/Greeter.java");
30: assertTrue("PortType file is not generated", seiFile.exists());
31: FileReader fileReader = new FileReader(seiFile);
32: char[] chars = new char[100];
33: int size = 0;
34: StringBuffer sb = new StringBuffer();
35: while (size < seiFile.length()) {
36: int readLen = fileReader.read(chars);
37: sb.append(chars, 0, readLen);
38: size = size + readLen;
39:
40: }
41: String seiString = new String(sb);
42: if (System.getProperty("os.name").toLowerCase().indexOf(
43: "windows") >= 0) {
44: assertTrue("EOL Style is not correct on windows platform",
45: seiString.indexOf("\r\n") >= 0);
46: } else {
47: assertTrue("EOL Style is not correct on unix platform",
48: seiString.indexOf("\r") < 0);
49: }
50:
51: }
52:
53: private String getLocation(String wsdlFile) {
54: return WSDLTOJavaEOLStyleTest.class.getResource(wsdlFile)
55: .getFile();
56: }
57: }
|