1 18 package org.objectweb.kilim.repository; 19 20 import houseexample.House; 21 import houseexample.Man; 22 23 import java.util.Iterator ; 24 import javax.swing.JTextArea ; 25 import javax.xml.parsers.ParserConfigurationException ; 26 import junit.framework.TestCase; 27 28 import org.objectweb.kilim.InternalException; 29 import org.objectweb.kilim.KilimException; 30 import org.objectweb.kilim.description.TemplateDescription; 31 import org.objectweb.kilim.model.Component; 32 import org.objectweb.kilim.model.ComponentFactory; 33 import org.objectweb.kilim.model.ComponentInterface; 34 import org.objectweb.kilim.model.ComponentSlot; 35 import org.objectweb.kilim.model.RtComponent; 36 import org.objectweb.kilim.model.RtComponentElement; 37 import org.objectweb.kilim.model.RtSingleValuePort; 38 import org.objectweb.kilim.model.mapping.DefaultMappingContext; 39 import org.objectweb.kilim.model.mapping.NullMapper; 40 import org.objectweb.kilim.model.mapping.JavaRuntimeMapper; 41 import org.objectweb.kilim.model.mapping.MappingContext; 42 import org.objectweb.kilim.model.mapping.TextAreaMapper; 43 import org.objectweb.kilim.model.mapping.TreeModelMapper; 44 import org.objectweb.kilim.model.instanciation.DefaultInstanciationStrategy; 45 import org.objectweb.kilim.model.instanciation.InstanciationStrategy; 46 import org.objectweb.kilim.model.instanciation.NullInstanciationMger; 47 import org.objectweb.kilim.tools.KilimComponentViewer; 48 import org.objectweb.kilim.tools.KilimTemplateViewer; 49 import org.objectweb.kilim.tools.KilimTraceTreeModel; 50 import org.objectweb.kilim.tools.KilimTraceTreeViewer; 51 52 import org.xml.sax.SAXException ; 53 54 62 public class CurrentTest extends TestCase { 63 64 private ResourceRepository rep; 65 private ResourceRepository rep1; 66 67 73 public CurrentTest(String arg0) throws SAXException , ParserConfigurationException { 74 super(arg0); 75 TemplateDescriptionParser parser = new TemplateDescriptionParser(true); 76 rep = new ResourceRepository(parser); 77 rep.setResourceLoader(new ClassLoaderResourceLoader(this.getClass().getClassLoader())); 78 rep1 = new ResourceRepository1(parser); 79 rep1.setResourceLoader(new ClassLoaderResourceLoader(this.getClass().getClassLoader())); 80 } 81 82 public void testForkOfPlugged3() throws ResourceNotFoundException, SAXException , ParserConfigurationException , KilimException { 83 try { 84 TemplateDescription ts0 = rep1.getTemplateDescription("test/Plugging Plug into Container with NAry Slot"); 85 Component compo = ComponentFactory.newComponent(ts0); 86 Component compo1 = compo.getSubComponent("Container"); 87 Component compo2 = compo.getSubComponent("Plug"); 88 System.out.println("RESULT " + compo2.getQualifiedName() + " de CONTENEUR " + compo2.getContainingComponent()); 89 Iterator iter = compo.getSubComponents(); 90 91 System.out.println("========================================================"); 92 while (iter.hasNext()) { 93 Component tCompo = (Component) iter.next(); 94 System.out.println("sous composant " + tCompo.toString() + " :: " + tCompo.getContainingComponent()); 95 } 96 Component compo3 = compo2.fork(); 97 System.out.println("RESULT " + compo3.getQualifiedName() + " de CONTENEUR " + compo3.getContainingComponent()); 98 99 System.out.println("========================================================"); 100 iter = compo.getSubComponents(); 101 while (iter.hasNext()) { 102 Component tCompo = (Component) iter.next(); 103 System.out.println("sous composant " + tCompo.toString() + " :: " + tCompo.getContainingComponent()); 104 } 105 Component compo4 = compo3.fork(); 106 System.out.println("========================================================"); 107 iter = compo.getSubComponents(); 108 while (iter.hasNext()) { 109 Component tCompo = (Component) iter.next(); 110 System.out.println("sous composant " + tCompo.toString() + " :: " + tCompo.getContainingComponent()); 111 } 112 113 Component compo5 = compo4.fork(); 114 System.out.println("========================================================"); 115 iter = compo.getSubComponents(); 116 while (iter.hasNext()) { 117 Component tCompo = (Component) iter.next(); 118 System.out.println("sous composant " + tCompo.toString() + " :: " + tCompo.getContainingComponent()); 119 } 120 121 ComponentInterface interf = compo.getInterface("result"); 122 StringBuffer rslt = (StringBuffer ) interf.getValue(); 123 assertEquals(rslt.toString() , "42424242-is--is--is--is-the answerthe answerthe answerthe answer"); 124 } catch (Exception ex) { 127 ex.printStackTrace(); 128 throw new InternalException(ex); 129 } 130 } 131 } 132 | Popular Tags |