Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
(cherry picked from commit f9b321c)
  • Loading branch information
marcusdacoregio committed Nov 29, 2023
1 parent dcd5e23 commit 20fbf85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dependencies {
implementation "org.webjars:bootstrap"
implementation "org.webjars:html5shiv"
implementation "org.webjars:webjars-locator-core"
implementation "org.apache.httpcomponents:httpclient"

testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation "org.assertj:assertj-core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

package sample.web;

import java.util.Collections;

import jakarta.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -31,10 +34,11 @@ public class HomeController {

@RequestMapping("/setValue")
public String setValue(@RequestParam(name = "key", required = false) String key,
@RequestParam(name = "value", required = false) String value, HttpServletRequest request) {
@RequestParam(name = "value", required = false) String value, HttpServletRequest request, Model model) {
if (!ObjectUtils.isEmpty(key) && !ObjectUtils.isEmpty(value)) {
request.getSession().setAttribute(key, value);
}
model.addAttribute("sessionAttributeNames", Collections.list(request.getSession().getAttributeNames()));
return "home";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</tr>
</thead>
<tbody>
<tr th:each="name : ${T(org.springframework.util.CollectionUtils).toIterator(httpSession?.getAttributeNames())}">
<tr th:each="name : ${sessionAttributeNames}">
<td th:text="${name}"></td>
<td th:text="${httpSession.getAttribute(name)}"></td>
</tr>
Expand Down

0 comments on commit 20fbf85

Please sign in to comment.