Skip to content

Commit 929fb83

Browse files
committed
Integration tests: remove checkServerResponseCode() check.
I don't want to port it to Robot Framework because a) it will be hard b) now I don't think that this check was so useful
1 parent e49a963 commit 929fb83

17 files changed

+0
-102
lines changed

src/test/java/ru/mystamps/web/tests/cases/WhenAdminAddCategory.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ public void shouldHaveStandardStructure() {
6464
checkStandardStructure();
6565
}
6666

67-
@Override
68-
protected void checkServerResponseCode() {
69-
// Ignore this check because server always returns 403 for anonymous user and our test suite
70-
// lack ability to check response code after authentication.
71-
}
72-
7367
@Override
7468
protected void shouldHaveUserBar() {
7569
// Ignore this check because when user authenticated there is no links for login/register.

src/test/java/ru/mystamps/web/tests/cases/WhenAdminAddCountry.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ public void shouldHaveStandardStructure() {
6464
checkStandardStructure();
6565
}
6666

67-
@Override
68-
protected void checkServerResponseCode() {
69-
// Ignore this check because server always returns 403 for anonymous user and our test suite
70-
// lack ability to check response code after authentication.
71-
}
72-
7367
@Override
7468
protected void shouldHaveUserBar() {
7569
// Ignore this check because when user authenticated there is no links for login/register.

src/test/java/ru/mystamps/web/tests/cases/WhenAdminAddSeries.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,6 @@ public Object[][] getInvalidCatalogPrices() {
448448
};
449449
}
450450

451-
@Override
452-
protected void checkServerResponseCode() {
453-
// Ignore this check because server always returns 403 for anonymous user and our test suite
454-
// lack ability to check response code after authentication.
455-
}
456-
457451
@Override
458452
protected void shouldHaveUserBar() {
459453
// Ignore this check because when user authenticated there is no links for login/register.

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserAddCategory.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.testng.annotations.BeforeClass;
2321
import org.testng.annotations.Test;
2422

@@ -34,7 +32,6 @@ public class WhenAnonymousUserAddCategory extends WhenAnyUserAtAnyPage<Unauthori
3432
public WhenAnonymousUserAddCategory() {
3533
super(UnauthorizedErrorPage.class);
3634
hasTitleWithoutStandardPrefix(tr("t_403_title"));
37-
hasResponseServerCode(HttpURLConnection.HTTP_FORBIDDEN);
3835
}
3936

4037
@BeforeClass

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserAddCountry.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.testng.annotations.BeforeClass;
2321
import org.testng.annotations.Test;
2422

@@ -35,7 +33,6 @@ public class WhenAnonymousUserAddCountry extends WhenAnyUserAtAnyPage<Unauthoriz
3533
public WhenAnonymousUserAddCountry() {
3634
super(UnauthorizedErrorPage.class);
3735
hasTitleWithoutStandardPrefix(tr("t_403_title"));
38-
hasResponseServerCode(HttpURLConnection.HTTP_FORBIDDEN);
3936
}
4037

4138
@BeforeClass

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserAddSeries.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.testng.annotations.BeforeClass;
2321
import org.testng.annotations.Test;
2422

@@ -35,7 +33,6 @@ public class WhenAnonymousUserAddSeries extends WhenAnyUserAtAnyPage<Unauthorize
3533
public WhenAnonymousUserAddSeries() {
3634
super(UnauthorizedErrorPage.class);
3735
hasTitleWithoutStandardPrefix(tr("t_403_title"));
38-
hasResponseServerCode(HttpURLConnection.HTTP_FORBIDDEN);
3936
}
4037

4138
@BeforeClass

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserAtForbiddenPage.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.testng.annotations.BeforeClass;
2321
import org.testng.annotations.Test;
2422

@@ -36,7 +34,6 @@ public class WhenAnonymousUserAtForbiddenPage
3634
public WhenAnonymousUserAtForbiddenPage() {
3735
super(ForbiddenErrorPage.class);
3836
hasTitleWithoutStandardPrefix(tr("t_403_title"));
39-
hasResponseServerCode(HttpURLConnection.HTTP_FORBIDDEN);
4037
}
4138

4239
@BeforeClass

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserOpenNotExistingCategoryPage.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.testng.annotations.Test;
2321

2422
import ru.mystamps.web.Url;
@@ -34,7 +32,6 @@ public class WhenAnonymousUserOpenNotExistingCategoryPage
3432
public WhenAnonymousUserOpenNotExistingCategoryPage() {
3533
super(NotFoundErrorPage.class);
3634
hasTitleWithoutStandardPrefix(tr("t_404_title"));
37-
hasResponseServerCode(HttpURLConnection.HTTP_NOT_FOUND);
3835
}
3936

4037
@Test(groups = "logic")

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserOpenNotExistingCollectionPage.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.testng.annotations.Test;
2321

2422
import ru.mystamps.web.Url;
@@ -34,7 +32,6 @@ public class WhenAnonymousUserOpenNotExistingCollectionPage
3432
public WhenAnonymousUserOpenNotExistingCollectionPage() {
3533
super(NotFoundErrorPage.class);
3634
hasTitleWithoutStandardPrefix(tr("t_404_title"));
37-
hasResponseServerCode(HttpURLConnection.HTTP_NOT_FOUND);
3835
}
3936

4037
@Test(groups = "logic")

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserOpenNotExistingCountryPage.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import static org.fest.assertions.api.Assertions.assertThat;
2321

2422
import org.testng.annotations.Test;
@@ -34,7 +32,6 @@ public class WhenAnonymousUserOpenNotExistingCountryPage
3432
public WhenAnonymousUserOpenNotExistingCountryPage() {
3533
super(NotFoundErrorPage.class);
3634
hasTitleWithoutStandardPrefix(tr("t_404_title"));
37-
hasResponseServerCode(HttpURLConnection.HTTP_NOT_FOUND);
3835
}
3936

4037
@Test(groups = "logic")

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserOpenNotExistingPage.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
import static org.fest.assertions.api.Assertions.assertThat;
2121

22-
import java.net.HttpURLConnection;
23-
2422
import org.testng.annotations.BeforeClass;
2523
import org.testng.annotations.Test;
2624

@@ -33,7 +31,6 @@ public class WhenAnonymousUserOpenNotExistingPage extends WhenAnyUserAtAnyPage<N
3331
public WhenAnonymousUserOpenNotExistingPage() {
3432
super(NotFoundErrorPage.class);
3533
hasTitleWithoutStandardPrefix(tr("t_404_title"));
36-
hasResponseServerCode(HttpURLConnection.HTTP_NOT_FOUND);
3734
}
3835

3936
@BeforeClass

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserOpenNotExistingSeriesPage.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import static org.fest.assertions.api.Assertions.assertThat;
2321

2422
import org.testng.annotations.Test;
@@ -34,7 +32,6 @@ public class WhenAnonymousUserOpenNotExistingSeriesPage
3432
public WhenAnonymousUserOpenNotExistingSeriesPage() {
3533
super(NotFoundErrorPage.class);
3634
hasTitleWithoutStandardPrefix(tr("t_404_title"));
37-
hasResponseServerCode(HttpURLConnection.HTTP_NOT_FOUND);
3835
}
3936

4037
@Test(groups = "logic")

src/test/java/ru/mystamps/web/tests/cases/WhenAnonymousUserOpenTogglzConsole.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.testng.annotations.BeforeClass;
2321
import org.testng.annotations.Test;
2422

@@ -34,7 +32,6 @@ public class WhenAnonymousUserOpenTogglzConsole extends WhenAnyUserAtAnyPage<For
3432
public WhenAnonymousUserOpenTogglzConsole() {
3533
super(ForbiddenErrorPage.class);
3634
hasTitleWithoutStandardPrefix(tr("t_403_title"));
37-
hasResponseServerCode(HttpURLConnection.HTTP_FORBIDDEN);
3835
}
3936

4037
@BeforeClass

src/test/java/ru/mystamps/web/tests/cases/WhenAnyUserAtAnyPage.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.openqa.selenium.support.PageFactory;
2321

2422
import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
@@ -52,11 +50,6 @@ abstract class WhenAnyUserAtAnyPage<T extends AbstractPage>
5250

5351
protected final T page;
5452

55-
/**
56-
* @see hasResponseServerCode()
57-
*/
58-
private int serverCode = HttpURLConnection.HTTP_OK;
59-
6053
/**
6154
* @see hasTitle()
6255
* @see hasTitleWithoutStandardPrefix()
@@ -73,10 +66,6 @@ abstract class WhenAnyUserAtAnyPage<T extends AbstractPage>
7366
page = PageFactory.initElements(WebDriverFactory.getDriver(), pageClass);
7467
}
7568

76-
protected void hasResponseServerCode(int serverCode) {
77-
this.serverCode = serverCode;
78-
}
79-
8069
protected void hasTitle(String title) {
8170
this.title = TITLE_PREFIX + title;
8271
}
@@ -90,7 +79,6 @@ protected void hasHeader(String header) {
9079
}
9180

9281
protected void checkStandardStructure() {
93-
checkServerResponseCode();
9482
shouldHaveTitle();
9583
shouldHaveLogo();
9684
shouldHaveUserBar();
@@ -99,12 +87,6 @@ protected void checkStandardStructure() {
9987
shouldHaveFooter();
10088
}
10189

102-
protected void checkServerResponseCode() {
103-
assertThat(page.getServerResponseCode())
104-
.overridingErrorMessage("Server response code")
105-
.isEqualTo(serverCode);
106-
}
107-
10890
private void shouldHaveTitle() {
10991
Validate.validState(
11092
title != null,

src/test/java/ru/mystamps/web/tests/cases/WhenUserAddSeries.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,6 @@ public Object[][] getInvalidCatalogPrices() {
415415
};
416416
}
417417

418-
@Override
419-
protected void checkServerResponseCode() {
420-
// Ignore this check because server always returns 403 for anonymous user and our test suite
421-
// lack ability to check response code after authentication.
422-
}
423-
424418
@Override
425419
protected void shouldHaveUserBar() {
426420
// Ignore this check because when user authenticated there is no links for login/register.

src/test/java/ru/mystamps/web/tests/cases/WhenUserOpenTogglzConsole.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.cases;
1919

20-
import java.net.HttpURLConnection;
21-
2220
import org.testng.annotations.AfterClass;
2321
import org.testng.annotations.BeforeClass;
2422
import org.testng.annotations.Test;
@@ -43,7 +41,6 @@ public class WhenUserOpenTogglzConsole extends WhenAnyUserAtAnyPage<ForbiddenErr
4341
public WhenUserOpenTogglzConsole() {
4442
super(ForbiddenErrorPage.class);
4543
hasTitleWithoutStandardPrefix(tr("t_403_title"));
46-
hasResponseServerCode(HttpURLConnection.HTTP_FORBIDDEN);
4744
}
4845

4946
@BeforeClass

src/test/java/ru/mystamps/web/tests/page/AbstractPage.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
*/
1818
package ru.mystamps.web.tests.page;
1919

20-
import java.io.IOException;
21-
import java.net.URL;
22-
import java.net.HttpURLConnection;
2320
import java.util.List;
2421

2522
import org.openqa.selenium.By;
@@ -59,30 +56,6 @@ public void open(String pageUrl) {
5956
driver.get(Url.SITE + pageUrl);
6057
}
6158

62-
/**
63-
* Opens page and returns server response code.
64-
* In case of error returns -1.
65-
*/
66-
public int getServerResponseCode() {
67-
/**
68-
* FIXME: currently we can't get access to server response from Selenium :(
69-
* @see http://code.google.com/p/selenium/issues/detail?id=141
70-
*/
71-
72-
try {
73-
// As workaround, for a while, use HttpUrlConnection
74-
// (but it leads to two connection to each page).
75-
URL url = new URL(getFullUrl());
76-
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
77-
return conn.getResponseCode();
78-
79-
} catch (IOException ex) {
80-
// don't throw exception because it leads to error in tests
81-
// instead of failure
82-
return -1;
83-
}
84-
}
85-
8659
private String getFullUrl() {
8760
return Url.SITE + pageUrl;
8861
}

0 commit comments

Comments
 (0)