1 package test.badWSDL; 2 3 import junit.framework.Test; 4 import junit.framework.TestCase; 5 import junit.framework.TestSuite; 6 import org.apache.axis.wsdl.toJava.Emitter; 7 8 import java.io.File ; 9 import java.io.FilenameFilter ; 10 11 15 16 public class WSDL2JavaFailuresTestCase extends TestCase { 17 private static final String badWSDL = "test" + File.separatorChar + 18 "badWSDL"; 19 private String wsdl; 20 21 public WSDL2JavaFailuresTestCase(String wsdl) { 22 super("testWSDLFailures"); 23 this.wsdl = wsdl; 24 } 25 26 30 public static Test suite() { 31 TestSuite tests = new TestSuite(); 32 String [] wsdls = getWSDLs(); 33 for (int i = 0; i < wsdls.length; ++i) { 34 tests.addTest(new WSDL2JavaFailuresTestCase(badWSDL + 35 File.separatorChar + wsdls[i])); 36 } 37 return tests; 38 } 40 43 private static String [] getWSDLs() { 44 String [] wsdls = null; 45 try { 46 File failuresDir = new File (badWSDL); 47 FilenameFilter fnf = new FilenameFilter () 48 { 49 public boolean accept(File dir, String name) { 50 return name.endsWith(".wsdl"); 51 } 52 }; 53 wsdls = failuresDir.list(fnf); 54 } 55 catch (Throwable t) { 56 wsdls = null; 57 } 58 if (wsdls == null) { 59 wsdls = new String [0]; 60 } 61 return wsdls; 62 } 64 67 public void testWSDLFailures() { 68 boolean failed = false; 69 Emitter emitter = new Emitter(); 70 71 emitter.setTestCaseWanted(true); 72 emitter.setHelperWanted(true); 73 emitter.setImports(true); 74 emitter.setAllWanted(true); 75 emitter.setServerSide(true); 76 emitter.setSkeletonWanted(true); 77 try { 78 emitter.run(wsdl); 79 failed = true; 80 } 81 catch (Throwable e) { 82 } 83 if (failed) { 84 fail("WSDL2Java " + wsdl + " should have failed."); 85 } 86 } } 89 | Popular Tags |