1 7 package com.inversoft.verge.repository.config.test; 8 9 10 import java.io.File ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 import junit.framework.TestCase; 15 16 import org.jdom.Document; 17 import org.jdom.input.SAXBuilder; 18 19 import com.inversoft.config.ConfigurationException; 20 import com.inversoft.util.FileTools; 21 import com.inversoft.verge.repository.config.RepositoryConfigBuilder; 22 import com.inversoft.verge.repository.config.RepositoryConfigFactory; 23 import com.inversoft.verge.repository.config.RepositoryConfigRegistry; 24 25 26 35 public class RepositoryConfigBuilderTest extends TestCase { 36 37 40 public RepositoryConfigBuilderTest(String name) { 41 super(name); 42 } 43 44 45 48 public void testBuild() { 49 50 RepositoryConfigBuilder builder = new RepositoryConfigBuilder(); 51 RepositoryConfigRegistry registry = 52 (RepositoryConfigRegistry) new RepositoryConfigFactory().createRegistry(); 53 Document doc = getDocument(); 54 try { 55 builder.build(doc, registry); 56 } catch (ConfigurationException ce) { 57 fail(ce.toString()); 58 } 59 } 60 61 64 public void testValidate() { 65 66 RepositoryConfigBuilder builder = new RepositoryConfigBuilder(); 67 RepositoryConfigRegistry registry = 68 (RepositoryConfigRegistry) new RepositoryConfigFactory().createRegistry(); 69 Document doc = getDocument(); 70 Map registries = new HashMap (); 71 registries.put(RepositoryConfigFactory.NAME, registry); 72 try { 73 builder.build(doc, registry); 74 builder.validate(registry, registries); 75 } catch (Exception e) { 76 fail(e.toString()); 77 } 78 } 79 80 83 public Document getDocument() { 84 85 try { 86 SAXBuilder builder = new SAXBuilder(); 87 File file = new File (FileTools.convertPath("src/com/inversoft/verge/repository/test/test-config.xml")); 88 return builder.build(file); 89 } catch (Exception e) { 90 fail(e.toString()); 91 } 92 93 return null; 94 } 95 } 96 | Popular Tags |