diff options
author | Vitaly Takmazov | 2019-10-22 14:18:47 +0000 |
---|---|---|
committer | Vitaly Takmazov | 2019-10-22 14:18:47 +0000 |
commit | f62db11edaa4c7420591e03a04b63cb3e3e136c2 (patch) | |
tree | 1d187ba51a081374e108d9b19ab50ab47bcc6436 /src | |
parent | f00be8c6d4b1d420119f9f08d400719fd62d2d39 (diff) |
Revert "Spring Boot 2.2"
This reverts commit d3648888eaea9904fb3b806d56b22827c7614f54.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/juick/server/api/Messages.java | 2 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/Notifications.java | 12 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/PM.java | 6 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/Post.java | 4 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/Tags.java | 2 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/Users.java | 8 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/activity/Profile.java | 2 | ||||
-rw-r--r-- | src/main/resources/application.properties | 1 | ||||
-rw-r--r-- | src/test/java/com/juick/FormatterTest.java | 8 | ||||
-rw-r--r-- | src/test/java/com/juick/MessageTest.java | 8 | ||||
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 25 |
11 files changed, 38 insertions, 40 deletions
diff --git a/src/main/java/com/juick/server/api/Messages.java b/src/main/java/com/juick/server/api/Messages.java index f7b8c156..1c9e37ad 100644 --- a/src/main/java/com/juick/server/api/Messages.java +++ b/src/main/java/com/juick/server/api/Messages.java @@ -49,7 +49,7 @@ import java.util.stream.Collectors; * @author ugnich */ @RestController -@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE) +@RequestMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public class Messages { private static final ResponseEntity<List<com.juick.Message>> NOT_FOUND = ResponseEntity diff --git a/src/main/java/com/juick/server/api/Notifications.java b/src/main/java/com/juick/server/api/Notifications.java index 72988298..f2c2d712 100644 --- a/src/main/java/com/juick/server/api/Notifications.java +++ b/src/main/java/com/juick/server/api/Notifications.java @@ -84,7 +84,7 @@ public class Notifications { } @ApiIgnore - @RequestMapping(value = "/api/notifications", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/notifications", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public ResponseEntity<List<User>> doGet( @Visitor User visitor, @RequestParam(required = false, defaultValue = "0") int uid, @@ -119,7 +119,7 @@ public class Notifications { } @ApiIgnore - @RequestMapping(value = "/api/notifications", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/notifications", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public ResponseEntity<Status> doDelete( @Visitor User visitor, @RequestBody List<ExternalToken> list) { @@ -145,7 +145,7 @@ public class Notifications { return ResponseEntity.ok(Status.OK); } @ApiIgnore - @RequestMapping(value = "/api/notifications/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/notifications/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public ResponseEntity<Status> doDeleteTokens( @Visitor User visitor, @RequestBody List<ExternalToken> list) { @@ -172,7 +172,7 @@ public class Notifications { } @ApiIgnore - @RequestMapping(value = "/api/notifications", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/notifications", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public Status doPut( @Visitor User visitor, @RequestBody List<ExternalToken> list) throws IOException { @@ -195,7 +195,7 @@ public class Notifications { } @Deprecated - @RequestMapping(value = "/api/android/register", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/android/register", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public Status doAndroidRegister( @Visitor User visitor, @RequestParam(name = "regid") String regId) { @@ -204,7 +204,7 @@ public class Notifications { } @Deprecated - @RequestMapping(value = "/api/winphone/register", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/winphone/register", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public Status doWinphoneRegister( @Visitor User visitor, @RequestParam(name = "url") String regId) { diff --git a/src/main/java/com/juick/server/api/PM.java b/src/main/java/com/juick/server/api/PM.java index 6e6cdcac..4a408dce 100644 --- a/src/main/java/com/juick/server/api/PM.java +++ b/src/main/java/com/juick/server/api/PM.java @@ -55,7 +55,7 @@ public class PM { @Inject private WebApp webApp; - @RequestMapping(value = "/api/pm", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/pm", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public List<com.juick.Message> doGetPM( @Visitor User visitor, @RequestParam(required = false) String uname) { @@ -73,7 +73,7 @@ public class PM { return msgs; } - @RequestMapping(value = "/api/pm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/pm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public com.juick.Message doPostPM( @Visitor User visitor, @RequestParam String uname, @@ -105,7 +105,7 @@ public class PM { } throw new HttpBadRequestException(); } - @RequestMapping(value = "/api/groups_pms", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/groups_pms", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public PrivateChats doGetGroupsPMs( @Visitor User visitor, @RequestParam(defaultValue = "5") int cnt) { diff --git a/src/main/java/com/juick/server/api/Post.java b/src/main/java/com/juick/server/api/Post.java index 59bd05a7..10e19faf 100644 --- a/src/main/java/com/juick/server/api/Post.java +++ b/src/main/java/com/juick/server/api/Post.java @@ -67,7 +67,7 @@ public class Post { @Inject CommandsManager commandsManager; - @RequestMapping(value = "/api/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseStatus(value = HttpStatus.OK) public CommandResult doPostMessage( @Visitor User visitor, @@ -99,7 +99,7 @@ public class Post { return commandsManager.processCommand(visitor, body, attachmentFName); } - @RequestMapping(value = "/api/comment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/comment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public CommandResult doPostComment( @Visitor User visitor, @RequestParam(defaultValue = "0") int mid, diff --git a/src/main/java/com/juick/server/api/Tags.java b/src/main/java/com/juick/server/api/Tags.java index 2862d883..35f2bc66 100644 --- a/src/main/java/com/juick/server/api/Tags.java +++ b/src/main/java/com/juick/server/api/Tags.java @@ -38,7 +38,7 @@ public class Tags { @Inject private TagService tagService; - @RequestMapping(value = "/api/tags", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/tags", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public List<TagStats> tags( @Visitor User visitor, @RequestParam(required = false, defaultValue = "0") int user_id diff --git a/src/main/java/com/juick/server/api/Users.java b/src/main/java/com/juick/server/api/Users.java index 6d7c7a45..74a720d4 100644 --- a/src/main/java/com/juick/server/api/Users.java +++ b/src/main/java/com/juick/server/api/Users.java @@ -81,12 +81,12 @@ public class Users { @Inject private EmailManager emailManager; - @RequestMapping(value = "/api/auth", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/auth", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public String getAuthToken(@Visitor User visitor) { return userService.getHashByUID(visitor.getUid()); } - @RequestMapping(value = "/api/users", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/users", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public List<User> doGetUsers( @Visitor User visitor, @RequestParam(value = "uname", required = false) List<String> unames) { @@ -190,7 +190,7 @@ public class Users { } } - @RequestMapping(value = "/api/users/read", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/users/read", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public List<User> doGetUserRead( @Visitor User visitor, @RequestParam String uname) { @@ -214,7 +214,7 @@ public class Users { throw new HttpNotFoundException(); } - @RequestMapping(value = "/api/users/readers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/api/users/readers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public List<User> doGetUserReaders( @Visitor User visitor, @RequestParam String uname) { diff --git a/src/main/java/com/juick/server/api/activity/Profile.java b/src/main/java/com/juick/server/api/activity/Profile.java index 88c76a93..77945d6b 100644 --- a/src/main/java/com/juick/server/api/activity/Profile.java +++ b/src/main/java/com/juick/server/api/activity/Profile.java @@ -388,7 +388,7 @@ public class Profile { } return new ResponseEntity<>(CommandResult.fromString("Can not authenticate"), HttpStatus.UNAUTHORIZED); } - @PostMapping(value = "/u/", produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "/u/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public User fetchUser(@RequestParam URI uri) { return activityPubManager.personToUser(uri); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e9d9b77f..e89670fa 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -3,4 +3,3 @@ spring.jackson.default-property-inclusion=non_default spring.jackson.serialization.write-dates-as-timestamps=false spring.h2.console.enabled=true spring.datasource.platform=h2 -spring.http.encoding.force=true diff --git a/src/test/java/com/juick/FormatterTest.java b/src/test/java/com/juick/FormatterTest.java index 8a6bf83f..da9f5d26 100644 --- a/src/test/java/com/juick/FormatterTest.java +++ b/src/test/java/com/juick/FormatterTest.java @@ -39,13 +39,13 @@ public class FormatterTest { public void forAnyDateFormatterShouldReturnNotEmptyString() throws Exception { Instant ts = Instant.now(); - assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(emptyOrNullString())); - assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(emptyOrNullString())); + assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(isEmptyOrNullString())); + assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(isEmptyOrNullString())); ts = Instant.ofEpochMilli(RandomUtils.nextLong(1, Long.MAX_VALUE / 10000)); - assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(emptyOrNullString())); - assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(emptyOrNullString())); + assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(isEmptyOrNullString())); + assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(isEmptyOrNullString())); } @Test diff --git a/src/test/java/com/juick/MessageTest.java b/src/test/java/com/juick/MessageTest.java index 64d19e13..b4c5f4ab 100644 --- a/src/test/java/com/juick/MessageTest.java +++ b/src/test/java/com/juick/MessageTest.java @@ -129,20 +129,20 @@ public class MessageTest { public void tagsStringShouldBeEmptyIfNoTags() { Message message = new Message(); - assertThat(MessageUtils.getTagsString(message), is(emptyString())); + assertThat(MessageUtils.getTagsString(message), isEmptyString()); message.FriendsOnly = true; - assertThat(MessageUtils.getTagsString(message), is(emptyString())); + assertThat(MessageUtils.getTagsString(message), isEmptyString()); message.Hidden = true; message.ReadOnly = true; - assertThat(MessageUtils.getTagsString(message), is(emptyString())); + assertThat(MessageUtils.getTagsString(message), isEmptyString()); message.setTags(MessageUtils.parseTags(" ")); - assertThat(MessageUtils.getTagsString(message), is(emptyString())); + assertThat(MessageUtils.getTagsString(message), isEmptyString()); } @Test diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index e6c394d2..644ff096 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -504,7 +504,7 @@ public class ServerTests { get("/api/home") .with(httpBasic(ugnichName, ugnichPassword))) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$[0].mid", is(msg.getMid()))) .andExpect(jsonPath("$[0].timestamp", is(DateFormattersHolder.getMessageFormatterInstance().format(msg.getCreated())))) @@ -574,7 +574,7 @@ public class ServerTests { .param("uname", "ugnich") .param("uname", "freefd")) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$", hasSize(2))); } @@ -593,7 +593,7 @@ public class ServerTests { mockMvc.perform(get("/api/messages?"+ "hash=" + userIdHash)) .andDo(print()) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect((jsonPath("$[0].reactions[?(@.id == 3)].count", is(Collections.singletonList(1))))) .andExpect((jsonPath("$[0].reactions[?(@.id == 2)].count", @@ -601,7 +601,7 @@ public class ServerTests { mockMvc.perform(get("/api/reactions?hash=" + userIdHash)) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$.length()", is(7))); } @@ -660,7 +660,7 @@ public class ServerTests { String token = "123456"; ExternalToken registration = new ExternalToken(null, "apns", token, null); mockMvc.perform(put("/api/notifications").with(httpBasic(ugnichName, ugnichPassword)) - .contentType(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON_UTF8) .content(jsonMapper.writeValueAsBytes(Collections.singletonList(registration)))) .andExpect(status().isOk()); MvcResult result = mockMvc.perform(get("/api/notifications") @@ -685,10 +685,10 @@ public class ServerTests { public void notificationsTokensTest() throws Exception { List<ExternalToken> tokens = Collections.singletonList(new ExternalToken(null, "gcm", "123456", null)); mockMvc.perform(delete("/api/notifications").with(httpBasic(ugnichName, ugnichPassword)) - .contentType(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON_UTF8) .content(jsonMapper.writeValueAsBytes(tokens))).andExpect(status().isForbidden()); mockMvc.perform(delete("/api/notifications").with(httpBasic(juickName, juickPassword)) - .contentType(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON_UTF8) .content(jsonMapper.writeValueAsBytes(tokens))).andExpect(status().isOk()); } @Test @@ -1135,8 +1135,7 @@ public class ServerTests { .andExpect(status().isOk()) .andReturn(); List<Message> fromApi = jsonMapper.readValue(apiResult.getResponse().getContentAsString(), - new TypeReference<>() { - }); + new TypeReference<List<Message>>() {}); assertThat(fromApi.get(0).getTags(), is(tags)); } @Test @@ -1672,7 +1671,7 @@ public class ServerTests { public void appAssociationsTest() throws Exception { mockMvc.perform((get("/.well-known/apple-app-site-association"))) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$.webcredentials.apps[0]", is(appId))); } @Test @@ -1706,7 +1705,7 @@ public class ServerTests { @Test public void swaggerOutput() throws Exception { MvcResult result = mockMvc.perform(get("/v2/api-docs") - .accept(MediaType.APPLICATION_JSON)) + .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()) .andReturn(); String outputDir = System.getProperty("io.springfox.staticdocs.outputDir"); @@ -1835,9 +1834,9 @@ public class ServerTests { URI testuserkeyUri = URI.create("https://example.com/u/testuser#main-key"); MockRestServiceServer restServiceServer = MockRestServiceServer.createServer(apClient); restServiceServer.expect(times(3), requestTo(testuserUri)) - .andRespond(withSuccess(testuserResponseString, MediaType.APPLICATION_JSON)); + .andRespond(withSuccess(testuserResponseString, MediaType.APPLICATION_JSON_UTF8)); restServiceServer.expect(times(3), requestTo(testuserkeyUri)) - .andRespond(withSuccess(testuserResponseString, MediaType.APPLICATION_JSON)); + .andRespond(withSuccess(testuserResponseString, MediaType.APPLICATION_JSON_UTF8)); Person testuser = (Person)signatureManager.getContext(testuserUri).get(); Assert.assertThat(testuser.getPublicKey().getPublicKeyPem(), is(testKeystoreManager.getPublicKeyPem())); Instant now2 = Instant.now(); |