-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for cookie behavior verification
It seems that the problem described in #354 is some client specific issue. Both tests could not reproduce the error on framework level, so we might close this issue for now. see: #354
- Loading branch information
Showing
14 changed files
with
480 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
testsuite/src/main/java/org/eclipse/krazo/test/redirectboundary/RedirectApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.eclipse.krazo.test.redirectboundary; | ||
|
||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.eclipse.krazo.Properties; | ||
|
||
@ApplicationPath("resources") | ||
public class RedirectApplication extends Application { | ||
|
||
@Override | ||
public Map<String, Object> getProperties() { | ||
final Map<String, Object> props = new HashMap<>(); | ||
props.put(Properties.REDIRECT_SCOPE_COOKIES, true); | ||
props.put(Properties.REDIRECT_SCOPE_COOKIE_NAME, "custom_cookie"); | ||
return props; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
testsuite/src/main/java/org/eclipse/krazo/test/redirectboundary/RedirectBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.eclipse.krazo.test.redirectboundary; | ||
|
||
import jakarta.mvc.RedirectScoped; | ||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
@RedirectScoped | ||
public class RedirectBean implements Serializable { | ||
|
||
private static final long serialVersionUID = -1; | ||
|
||
private String message; | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
RedirectBean that = (RedirectBean) o; | ||
return Objects.equals(message, that.message); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(message); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "RedirectBean{" + | ||
"message='" + message + '\'' + | ||
'}'; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...te/src/main/java/org/eclipse/krazo/test/redirectboundary/RedirectBoundaryAController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.eclipse.krazo.test.redirectboundary; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.mvc.Controller; | ||
import jakarta.mvc.Models; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
|
||
@Path("/a") | ||
@RequestScoped | ||
@Controller | ||
public class RedirectBoundaryAController { | ||
|
||
@Inject | ||
RedirectBean bean; | ||
|
||
@Inject | ||
Models models; | ||
|
||
@GET | ||
public String index() { | ||
models.put("redirectBeanValue", bean.getMessage()); | ||
return "a.jsp"; | ||
} | ||
|
||
@POST | ||
@Path("/toA") | ||
public String postA() { | ||
bean.setMessage("Redirect to A!"); | ||
|
||
return "redirect:/a"; | ||
} | ||
|
||
@POST | ||
@Path("/toB") | ||
public String postB() { | ||
bean.setMessage("Redirect to B!"); | ||
|
||
return "redirect:/b"; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...te/src/main/java/org/eclipse/krazo/test/redirectboundary/RedirectBoundaryBController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.eclipse.krazo.test.redirectboundary; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.mvc.Controller; | ||
import jakarta.mvc.Models; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
@Path("/b") | ||
@RequestScoped | ||
@Controller | ||
public class RedirectBoundaryBController { | ||
|
||
@Inject | ||
RedirectBean bean; | ||
|
||
@Inject | ||
Models models; | ||
|
||
@GET | ||
public String index() { | ||
models.put("redirectBeanValue", bean.getMessage()); | ||
return "b.jsp"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...uite/src/main/java/org/eclipse/krazo/test/redirectboundaryonroot/RedirectApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.eclipse.krazo.test.redirectboundaryonroot; | ||
|
||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.eclipse.krazo.Properties; | ||
|
||
@ApplicationPath("") | ||
public class RedirectApplication extends Application { | ||
|
||
@Override | ||
public Map<String, Object> getProperties() { | ||
final Map<String, Object> props = new HashMap<>(); | ||
props.put(Properties.REDIRECT_SCOPE_COOKIES, true); | ||
props.put(Properties.REDIRECT_SCOPE_COOKIE_NAME, "custom_cookie"); | ||
return props; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
testsuite/src/main/java/org/eclipse/krazo/test/redirectboundaryonroot/RedirectBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.eclipse.krazo.test.redirectboundaryonroot; | ||
|
||
import jakarta.mvc.RedirectScoped; | ||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
@RedirectScoped | ||
public class RedirectBean implements Serializable { | ||
|
||
private static final long serialVersionUID = -1; | ||
|
||
private String message; | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
RedirectBean that = (RedirectBean) o; | ||
return Objects.equals(message, that.message); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(message); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "RedirectBean{" + | ||
"message='" + message + '\'' + | ||
'}'; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.../main/java/org/eclipse/krazo/test/redirectboundaryonroot/RedirectBoundaryAController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.eclipse.krazo.test.redirectboundaryonroot; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.mvc.Controller; | ||
import jakarta.mvc.Models; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
|
||
@Path("/a") | ||
@RequestScoped | ||
@Controller | ||
public class RedirectBoundaryAController { | ||
|
||
@Inject | ||
RedirectBean bean; | ||
|
||
@Inject | ||
Models models; | ||
|
||
@GET | ||
public String index() { | ||
models.put("redirectBeanValue", bean.getMessage()); | ||
return "a.jsp"; | ||
} | ||
|
||
@POST | ||
@Path("/toA") | ||
public String postA() { | ||
bean.setMessage("Redirect to A!"); | ||
|
||
return "redirect:/a"; | ||
} | ||
|
||
@POST | ||
@Path("/toB") | ||
public String postB() { | ||
bean.setMessage("Redirect to B!"); | ||
|
||
return "redirect:/b"; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../main/java/org/eclipse/krazo/test/redirectboundaryonroot/RedirectBoundaryBController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.eclipse.krazo.test.redirectboundaryonroot; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.mvc.Controller; | ||
import jakarta.mvc.Models; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
@Path("/b") | ||
@RequestScoped | ||
@Controller | ||
public class RedirectBoundaryBController { | ||
|
||
@Inject | ||
RedirectBean bean; | ||
|
||
@Inject | ||
Models models; | ||
|
||
@GET | ||
public String index() { | ||
models.put("redirectBeanValue", bean.getMessage()); | ||
return "b.jsp"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<%@ page contentType="text/html;charset=UTF-8" language="java" %> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Redirect boundary test</title> | ||
</head> | ||
<body> | ||
<h1>Page A</h1> | ||
|
||
<p id="result">${redirectBeanValue}</p> | ||
|
||
<form name="toAForm" action="${mvc.basePath}/a/toA" method="post"> | ||
<button name="submit">Submit</button> | ||
</form> | ||
|
||
<form name="toBForm" action="${mvc.basePath}/a/toB" method="post"> | ||
<button name="submit">Submit</button> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%@ page contentType="text/html;charset=UTF-8" language="java" %> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Redirect boundary test</title> | ||
</head> | ||
<body> | ||
<h1>Page B</h1> | ||
|
||
<p id="result">${redirectBeanValue}</p> | ||
|
||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
testsuite/src/main/resources/redirectboundaryonroot/views/a.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<%@ page contentType="text/html;charset=UTF-8" language="java" %> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Redirect boundary test</title> | ||
</head> | ||
<body> | ||
<h1>Page A</h1> | ||
|
||
<p id="result">${redirectBeanValue}</p> | ||
|
||
<form name="toAForm" action="${mvc.basePath}/a/toA" method="post"> | ||
<button name="submit">Submit</button> | ||
</form> | ||
|
||
<form name="toBForm" action="${mvc.basePath}/a/toB" method="post"> | ||
<button name="submit">Submit</button> | ||
</form> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
testsuite/src/main/resources/redirectboundaryonroot/views/b.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%@ page contentType="text/html;charset=UTF-8" language="java" %> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Redirect boundary test</title> | ||
</head> | ||
<body> | ||
<h1>Page B</h1> | ||
|
||
<p id="result">${redirectBeanValue}</p> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.