1 18 package org.objectweb.kilim.repository; 19 20 import java.util.Iterator ; 21 import javax.xml.parsers.ParserConfigurationException ; 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 ; 36 37 41 public class TemplateParserTest extends TestCase { 42 43 private ResourceRepository rep; 44 private ResourceRepository rep1; 45 46 52 public TemplateParserTest(String arg0) throws SAXException , ParserConfigurationException { 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 67 public void testPort1() throws ResourceNotFoundException, SAXException , ParserConfigurationException { 68 try { 69 TemplateDescription ts0 = rep.getTemplateDescription("test-port1"); 70 Iterator iter = ts0.getProperties(true); 71 Property prop = (Property) iter.next(); 72 assertEquals(prop.getValue(), null); 73 } catch (Exception ex) { 74 ex.printStackTrace(); 75 throw new InternalException(ex); 76 } 77 } 78 79 85 public void testPort2() throws ResourceNotFoundException, SAXException , ParserConfigurationException { 86 try { 87 TemplateDescription ts0 = rep.getTemplateDescription("test-port2"); 88 } catch (Exception ex) { 89 ex.printStackTrace(); 90 throw new InternalException(ex); 91 } 92 } 93 94 101 public void testParsingEric() throws ResourceNotFoundException, SAXException , ParserConfigurationException , KilimException { 102 TemplateDescription ts0 = rep.getTemplateDescription("eric/ClientImpl"); 103 } 105 106 113 public void testParsing2() throws ResourceNotFoundException, SAXException , ParserConfigurationException , KilimException { 114 TemplateDescription ts0 = rep.getTemplateDescription("com/kelua/web framework/folders/folder with menu"); 115 } 116 117 124 public void testParsing3() throws ResourceNotFoundException, SAXException , ParserConfigurationException , KilimException { 125 TemplateDescription ts0 = rep.getTemplateDescription("main/all"); 126 try { 128 InstanciationStrategy strgy = new DefaultInstanciationStrategy(); 130 KilimConfiguration.setInstanciationStrategy(strgy); 131 Component compo = ComponentFactory.newComponent(ts0); 133 } catch (Exception ex) { 135 ex.printStackTrace(); 136 throw new InternalException(ex); 137 } 138 } 139 } 140 | Popular Tags |