1 16 17 package org.apache.batik.dom.svg; 18 19 import java.util.Locale ; 20 import java.util.ResourceBundle ; 21 import java.util.StringTokenizer ; 22 import java.util.MissingResourceException ; 23 24 import org.apache.batik.test.AbstractTest; 25 import org.apache.batik.test.TestReport; 26 import org.apache.batik.test.DefaultTestReport; 27 28 35 public class SystemIdTest extends AbstractTest { 36 public static final String ERROR_MISSING_SYSTEM_ID 37 = "error.missing.system.id"; 38 39 public static final String KEY_MISSING_IDS 40 = "key.missing.ids"; 41 42 public SystemIdTest() { 43 } 44 45 public TestReport runImpl() throws Exception { 46 ResourceBundle rb = 47 ResourceBundle.getBundle(SAXSVGDocumentFactory.DTDIDS, 48 Locale.getDefault()); 49 String dtdids = rb.getString(SAXSVGDocumentFactory.KEY_PUBLIC_IDS); 50 51 StringTokenizer st = new StringTokenizer (dtdids, "-"); 52 int nIds = st.countTokens(); 53 String missingIds = ""; 54 for (int i=0; i<nIds; i++) { 55 String publicId = st.nextToken(); 56 publicId = "-" + publicId.trim(); 57 System.out.println("Testing public id: " + publicId); 58 try { 59 rb.getString(SAXSVGDocumentFactory.KEY_SYSTEM_ID 60 + publicId.replace(' ', '_')); 61 } catch (MissingResourceException e) { 62 missingIds += "[" + publicId + "] -- "; 63 } 64 } 65 66 if (!"".equals(missingIds)) { 67 DefaultTestReport report = new DefaultTestReport(this); 68 report.setErrorCode(ERROR_MISSING_SYSTEM_ID); 69 report.addDescriptionEntry(KEY_MISSING_IDS, missingIds); 70 report.setPassed(false); 71 return report; 72 } 73 74 return reportSuccess(); 75 } 76 } 77 | Popular Tags |