diff options
author | Vitaly Takmazov | 2016-01-15 12:51:21 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-01-15 12:51:21 +0300 |
commit | 690b3ea447a7a2434ecf1d210e5f5ef89ce27f04 (patch) | |
tree | 2e96768580044b2144b38e423f0fe20f73f522d8 /src/test/java/com/juick | |
parent | 5c207f65b0cafbaa0cbdae72a5a485cf7aa62556 (diff) |
spring-jdbc WIP
Diffstat (limited to 'src/test/java/com/juick')
-rw-r--r-- | src/test/java/com/juick/tests/ApiTests.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java new file mode 100644 index 00000000..01cdd4c5 --- /dev/null +++ b/src/test/java/com/juick/tests/ApiTests.java @@ -0,0 +1,40 @@ +package com.juick.tests; + +import com.juick.User; +import com.juick.server.UserQueries; +import junit.framework.Assert; +import org.apache.commons.dbcp2.BasicDataSource; +import org.junit.Before; +import org.junit.Test; +import org.springframework.jdbc.core.JdbcTemplate; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; + +/** + * Created by vt on 14.01.2016. + */ +public class ApiTests { + 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 userTests() { + User user = UserQueries.getUserByUID(jdbc, 3694); + Assert.assertEquals("it should be me", "vt", user.UName); + } +} |