From d8f9f16d16f4e2f7133de464ba8d3f6cc704bd00 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 17 Jan 2016 00:18:33 +0300 Subject: almost working messages api --- src/test/java/com/juick/tests/ApiTests.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/test/java/com/juick') 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()); } } -- cgit v1.2.3