View Javadoc
1 /* 2 * Angkor Web Framework 3 * 4 * Distributable under LGPL license. 5 * See terms of license at gnu.org. 6 */ 7 package com.tirsen.angkor.test.unit; 8 9 import com.tirsen.angkor.ApplicationFactory; 10 import com.tirsen.angkor.ComponentServlet; 11 import com.tirsen.angkor.View; 12 import com.tirsen.angkor.ViewFactory; 13 import com.tirsen.angkor.test.unit.mock.MockServletRequest; 14 import com.tirsen.angkor.test.unit.mock.MockServletResponse; 15 import com.tirsen.angkor.test.unit.mock.MockComponent; 16 import com.tirsen.angkor.widget.TextLabel; 17 import junit.framework.TestCase; 18 import org.w3c.dom.Document; 19 20 import javax.servlet.ServletException; 21 import java.io.IOException; 22 23 24 /*** 25 * TODO document ComponentServletTest 26 * 27 * <!-- $Id: ComponentServletTest.java,v 1.3 2002/10/13 19:59:23 tirsen Exp $ --> 28 * 29 * @author $Author: tirsen $ 30 * @version $Revision: 1.3 $ 31 */ 32 public class ComponentServletTest extends TestCase 33 { 34 public void testComponentServlet() throws ServletException, IOException 35 { 36 ComponentServlet componentServlet = new ComponentServlet(); 37 38 MockServletRequest servletRequest = new MockServletRequest(); 39 ApplicationFactory applicationFactory = new ApplicationFactory(servletRequest.getSession()); 40 applicationFactory.ensureApplicationInit(MockApplication.class); 41 42 String componentName = "comp"; 43 servletRequest.setRequestURI("/app/" + componentName); 44 45 final TextLabel textLabel = new TextLabel("test"); 46 textLabel.setId(componentName); 47 48 MockApplication application = (MockApplication) applicationFactory.getApplication(); 49 application.registerComponent(componentName, new ViewFactory() 50 { 51 public View getView() 52 { 53 return textLabel; 54 } 55 }); 56 57 MockServletResponse servletResponse = new MockServletResponse(); 58 componentServlet.service(servletRequest, servletResponse); 59 60 org.jdom.Document document = servletResponse.getResultingDocument(); 61 assertNotNull(TestUtility.selectElement(document, "//*[@id='" + componentName + "']")); 62 } 63 }

This page was automatically generated by Maven