KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > web > test > AltDDUnitTestCase


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.test.web.test;
23
24 import java.net.URL JavaDoc;
25
26 import junit.framework.Test;
27
28 import org.apache.commons.httpclient.Header;
29 import org.apache.commons.httpclient.HttpMethodBase;
30 import org.jboss.test.JBossTestCase;
31 import org.jboss.test.util.web.HttpUtils;
32
33 /** Tests of using a war alt-dd web.xml
34  
35  @author Scott.Stark@jboss.org
36  @version $Revision: 58331 $
37  */

38 public class AltDDUnitTestCase extends JBossTestCase
39 {
40    private String JavaDoc baseURL = HttpUtils.getBaseURL();
41    
42    public static Test suite() throws Exception JavaDoc
43    {
44       return getDeploySetup(AltDDUnitTestCase.class, "altdd-web.ear");
45    }
46
47    public AltDDUnitTestCase(String JavaDoc name)
48    {
49       super(name);
50    }
51
52    /** Access the http://{host}/altdd-test/AltRequestInfoServlet to see
53     * that the altenate uri for the RequestInfoServlet was used
54     */

55    public void testAltRequestInfoServlet()
56       throws Exception JavaDoc
57    {
58       URL JavaDoc url = new URL JavaDoc(baseURL+"altdd-test/AltRequestInfoServlet");
59       HttpMethodBase request = HttpUtils.accessURL(url);
60       Header errors = request.getResponseHeader("X-Exception");
61       log.info("X-Exception: "+errors);
62       assertTrue("X-Exception("+errors+") is null", errors == null);
63    }
64
65    /** Access the http://{host}/altdd-test/AltRequestInfoServlet2 to see
66     * that the RequestInfoServlet2 was added
67     */

68    public void testAltRequestInfoServlet2()
69       throws Exception JavaDoc
70    {
71       URL JavaDoc url = new URL JavaDoc(baseURL+"altdd-test/AltRequestInfoServlet2");
72       HttpMethodBase request = HttpUtils.accessURL(url);
73       Header errors = request.getResponseHeader("X-Exception");
74       log.info("X-Exception: "+errors);
75       assertTrue("X-Exception("+errors+") is null", errors == null);
76    }
77 }
78
Popular Tags