1 64 package com.jcorporate.expresso.kernel.digester.test; 65 66 import com.jcorporate.expresso.kernel.digester.ComponentMetadataConfig; 67 import com.jcorporate.expresso.kernel.metadata.ComponentMetadata; 68 import com.jcorporate.expresso.kernel.metadata.ControllerData; 69 import com.jcorporate.expresso.kernel.metadata.DBObjectData; 70 import com.jcorporate.expresso.kernel.metadata.JobData; 71 import com.jcorporate.expresso.kernel.metadata.ReportData; 72 import com.jcorporate.expresso.kernel.metadata.SchemaData; 73 import junit.framework.TestCase; 74 75 import java.util.List ; 76 77 80 public class TestComponentMetadataConfig extends TestCase { 81 82 public TestComponentMetadataConfig(String _name) { 83 super(_name); 84 } 85 86 89 public void testLoadComponentMetadata() { 90 ComponentMetadataConfig esc; 91 try { 92 esc = new ComponentMetadataConfig(); 93 esc.loadComponentMetadata("/com/jcorporate/expresso/kernel/digester/test/SampleConfig.xml"); 94 } catch (Exception ex) { 95 fail("Error attempting to digest services file"); 96 return; 97 } 98 99 ComponentMetadata metadata = esc.getMetadata(); 100 assertTrue("Must have metadata", metadata != null); 101 assertTrue("Must have a valid name", metadata.getName().equals("test")); 102 assertTrue("Must have a valid version", metadata.getVersionNumber().equals("1.2.3")); 103 assertTrue("Must have a valid description", metadata.getDescription().equals("Test Component")); 104 assertTrue("Must have valid message bundle path", 105 metadata.getMessageBundle() 106 .equals("/com/jcorporate/expresso/core/Messages.properties")); 107 SchemaData sd = metadata.getSchemaData(); 108 assertTrue("Must have a Schema metadata", sd != null); 109 List list = sd.getControllers(); 110 assertTrue("Must have controllers", list != null && list.size() == 1); 111 assertTrue("First controller is DBMaint", ((ControllerData) list.get(0)) 112 .getClassName().equals("com.jcorporate.expresso.services.controller.DBMaint")); 113 list = sd.getDataObjects(); 114 assertTrue("Must have data objects", list != null && list.size() == 1); 115 assertTrue("First data object is MimeTypes", ((DBObjectData) list.get(0)) 116 .getClassName().equals("com.jcorporate.expresso.services.dbobj.MimeTypes")); 117 list = sd.getJobs(); 118 assertTrue("Must have jobs", list != null && list.size() == 1); 119 assertTrue("First job is test jobs", ((JobData) list.get(0)). 120 getClassName().equals("com.jcorporate.expresso.services.job.TestJob")); 121 list = sd.getReports(); 122 assertTrue("Must have reports", list != null && list.size() == 1); 123 assertTrue("First report is test report", ((ReportData) list.get(0)). 124 getClassName().equals("com.jcorporate.expresso.ext.report.TestReport")); 125 126 List nested = metadata.getChildren(); 127 assertTrue("Must have child components", nested != null && nested.size() == 1); 128 ComponentMetadata oneNested = (ComponentMetadata) nested.get(0); 129 assertTrue("Checking nested component description", 130 oneNested.getDescription().equals("Sample Nested Do Nothing Component")); 131 assertTrue("Checking nested component name", oneNested.getName().equals("nested1")); 132 assertTrue("Checking nested component version number", oneNested.getVersionNumber().equals("4.5.6")); 133 } 134 135 140 public static void main(String [] argv) { 141 String [] testCaseList = {TestComponentMetadataConfig.class.getName()}; 142 junit.textui.TestRunner.main(testCaseList); 143 } 144 } 145 | Popular Tags |