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

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Mon Mar 9 19:36:11 EDT 2009


Author: ozizka at redhat.com
Date: 2009-03-09 19:36:10 -0400 (Mon, 09 Mar 2009)
New Revision: 197

Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DebugUtils.java
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java
Log:


Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DebugUtils.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DebugUtils.java	2009-03-09 23:30:26 UTC (rev 196)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DebugUtils.java	2009-03-09 23:36:10 UTC (rev 197)
@@ -1,8 +1,10 @@
 package org.jboss.jopr.jsfunit;
 
+import java.io.BufferedReader;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.nio.channels.FileChannel;
@@ -37,10 +39,26 @@
 		// TODO: Do this better... Maven surely provides target path.
 		//sFilePath = "target/"+sFilePath;
 
-		new FileWriter(sFilePath).write(content);
+		//new FileWriter(sFilePath).write(content);
+		new FileOutputStream(sFilePath).write(content.getBytes());
 
 	}
+	
+	static void writeFile(String sToPath, byte[] bytes) throws FileNotFoundException, IOException {
+		new FileOutputStream(sToPath).write(bytes);
+	}
 
+	public static String readFileAsString(String filePath) throws java.io.IOException {
+		StringBuilder fileData = new StringBuilder(1024);
+		BufferedReader reader = new BufferedReader(new FileReader(filePath));
+		char[] buf = new char[1024];
+		int numRead=0;
+		while((numRead=reader.read(buf)) != -1){
+			fileData.append(buf, 0, numRead);
+		}
+		reader.close();
+		return fileData.toString();
+	}
 
 
 	/**
@@ -84,4 +102,5 @@
 
 
 
+
 }

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-09 23:30:26 UTC (rev 196)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/MultipleUserLoginTest.java	2009-03-09 23:36:10 UTC (rev 197)
@@ -151,6 +151,7 @@
 
 
 		// USER B.
+
 		final WebClient wc = new WebClient(BrowserVersion.FIREFOX_3);
 		wc.setThrowExceptionOnFailingStatusCode(false);
 		wc.setConfirmHandler(new SimpleConfirmHandler(true));
@@ -166,13 +167,14 @@
 		setValue(loginPage, passwordComponent, PASS_B);
 		clickSubmitComponent(loginPage, submitComponent);
 
-		String pageBText = new WebClientTools(wc).getResponseBodyAsText();
+		String pageBText = sessBclient.getPageAsText();
 		assertTrue("Page doesn't contain user's name.", pageBText.contains(USER_B) );
 		assertTrue("Page doesn't contain '"+LABEL_LOGOUT+"'.", pageBText.contains(LABEL_LOGOUT) );
 
 
 		
 		// Refresh and log USER_A out.
+
 		((HtmlPage) client.getContentPage()).refresh();
 		byte[] responseBBody = client.getContentPage().getWebResponse().getResponseBody();
 
@@ -181,8 +183,9 @@
 
 
 		// Refresh sessB page Check that USER_B is still logged in.
+
 		((HtmlPage) new WebClientTools(wc).getContentPage()).refresh();
-		String pageBText2 = new WebClientTools(wc).getResponseBodyAsText();
+		String pageBText2 = sessBclient.getPageAsText();
 		assertTrue("Page doesn't contain user's name.", pageBText2.contains(USER_B) );
 		assertTrue("Page doesn't contain '"+LABEL_LOGOUT+"'.", pageBText2.contains(LABEL_LOGOUT) );
 	}




More information about the embjopr-commits mailing list