1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.jwebunit.tests;
20
21 import static net.sourceforge.jwebunit.junit.JWebUnit.assertTitleEquals;
22 import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
23 import static net.sourceforge.jwebunit.junit.JWebUnit.clickLinkWithText;
24 import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
25 import static net.sourceforge.jwebunit.junit.JWebUnit.setBaseUrl;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.fail;
28
29 import com.google.code.tempusfugit.concurrency.annotations.Repeating;
30
31 import com.google.code.tempusfugit.concurrency.annotations.Concurrent;
32
33 import com.google.code.tempusfugit.concurrency.ConcurrentRule;
34
35 import com.google.code.tempusfugit.concurrency.RepeatingRule;
36
37 import org.junit.Rule;
38 import org.junit.Test;
39 import org.junit.rules.Timeout;
40
41
42
43
44
45
46
47 public class ConcurrentJWebUnitTest extends JWebUnitAPITestCase {
48
49 public void setUp() throws Exception {
50
51 getTestContext().setAuthorization("admin", "admin");
52 setBaseUrl(HOST_PATH + "/NavigationTest");
53 }
54
55 @Rule public Timeout timeoutRule = new Timeout(10000);
56
57 @Rule public ConcurrentRule concurrently = new ConcurrentRule();
58 @Rule public RepeatingRule repeatedly = new RepeatingRule();
59
60 @Test
61 @Concurrent(count = 5)
62 @Repeating (repetition = 10)
63 public void testClickLinkWithTextN() {
64 beginAt("/pageWithLink.html");
65 assertTitleEquals("pageWithLink");
66
67 clickLinkWithText("an active link", 0);
68 assertTitleEquals("targetPage");
69
70 beginAt("/pageWithLink.html");
71 clickLinkWithText("an active link", 1);
72
73 assertTitleEquals("targetPage2");
74 beginAt("/pageWithLink.html");
75 try {
76 clickLinkWithText("an active link", 2);
77 fail();
78 } catch (AssertionError expected) {
79 assertEquals("Link with text [an active link] and index [2] "
80 + "not found in response.", expected.getMessage());
81 }
82 assertTitleEquals("pageWithLink");
83 }
84
85 }