FileDocCategorySizeDatePackage
WSDL2JavaFailuresTestCase.javaAPI DocApache Axis 1.42474Sat Apr 22 18:57:28 BST 2006test.badWSDL

WSDL2JavaFailuresTestCase

public class WSDL2JavaFailuresTestCase extends TestCase
This test grabs each WSDL file in the directory and runs WSDL2Java against them. They should all fail. If one does not, this test fails.

Fields Summary
private static final String
badWSDL
private String
wsdl
Constructors Summary
public WSDL2JavaFailuresTestCase(String wsdl)


       
        super("testWSDLFailures");
        this.wsdl = wsdl;
    
Methods Summary
private static java.lang.String[]getWSDLs()
Get a list of all WSDL files in this directory.

        String[] wsdls = null;
        try {
            File failuresDir = new File(badWSDL);
            FilenameFilter fnf = new FilenameFilter()
            {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".wsdl");
                }
            };
            wsdls = failuresDir.list(fnf);
        }
        catch (Throwable t) {
            wsdls = null;
        }
        if (wsdls == null) {
            wsdls = new String[0];
        }
        return wsdls;
    
public static junit.framework.Testsuite()
Create a test suite with a single test for each WSDL file in this directory.

        TestSuite tests = new TestSuite();
        String[] wsdls = getWSDLs();
        for (int i = 0; i < wsdls.length; ++i) {
            tests.addTest(new WSDL2JavaFailuresTestCase(badWSDL +
                    File.separatorChar + wsdls[i]));
        }
        return tests;
    
public voidtestWSDLFailures()
Call WSDL2Java on this WSDL file, failing if WSDL2Java succeeds.

        boolean failed  = false;
        Emitter emitter = new Emitter();

        emitter.setTestCaseWanted(true);
        emitter.setHelperWanted(true);    
        emitter.setImports(true);
        emitter.setAllWanted(true);
        emitter.setServerSide(true);
        emitter.setSkeletonWanted(true);
        try {
            emitter.run(wsdl);
            failed = true;
        }
        catch (Throwable e) {
        }
        if (failed) {
            fail("WSDL2Java " + wsdl + " should have failed.");
        }