diff options
Diffstat (limited to 'src/test/java/com/juick')
-rw-r--r-- | src/test/java/com/juick/tests/ApiTests.java | 1 | ||||
-rw-r--r-- | src/test/java/com/juick/tests/JsonTests.java | 109 |
2 files changed, 56 insertions, 54 deletions
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java index 01cdd4c5..f111ffc7 100644 --- a/src/test/java/com/juick/tests/ApiTests.java +++ b/src/test/java/com/juick/tests/ApiTests.java @@ -27,6 +27,7 @@ public class ApiTests { dataSource.setUrl("jdbc:mysql://localhost/juick?autoReconnect=true&user=" + conf.getProperty("mysql_username", "") + "&password=" + conf.getProperty("mysql_password", "")); + jdbc = new JdbcTemplate(dataSource); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/test/java/com/juick/tests/JsonTests.java b/src/test/java/com/juick/tests/JsonTests.java index 99d9ca46..496dea24 100644 --- a/src/test/java/com/juick/tests/JsonTests.java +++ b/src/test/java/com/juick/tests/JsonTests.java @@ -1,54 +1,55 @@ -package com.juick.tests;
-
-import com.juick.json.MessageSerializer;
-import com.juick.server.MessagesQueries;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Properties;
-import org.apache.commons.dbcp2.BasicDataSource;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-public class JsonTests {
-
- JdbcTemplate jdbc;
- @Before
- public void setupConnection() {
- Properties conf = new Properties();
- try {
- conf.load(new FileInputStream("/etc/juick/api.conf"));
- BasicDataSource dataSource = new BasicDataSource();
- dataSource.setDriverClassName("com.mysql.jdbc.Driver");
- dataSource.setUrl("jdbc:mysql://localhost/juick?autoReconnect=true&user="
- + conf.getProperty("mysql_username", "")
- + "&password=" + conf.getProperty("mysql_password", ""));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void CompareSerializers() {
- List<Integer> mids = MessagesQueries.getMyFeed(jdbc, 3694, 2799786);
- MessageSerializer messageSerializer = new MessageSerializer();
- if (mids != null && !mids.isEmpty()) {
- List<com.juick.Message> msgs = MessagesQueries.getMessages(jdbc, mids);
- if (msgs != null && !msgs.isEmpty()) {
- String json = messageSerializer.serializeList(msgs);
- try {
- String data = new String(Files.readAllBytes(Paths.get("original.json")), "UTF-8");
- Assert.assertEquals("json should match", data, json);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
- }
- }
-}
\ No newline at end of file +package com.juick.tests; + +import com.juick.json.MessageSerializer; +import com.juick.server.MessagesQueries; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; +import java.util.Properties; +import org.apache.commons.dbcp2.BasicDataSource; +import org.springframework.jdbc.core.JdbcTemplate; + +public class JsonTests { + + JdbcTemplate jdbc; + @Before + public void setupConnection() { + Properties conf = new Properties(); + try { + conf.load(new FileInputStream("/etc/juick/api.conf")); + BasicDataSource dataSource = new BasicDataSource(); + dataSource.setDriverClassName("com.mysql.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://localhost/juick?autoReconnect=true&user=" + + conf.getProperty("mysql_username", "") + + "&password=" + conf.getProperty("mysql_password", "")); + jdbc = new JdbcTemplate(dataSource); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + public void CompareSerializers() { + List<Integer> mids = MessagesQueries.getMyFeed(jdbc, 3694, 2799786); + MessageSerializer messageSerializer = new MessageSerializer(); + if (mids != null && !mids.isEmpty()) { + List<com.juick.Message> msgs = MessagesQueries.getMessages(jdbc, mids); + if (msgs != null && !msgs.isEmpty()) { + String json = messageSerializer.serializeList(msgs); + try { + String data = new String(Files.readAllBytes(Paths.get("original.json")), "UTF-8"); + Assert.assertEquals("json should match", data, json); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + } +} |