Skip to content

Commit 6134274

Browse files
author
Yegor Bugayenko
committed
#6 reproduced
1 parent 6889c03 commit 6134274

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

pom.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
2929
* OF THE POSSIBILITY OF SUCH DAMAGE.
3030
-->
31-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
31+
<project xmlns="http://maven.apache.org/POM/4.0.0"
32+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3234
<modelVersion>4.0.0</modelVersion>
3335
<parent>
3436
<groupId>com.jcabi</groupId>
@@ -160,6 +162,12 @@
160162
<groupId>javax.servlet</groupId>
161163
<artifactId>servlet-api</artifactId>
162164
</dependency>
165+
<dependency>
166+
<groupId>com.sun.grizzly</groupId>
167+
<artifactId>grizzly-servlet-webserver</artifactId>
168+
<version>1.9.60</version>
169+
<scope>test</scope>
170+
</dependency>
163171
</dependencies>
164172
<build>
165173
<plugins>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Copyright (c) 2014, stateful.co
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met: 1) Redistributions of source code must retain the above
8+
* copyright notice, this list of conditions and the following
9+
* disclaimer. 2) Redistributions in binary form must reproduce the above
10+
* copyright notice, this list of conditions and the following
11+
* disclaimer in the documentation and/or other materials provided
12+
* with the distribution. 3) Neither the name of the stateful.co nor
13+
* the names of its contributors may be used to endorse or promote
14+
* products derived from this software without specific prior written
15+
* permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
19+
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20+
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21+
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28+
* OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
package co.stateful;
31+
32+
import com.jcabi.http.Request;
33+
import com.jcabi.http.mock.MkAnswer;
34+
import com.jcabi.http.mock.MkContainer;
35+
import com.jcabi.http.mock.MkGrizzlyContainer;
36+
import com.jcabi.http.request.JdkRequest;
37+
import java.net.HttpURLConnection;
38+
import org.hamcrest.MatcherAssert;
39+
import org.hamcrest.Matchers;
40+
import org.junit.Test;
41+
42+
/**
43+
* Test case for {@link RtLock}.
44+
* @author Yegor Bugayenko (yegor@tpc2.com)
45+
* @version $Id$
46+
* @since 0.12.3
47+
*/
48+
public final class RtLockTest {
49+
50+
/**
51+
* RtLock can lock.
52+
* @throws Exception If some problem inside
53+
*/
54+
@Test
55+
public void locksViaHttp() throws Exception {
56+
final String xml = "<page><links><link rel='lock' href=''/></links></page>";
57+
final MkContainer container = new MkGrizzlyContainer()
58+
.next(new MkAnswer.Simple(xml))
59+
.next(new MkAnswer.Simple(HttpURLConnection.HTTP_SEE_OTHER, ""))
60+
.start();
61+
final Lock lock = new RtLock("test", new JdkRequest(container.home()));
62+
try {
63+
MatcherAssert.assertThat(lock.lock(), Matchers.equalTo(true));
64+
} finally {
65+
container.stop();
66+
}
67+
MatcherAssert.assertThat(
68+
container.take().method(),
69+
Matchers.equalTo(Request.GET)
70+
);
71+
MatcherAssert.assertThat(
72+
container.take().method(),
73+
Matchers.equalTo(Request.POST)
74+
);
75+
}
76+
77+
}

0 commit comments

Comments
 (0)