1 16 17 package org.apache.ws.jaxme.xs.junit; 18 19 import junit.framework.TestCase; 20 21 import java.io.File ; 22 import java.util.Enumeration ; 23 import java.util.zip.ZipEntry ; 24 import java.util.zip.ZipFile ; 25 26 import org.apache.ws.jaxme.xs.XSParser; 27 import org.xml.sax.InputSource ; 28 29 30 public class TestSrcContent extends TestCase { 31 public TestSrcContent(String name) { 32 super(name); 33 } 34 35 public void testSourceFiles() throws Exception { 36 String path = System.getProperty("xstc.zip.file"); 37 if (path == null || "".equals(path)) { 38 fail("The property xstc.zip.file is not set."); 39 } 40 File f = new File (path); 41 if (!f.exists() || !f.isFile()) { 42 fail("The file " + f.getAbsolutePath() + 43 ", given by property xstc.zip.file, does not exist "); 44 } 45 46 int passXSDFiles = 0; 47 int failXSDFiles = 0; 48 49 ZipFile zipFile = new ZipFile (f); 50 for (Enumeration en = zipFile.entries(); en.hasMoreElements(); ) { 51 ZipEntry entry = (ZipEntry ) en.nextElement(); 52 if (entry.isDirectory()) { 53 continue; 54 } 55 String name = entry.getName(); 56 if (!name.endsWith(".xsd")) { 57 continue; 58 } 59 60 InputSource iSource = new InputSource (zipFile.getInputStream(entry)); 61 iSource.setSystemId(name); 62 System.out.print(name); 63 XSParser parser = new XSParser(); 64 parser.setValidating(false); 65 try { 66 parser.parseSyntax(iSource); 67 passXSDFiles++; 68 System.out.println(": PASS"); 69 } catch (Exception e) { 70 failXSDFiles++; 71 System.out.println(": FAIL"); 72 e.printStackTrace(System.out); 73 } 74 } 75 76 System.out.println(); 77 System.out.println(); 78 System.out.println("Total files = " + (passXSDFiles + failXSDFiles)); 79 System.out.println("Passed = " + passXSDFiles); 80 System.out.println("Failed = " + failXSDFiles); 81 } 82 83 public static void main(String [] args) throws Exception { 84 TestSrcContent testSrcContent = new TestSrcContent(TestSrcContent.class.getName()); 85 testSrcContent.testSourceFiles(); 86 } 87 } 88 | Popular Tags |