1 15 package org.apache.hivemind.xml; 16 17 import java.util.Locale ; 18 19 import hivemind.test.FrameworkTestCase; 20 21 import org.apache.hivemind.ClassResolver; 22 import org.apache.hivemind.Registry; 23 import org.apache.hivemind.Resource; 24 import org.apache.hivemind.impl.DefaultErrorHandler; 25 import org.apache.hivemind.impl.RegistryBuilder; 26 import org.apache.hivemind.parse.DependencyDescriptor; 27 import org.apache.hivemind.parse.ModuleDescriptor; 28 import org.apache.hivemind.parse.XmlResourceProcessor; 29 import org.apache.hivemind.test.HiveMindTestCase; 30 31 36 public abstract class XmlTestCase extends FrameworkTestCase 37 { 38 42 protected Registry buildFrameworkRegistry(String file) throws Exception 43 { 44 return buildFrameworkRegistry(new String [] 45 { file }); 46 } 47 48 53 protected Registry buildFrameworkRegistry(String [] files) throws Exception 54 { 55 ClassResolver resolver = getClassResolver(); 56 57 RegistryBuilder builder = new RegistryBuilder(); 58 builder.autoDetectModules(); 59 60 for (int i = 0; i < files.length; i++) 61 { 62 Resource resource = getResource(files[i]); 63 64 org.apache.hivemind.impl.XmlModuleReader reader = new org.apache.hivemind.impl.XmlModuleReader(builder.getRegistryDefinition(), 65 resolver, builder.getErrorHandler()); 66 reader.readModule(resource); 67 } 68 69 return builder.constructRegistry(Locale.getDefault()); 70 } 71 72 protected ModuleDescriptor parse(String file) 73 throws Exception 74 { 75 Resource location = getResource(file); 76 DefaultErrorHandler eh = new DefaultErrorHandler(); 77 78 XmlResourceProcessor p = new XmlResourceProcessor(_resolver, eh); 79 80 ModuleDescriptor result = p.processResource(location); 81 82 return result; 83 } 84 85 89 protected DependencyDescriptor createDependencyDescriptor(String moduleId, String version) 90 { 91 DependencyDescriptor result = new DependencyDescriptor(); 92 93 result.setModuleId(moduleId); 94 result.setVersion(version); 95 result.setLocation(newLocation()); 96 97 return result; 98 } 99 100 } 101 | Popular Tags |