I’ve made some administrative updates to my jersey-gson project.
First, I’ve updated the pom.xml to automatically start the application in jetty during the maven process-test-classes phase and to automatically stop the jetty instance during the maven install phase. This insures that the webapp will be running and available in the maven test, integration-test and verify phases.
1 | diff --git a/pom.xml b/pom.xml index 318325d..47b6a2c 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,22 @@ <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.version}</version> + <executions> + <execution> + <id>start-jetty</id> + <phase>process-test-classes</phase> + <goals> + <goal>start</goal> + </goals> + </execution> + <execution> + <id>stop-jetty</id> + <phase>install</phase> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> </plugin> <plugin> |
With this change, it is no longer necessary to start jetty via “mvn jetty:run” before executing the Selenium tests. I’ve also changed the name of the class running the Selenium tests from SetupTest to BrowserTest and made some minor updates:
- Added the invocationCount=2 to the userCreate @Test annotation to automatically run the test twice. The first invocation demonstrates the behavior when the user does not pre-exist and the second demonstrates behavior when the user does exist.
- Added the groups=”browser” to the userCreate @Test annotation.
- Moved the Thread.sleep invocation to a new method. This method is annotated to depend on the “browser” group so that it runs after the userCreate method.
1 | $ diff -U2 SetupTest.java BrowserTest.java --- SetupTest.java 2015-10-25 18:20:28.031091530 -0400 +++ BrowserTest.java 2015-10-25 18:21:37.855086967 -0400 @@ -17,5 +17,5 @@ -public class SetupTest { +public class BrowserTest { protected boolean ajaxWait = false; @@ -77,7 +77,6 @@ @Parameters({"browser","baseurl","waitajax"}) - @Test + @Test(invocationCount = 2, groups="browser") public void userCreate( String browser, String baseurl, String waitajax ) - throws Exception { WebDriver driver = "chrome".equalsIgnoreCase(browser) @@ -92,7 +91,14 @@ addUsers(driver); - Thread.sleep(10000); driver.quit(); } + @Test(dependsOnGroups = "browser") + public void pause() + throws Exception + { + System.out.println("Sleeping"); + Thread.sleep(10000); + } + } |
With this change, the “mvn test” output looks like this:
1 | $ mvn test [INFO] Scanning for projects... ... [INFO] jetty-9.3.0.M2 [INFO] Started o.e.j.m.p.JettyWebAppContext@1813f3e9{/,file:///Projects/webapp/jersey-gson/src/main/webapp/,AVAILABLE}{file:///Projects/webapp/jersey-gson/src/main/webapp/} [INFO] Started ServerConnector@806996{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} [INFO] Started @3741ms [INFO] Started Jetty Server [INFO] [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ jersey-gson --- [INFO] Surefire report directory: /Projects/webapp/jersey-gson/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.ideoplex.tutorial.BrowserTest Configuring TestNG with: TestNG652Configurator Compare george@example.com to No data available in table Compare john@example.com to No matching records found Compare thomas@example.com to No matching records found Compare james@example.com to No matching records found Compare james2@example.com to No matching records found Compare john2@example.com to No matching records found Compare andrew@example.com to No matching records found Compare martin@example.com to No matching records found Compare william@example.com to No matching records found Compare john3@example.com to No matching records found Compare james3@example.com to No matching records found Compare zachary@example.com to No matching records found Compare millard@example.com to No matching records found Compare abraham@example.com to No matching records found Compare george@example.com to george@example.com Compare john@example.com to john@example.com Compare thomas@example.com to thomas@example.com Compare james@example.com to james@example.com Compare james2@example.com to james2@example.com Compare john2@example.com to john2@example.com Compare andrew@example.com to andrew@example.com Compare martin@example.com to martin@example.com Compare william@example.com to william@example.com Compare john3@example.com to john3@example.com Compare james3@example.com to james3@example.com Compare zachary@example.com to zachary@example.com Compare millard@example.com to millard@example.com Compare abraham@example.com to abraham@example.com Sleeping Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 59.271 sec - in com.ideoplex.tutorial.BrowserTest Results : Tests run: 3, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:02 min [INFO] Finished at: 2015-10-25T20:06:20-04:00 [INFO] Final Memory: 24M/285M [INFO] ------------------------------------------------------------------------ |
16 Aug
DataTables, Bootstrap and Text Overflow
31 Oct jersey-gson Content-Type Woes