[embjopr-commits] EMBJOPR SVN: r212 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Wed Mar 11 14:41:25 EDT 2009


Author: ozizka at redhat.com
Date: 2009-03-11 14:41:25 -0400 (Wed, 11 Mar 2009)
New Revision: 212

Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java
Log:
Added testMultipleSuccessiveLogins(), trying to trigger EMBJOPR-92

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java	2009-03-11 17:26:01 UTC (rev 211)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java	2009-03-11 18:41:25 UTC (rev 212)
@@ -25,20 +25,11 @@
 import com.gargoylesoftware.htmlunit.BrowserVersion;
 import com.gargoylesoftware.htmlunit.Page;
 import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.WebResponse;
 import com.gargoylesoftware.htmlunit.html.*;
-import java.io.BufferedReader;
-import java.io.FileReader;
 import java.io.IOException;
-import java.io.StringReader;
 import java.util.List;
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import org.apache.xerces.xni.parser.XMLDocumentFilter;
-import org.apache.xerces.xni.parser.XMLInputSource;
-import org.cyberneko.html.HTMLConfiguration;
-import org.cyberneko.html.filters.DefaultFilter;
-import org.cyberneko.html.filters.Writer;
 import org.jboss.jsfunit.framework.WebClientSpec;
 import org.jboss.jsfunit.framework.WebConversationFactory;
 import org.jboss.jsfunit.jsfsession.JSFClientSession;
@@ -69,7 +60,9 @@
 	private static final String LABEL_LOGOUT = "Logout";
 
 
-	public void XsetUp() throws IOException
+
+	/** Disabled, second login solved using HTMLUnit. */
+	public void DISABLEDsetUp() throws IOException
 	{
 
 		// Announce this test in the JBoss log.
@@ -92,6 +85,7 @@
 		// Contrary to super class, this test skips the session creation in setUp().
 
 	}
+	/**/
 
 	/**
 	 * Instance of JSF session. Keeps server and client session parts, and user's name and pass.
@@ -175,8 +169,8 @@
 		
 		// Refresh and log USER_A out.
 
-		((HtmlPage) client.getContentPage()).refresh();
-		byte[] responseBBody = client.getContentPage().getWebResponse().getResponseBody();
+		//((HtmlPage) client.getContentPage()).refresh();
+		//byte[] responseBBody = client.getContentPage().getWebResponse().getResponseBody();
 
 		HtmlAnchor logoutLink = (HtmlAnchor) client.getElement("logoutLink");
 		logoutLink.click();
@@ -193,8 +187,46 @@
 
 
 
+	/**
+	 * Perhaps reveals EMBJOPR-92 - Nav tree is not filled right after login
+	 */
+	public void testMultipleSuccessiveLogins() throws IOException
+	{
+		final WebClient wc = new WebClient(BrowserVersion.FIREFOX_3);
+		wc.setThrowExceptionOnFailingStatusCode(false);
+		wc.setConfirmHandler(new SimpleConfirmHandler(true));
+		final WebClientTools clientTools = new WebClientTools(wc);
 
+		final String userNameComponent = "login_form:name";
+		final String passwordComponent = "login_form:password";
+		final String submitComponent = "login_form:submit";
 
+		final String url = WebConversationFactory.getWARURL() + "/";
+
+		int retries = 10;
+
+		while( retries-- > 0 ) {
+
+			log.info("Logging in, "+retries+" logins remaining after this one.");
+			
+			// Login
+			HtmlPage loginPage = wc.getPage(url);
+			setValue(loginPage, userNameComponent, USER_B);
+			setValue(loginPage, passwordComponent, PASS_B);
+			clickSubmitComponent(loginPage, submitComponent);
+
+
+			String pageBText = clientTools.getPageAsText();
+			assertTrue("Page doesn't contain user's name.", pageBText.contains(USER_B) );
+			assertTrue("Page doesn't contain '"+LABEL_LOGOUT+"'.", pageBText.contains(LABEL_LOGOUT) );
+
+			// Logout
+			HtmlAnchor logoutLink = (HtmlAnchor) clientTools.getElement("logoutLink");
+			logoutLink.click();
+		}
+	}
+
+
 	
 
 	// These were taken from FomrAuthenticationStrategy.java; unfortunately not reusable from there.




More information about the embjopr-commits mailing list