1 18 package org.objectweb.kilim.repository; 19 20 import javax.xml.parsers.ParserConfigurationException ; 21 import junit.framework.TestCase; 22 23 import org.objectweb.kilim.InternalException; 24 import org.objectweb.kilim.description.TemplateDescription; 25 import org.objectweb.kilim.model.Component; 26 import org.objectweb.kilim.model.ComponentFactory; 27 import org.objectweb.kilim.model.ComponentInterface; 28 import org.objectweb.kilim.model.mapping.DefaultMappingContext; 29 import org.objectweb.kilim.model.mapping.JavaLoggerMapper; 30 import org.objectweb.kilim.model.mapping.JavaRuntimeMapper; 31 import org.objectweb.kilim.model.mapping.MappingContext; 32 import org.objectweb.kilim.model.mapping.TextAreaMapper; 33 import org.objectweb.kilim.model.mapping.TreeModelMapper; 34 import org.objectweb.kilim.model.instanciation.DefaultInstanciationStrategy; 35 import org.objectweb.kilim.model.instanciation.InstanciationStrategy; 36 import org.objectweb.kilim.model.instanciation.NullInstanciationMger; 37 import org.objectweb.kilim.tools.KilimComponentViewer; 38 import org.objectweb.kilim.tools.KilimTemplateViewer; 39 import org.objectweb.kilim.tools.KilimTraceTreeModel; 40 import org.objectweb.kilim.tools.KilimTraceTreeViewer; 41 42 import org.xml.sax.SAXException ; 43 44 52 public class QuotesWireTests extends TestCase { 53 54 private ResourceRepository rep; 55 private ResourceRepository rep1; 56 57 63 public QuotesWireTests(String arg0) throws SAXException , ParserConfigurationException { 64 super(arg0); 65 TemplateDescriptionParser parser = new TemplateDescriptionParser(true); 66 rep = new ResourceRepository(parser); 67 rep.setResourceLoader(new ClassLoaderResourceLoader(this.getClass().getClassLoader())); 68 rep1 = new ResourceRepository1(parser); 69 rep1.setResourceLoader(new ClassLoaderResourceLoader(this.getClass().getClassLoader())); 70 } 71 72 78 public void testQuotes1() throws ResourceNotFoundException, SAXException , ParserConfigurationException { 79 try { 80 TemplateDescription ts0 = rep.getTemplateDescription("quoteswire/TradingConsoleV3"); 81 InstanciationStrategy strgy = new DefaultInstanciationStrategy(); 84 TextAreaMapper textMapper = new TextAreaMapper(new JavaRuntimeMapper()); 85 TreeModelMapper treeMapper = new TreeModelMapper(textMapper); 86 KilimTraceTreeModel treeModel = treeMapper.getTraceTree(); 87 Component compo = ComponentFactory.newComponent(ts0); 89 ComponentInterface interf = compo.getInterface("publishers"); 90 Object res = interf.getValue(); 91 interf = compo.getInterface("trader's workspace"); 92 res = interf.getValue(); 93 Thread.sleep(5000); 94 97 } catch (Exception ex) { 98 ex.printStackTrace(); 99 throw new InternalException(ex); 100 } 101 } 102 103 109 private void plugsAndSlots(String tmpl_nm) throws ResourceNotFoundException, SAXException , ParserConfigurationException { 110 try { 111 InstanciationStrategy strgy = new DefaultInstanciationStrategy(); 113 Component compo = org.objectweb.kilim.helpers.KilimHelper.newComponent(tmpl_nm , this.getClass(), strgy); 114 ComponentInterface interf = compo.getInterface("console"); 115 Object res = interf.getValue(); 116 Thread.sleep(5000); 117 } catch (Exception ex) { 118 ex.printStackTrace(); 119 throw new InternalException(ex); 120 } 121 } 122 123 129 public void testQuotes2() throws ResourceNotFoundException, SAXException , ParserConfigurationException { 130 plugsAndSlots("quoteswire/ExtensibleConsole"); 131 } 132 133 139 public void testQuotes3() throws ResourceNotFoundException, SAXException , ParserConfigurationException { 140 plugsAndSlots("quoteswire/ExtensibleConsole2"); 141 } 142 143 149 public void testQuotes4() throws ResourceNotFoundException, SAXException , ParserConfigurationException { 150 plugsAndSlots("quoteswire/AnotherExtensibleConsole"); 151 } 152 158 public void testQuotes5() throws ResourceNotFoundException, SAXException , ParserConfigurationException { 159 plugsAndSlots("quoteswire/AnotherExtensibleConsole2"); 160 } 161 162 168 public void testQuotes6() throws ResourceNotFoundException, SAXException , ParserConfigurationException { 169 try { 170 TemplateDescription ts0 = rep1.getTemplateDescription("quoteswire/channels/SimpleChannelWithSlot"); 171 Component compo = ComponentFactory.newComponent(ts0); 173 ComponentInterface interf = compo.getInterface("channel"); 174 Object res = interf.getValue(); 175 Thread.sleep(5000); 176 } catch (Exception ex) { 177 ex.printStackTrace(); 178 throw new InternalException(ex); 179 } 180 } 181 182 } 183 | Popular Tags |