[Lipog-commit] net.heilancoo.portal.testutils/src/net/heilancoo/portal/testutils AppUtils.java, NO
Status: Beta
Brought to you by:
jbu
From: Joerg B. <jb...@us...> - 2009-07-31 18:09:08
|
Update of /cvsroot/lipog/net.heilancoo.portal.testutils/src/net/heilancoo/portal/testutils In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27336/src/net/heilancoo/portal/testutils Added Files: AppUtils.java Log Message: this is going to be a collection of web test convenience methods --- NEW FILE: AppUtils.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.testutils; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.net.MalformedURLException; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlPage; /** * @author joerg * */ public class AppUtils { public static HtmlPage doDefaultLogin(String protoHostPort, String app, String user, String passwd) throws FailingHttpStatusCodeException, MalformedURLException, IOException { WebClient cl = new WebClient(); HtmlPage loginPage = cl.getPage(protoHostPort + "/" + app); assertEquals("Login", loginPage.getTitleText()); HtmlForm login = loginPage.getFormByName("loginForm"); login.getInputByName("user").setValueAttribute(user); login.getInputByName("password").setValueAttribute(passwd); HtmlPage loggedIn = login.getInputByName("login").click(); return loggedIn; } } |