aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/java/com/juick/tests/JsonTests.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/test/java/com/juick/tests/JsonTests.java b/src/test/java/com/juick/tests/JsonTests.java
index 35854171..99d9ca46 100644
--- a/src/test/java/com/juick/tests/JsonTests.java
+++ b/src/test/java/com/juick/tests/JsonTests.java
@@ -10,41 +10,35 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import org.apache.commons.dbcp2.BasicDataSource;
+import org.springframework.jdbc.core.JdbcTemplate;
public class JsonTests {
- Connection sql;
-
+ JdbcTemplate jdbc;
@Before
public void setupConnection() {
Properties conf = new Properties();
try {
conf.load(new FileInputStream("/etc/juick/api.conf"));
- Class.forName("com.mysql.jdbc.Driver");
- sql = DriverManager.getConnection("jdbc:mysql://localhost/juick?autoReconnect=true&user="
+ 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();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
}
}
@Test
public void CompareSerializers() {
- List<Integer> mids = MessagesQueries.getMyFeed(sql, 3694, 2799786);
+ List<Integer> mids = MessagesQueries.getMyFeed(jdbc, 3694, 2799786);
MessageSerializer messageSerializer = new MessageSerializer();
if (mids != null && !mids.isEmpty()) {
- List<com.juick.Message> msgs = MessagesQueries.getMessages(sql, mids);
+ List<com.juick.Message> msgs = MessagesQueries.getMessages(jdbc, mids);
if (msgs != null && !msgs.isEmpty()) {
String json = messageSerializer.serializeList(msgs);
try {