aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/juick/rss/LegacyRSS.java15
-rw-r--r--src/test/java/com/juick/tests/ApiTests.java11
2 files changed, 14 insertions, 12 deletions
diff --git a/src/test/java/com/juick/rss/LegacyRSS.java b/src/test/java/com/juick/rss/LegacyRSS.java
index 1d6ef151..220f00cb 100644
--- a/src/test/java/com/juick/rss/LegacyRSS.java
+++ b/src/test/java/com/juick/rss/LegacyRSS.java
@@ -19,26 +19,21 @@ package com.juick.rss;
import com.juick.Message;
import com.juick.Tag;
-import com.juick.server.MessagesQueries;
-import com.juick.server.UserQueries;
import com.juick.util.DateFormattersHolder;
import com.juick.util.MessageUtils;
-import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
-import java.util.Properties;
/**
* @author ugnich
@@ -61,7 +56,7 @@ public class LegacyRSS {
int hours = NumberUtils.toInt(request.getParameter("hours"), 0);
if (hours > 0 && hours < 13) {
List<Integer> mids = getLastMessages(hours);
- List<Message> msgs = MessagesQueries.getMessages(sql, mids);
+ List<Message> msgs = Collections.emptyList(); //MessagesQueries.getMessages(sql, mids);
responseMessages(response, 0, null, msgs);
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
@@ -75,11 +70,11 @@ public class LegacyRSS {
}
} else if (uri.matches("^/[a-zA-Z0-9\\-]{2,16}/blog$")) {
String uname = uri.substring(1, uri.length() - 5);
- int uid = UserQueries.getUIDbyName(sql, uname);
+ int uid = 0; // UserQueries.getUIDbyName(sql, uname);
if (uid > 0) {
- List<Integer> mids = MessagesQueries.getUserBlog(sql, uid, 0, 0);
+ List<Integer> mids = Collections.emptyList(); //MessagesQueries.getUserBlog(sql, uid, 0, 0);
if (!mids.isEmpty()) {
- List<Message> msgs = MessagesQueries.getMessages(sql, mids);
+ List<Message> msgs = Collections.emptyList();// MessagesQueries.getMessages(sql, mids);
responseMessages(response, uid, uname, msgs);
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java
index 53a8fd7c..c1a1bb35 100644
--- a/src/test/java/com/juick/tests/ApiTests.java
+++ b/src/test/java/com/juick/tests/ApiTests.java
@@ -74,6 +74,11 @@ public class ApiTests {
}
@Bean
+ public PageTemplates templates() {
+ return new PageTemplates();
+ }
+
+ @Bean
public PlatformTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource());
}
@@ -124,6 +129,8 @@ public class ApiTests {
JdbcTemplate jdbcTemplate;
@Inject
JuickProtocol juickProtocol;
+ @Inject
+ PageTemplates templates;
@Mock
ProtocolListener listener;
@@ -144,7 +151,7 @@ public class ApiTests {
assertEquals("yo", msg.getText());
Calendar calendar = Calendar.getInstance();
calendar.setTime(msg.getDate());
- assertEquals(2016, calendar.get(Calendar.YEAR));
+ assertEquals(2017, calendar.get(Calendar.YEAR));
User me = msg.getUser();
assertEquals("mmmme", me.getName());
assertEquals("mmmme", messagesService.getMessageAuthor(mid).getName());
@@ -177,7 +184,7 @@ public class ApiTests {
assertNotEquals("db tags should be escaped", dbTagName, htmlTag.getName());
assertEquals("object tags should unescaped", htmlTag.getName(), StringEscapeUtils.unescapeHtml4(dbTagName));
assertEquals("template should encode escaped tag in url and show escaped tag in name",
- "<a href=\"/tag/%3E_%3C\" rel=\"nofollow\">&gt;_&lt;</a>", PageTemplates.formatTags(Collections.singletonList(htmlTagStats)));
+ "<a href=\"/tag/%3E_%3C\" rel=\"nofollow\">&gt;_&lt;</a>", templates.formatTags(Collections.singletonList(htmlTagStats)));
}
@Test