aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-02-22 14:26:09 +0300
committerGravatar Vitaly Takmazov2018-02-22 14:26:09 +0300
commit445efce2abf8310acc5b7bb652feef7968c86a2a (patch)
tree04ef8712a014a2f75b8bd96cf68c8bd3a5af6dc6
parentb74b92f124f6d31a7ee48deaf48f0604886836f8 (diff)
default database is h2
-rw-r--r--juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java1
-rw-r--r--juick-server-jdbc/build.gradle2
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java178
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/configuration/SearchConfiguration.java1
-rw-r--r--juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java196
-rw-r--r--juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPServer.java8
-rw-r--r--juick-server/src/main/java/com/juick/server/configuration/ApiSecurityConfig.java2
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java3
-rw-r--r--juick-www/src/main/java/com/juick/service/CloudflareCache.java6
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/SapeConfiguration.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/SocialLogin.java14
-rw-r--r--juick-www/src/test/java/com/juick/www/WebAppTests.java2
14 files changed, 195 insertions, 225 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java
index b557cfc7..27ff3162 100644
--- a/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java
+++ b/juick-notifications/src/main/java/com/juick/components/configuration/NotificationsAppConfiguration.java
@@ -16,7 +16,6 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@Configuration
@EnableWebMvc
@EnableScheduling
-@PropertySource("classpath:juick.conf")
@ComponentScan(basePackages = "com.juick.components.service")
@Import({ APNSConfiguration.class, MPNSConfiguration.class,
GCMConfiguration.class, JuickServerWebsocketConfiguration.class})
diff --git a/juick-server-jdbc/build.gradle b/juick-server-jdbc/build.gradle
index 7c1b2b1f..2ffb1642 100644
--- a/juick-server-jdbc/build.gradle
+++ b/juick-server-jdbc/build.gradle
@@ -33,13 +33,13 @@ dependencies {
compile 'org.imgscalr:imgscalr-lib:4.2'
+ providedCompile 'com.h2database:h2:1.4.196'
providedCompile "javax.servlet:javax.servlet-api:3.1.0"
providedRuntime 'mysql:mysql-connector-java:5.1.40'
providedRuntime "commons-fileupload:commons-fileupload:1.3.3"
testCompile project(path: ':juick-core', configuration: 'testArtifacts')
- testCompile 'com.h2database:h2:1.4.196'
testCompile "junit:junit:${rootProject.junitVersion}"
testCompile "org.hamcrest:hamcrest-all:${rootProject.hamcrestVersion}"
testCompile "org.mockito:mockito-core:${rootProject.mockitoVersion}"
diff --git a/juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java b/juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java
index c728b527..03009565 100644
--- a/juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java
+++ b/juick-server-jdbc/src/main/java/com/juick/configuration/DataConfiguration.java
@@ -37,16 +37,16 @@ import java.util.List;
*/
@Configuration
@EnableTransactionManagement
-@PropertySource(value = {"classpath:juick.conf"})
+@PropertySource(value = {"classpath:juick.conf"}, ignoreResourceNotFound = true)
@ComponentScan(basePackages = {"com.juick.service"})
public class DataConfiguration implements TransactionManagementConfigurer {
- @Value("${datasource_driver:com.mysql.jdbc.Driver}")
+ @Value("${datasource_driver:org.h2.Driver}")
private String datasourceDriver;
- @Value("${datasource_url:}")
+ @Value("${datasource_url:jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;mode=MYSQL}")
private String datasourceUrl;
- @Value("${datasource_user:}")
+ @Value("${datasource_user:juick}")
private String datasourceUser;
- @Value("${datasource_password:}")
+ @Value("${datasource_password:secret}")
private String datasourcePassword;
// NOTE: The close() method will be called automatically with default @Bean settings
@@ -76,9 +76,173 @@ public class DataConfiguration implements TransactionManagementConfigurer {
}
@Bean
- @DependsOn("dataSource")
public JdbcTemplate jdbcTemplate() {
- return new JdbcTemplate(dataSource());
+ JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource());
+ if (datasourceDriver.equals("org.h2.Driver")) {
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS bl_users (user_id int(10) unsigned NOT NULL, " +
+ "bl_user_id int(10) unsigned NOT NULL, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP )");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS bl_tags (user_id int(10) unsigned NOT NULL, " +
+ "tag_id int(10) unsigned NOT NULL)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS wl_users (user_id int(10) unsigned NOT NULL, " +
+ "wl_user_id int(10) unsigned NOT NULL, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP )");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS messages (" +
+ "message_id int(10) unsigned NOT NULL AUTO_INCREMENT," +
+ "user_id int(10) unsigned NOT NULL," +
+ "place_id int(10) unsigned DEFAULT NULL," +
+ "lat decimal(10,7) DEFAULT NULL," +
+ "lon decimal(10,7) DEFAULT NULL," +
+ "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
+ "replies smallint(5) unsigned NOT NULL DEFAULT 0," +
+ "maxreplyid smallint(5) unsigned NOT NULL DEFAULT 0," +
+ "privacy tinyint(4) NOT NULL DEFAULT '1'," +
+ "attach nchar(3) check (attach in ('jpg', 'mp4', 'png'))," +
+ "readonly tinyint(1) NOT NULL DEFAULT 0," +
+ "likes smallint(6) NOT NULL DEFAULT 0," +
+ "`popular` tinyint(4) NOT NULL DEFAULT '0'," +
+ "hidden tinyint(3) unsigned NOT NULL DEFAULT 0," +
+ "updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS messages_tags (" +
+ "message_id int(10) unsigned NOT NULL," +
+ "tag_id int(10) unsigned NOT NULL" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS users (" +
+ "id int(10) unsigned NOT NULL AUTO_INCREMENT," +
+ "nick char(64) NOT NULL," +
+ "`lang` enum('en','ru','fr','fa','__') NOT NULL DEFAULT '__'," +
+ "passw char(32) NOT NULL," +
+ "banned tinyint(3) unsigned NOT NULL DEFAULT 0, " +
+ "PRIMARY KEY(id), UNIQUE KEY(nick))");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS useroptions (" +
+ "user_id int(10) unsigned NOT NULL," +
+ "jnotify tinyint(1) NOT NULL DEFAULT 1," +
+ "`repliesview` tinyint(1) NOT NULL DEFAULT '0'," +
+ "subscr_active tinyint(1) NOT NULL DEFAULT 1)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS subscr_users (" +
+ "user_id int(10) unsigned NOT NULL," +
+ "suser_id int(10) unsigned NOT NULL," +
+ "jid char(64) DEFAULT NULL," +
+ "active tinyint(1) NOT NULL DEFAULT 1," +
+ "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, " +
+ "PRIMARY KEY (suser_id, user_id))");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS subscr_messages (" +
+ "message_id int(10) unsigned NOT NULL," +
+ "suser_id int(10) unsigned NOT NULL, PRIMARY KEY (suser_id, message_id))");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS subscr_tags (" +
+ "tag_id int(10) unsigned NOT NULL," +
+ "suser_id int(10) unsigned NOT NULL, PRIMARY KEY (suser_id, tag_id))");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS messages_txt (" +
+ "message_id int(10) unsigned NOT NULL," +
+ "tags varchar(255)," +
+ "repliesby varchar(96)," +
+ "txt TEXT)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS tags(" +
+ "tag_id int(10) unsigned NOT NULL AUTO_INCREMENT," +
+ "synonym_id int(10) unsigned DEFAULT NULL," +
+ "name char(48) NOT NULL," +
+ "top tinyint(1) unsigned NOT NULL DEFAULT 0," +
+ "stat_messages int(10) unsigned NOT NULL DEFAULT 0," +
+ "stat_users smallint(5) unsigned NOT NULL DEFAULT 0)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS jids(" +
+ "user_id int(10) unsigned NOT NULL AUTO_INCREMENT," +
+ "jid char(64) NOT NULL," +
+ "active tinyint(1) unsigned NOT NULL DEFAULT '1'," +
+ "loginhash char(36) unsigned DEFAULT NULL," +
+ "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS replies (" +
+ "message_id int(10) unsigned NOT NULL," +
+ "reply_id smallint(5) unsigned NOT NULL," +
+ "user_id int(10) unsigned NOT NULL," +
+ "replyto smallint(5) unsigned NOT NULL DEFAULT 0," +
+ "ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," +
+ "attach nchar(3) check (attach in ('jpg', 'mp4', 'png'))," +
+ "txt text)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS twitter(" +
+ "user_id int(10) unsigned NOT NULL," +
+ "access_token char(64) NOT NULL," +
+ "access_token_secret char(64) NOT NULL," +
+ "crosspost tinyint(1) unsigned NOT NULL DEFAULT '1'," +
+ "uname char(64) NOT NULL," +
+ "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS facebook(" +
+ "user_id int(10) unsigned NOT NULL," +
+ "fb_id int(20) unsigned NOT NULL," +
+ "access_token char(255) NOT NULL," +
+ "loginhash char(36) NOT NULL," +
+ "crosspost tinyint(1) unsigned NOT NULL DEFAULT '1'," +
+ "fb_name char(64) NOT NULL," +
+ "fb_link char(64) NOT NULL," +
+ "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS vk(" +
+ "user_id int(10) unsigned NOT NULL," +
+ "vk_id int(20) unsigned NOT NULL," +
+ "access_token char(128) NOT NULL," +
+ "loginhash char(36) NOT NULL," +
+ "crosspost tinyint(1) unsigned NOT NULL DEFAULT '1'," +
+ "vk_name char(64) NOT NULL," +
+ "vk_link char(64) NOT NULL," +
+ "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS emails (" +
+ " user_id int(10) unsigned NOT NULL," +
+ " email char(64) NOT NULL," +
+ " subscr_hour tinyint(4) DEFAULT NULL," +
+ " PRIMARY KEY (email)" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS favorites (" +
+ " user_id int(10) unsigned NOT NULL," +
+ " message_id int(10) unsigned NOT NULL," +
+ " ts datetime NOT NULL" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS logins (" +
+ " user_id int(10) unsigned NOT NULL," +
+ " hash char(16) NOT NULL," +
+ " PRIMARY KEY (user_id)" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `telegram` (" +
+ " `user_id` int(10) unsigned DEFAULT NULL," +
+ " `tg_id` bigint(20) NOT NULL," +
+ " `tg_name` char(64) NOT NULL," +
+ " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," +
+ " `loginhash` char(36) DEFAULT NULL" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `pm` (" +
+ " `user_id` int(10) unsigned NOT NULL," +
+ " `user_id_to` int(10) unsigned NOT NULL," +
+ " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," +
+ " `txt` text NOT NULL" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `pm_streams` (" +
+ " `user_id` int(10) unsigned NOT NULL," +
+ " `user_id_to` int(10) unsigned NOT NULL," +
+ " `lastmessage` datetime NOT NULL," +
+ " `lastview` datetime DEFAULT NULL," +
+ " `unread` smallint(5) unsigned NOT NULL DEFAULT '0'" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `android` (" +
+ " `user_id` int(10) unsigned NOT NULL," +
+ " `regid` char(255) NOT NULL," +
+ " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `ios` (" +
+ " `user_id` int(10) unsigned NOT NULL," +
+ " `token` char(64) NOT NULL," +
+ " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `winphone` (" +
+ " `user_id` int(10) unsigned NOT NULL," +
+ " `url` char(255) NOT NULL," +
+ " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `tags_ignore` (" +
+ " `tag_id` int(10) unsigned NOT NULL" +
+ ")");
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS `users_subscr` (" +
+ " `user_id` int(10) unsigned NOT NULL," +
+ " `cnt` smallint(5) unsigned NOT NULL DEFAULT '0'," +
+ " PRIMARY KEY (`user_id`)" +
+ ")");
+ }
+ return jdbcTemplate;
}
@Bean
diff --git a/juick-server-jdbc/src/main/java/com/juick/configuration/SearchConfiguration.java b/juick-server-jdbc/src/main/java/com/juick/configuration/SearchConfiguration.java
index e3c244d8..70461c91 100644
--- a/juick-server-jdbc/src/main/java/com/juick/configuration/SearchConfiguration.java
+++ b/juick-server-jdbc/src/main/java/com/juick/configuration/SearchConfiguration.java
@@ -33,7 +33,6 @@ import javax.annotation.Resource;
* Created by aalexeev on 11/18/16.
*/
@Configuration
-@PropertySource(value = {"classpath:juick.conf"})
public class SearchConfiguration {
@Resource
private Environment env;
diff --git a/juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java b/juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java
index 08b5b787..eac98354 100644
--- a/juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java
+++ b/juick-server-jdbc/src/test/java/com/juick/configuration/RepositoryConfiguration.java
@@ -37,202 +37,6 @@ import java.util.List;
@Configuration
@ComponentScan(basePackages = "com.juick.service")
public class RepositoryConfiguration {
-
- @Bean
- public DataSource dataSource() {
- DriverManagerDataSource dataSource = new DriverManagerDataSource();
- dataSource.setDriverClassName("org.h2.Driver");
- dataSource.setUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;mode=MYSQL");
-
- return dataSource;
- }
-
- @Bean
- public JdbcTemplate jdbcTemplate() {
- JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource());
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS bl_users (user_id int(10) unsigned NOT NULL, " +
- "bl_user_id int(10) unsigned NOT NULL, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP )");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS bl_tags (user_id int(10) unsigned NOT NULL, " +
- "tag_id int(10) unsigned NOT NULL)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS wl_users (user_id int(10) unsigned NOT NULL, " +
- "wl_user_id int(10) unsigned NOT NULL, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP )");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS messages (" +
- "message_id int(10) unsigned NOT NULL AUTO_INCREMENT," +
- "user_id int(10) unsigned NOT NULL," +
- "place_id int(10) unsigned DEFAULT NULL," +
- "lat decimal(10,7) DEFAULT NULL," +
- "lon decimal(10,7) DEFAULT NULL," +
- "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
- "replies smallint(5) unsigned NOT NULL DEFAULT 0," +
- "maxreplyid smallint(5) unsigned NOT NULL DEFAULT 0," +
- "privacy tinyint(4) NOT NULL DEFAULT '1'," +
- "attach nchar(3) check (attach in ('jpg', 'mp4', 'png'))," +
- "readonly tinyint(1) NOT NULL DEFAULT 0," +
- "likes smallint(6) NOT NULL DEFAULT 0," +
- "`popular` tinyint(4) NOT NULL DEFAULT '0'," +
- "hidden tinyint(3) unsigned NOT NULL DEFAULT 0," +
- "updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" +
- ")");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS messages_tags (" +
- "message_id int(10) unsigned NOT NULL," +
- "tag_id int(10) unsigned NOT NULL" +
- ")");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS users (" +
- "id int(10) unsigned NOT NULL AUTO_INCREMENT," +
- "nick char(64) NOT NULL," +
- "`lang` enum('en','ru','fr','fa','__') NOT NULL DEFAULT '__'," +
- "passw char(32) NOT NULL," +
- "banned tinyint(3) unsigned NOT NULL DEFAULT 0, " +
- "PRIMARY KEY(id), UNIQUE KEY(nick))");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS useroptions (" +
- "user_id int(10) unsigned NOT NULL," +
- "jnotify tinyint(1) NOT NULL DEFAULT 1," +
- "`repliesview` tinyint(1) NOT NULL DEFAULT '0'," +
- "subscr_active tinyint(1) NOT NULL DEFAULT 1)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS subscr_users (" +
- "user_id int(10) unsigned NOT NULL," +
- "suser_id int(10) unsigned NOT NULL," +
- "jid char(64) DEFAULT NULL," +
- "active tinyint(1) NOT NULL DEFAULT 1," +
- "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, " +
- "PRIMARY KEY (suser_id, user_id))");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS subscr_messages (" +
- "message_id int(10) unsigned NOT NULL," +
- "suser_id int(10) unsigned NOT NULL, PRIMARY KEY (suser_id, message_id))");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS subscr_tags (" +
- "tag_id int(10) unsigned NOT NULL," +
- "suser_id int(10) unsigned NOT NULL, PRIMARY KEY (suser_id, tag_id))");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS messages_txt (" +
- "message_id int(10) unsigned NOT NULL," +
- "tags varchar(255)," +
- "repliesby varchar(96)," +
- "txt TEXT)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS tags(" +
- "tag_id int(10) unsigned NOT NULL AUTO_INCREMENT," +
- "synonym_id int(10) unsigned DEFAULT NULL," +
- "name char(48) NOT NULL," +
- "top tinyint(1) unsigned NOT NULL DEFAULT 0," +
- "stat_messages int(10) unsigned NOT NULL DEFAULT 0," +
- "stat_users smallint(5) unsigned NOT NULL DEFAULT 0)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS jids(" +
- "user_id int(10) unsigned NOT NULL AUTO_INCREMENT," +
- "jid char(64) NOT NULL," +
- "active tinyint(1) unsigned NOT NULL DEFAULT '1'," +
- "loginhash char(36) unsigned DEFAULT NULL," +
- "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS replies (" +
- "message_id int(10) unsigned NOT NULL," +
- "reply_id smallint(5) unsigned NOT NULL," +
- "user_id int(10) unsigned NOT NULL," +
- "replyto smallint(5) unsigned NOT NULL DEFAULT 0," +
- "ts timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," +
- "attach nchar(3) check (attach in ('jpg', 'mp4', 'png'))," +
- "txt text)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS twitter(" +
- "user_id int(10) unsigned NOT NULL," +
- "access_token char(64) NOT NULL," +
- "access_token_secret char(64) NOT NULL," +
- "crosspost tinyint(1) unsigned NOT NULL DEFAULT '1'," +
- "uname char(64) NOT NULL," +
- "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS facebook(" +
- "user_id int(10) unsigned NOT NULL," +
- "fb_id int(20) unsigned NOT NULL," +
- "access_token char(255) NOT NULL," +
- "loginhash char(36) NOT NULL," +
- "crosspost tinyint(1) unsigned NOT NULL DEFAULT '1'," +
- "fb_name char(64) NOT NULL," +
- "fb_link char(64) NOT NULL," +
- "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS vk(" +
- "user_id int(10) unsigned NOT NULL," +
- "vk_id int(20) unsigned NOT NULL," +
- "access_token char(128) NOT NULL," +
- "loginhash char(36) NOT NULL," +
- "crosspost tinyint(1) unsigned NOT NULL DEFAULT '1'," +
- "vk_name char(64) NOT NULL," +
- "vk_link char(64) NOT NULL," +
- "ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)");
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS emails (" +
- " user_id int(10) unsigned NOT NULL," +
- " email char(64) NOT NULL," +
- " subscr_hour tinyint(4) DEFAULT NULL," +
- " PRIMARY KEY (email)" +
- ")");
- jdbcTemplate.execute("CREATE TABLE favorites (" +
- " user_id int(10) unsigned NOT NULL," +
- " message_id int(10) unsigned NOT NULL," +
- " ts datetime NOT NULL" +
- ")");
- jdbcTemplate.execute("CREATE TABLE logins (" +
- " user_id int(10) unsigned NOT NULL," +
- " hash char(16) NOT NULL," +
- " PRIMARY KEY (user_id)" +
- ")");
- jdbcTemplate.execute("CREATE TABLE `telegram` (" +
- " `user_id` int(10) unsigned DEFAULT NULL," +
- " `tg_id` bigint(20) NOT NULL," +
- " `tg_name` char(64) NOT NULL," +
- " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," +
- " `loginhash` char(36) DEFAULT NULL" +
- ")");
- jdbcTemplate.execute("CREATE TABLE `pm` (" +
- " `user_id` int(10) unsigned NOT NULL," +
- " `user_id_to` int(10) unsigned NOT NULL," +
- " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," +
- " `txt` text NOT NULL" +
- ")");
- jdbcTemplate.execute("CREATE TABLE `pm_streams` (" +
- " `user_id` int(10) unsigned NOT NULL," +
- " `user_id_to` int(10) unsigned NOT NULL," +
- " `lastmessage` datetime NOT NULL," +
- " `lastview` datetime DEFAULT NULL," +
- " `unread` smallint(5) unsigned NOT NULL DEFAULT '0'" +
- ")");
- jdbcTemplate.execute("CREATE TABLE `android` (" +
- " `user_id` int(10) unsigned NOT NULL," +
- " `regid` char(255) NOT NULL," +
- " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" +
- ")");
- jdbcTemplate.execute("CREATE TABLE `ios` (" +
- " `user_id` int(10) unsigned NOT NULL," +
- " `token` char(64) NOT NULL," +
- " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" +
- ")");
- jdbcTemplate.execute("CREATE TABLE `winphone` (" +
- " `user_id` int(10) unsigned NOT NULL," +
- " `url` char(255) NOT NULL," +
- " `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" +
- ")");
- jdbcTemplate.execute("CREATE TABLE `tags_ignore` (" +
- " `tag_id` int(10) unsigned NOT NULL" +
- ")");
- jdbcTemplate.execute("CREATE TABLE `users_subscr` (" +
- " `user_id` int(10) unsigned NOT NULL," +
- " `cnt` smallint(5) unsigned NOT NULL DEFAULT '0'," +
- " PRIMARY KEY (`user_id`)" +
- ")");
- return jdbcTemplate;
- }
-
- @Bean
- public SearchService emptySearchService() {
- return new SearchService() {
- @Override
- public void setMaxResult(int maxResult) {
- }
-
- @Override
- public List<Integer> searchInAllMessages(String searchString, int messageIdBefore) {
- return Collections.emptyList();
- }
-
- @Override
- public List<Integer> searchByStringAndUser(String searchString, int userId, int messageIdBefore) {
- return Collections.emptyList();
- }
- };
- }
@Bean
public ImagesService imagesService() {
return new MockImagesService();
diff --git a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java
index b6bfab61..8c54cae1 100644
--- a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java
+++ b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java
@@ -20,6 +20,7 @@ package com.juick.service;
import com.juick.Message;
import com.juick.Tag;
import com.juick.User;
+import com.juick.configuration.DataConfiguration;
import com.juick.configuration.RepositoryConfiguration;
import com.juick.server.helpers.AnonymousUser;
import com.juick.server.helpers.TagStats;
@@ -47,7 +48,7 @@ import static org.junit.Assert.assertEquals;
* Created by aalexeev on 11/25/16.
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = RepositoryConfiguration.class)
+@ContextConfiguration(classes = { DataConfiguration.class, RepositoryConfiguration.class })
public class MessageServiceTest extends AbstractJUnit4SpringContextTests {
@Inject
private MessagesService messagesService;
diff --git a/juick-server/src/main/java/com/juick/server/XMPPServer.java b/juick-server/src/main/java/com/juick/server/XMPPServer.java
index 358860f7..9f0a8183 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPServer.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPServer.java
@@ -67,13 +67,13 @@ public class XMPPServer implements ConnectionListener, AutoCloseable {
private Jid jid;
@Value("${s2s_port:5269}")
private int s2sPort;
- @Value("${keystore}")
+ @Value("${keystore:juick.p12}")
public String keystore;
- @Value("${keystore_password}")
+ @Value("${keystore_password:secret}")
public String keystorePassword;
- @Value("${broken_ssl_hosts}")
+ @Value("${broken_ssl_hosts:}")
public String[] brokenSSLhosts;
- @Value("${banned_hosts}")
+ @Value("${banned_hosts:}")
public String[] bannedHosts;
private final List<ConnectionIn> inConnections = new CopyOnWriteArrayList<>();
diff --git a/juick-server/src/main/java/com/juick/server/configuration/ApiSecurityConfig.java b/juick-server/src/main/java/com/juick/server/configuration/ApiSecurityConfig.java
index 58fd4231..f074f9c7 100644
--- a/juick-server/src/main/java/com/juick/server/configuration/ApiSecurityConfig.java
+++ b/juick-server/src/main/java/com/juick/server/configuration/ApiSecurityConfig.java
@@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit;
@Configuration
@EnableWebSecurity
public class ApiSecurityConfig extends WebSecurityConfigurerAdapter {
- @Value("${auth_remember_me_key}")
+ @Value("${auth_remember_me_key:secret}")
private String rememberMeKey;
@Inject
private UserService userService;
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index b1848986..c9c47a39 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -24,6 +24,7 @@ import com.juick.ExternalToken;
import com.juick.Message;
import com.juick.Tag;
import com.juick.User;
+import com.juick.configuration.DataConfiguration;
import com.juick.configuration.RepositoryConfiguration;
import com.juick.server.EmailManager;
import com.juick.server.XMPPBot;
@@ -76,7 +77,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* Created by vitalyster on 25.11.2016.
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {ApiAppConfiguration.class, ApiSecurityConfig.class, RepositoryConfiguration.class})
+@ContextConfiguration(classes = {ApiAppConfiguration.class, ApiSecurityConfig.class, DataConfiguration.class, RepositoryConfiguration.class})
@TestPropertySource(properties = {"broken_ssl_hosts=localhost,serverstorageisfull.tld"})
@WebAppConfiguration
public class ServerTests extends AbstractJUnit4SpringContextTests {
diff --git a/juick-www/src/main/java/com/juick/service/CloudflareCache.java b/juick-www/src/main/java/com/juick/service/CloudflareCache.java
index 00e1f684..5046f692 100644
--- a/juick-www/src/main/java/com/juick/service/CloudflareCache.java
+++ b/juick-www/src/main/java/com/juick/service/CloudflareCache.java
@@ -18,11 +18,11 @@ import java.util.Collections;
public class CloudflareCache implements ApplicationListener<UserUpdatedEvent> {
private static final Logger logger = LoggerFactory.getLogger(CloudflareCache.class);
- @Value("${cloudflare_auth_email}")
+ @Value("${cloudflare_auth_email:email@example.com}")
private String authEmail;
- @Value("${cloudflare_api_key}")
+ @Value("${cloudflare_api_key:secret}")
private String apiKey;
- @Value("${cloudflare_zone_id}")
+ @Value("${cloudflare_zone_id:zoneid}")
private String zoneId;
private final static String baseUri = "https://api.cloudflare.com/client/v4";
@Override
diff --git a/juick-www/src/main/java/com/juick/www/configuration/SapeConfiguration.java b/juick-www/src/main/java/com/juick/www/configuration/SapeConfiguration.java
index 006c159c..68ff28d2 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/SapeConfiguration.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/SapeConfiguration.java
@@ -27,7 +27,7 @@ import ru.sape.Sape;
*/
@Configuration
public class SapeConfiguration {
- @Value("${sape_user}")
+ @Value("${sape_user:secret}")
private String token;
@Bean
diff --git a/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
index bde85ee4..19329dad 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
@@ -41,7 +41,7 @@ import javax.annotation.Resource;
*/
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
- @Value("${auth_remember_me_key}")
+ @Value("${auth_remember_me_key:secret}")
private String rememberMeKey;
@Value("${web_domain:localhost}")
private String webDomain;
diff --git a/juick-www/src/main/java/com/juick/www/controllers/SocialLogin.java b/juick-www/src/main/java/com/juick/www/controllers/SocialLogin.java
index 64d59b9f..674be157 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/SocialLogin.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/SocialLogin.java
@@ -66,9 +66,9 @@ public class SocialLogin {
private static final Logger logger = LoggerFactory.getLogger(SocialLogin.class);
- @Value("${facebook_appid}")
+ @Value("${facebook_appid:appid}")
private String FACEBOOK_APPID;
- @Value("${facebook_secret}")
+ @Value("${facebook_secret:secret}")
private String FACEBOOK_SECRET;
private static final String FACEBOOK_REDIRECT = "http://juick.com/_fblogin";
private static final String VK_REDIRECT = "http://juick.com/_vklogin";
@@ -77,15 +77,15 @@ public class SocialLogin {
private ObjectMapper jsonMapper;
private ServiceBuilder facebookBuilder, twitterBuilder, vkBuilder;
- @Value("${twitter_consumer_key}")
+ @Value("${twitter_consumer_key:appid}")
private String twitterConsumerKey;
- @Value("${twitter_consumer_secret}")
+ @Value("${twitter_consumer_secret:secret}")
private String twitterConsumerSecret;
- @Value("${vk_appid}")
+ @Value("${vk_appid:appid}")
private String VK_APPID;
- @Value("${vk_secret}")
+ @Value("${vk_secret:secret}")
private String VK_SECRET;
- @Value("${telegram_token}")
+ @Value("${telegram_token:secret}")
private String telegramToken;
@Inject
diff --git a/juick-www/src/test/java/com/juick/www/WebAppTests.java b/juick-www/src/test/java/com/juick/www/WebAppTests.java
index 60e0fae6..e3ac53cf 100644
--- a/juick-www/src/test/java/com/juick/www/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/www/WebAppTests.java
@@ -26,6 +26,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.juick.Message;
import com.juick.Tag;
import com.juick.User;
+import com.juick.configuration.DataConfiguration;
import com.juick.configuration.RepositoryConfiguration;
import com.juick.service.ImagesService;
import com.juick.service.MessagesService;
@@ -88,6 +89,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = {
+ DataConfiguration.class,
WwwServletConfiguration.class, WwwAppConfiguration.class, SapeConfiguration.class,
RepositoryConfiguration.class, WebSecurityConfig.class
})