diff options
author | Vitaly Takmazov | 2019-04-29 11:33:37 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-04-29 11:33:37 +0300 |
commit | db25e044786dc98aaa4e56700d4bbddb7d97ca2e (patch) | |
tree | 974fae4dbaaca67f1232e622c6e7df6701552092 | |
parent | 57bbef026ee44c0e52680f4bb101df6fa6431303 (diff) |
rss test
-rw-r--r-- | src/main/java/com/juick/server/api/rss/Feeds.java | 10 | ||||
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 13 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/com/juick/server/api/rss/Feeds.java b/src/main/java/com/juick/server/api/rss/Feeds.java index 47d9fd5e..d6e0587c 100644 --- a/src/main/java/com/juick/server/api/rss/Feeds.java +++ b/src/main/java/com/juick/server/api/rss/Feeds.java @@ -18,15 +18,13 @@ package com.juick.server.api.rss; import com.juick.User; -import com.juick.server.util.HttpBadRequestException; import com.juick.server.util.HttpNotFoundException; import com.juick.server.util.UserUtils; import com.juick.service.MessagesService; import com.juick.service.UserService; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; @@ -44,7 +42,7 @@ public class Feeds { @Inject private UserService userService; - @RequestMapping(value = "/rss/{userName}/blog", method = RequestMethod.GET, produces = "text/xml; charset=utf-8") + @GetMapping("/rss/{userName}/blog") public ModelAndView getBlog(@PathVariable String userName) { User user = userService.getUserByName(userName); if (!user.isAnonymous() && !user.isBanned()) { @@ -58,7 +56,7 @@ public class Feeds { throw new HttpNotFoundException(); } - @RequestMapping(value = "/rss/", method = RequestMethod.GET, produces = "text/xml; charset=utf-8") + @GetMapping("/rss/") public ModelAndView getLast(@RequestParam(value = "hours", required = false, defaultValue = "0") Integer hours) { List<Integer> mids = messagesService.getLastMessages(hours); ModelAndView modelAndView = new ModelAndView(); @@ -66,7 +64,7 @@ public class Feeds { modelAndView.addObject("messages", messagesService.getMessages(UserUtils.getCurrentUser(),mids)); return modelAndView; } - @RequestMapping(value = "/rss/comments", method = RequestMethod.GET, produces = "text/xml; charset=utf-8") + @GetMapping("/rss/comments") public ModelAndView getLastReplies(@RequestParam(value = "hours", required = false, defaultValue = "0") Integer hours) { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("repliesView"); diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 770c7e7c..be077e00 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -2052,4 +2052,17 @@ public class ServerTests { mockMvc.perform(get("/api/notifications")).andExpect(status().isUnauthorized()); mockMvc.perform(delete("/api/notifications")).andExpect(status().isUnauthorized()); } + @Test + public void rssFeeds() throws Exception { + mockMvc.perform(get("/rss/ugnich/blog") + .accept(MediaType.TEXT_XML)) + .andExpect(status().isOk()); + // fallback + mockMvc.perform(get("/rss/ugnich/blog") + .header("Accept", + "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;" + + "q=0.8,application/signed-exchange;v=b3")) + .andExpect(status().isOk()) + .andExpect(content().contentType("application/rss+xml;charset=UTF-8")); + } } |