KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > kilim > repository > CurrentTest


1 /**
2  * Copyright (C) 2002 Kelua SA
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package org.objectweb.kilim.repository;
19
20 import houseexample.House;
21 import houseexample.Man;
22
23 import java.util.Iterator JavaDoc;
24 import javax.swing.JTextArea JavaDoc;
25 import javax.xml.parsers.ParserConfigurationException JavaDoc;
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 JavaDoc;
53
54 /**
55  * @author delpiano
56  *
57  * To change this generated comment edit the template variable "typecomment":
58  * Window>Preferences>Java>Templates.
59  * To enable and disable the creation of type comments go to
60  * Window>Preferences>Java>Code Generation.
61  */

62 public class CurrentTest extends TestCase {
63
64     private ResourceRepository rep;
65     private ResourceRepository rep1;
66
67     /**
68      * Constructor for TemplateParserTest.
69      * @param arg0 for junit
70      * @throws SAXException should not happen
71      * @throws ParserConfigurationException should not happen
72      */

73     public CurrentTest(String JavaDoc arg0) throws SAXException JavaDoc, ParserConfigurationException JavaDoc {
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 JavaDoc, ParserConfigurationException JavaDoc, 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 JavaDoc 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 JavaDoc rslt = (StringBuffer JavaDoc) interf.getValue();
123             assertEquals(rslt.toString() , "42424242-is--is--is--is-the answerthe answerthe answerthe answer");
124             //correct result when using the preplug implementation
125
//assertEquals(rslt.toString() , "42-is-the answer42-is-the answer42-is-the answer42-is-the answer");
126
} catch (Exception JavaDoc ex) {
127             ex.printStackTrace();
128             throw new InternalException(ex);
129         }
130     }
131 }
132
Popular Tags