KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Iterator JavaDoc;
21 import javax.xml.parsers.ParserConfigurationException JavaDoc;
22 import junit.framework.TestCase;
23
24 import org.objectweb.kilim.InternalException;
25 import org.objectweb.kilim.KilimException;
26 import org.objectweb.kilim.KilimConfiguration;
27 import org.objectweb.kilim.description.Property;
28 import org.objectweb.kilim.description.TemplateDescription;
29 import org.objectweb.kilim.model.Component;
30 import org.objectweb.kilim.model.ComponentFactory;
31 import org.objectweb.kilim.model.instanciation.DefaultInstanciationStrategy;
32 import org.objectweb.kilim.model.instanciation.InstanciationStrategy;
33 import org.objectweb.kilim.model.instanciation.NullInstanciationMger;
34
35 import org.xml.sax.SAXException JavaDoc;
36
37 /**
38  * @author horn, delpiano
39  * Kilim2 xml parser tests
40  */

41 public class TemplateParserTest extends TestCase {
42     
43     private ResourceRepository rep;
44     private ResourceRepository rep1;
45     
46     /**
47      * Constructor for TemplateParserTest.
48      * @param arg0 for junit
49      * @throws SAXException should not happen
50      * @throws ParserConfigurationException should not happen
51      */

52     public TemplateParserTest(String JavaDoc arg0) throws SAXException JavaDoc, ParserConfigurationException JavaDoc {
53         super(arg0);
54         TemplateDescriptionParser parser = new TemplateDescriptionParser(true);
55         rep = new ResourceRepository(parser);
56         rep.setResourceLoader(new ClassLoaderResourceLoader(this.getClass().getClassLoader()));
57         rep1 = new ResourceRepository1(parser);
58         rep1.setResourceLoader(new ClassLoaderResourceLoader(this.getClass().getClassLoader()));
59     }
60     
61         /**
62      * Basic parsing tests
63      * @throws ResourceNotFoundException should not happen
64      * @throws ParserConfigurationException should not happen
65      * @throws SAXException should not happen
66      */

67     public void testPort1() throws ResourceNotFoundException, SAXException JavaDoc, ParserConfigurationException JavaDoc {
68         try {
69             TemplateDescription ts0 = rep.getTemplateDescription("test-port1");
70             Iterator JavaDoc iter = ts0.getProperties(true);
71             Property prop = (Property) iter.next();
72             assertEquals(prop.getValue(), null);
73         } catch (Exception JavaDoc ex) {
74             ex.printStackTrace();
75             throw new InternalException(ex);
76         }
77     }
78     
79     /**
80      * Basic parsing tests
81      * @throws ResourceNotFoundException should not happen
82      * @throws ParserConfigurationException should not happen
83      * @throws SAXException should not happen
84      */

85     public void testPort2() throws ResourceNotFoundException, SAXException JavaDoc, ParserConfigurationException JavaDoc {
86         try {
87             TemplateDescription ts0 = rep.getTemplateDescription("test-port2");
88         } catch (Exception JavaDoc ex) {
89             ex.printStackTrace();
90             throw new InternalException(ex);
91         }
92     }
93     
94     /**
95      * Method testParsingEric0.
96      * @throws ResourceNotFoundException :
97      * @throws SAXException :
98      * @throws ParserConfigurationException :
99      * @throws KilimException :
100      */

101     public void testParsingEric() throws ResourceNotFoundException, SAXException JavaDoc, ParserConfigurationException JavaDoc, KilimException {
102         TemplateDescription ts0 = rep.getTemplateDescription("eric/ClientImpl");
103         //KilimTemplateViewer.viewTemplate(ts0);
104
}
105
106     /**
107      * Method testParsing2.
108      * @throws ResourceNotFoundException :
109      * @throws SAXException :
110      * @throws ParserConfigurationException :
111      * @throws KilimException :
112      */

113     public void testParsing2() throws ResourceNotFoundException, SAXException JavaDoc, ParserConfigurationException JavaDoc, KilimException {
114         TemplateDescription ts0 = rep.getTemplateDescription("com/kelua/web framework/folders/folder with menu");
115     }
116
117     /**
118      * Method testParsing3.
119      * @throws ResourceNotFoundException :
120      * @throws SAXException :
121      * @throws ParserConfigurationException :
122      * @throws KilimException :
123      */

124     public void testParsing3() throws ResourceNotFoundException, SAXException JavaDoc, ParserConfigurationException JavaDoc, KilimException {
125         TemplateDescription ts0 = rep.getTemplateDescription("main/all");
126         //KilimTemplateViewer.viewTemplate(ts0);
127
try {
128             //this specific strategy should be defined in order to obtain the expected behaviour ...
129
InstanciationStrategy strgy = new DefaultInstanciationStrategy();
130             KilimConfiguration.setInstanciationStrategy(strgy);
131             //Component compo = ComponentFactory.newComponent(ts0, strgy);
132
Component compo = ComponentFactory.newComponent(ts0);
133             //KilimComponentViewer.viewComponent(compo);
134
} catch (Exception JavaDoc ex) {
135             ex.printStackTrace();
136             throw new InternalException(ex);
137         }
138     }
139 }
140
Popular Tags