1   /***
2    Copyright (C) 2005 The Java Community
3   
4    This program is free software; you can redistribute it and/or modify  it under
5    the terms of the GNU General Public License as published by  the Free Software
6    Foundation; either version 2 of the License, or  (at your option) any later
7    version.
8   
9    This program is distributed in the hope that it will be useful,  but WITHOUT
10   ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
12  
13   You should have received a copy of the GNU General Public License  along with
14   this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
15   Place, Suite 330, Boston, MA 02111-1307 USA.
16  
17   */
18  
19  package org.bejug.javacareers.jobs.view.jsf.common;
20  
21  import java.io.IOException;
22  import java.net.MalformedURLException;
23  
24  import org.xml.sax.SAXException;
25  
26  import junit.framework.Test;
27  import junit.framework.TestCase;
28  import junit.framework.TestSuite;
29  
30  import com.meterware.httpunit.GetMethodWebRequest;
31  import com.meterware.httpunit.WebConversation;
32  import com.meterware.httpunit.WebLink;
33  import com.meterware.httpunit.WebRequest;
34  import com.meterware.httpunit.WebResponse;
35  
36  /***
37   * @author Peter Symoens (last modified by $Author: shally $)
38   * @version $Revision: 1.8 $ - $Date: 2005/12/21 11:38:43 $
39   */
40  public class JSFCommonsTest extends TestCase {
41  
42      /***
43       * The JavaCareers test url.
44       */
45      private static final String JAVACAREERS_URL =
46              "http://localhost:8080/javacareers-webclient/";
47  
48      /***
49       * @return Test suite
50       */
51      public static Test suite() {
52          return new TestSuite(JSFCommonsTest.class);
53      }
54  
55      /***
56       * @param name String.
57       */
58      public JSFCommonsTest(String name) {
59          super(name);
60      }
61  
62      /***
63       * Test the welcome page title.
64       */
65      public void testWelcomePage(){
66          try {
67  			WebConversation conversation = new WebConversation();
68  			WebRequest request = new GetMethodWebRequest(JAVACAREERS_URL);
69  			WebResponse response = conversation.getResponse(request);
70  			assertEquals("Page title", "Java Careers", response.getTitle());
71  		} catch (MalformedURLException e) {
72  			fail("Exception:" + e.getMessage());
73  		} catch (IOException e) {
74  			fail("Exception:" + e.getMessage());
75  		} catch (SAXException e) {
76  			fail("Exception:" + e.getMessage());
77  		}
78      }
79  
80      /***
81       * Test all menu links.
82       */
83      public void testMenuLinks(){
84          try {
85  			WebConversation conversation = new WebConversation();
86  			WebRequest request = new GetMethodWebRequest(JAVACAREERS_URL);
87  			WebResponse response = conversation.getResponse(request);
88  			WebLink[] menuLinks = response.getLinks();
89  			//Testing the Home page link
90  			WebLink menuLink = menuLinks[0];
91  			response = menuLink.click();
92  			assertEquals("Page title", "Java Careers", response.getTitle());
93  			//Testing the other menu links
94  			for (int i = 1; i < menuLinks.length; i++) {
95  			    menuLink = menuLinks[i];
96  			    response = menuLink.click();
97  			    assertEquals("Page title", menuLink.getText(), response.getTitle());
98  			}
99  		} catch (MalformedURLException e) {
100 			fail("Exception:" + e.getMessage());
101 		} catch (IOException e) {
102 			fail("Exception:" + e.getMessage());
103 		} catch (SAXException e) {
104 			fail("Exception:" + e.getMessage());
105 		}
106 
107     }
108 }
109 
110 /***
111  * $Log: JSFCommonsTest.java,v $
112  * Revision 1.8  2005/12/21 11:38:43  shally
113  * *** empty log message ***
114  *
115  * Revision 1.7  2005/12/09 10:46:57  shally
116  * Opkuis voor checkstyle en PMD
117  *
118  * Revision 1.6  2005/12/08 14:53:46  shally
119  * Opkuis voor checkstyle.
120  *
121  * Revision 1.5  2005/08/30 13:07:48  psong09
122  * renamed author: psong09
123  *
124  * Revision 1.4  2005/06/29 09:00:27  psong09
125  * comment component updated
126  *
127  * Revision 1.3  2005/06/10 13:27:22  bavo_jcs
128  * new version
129  *
130  * Revision 1.2  2005/06/09 08:19:04  bejug_cc
131  * Fix initial import
132  *
133  * Revision 1.7  2005/05/11 12:49:30  ssc
134  * Checstyle errors
135  *
136  * Revision 1.6  2005/05/01 11:18:51  sja
137  * Corrected JAVACAREERS_URL content.
138  *
139  * Revision 1.5  2005/04/29 18:19:38  sja
140  * Added CVS tags.
141  *
142  */