aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-17 00:18:33 +0300
committerGravatar Vitaly Takmazov2016-01-17 00:18:33 +0300
commitd8f9f16d16f4e2f7133de464ba8d3f6cc704bd00 (patch)
tree3583ee665032f722a06d8d65a131b74447d9af94 /src/test/java/com/juick
parent261d89f398bde4aeb6d84c2ae789a90732793272 (diff)
almost working messages api
Diffstat (limited to 'src/test/java/com/juick')
-rw-r--r--src/test/java/com/juick/tests/ApiTests.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java
index 83afb62e..7b0264c0 100644
--- a/src/test/java/com/juick/tests/ApiTests.java
+++ b/src/test/java/com/juick/tests/ApiTests.java
@@ -4,6 +4,7 @@ import com.juick.Message;
import com.juick.Tag;
import com.juick.User;
import com.juick.server.MessagesQueries;
+import com.juick.server.SubscriptionsQueries;
import com.juick.server.TagQueries;
import com.juick.server.UserQueries;
import junit.framework.Assert;
@@ -28,6 +29,7 @@ public class ApiTests {
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:~/test");
jdbc = new JdbcTemplate(dataSource);
+ jdbc.execute("DROP ALL OBJECTS DELETE FILES");
jdbc.execute("CREATE TABLE bl_users (user_id int(10) unsigned NOT NULL, " +
"bl_user_id int(10) unsigned NOT NULL, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP )");
jdbc.execute("CREATE TABLE messages (" +
@@ -64,6 +66,9 @@ public class ApiTests {
"jid char(64) DEFAULT NULL," +
"active tinyint(1) NOT NULL DEFAULT 1," +
"ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
+ jdbc.execute("CREATE TABLE subscr_messages (" +
+ "message_id int(10) unsigned NOT NULL," +
+ "suser_id int(10) unsigned NOT NULL)");
jdbc.execute("CREATE TABLE messages_txt (" +
"message_id int(10) unsigned NOT NULL," +
"tags varchar(255)," +
@@ -85,10 +90,6 @@ public class ApiTests {
"attach nchar(3) check (attach in ('jpg', 'mp4', 'png'))," +
"txt text)");
}
- @After
- public void tearDown() {
- jdbc.execute("DROP ALL OBJECTS DELETE FILES");
- }
@Test
@@ -121,6 +122,8 @@ public class ApiTests {
org.junit.Assert.assertEquals("weather", msg3.Tags.get(0));
org.junit.Assert.assertEquals(ugnich.getUID(), UserQueries.checkPassword(jdbc, ugnich.getUName(), "x"));
org.junit.Assert.assertEquals(-1, UserQueries.checkPassword(jdbc, ugnich.getUName(), "xy"));
+ SubscriptionsQueries.subscribeMessage(jdbc, msg.getMID(), ugnich.getUID());
+ Assert.assertEquals(1, SubscriptionsQueries.getUsersSubscribedToComments(jdbc, msg.getMID(), user.getUID()).size());
}
}