Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating and fixing musicjungle acceptance tests #941

Merged
merged 4 commits into from
Feb 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vraptor-musicjungle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.41.0</version>
<version>2.44.0</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ResultSerializationTest extends AcceptanceTestCase{

@Before
public void setUpBeforeClass() {
loginPage().createAndloginAsUser("vraptortest");
loginPage().loginAsUser("vraptor");
HomePage page = homePage();
this.mozart = new MusicBuilder(1, "Mozart - Symphony #40", "Mozart", CLASSICAL).create();
this.beethoven = new MusicBuilder(2, "Moonlight Sonata", "Beethoven", CLASSICAL).create();
Expand Down Expand Up @@ -68,19 +68,19 @@ private String JSON(Music music) {
}

private String getExpectedXml() {
return "<list>\n"+
" <music>\n"+
" <id>1</id>\n"+
" <title>"+ mozart.getTitle() +"</title>\n"+
" <description>"+ mozart.getDescription() +"</description>\n"+
" <type>"+ mozart.getType().toString() +"</type>\n"+
" </music>\n"+
" <music>\n"+
" <id>2</id>\n"+
" <title>"+ beethoven.getTitle() +"</title>\n"+
" <description>"+ beethoven.getDescription() +"</description>\n"+
" <type>"+ beethoven.getType().toString() +"</type>\n"+
" </music>\n"+
return "<list>"+
"<music>"+
"<id>1</id>"+
"<title>"+ mozart.getTitle() +"</title>"+
"<description>"+ mozart.getDescription() +"</description>"+
"<type>"+ mozart.getType().toString() +"</type>"+
"</music>"+
"<music>"+
"<id>2</id>"+
"<title>"+ beethoven.getTitle() +"</title>"+
"<description>"+ beethoven.getDescription() +"</description>"+
"<type>"+ beethoven.getType().toString() +"</type>"+
"</music>"+
"</list>";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public class RoutesTest extends AcceptanceTestCase {

private LoginPage loginPage;
private Music music;
private String userName = "acceptancetest";
private String userName = "vraptor";

@Before
public void setUp() {
this.loginPage = loginPage();
loginPage.createAndloginAsUser(userName);
loginPage.loginAsUser(userName);
this.music = new MusicBuilder(3, "Please Please Me", "Beatles", ROCK).create();
homePage().addMusic(music);
loginPage.logout();
Expand All @@ -54,7 +54,7 @@ private void shouldAccessGetMethodWithADefinedValue() {
loginPage.loginAsUser(userName);
String musicTitle = music.getTitle();
SearchPage searchPage = homePage().searchFor(musicTitle);
assertPageContains(searchPage, "Search results", musicTitle);
assertPageContains(searchPage, musicTitle);
}

private void shouldAccessPostMethodWithDefaultURLValue() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package br.com.caelum.vraptor.musicjungle.acceptance.infra;

import static org.openqa.selenium.By.linkText;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

Expand Down Expand Up @@ -42,8 +39,7 @@ public ServiceResultPage accessFullUrl(String uri) {
}

public MusicExportPage accessMusicsExport() {
By linkText = linkText("Export all musics");
driver.findElement(linkText).click();
driver.get(getBaseUrl() + "/musics/list/form");
return new MusicExportPage(driver);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,7 @@ public void loginAsUser(String user) {
form.submitForm();
}

private void createUser(String value) {
By cssSelector = cssSelector("form[action$='users']");
PageForm form = new PageForm(driver, cssSelector);
form.input("user.name", value);
form.input("user.login", value);
form.input("user.password", value);
form.submitForm();
}

public void logout() {
driver.findElement(By.linkText("Logout")).click();
}

public void createAndloginAsUser(String userName) {
createUser(userName);
loginAsUser(userName);
}

}