Author: jharting
Date: 2010-09-10 10:16:53 -0400 (Fri, 10 Sep 2010)
New Revision: 13732
Modified:
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java
branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
Log:
Minor changes in functional tests.
Modified:
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java 2010-09-09
10:32:02 UTC (rev 13731)
+++
branches/enterprise/JBPAPP_5_0/src/test/ftest/seamgen/src/main/org/jboss/seam/test/functional/seamgen/HotDeploymentStaticTest.java 2010-09-10
14:16:53 UTC (rev 13732)
@@ -35,23 +35,23 @@
/**
* This test verifies hot deployment of static resources. It modifies home.xhtml
- * page and verifies that changes are reflected within the running app. All is done
- * within user session to detect if the whole application was restarted or not.
+ * page and verifies that changes are reflected within the running app. All is
+ * done within user session to detect if the whole application was restarted or
+ * not.
*
* @author Jozef Hartinger
*
*/
public class HotDeploymentStaticTest extends SeleniumSeamGenTest
{
-
+
private String newFeature;
-
- @BeforeClass
- public void modifyHomePage() throws IOException, InterruptedException
+
+ public void modifyHomePage() throws InterruptedException
{
String homePageLocation = WORKSPACE + "/" + APP_NAME +
"/view/home.xhtml";
newFeature = "Works flawlessly as it is tested by Selenium";
-
+
BufferedReader reader = null;
StringBuilder homePageContentBuilder = new StringBuilder();
try
@@ -65,16 +65,27 @@
line = reader.readLine();
}
}
+ catch (IOException e)
+ {
+ throw new RuntimeException("Unable to read home page " +
homePageLocation);
+ }
finally
{
- reader.close();
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Unable to close home page reader.");
+ }
}
-
+
String homePageContent = homePageContentBuilder.toString();
-
+
// add new item into the feature list
- homePageContent = homePageContent.replaceAll("<li>Internationalization
support</li>", "<li>Internationalization
support</li>\n<li>" + newFeature + "</li>");
-
+ homePageContent = homePageContent.replaceAll("<li>Internationalization
support</li>", "<li>Internationalization support</li>\n<li
id=\"newFeature\">" + newFeature + "</li>");
+
// write new content
Writer writer = null;
try
@@ -83,21 +94,37 @@
writer.write(homePageContent);
writer.flush();
}
+ catch (IOException e)
+ {
+ throw new RuntimeException("Unable write modified home page " +
homePageLocation);
+ }
finally
{
- writer.close();
+ try
+ {
+ writer.close();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Unable to close home page reader.");
+ }
}
-
+
seamGen.deploy();
}
-
+
@Test(dependsOnGroups = { "newProjectGroup" })
- public void hotDeploymentOfFaceletTemplateTest()
+ public void hotDeploymentOfFaceletTemplateTest() throws InterruptedException
{
-
+
login();
-
- assertTrue(browser.isTextPresent(newFeature), "New feature not found. Hot
deployment failure.");
+
+ modifyHomePage();
+
+ waitForAppToDeploy(HOME_PAGE, "id=newFeature");
+
+ browser.open(HOME_PAGE);
+ assertTrue(browser.isElementPresent("id=newFeature"), "New feature
not found. Hot deployment failure.");
assertTrue(isLoggedIn(), "Session lost. Hot deployment failure.");
}
}
Modified:
branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java 2010-09-09
10:32:02 UTC (rev 13731)
+++
branches/enterprise/JBPAPP_5_0/src/test/ftest/src/main/org/jboss/seam/example/common/test/selenium/SeamSelenium.java 2010-09-10
14:16:53 UTC (rev 13732)
@@ -28,6 +28,7 @@
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleniumException;
import com.thoughtworks.selenium.Wait;
+import com.thoughtworks.selenium.SeleniumException;
/**
* This class slightly enhaces a Selenium API for controlling a browser.
@@ -341,4 +342,18 @@
{
this.suppressSeleniumTimeoutException = suppressSeleniumTimeoutException;
}
+
+ @Override
+ public void open(String url)
+ {
+ try
+ {
+ super.open(url);
+ }
+ catch (SeleniumException e)
+ {
+ // since 1.0.3 Selenium throws SeleniumException when a server returns 404
+ // we suppress this behavior in order to retain backward compatibility
+ }
+ }
}
Show replies by date