Skip to content

Commit

Permalink
#829 shorter name for TkPrevious cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Mar 12, 2018
1 parent 7ee9651 commit 2b91328
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/takes/facets/previous/RsPrevious.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public RsPrevious(final Response rsp, final String location) {
super(
new RsWithCookie(
rsp,
TkPrevious.class.getName(),
TkPrevious.class.getSimpleName(),
location
)
);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/takes/facets/previous/TkPrevious.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public TkPrevious(final Take take) {
@Override
public Response act(final Request req) throws IOException {
final Iterator<String> cookies = new RqCookies.Base(req)
.cookie(TkPrevious.class.getName())
.cookie(TkPrevious.class.getSimpleName())
.iterator();
final Response response;
if (cookies.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void buildsResponse() throws IOException {
new RsPrevious(new RsText(""), "/home")
).print(),
Matchers.containsString(
"Set-Cookie: org.takes.facets.previous.TkPrevious=/home"
"Set-Cookie: TkPrevious=/home"
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void redirectsOnCookie() throws IOException {
new RqWithHeader(
new RqFake(),
"Cookie",
"org.takes.facets.previous.TkPrevious=/home"
"TkPrevious=/home"
)
)
).print(),
Expand Down
55 changes: 55 additions & 0 deletions src/test/java/org/takes/rs/RsRedirectTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2014-2018 Yegor Bugayenko
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.takes.rs;

import java.io.IOException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

/**
* Test case for {@link RsRedirect}.
* @author Yegor Bugayenko (yegor256@gmail.com)
* @version $Id$
* @since 0.12
*/
public final class RsRedirectTest {

/**
* RsRedirect can redirect.
* @throws IOException If some problem inside
*/
@Test
public void redirects() throws IOException {
MatcherAssert.assertThat(
new RsPrint(
new RsRedirect(
"/home"
)
).print(),
Matchers.containsString("HTTP/1.1 303 See Other")
);
}

}

0 comments on commit 2b91328

Please sign in to comment.