Skip to content
Browse files

True End-To-End Integration Testing

  • Loading branch information...
1 parent c7f2ed3 commit 079c069ddc6ce5dee27d25450db85200d6393f5b @css181 css181 committed
View
2 pom.xml
@@ -123,7 +123,7 @@
</build>
</profile>
<profile>
- <id>JBOSS_AS_MANAGED_7.X2</id>
+ <id>JBOSS_AS_MANAGED_7.X</id>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
View
55 src/test/java/com/example/domain/MyWebServiceTest.java
@@ -253,4 +253,59 @@ public boolean userNameInList(User user, ArrayList<String> friendNamesList){
}
return list;
}
+
+ @Test
+ public void testSubmitAllWrongAnswers(){
+ String appName = "TutorialDemo";
+ Player playerWith5Friends = TestUtils.getPlayer(1005);
+
+ //Take note of the player's points before they submit the wrong answers
+ long playerPointsOriginal = playerWith5Friends.getPoints();
+
+ //Submit 3 incorrect answers to our WebService as a POST request
+ String targetURL = "http://localhost:8080/"+ appName +"/rest/webService/GameAnswers/" +
+ "1005/67890/76543/89012/Four%20Friend/Five%20Friend/One%20Friend";
+ String JSONInput = "";
+ String response = TestUtils.doPOST(targetURL, JSONInput);
+
+ //Test that we get the correct String back from the incorrect answers and our points were deducted
+ String expectedResponse = "First entry was INCORRECT "
+ + "Second entry was INCORRECT "
+ + "Third entry was INCORRECT "
+ + "You will have a total of [" + 30
+ + "] points deducted.";
+
+ //Re-GET the player now that the score should be updated
+ playerWith5Friends = TestUtils.getPlayer(1005);
+ Assert.assertTrue(response.equals(expectedResponse));
+ Assert.assertTrue(playerWith5Friends.getPoints()==(playerPointsOriginal - 30));
+ }
+
+
+ @Test
+ public void testSubmitAllCorrectAnswers(){
+ String appName = "TutorialDemo";
+ Player playerWith5Friends = TestUtils.getPlayer(1005);
+
+ //Take note of the player's points before they submit the correct answers
+ long playerPointsOriginal = playerWith5Friends.getPoints();
+
+ //Submit 3 correct answers to our WebService as a POST request
+ String targetURL = "http://localhost:8080/"+ appName +"/rest/webService/GameAnswers/" +
+ "1005/67890/76543/89012/One%20Friend/Two%20Friend/Three%20Friend";
+ String JSONInput = "";
+ String response = TestUtils.doPOST(targetURL, JSONInput);
+
+ //Test that we get the correct String back from the incorrect answers and our points were deducted
+ String expectedResponse = "First entry was correct "
+ + "Second entry was correct "
+ + "Thrid entry was correct "
+ + "You will have a total of [" + 30
+ + "] points added!";
+
+ //Re-GET the player now that the score should be updated
+ playerWith5Friends = TestUtils.getPlayer(1005);
+ Assert.assertTrue(response.equals(expectedResponse));
+ Assert.assertTrue(playerWith5Friends.getPoints()==(playerPointsOriginal + 30));
+ }
}
View
2 target/m2e-wtp/web-resources/META-INF/maven/come.example/TutorialDemo/pom.properties
@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
-#Mon Apr 16 18:50:50 EDT 2012
+#Mon Apr 16 19:31:12 EDT 2012
version=1.0.0-SNAPSHOT
groupId=come.example
m2e.projectName=TutorialDemo
View
2 target/m2e-wtp/web-resources/META-INF/maven/come.example/TutorialDemo/pom.xml
@@ -123,7 +123,7 @@
</build>
</profile>
<profile>
- <id>JBOSS_AS_MANAGED_7.X2</id>
+ <id>JBOSS_AS_MANAGED_7.X</id>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>

0 comments on commit 079c069

Please sign in to comment.
Something went wrong with that request. Please try again.