aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/test/java/com/juick')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index d3654e90..86daff1f 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -18,7 +18,6 @@
package com.juick.server.tests;
import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gargoylesoftware.htmlunit.CookieManager;
@@ -38,9 +37,9 @@ import com.juick.server.api.activity.model.activities.Create;
import com.juick.server.api.activity.model.activities.Delete;
import com.juick.server.api.activity.model.activities.Follow;
import com.juick.server.api.activity.model.activities.Undo;
-import com.juick.server.api.activity.model.objects.Mention;
import com.juick.server.api.activity.model.objects.Note;
import com.juick.server.api.activity.model.objects.Person;
+import com.juick.server.api.webfinger.model.Account;
import com.juick.server.util.HttpUtils;
import com.juick.server.util.ImageUtils;
import com.juick.server.xmpp.helpers.XMPPStatus;
@@ -68,17 +67,16 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.core.io.ClassPathResource;
import org.springframework.http.*;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
-import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
-import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import org.w3c.dom.Document;
@@ -1432,6 +1430,8 @@ public class ServerTests {
.andExpect(jsonPath("$.links[0].href", is("http://localhost:8080/u/ugnich")));
mockMvc.perform(get("/.well-known/webfinger?resource=acct:durov@localhost"))
.andExpect(status().isNotFound());
+ Person ugnich = (Person) signatureManager.discoverPerson("ugnich@juick.com").get();
+ assertThat(ugnich.getName(), is(ugnichName));
}
@Test
public void userProfileAndBlogShouldBeExposedAsActivityStream() throws Exception {
@@ -1445,7 +1445,7 @@ public class ServerTests {
String.format("message %d", i), null, null))
.collect(Collectors.toCollection(ArrayDeque::new)).descendingIterator());
List<Integer> midsPage = mids.stream().limit(20).collect(Collectors.toList());
- mockMvc.perform(get("/u/ugnich/blog").accept(Context.ACTIVITY_JSON_MEDIA_TYPE))
+ mockMvc.perform(get("/u/ugnich/blog").accept(Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE))
.andExpect(status().isOk())
.andExpect(jsonPath("$.orderedItems", hasSize(20)))
.andExpect(jsonPath("$.next", is("http://localhost:8080/u/ugnich/blog?before=" + midsPage.get(midsPage.size() - 1))));
@@ -1699,19 +1699,19 @@ public class ServerTests {
}
@Test
public void ActivityDeserialization() throws IOException {
- String followJsonStr = IOUtils.toString(URI.create("classpath:follow.json"), StandardCharsets.UTF_8);
+ String followJsonStr = IOUtils.toString(new ClassPathResource("follow.json").getURI(), StandardCharsets.UTF_8);
Follow follow = (Follow)jsonMapper.readValue(followJsonStr, Context.class);
- String personJsonStr = IOUtils.toString(URI.create("classpath:person.json"), StandardCharsets.UTF_8);
+ String personJsonStr = IOUtils.toString(new ClassPathResource("person.json").getURI(), StandardCharsets.UTF_8);
Person person = (Person)jsonMapper.readValue(personJsonStr, Context.class);
- String undoJsonStr = IOUtils.toString(URI.create("classpath:undo.json"), StandardCharsets.UTF_8);
+ String undoJsonStr = IOUtils.toString(new ClassPathResource("undo.json").getURI(), StandardCharsets.UTF_8);
Undo undo = jsonMapper.readValue(undoJsonStr, Undo.class);
String undoFollower = (String)((Map)undo.getObject()).get("object");
- String createJsonStr = IOUtils.toString(URI.create("classpath:create.json"), StandardCharsets.UTF_8);
+ String createJsonStr = IOUtils.toString(new ClassPathResource("create.json").getURI(), StandardCharsets.UTF_8);
Create create = jsonMapper.readValue(createJsonStr, Create.class);
Map<String, Object> note = (Map<String, Object>) create.getObject();
Map<String, Object> attachmentObj = (Map<String, Object> )((List<Object>) note.get("attachment")).get(0);
String attachment = attachmentObj != null ? (String)attachmentObj.get("url") : StringUtils.EMPTY;
- String deleteJsonStr = IOUtils.toString(URI.create("classpath:delete.json"), StandardCharsets.UTF_8);
+ String deleteJsonStr = IOUtils.toString(new ClassPathResource("delete.json").getURI(), StandardCharsets.UTF_8);
Delete delete = jsonMapper.readValue(deleteJsonStr, Delete.class);
int mid = messagesService.createMessage(ugnich.getUid(), "YO", "", null);
User extUser = new User();
@@ -1725,8 +1725,9 @@ public class ServerTests {
Message replyToExt = messagesService.getReply(mid, rid2);
Note replyNote = activityPubManager.makeNote(replyToExt);
assertThat(replyNote.getInReplyTo(), equalTo(extMessageUri));
- String noteStr = IOUtils.toString(URI.create("classpath:mention.json"), StandardCharsets.UTF_8);
+ String noteStr = IOUtils.toString(new ClassPathResource("mention.json").getURI(), StandardCharsets.UTF_8);
Note create2 = jsonMapper.readValue(noteStr, Note.class);
+ jsonMapper.readValue(IOUtils.toString(new ClassPathResource("webfinger.json").getURI(), StandardCharsets.UTF_8), Account.class);
}
@Test
public void activitySerialization() throws Exception {