You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by cg...@apache.org on 2012/11/06 02:52:30 UTC
svn commit: r1406025 - in /rave/trunk:
rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/
rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/stories/
rave-integration-tests/...
Author: cgeer
Date: Tue Nov 6 01:52:28 2012
New Revision: 1406025
URL: http://svn.apache.org/viewvc?rev=1406025&view=rev
Log:
RAVE-846 Added integration tests to validate the administration (create, update & delete) or categories.
Added:
rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CategoryAdminSteps.java
rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CommonSteps.java
rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/UserAdminSteps.java
- copied, changed from r1404425, rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/DeleteNewUserSteps.java
rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/manageCategories.story
Removed:
rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/DeleteNewUserSteps.java
Modified:
rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/stories/AdminStories.java
rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/deleteNewUser.story
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/categories.jsp
Added: rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CategoryAdminSteps.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CategoryAdminSteps.java?rev=1406025&view=auto
==============================================================================
--- rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CategoryAdminSteps.java (added)
+++ rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CategoryAdminSteps.java Tue Nov 6 01:52:28 2012
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.rave.integrationtests.steps;
+
+import junit.framework.Assert;
+import org.apache.rave.integrationtests.pages.Portal;
+import org.jbehave.core.annotations.Given;
+import org.jbehave.core.annotations.Then;
+import org.jbehave.core.annotations.When;
+import org.openqa.selenium.By;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebElement;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+@Step
+public class CategoryAdminSteps {
+
+ @Autowired
+ private Portal portal;
+
+ @Given("I see the categories list table")
+ @Then("I see the categories list table")
+ public void isCategoryTableVisible(){
+ //Just need to make sure that the table is there
+ WebElement table = portal.findElement(By.tagName("H2"));
+ assertThat(table.getText().trim(), equalTo("Categories"));
+ }
+
+ @Given("I see the create category form")
+ public void isCreateCategoryVisible() {
+ WebElement btn = portal.findElement(By.tagName("button"));
+ assertThat(btn.getText().trim(), equalTo("Create Category"));
+ }
+
+ @When("I fill in a new category named \"$categoryName\"")
+ public void fillInNewCategory(String categoryName){
+ WebElement form = portal.findElement(By.id("createCategory"));
+ WebElement field = form.findElement(By.id("text"));
+ field.sendKeys(categoryName);
+ }
+
+ @When("I click the \"Create Category\" button")
+ public void clickCreateCategoryButton() {
+ WebElement form = portal.findElement(By.id("createCategory"));
+ WebElement btn = form.findElement(By.tagName("button"));
+ btn.click();
+ }
+
+ @Given("I see a category called \"$categoryName\" in the categories list table")
+ @Then("I see a category called \"$categoryName\" in the categories list table")
+ public void isCategoryInTable(String categoryName) {
+ WebElement categoryLink = getCategoryLinkFromListTable(categoryName);
+ assertThat(categoryLink, notNullValue());
+ assertThat(categoryLink.getText(), equalTo(categoryName));
+ }
+
+ @When("I click on the category named \"$categoryName\"")
+ public void clickOnCategoryInListTable(String categoryName) {
+ WebElement link = getCategoryLinkFromListTable(categoryName);
+ assertThat(link, notNullValue());
+ link.click();
+ }
+
+ @Then("I see the category details page")
+ public void isCategoryDetailsPageVisible() {
+ WebElement element = portal.findElement(By.id("deleteCategory"));
+ assertThat(element, notNullValue());
+ }
+
+ @When("I change the name of the category to \"$categoryName\"")
+ public void fillInUpdatedCategory(String categoryName) {
+ WebElement form = portal.findElement(By.id("updateCategory"));
+ WebElement field = form.findElement(By.id("text"));
+ field.clear();
+ field.sendKeys(categoryName);
+ }
+
+ @When("I click the \"Update Category\" button")
+ public void clickUpdateCategoryButton() {
+ WebElement form = portal.findElement(By.id("updateCategory"));
+ WebElement btn = form.findElement(By.tagName("button"));
+ btn.click();
+ }
+
+ @When("I click the \"Delete Category\" button")
+ public void clickDeleteCategoryButton() {
+ WebElement form = portal.findElement(By.id("deleteCategory"));
+ WebElement btn = form.findElement(By.tagName("button"));
+ btn.click();
+ }
+
+ @Given("I do not see a category called \"$categoryName\" in the categories list table")
+ @Then("I do not see a category called \"$categoryName\" in the categories list table")
+ public void isCategoryNotInTable(String categoryName) {
+ try {
+ WebElement categoryLink = getCategoryLinkFromListTable(categoryName);
+ Assert.fail();
+ } catch(NoSuchElementException ex) {
+ // Success
+ }
+ }
+
+ @When("I select the delete checkbox")
+ public void selectDeleteCategoryCheckbox() {
+ WebElement form = portal.findElement(By.id("deleteCategory"));
+ WebElement chk = form.findElement(By.xpath("fieldset/div/label/input"));
+ chk.click();
+ }
+
+ private WebElement getCategoryLinkFromListTable(String categoryName) {
+ WebElement table = portal.findElement(By.id("categoryList"));
+ return table.findElement(By.linkText(categoryName));
+ }
+}
Added: rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CommonSteps.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CommonSteps.java?rev=1406025&view=auto
==============================================================================
--- rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CommonSteps.java (added)
+++ rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/CommonSteps.java Tue Nov 6 01:52:28 2012
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.rave.integrationtests.steps;
+
+import org.apache.rave.integrationtests.pages.Portal;
+import org.jbehave.core.annotations.Then;
+import org.jbehave.core.annotations.When;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.startsWith;
+
+@Step
+public class CommonSteps {
+ @Autowired
+ private Portal portal;
+
+ @When("I go to \"$url\"")
+ public void goTo(String url) {
+ portal.go(url);
+ }
+
+ @Then("I see the login page")
+ public void isLoginPage() {
+ final WebElement title = portal.findElement(By.tagName("title"));
+ assertThat(title.getText().trim(), equalTo("Login - Rave"));
+ }
+
+ @When("I log in as an administrator with username \"$username\" and password \"$password\"")
+ public void loginAsAdmin(String username, String password) {
+ portal.login(username,password);
+ }
+
+ @Then("I see the admin interface link")
+ public void getAdminInterfaceLink() {
+ //TODO: make sure the admin interface actually is loaded
+ final WebElement adminInterfaceLink=portal.findElement(By.linkText("Admin interface"));
+ }
+
+ @When("I click the admin interface link")
+ public void clickAdminInterfaceLink() {
+ //TODO: there should be consequences if this fails.
+ final WebElement adminInterfaceLink=portal.findElement(By.linkText("Admin interface"));
+ portal.clickLink(adminInterfaceLink);
+ }
+
+ @Then("I see the admin interface")
+ public void getAdminInterface() {
+ final WebElement adminInterface=portal.findElement(By.tagName("title"));
+ assertThat(adminInterface.getText().trim(),startsWith("Rave admin interface"));
+ }
+
+ @When("I click the \"$linkName\" link")
+ public void clickLink(String linkName) {
+ final WebElement usersLink=portal.findElement(By.linkText(linkName));
+ usersLink.click();
+ }
+
+ @When("I log out")
+ public void iLogOut() {
+ portal.logout();
+ }
+
+ @Then("I see the Rave login page")
+ public void backToLoginPage() {
+ final WebElement title = portal.findElement(By.tagName("title"));
+ assertThat(title.getText().trim(), equalTo("Login - Rave"));
+ }
+}
Copied: rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/UserAdminSteps.java (from r1404425, rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/DeleteNewUserSteps.java)
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/UserAdminSteps.java?p2=rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/UserAdminSteps.java&p1=rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/DeleteNewUserSteps.java&r1=1404425&r2=1406025&rev=1406025&view=diff
==============================================================================
--- rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/DeleteNewUserSteps.java (original)
+++ rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/steps/UserAdminSteps.java Tue Nov 6 01:52:28 2012
@@ -35,52 +35,11 @@ import static org.hamcrest.Matchers.star
* Steps for the new user stories
*/
@Step
-public class DeleteNewUserSteps {
+public class UserAdminSteps {
@Autowired
private Portal portal;
- @When("I go to \"$url\"")
- public void goTo(String url) {
- portal.go(url);
- }
-
- @Then("I see the login page")
- public void isLoginPage() {
- final WebElement title = portal.findElement(By.tagName("title"));
- assertThat(title.getText().trim(), equalTo("Login - Rave"));
- }
-
- @When("I log in as an administrator with username \"$username\" and password \"$password\"")
- public void loginAsAdmin(String username, String password) {
- portal.login(username,password);
- }
-
- @Then("I see the admin interface link")
- public void getAdminInterfaceLink() {
- //TODO: make sure the admin interface actually is loaded
- final WebElement adminInterfaceLink=portal.findElement(By.linkText("Admin interface"));
- }
-
- @When("I click the admin interface link")
- public void clickAdminInterfaceLink() {
- //TODO: there should be consequences if this fails.
- final WebElement adminInterfaceLink=portal.findElement(By.linkText("Admin interface"));
- portal.clickLink(adminInterfaceLink);
- }
-
- @Then("I see the admin interface")
- public void getAdminInterface() {
- final WebElement adminInterface=portal.findElement(By.tagName("title"));
- assertThat(adminInterface.getText().trim(),startsWith("Rave admin interface"));
- }
-
- @When("I click the \"$usersLinkName\" link")
- public void clickUsersLink(String usersLinkName) {
- final WebElement usersLink=portal.findElement(By.linkText(usersLinkName));
- usersLink.click();
- }
-
@Then("I get the user search form")
public void getUserList(){
//Just need to make sure that the search button is there
@@ -94,7 +53,7 @@ public class DeleteNewUserSteps {
searchForm.submit();
}
- @Then("I see the matches for \"$newuser\"")
+ @Then("I see the user matches for \"$newuser\"")
public void getUserSearchMatches() {
WebElement searchResultsHeading=portal.findElement(By.tagName("h2"));
assertThat(searchResultsHeading.getText().trim(),equalTo("Showing 1 - 1 of 1 results that match 'newuser'"));
@@ -128,14 +87,4 @@ public class DeleteNewUserSteps {
assertThat(confirmationText.getText().trim(),startsWith(deletionConfirmationStatement));
}
- @When("I log out")
- public void iLogOut() {
- portal.logout();
- }
-
- @Then("I see the Rave login page")
- public void backToLoginPage() {
- final WebElement title = portal.findElement(By.tagName("title"));
- assertThat(title.getText().trim(), equalTo("Login - Rave"));
- }
}
Modified: rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/stories/AdminStories.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/stories/AdminStories.java?rev=1406025&r1=1406024&r2=1406025&view=diff
==============================================================================
--- rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/stories/AdminStories.java (original)
+++ rave/trunk/rave-integration-tests/rave-admin-tests/src/main/java/org/apache/rave/integrationtests/stories/AdminStories.java Tue Nov 6 01:52:28 2012
@@ -31,8 +31,14 @@ import static org.jbehave.core.io.CodeLo
*/
public class AdminStories extends PortalStories {
- @Override
- protected List<String> storyPaths() {
- return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(), asList("**/deleteNewUser.story"), null);
- }
+ @Override
+ protected List<String> storyPaths() {
+ String story = System.getProperty("story");
+ if (story != null && !story.isEmpty()) {
+ return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()), "**/" + story + ".story", "**/excluded*.story");
+ } else {
+ return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()), "**/*.story", "**/excluded*.story");
+ }
+
+ }
}
Modified: rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/deleteNewUser.story
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/deleteNewUser.story?rev=1406025&r1=1406024&r2=1406025&view=diff
==============================================================================
--- rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/deleteNewUser.story (original)
+++ rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/deleteNewUser.story Tue Nov 6 01:52:28 2012
@@ -34,7 +34,7 @@ Then I see the admin interface
When I click the "Users" link
Then I get the user search form
When I search for username "newuser"
-Then I see the matches for "newuser"
+Then I see the user matches for "newuser"
When I click the link for information on "newuser"
Then I see the information for user "newuser"
When I delete the the user "newuser"
Added: rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/manageCategories.story
URL: http://svn.apache.org/viewvc/rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/manageCategories.story?rev=1406025&view=auto
==============================================================================
--- rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/manageCategories.story (added)
+++ rave/trunk/rave-integration-tests/rave-admin-tests/src/main/stories/manageCategories.story Tue Nov 6 01:52:28 2012
@@ -0,0 +1,56 @@
+!--
+!-- Licensed to the Apache Software Foundation (ASF) under one
+!-- or more contributor license agreements. See the NOTICE file
+!-- distributed with this work for additional information
+!-- regarding copyright ownership. The ASF licenses this file
+!-- to you under the Apache License, Version 2.0 (the
+!-- "License"); you may not use this file except in compliance
+!-- with the License. You may obtain a copy of the License at
+!--
+!-- http://www.apache.org/licenses/LICENSE-2.0
+!--
+!-- Unless required by applicable law or agreed to in writing,
+!-- software distributed under the License is distributed on an
+!-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+!-- KIND, either express or implied. See the License for the
+!-- specific language governing permissions and limitations
+!-- under the License.
+!--
+
+Scenario: Admin logs into the portal and views all the existing categories
+When I go to "http://localhost:8080/portal"
+Then I see the login page
+When I log in as an administrator with username "canonical" and password "canonical"
+Then I see the admin interface link
+When I click the admin interface link
+Then I see the admin interface
+When I click the "Categories" link
+Then I see the categories list table
+
+Scenario: Admin creates a new category
+Given I see the create category form
+When I fill in a new category named "TestCategory"
+And I click the "Create Category" button
+Then I see the categories list table
+And I see a category called "TestCategory" in the categories list table
+
+Scenario: Admin updates "TestCategory" and renames it to "My Category"
+Given I see the categories list table
+And I see a category called "TestCategory" in the categories list table
+When I click on the category named "TestCategory"
+Then I see the category details page
+When I change the name of the category to "My Category"
+And I click the "Update Category" button
+Then I see the categories list table
+And I see a category called "My Category" in the categories list table
+And I do not see a category called "Test Category" in the categories list table
+
+Scenario: Admin deletes "My Category"
+Given I see the categories list table
+And I see a category called "My Category" in the categories list table
+When I click on the category named "My Category"
+Then I see the category details page
+When I select the delete checkbox
+And I click the "Delete Category" button
+Then I see the categories list table
+And I do not see a category called "My Category" in the categories list table
\ No newline at end of file
Modified: rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/categories.jsp
URL: http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/categories.jsp?rev=1406025&r1=1406024&r2=1406025&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/categories.jsp (original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/admin/categories.jsp Tue Nov 6 01:52:28 2012
@@ -40,7 +40,7 @@
</div>
</c:if>
- <table class="table table-striped table-bordered table-condensed">
+ <table id="categoryList" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th><fmt:message key="admin.categoryData.text"/></th>
@@ -80,7 +80,7 @@
</article>
<div>
- <form:form cssClass="form-inline" commandName="category" action="category/create" method="POST">
+ <form:form id="createCategory" cssClass="form-inline" commandName="category" action="category/create" method="POST">
<form:errors cssClass="error" element="p"/>
<fieldset>
<legend><fmt:message key="admin.category.create"/></legend>