1 package org.objectweb.celtix.tools.processors.wsdl2; 2 3 import java.io.File ; 4 import java.io.FileReader ; 5 6 import org.objectweb.celtix.tools.common.ToolConstants; 7 import org.objectweb.celtix.tools.processors.ProcessorTestBase; 8 9 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, getLocation("/wsdl/hello_world.wsdl")); 25 processor.setEnvironment(env); 26 processor.process(); 27 File seiFile = new File (output.getCanonicalPath() 28 + "/org/objectweb/hello_world_soap_http/Greeter.java"); 29 assertTrue("PortType file is not generated", seiFile.exists()); 30 FileReader fileReader = new FileReader (seiFile); 31 char[] chars = new char[100]; 32 int size = 0; 33 StringBuffer sb = new StringBuffer (); 34 while (size < seiFile.length()) { 35 int readLen = fileReader.read(chars); 36 sb.append(chars, 0, readLen); 37 size = size + readLen; 38 39 } 40 String seiString = new String (sb); 41 if (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0) { 42 assertTrue("EOL Style is not correct on windows platform", seiString.indexOf("\r\n") >= 0); 43 } else { 44 assertTrue("EOL Style is not correct on unix platform", seiString.indexOf("\r") < 0); 45 } 46 47 } 48 49 private String getLocation(String wsdlFile) { 50 return WSDLTOJavaEOLStyleTest.class.getResource(wsdlFile).getFile(); 51 } 52 } 53 | Popular Tags |