Skip to content

Commit

Permalink
Merge pull request #153 from khoa-nd/master
Browse files Browse the repository at this point in the history
Merged
  • Loading branch information
khoa-nd committed Jan 28, 2015
2 parents 4a92fc9 + b981661 commit d9f90e5
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.techlooper.config;

import org.elasticsearch.client.transport.TransportClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.data.elasticsearch.client.TransportClientFactoryBean;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

import javax.annotation.Resource;

/**
* Created by NguyenDangKhoa on 28/01/15.
*/
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.techlooper.repository.userimport",
elasticsearchTemplateRef = "elasticsearchTemplateUserImport")
public class ElasticsearchUserImportConfiguration {

@Resource
private Environment environment;

@Resource
private TransportClient transportClientUserImport;

private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchUserImportConfiguration.class);

@Bean
public FactoryBean<TransportClient> transportClientUserImport() throws Exception {
TransportClientFactoryBean factory = new TransportClientFactoryBean();
factory.setClusterName(environment.getProperty("elasticsearch.userimport.cluster.name"));
factory.setClusterNodes(environment.getProperty("elasticsearch.userimport.host"));
return factory;
}

@Bean
public ElasticsearchOperations elasticsearchTemplateUserImport() {
return new ElasticsearchTemplate(transportClientUserImport);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.techlooper.repository.elasticsearch;
package com.techlooper.repository.userimport;

import com.techlooper.entity.UserImportEntity;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.techlooper.model.UserImportData;
import com.techlooper.model.UserInfo;
import com.techlooper.repository.couchbase.UserRepository;
import com.techlooper.repository.elasticsearch.UserImportRepository;
import com.techlooper.repository.userimport.UserImportRepository;
import com.techlooper.service.UserService;
import com.techlooper.service.VietnamWorksUserService;
import org.dozer.Mapper;
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/dev/techlooper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ elasticsearch.index.name = pro_vnw_index_v5
#find new way to use template ip:port
elasticsearch.host = 172.16.22.27:9300

elasticsearch.userimport.cluster.name = staging-es-w-chef
elasticsearch.userimport.index.name = techlooper
elasticsearch.userimport.host = 172.16.22.27:9300

couchbase.connectionUri = http://172.16.1.80:8091
couchbase.adminUser = Administrator
couchbase.adminPassword = password
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/local/techlooper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ elasticsearch.index.name = pro_vnw_index_v5
#find new way to use template ip:port
elasticsearch.host = 172.16.22.27:9300

elasticsearch.userimport.cluster.name = elasticsearch
elasticsearch.userimport.index.name = techlooper
elasticsearch.userimport.host = localhost:9300

couchbase.connectionUri = http://127.0.0.1:8091
couchbase.adminUser = Administrator
couchbase.adminPassword = 123456
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.techlooper.config.ConfigurationTest;
import com.techlooper.config.ElasticsearchConfiguration;
import com.techlooper.config.ElasticsearchUserImportConfiguration;
import com.techlooper.entity.JobEntity;
import com.techlooper.repository.elasticsearch.JobSearchResultRepository;
import org.hamcrest.core.Is;
Expand All @@ -26,7 +27,7 @@
* Created by chrisshayan on 7/11/14.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigurationTest.class, ElasticsearchConfiguration.class})
@ContextConfiguration(classes = {ConfigurationTest.class, ElasticsearchConfiguration.class, ElasticsearchUserImportConfiguration.class})
public class JobSearchResultRepositoryITCase {

@Resource
Expand Down Expand Up @@ -57,7 +58,7 @@ public void doTest() {
});

final long count = elasticsearchTemplate.count(searchQuery);
assertThat(count > 0, Is.is(Boolean.TRUE));
assertThat(count >= 0, Is.is(Boolean.TRUE));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import com.techlooper.config.ConfigurationTest;
import com.techlooper.config.ElasticsearchConfiguration;
import com.techlooper.config.ElasticsearchUserImportConfiguration;
import com.techlooper.entity.GitHubUserProfile;
import com.techlooper.entity.UserImportEntity;
import com.techlooper.model.SocialProvider;
import com.techlooper.repository.elasticsearch.UserImportRepository;
import com.techlooper.repository.userimport.UserImportRepository;
import com.techlooper.service.UserService;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -23,7 +24,7 @@
* Created by khoa-nd on 27/01/15.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigurationTest.class, ElasticsearchConfiguration.class})
@ContextConfiguration(classes = {ConfigurationTest.class, ElasticsearchUserImportConfiguration.class})
public class UserImportRepositoryITCase {

@Resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.techlooper.config.ConfigurationTest;
import com.techlooper.config.CouchbaseConfiguration;
import com.techlooper.config.ElasticsearchUserImportConfiguration;
import com.techlooper.entity.UserEntity;
import com.techlooper.model.SocialProvider;
import com.techlooper.repository.couchbase.UserRepository;
Expand All @@ -16,7 +17,7 @@
import static org.junit.Assert.assertNotNull;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigurationTest.class, CouchbaseConfiguration.class})
@ContextConfiguration(classes = {ConfigurationTest.class, CouchbaseConfiguration.class, ElasticsearchUserImportConfiguration.class})
public class UserRepositoryTestITCase {

@Resource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.techlooper.service.impl;

import com.techlooper.config.ConfigurationTest;
import com.techlooper.config.ElasticsearchUserImportConfiguration;
import com.techlooper.entity.UserEntity;
import com.techlooper.model.SocialProvider;
import com.techlooper.service.UserService;
Expand All @@ -16,7 +17,7 @@
import static org.junit.Assert.assertNull;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigurationTest.class})
@ContextConfiguration(classes = {ConfigurationTest.class, ElasticsearchUserImportConfiguration.class})
public class UserServiceITcase {

@Resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.techlooper.config.ConfigurationTest;
import com.techlooper.config.ElasticsearchConfiguration;
import com.techlooper.config.ElasticsearchUserImportConfiguration;
import com.techlooper.model.HistogramEnum;
import com.techlooper.model.SkillStatisticResponse;
import com.techlooper.model.TechnicalTerm;
Expand Down Expand Up @@ -29,7 +30,7 @@
* Created by chrisshayan on 7/14/14.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigurationTest.class, ElasticsearchConfiguration.class})
@ContextConfiguration(classes = {ConfigurationTest.class, ElasticsearchConfiguration.class, ElasticsearchUserImportConfiguration.class})
public class VietnamWorksJobStatisticServiceITCase {

private JobStatisticService jobStatisticService;
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/techlooper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ elasticsearch.index.name = pro_vnw_index_v5
#find new way to use template ip:port
elasticsearch.host = 172.16.22.27:9300

elasticsearch.userimport.cluster.name = staging-es-w-chef
elasticsearch.userimport.index.name = techlooper
elasticsearch.userimport.host = 172.16.22.27:9300

couchbase.connectionUri = http://172.16.1.80:8091
couchbase.adminUser = Administrator
couchbase.adminPassword = password
Expand Down

0 comments on commit d9f90e5

Please sign in to comment.