Skip to content

Commit

Permalink
Fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
phuonghuynh committed Jan 9, 2015
1 parent 806ef64 commit 6eea1c7
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 68 deletions.
135 changes: 72 additions & 63 deletions src/test/java/com/techlooper/config/ConfigurationTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.techlooper.config;

import com.techlooper.converter.LocaleConverter;
import com.techlooper.repository.JobSearchAPIConfigurationRepository;
import com.techlooper.repository.JsonConfigRepository;
import com.techlooper.repository.TechnicalTermRepository;
Expand All @@ -9,11 +10,12 @@
import com.techlooper.service.impl.JobQueryBuilderImpl;
import com.techlooper.service.impl.UserServiceImpl;
import com.techlooper.service.impl.VietnamWorksJobSearchService;
import com.techlooper.converter.LocaleConverter;
import org.dozer.DozerBeanMapper;
import org.dozer.Mapper;
import org.dozer.loader.api.BeanMappingBuilder;
import org.dozer.loader.api.FieldsMappingOptions;
import org.jasypt.util.text.BasicTextEncryptor;
import org.jasypt.util.text.TextEncryptor;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
Expand All @@ -32,69 +34,76 @@

@Configuration
@PropertySources({
@PropertySource("classpath:techlooper.properties"),
@PropertySource("classpath:secret.properties")})
@PropertySource("classpath:techlooper.properties"),
@PropertySource("classpath:secret.properties")})
@Import(CouchbaseConfiguration.class)
public class ConfigurationTest implements ApplicationContextAware {

private ApplicationContext applicationContext;

@Resource
private Environment environment;

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}

@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}

@Bean
public JobSearchAPIConfigurationRepository apiConfiguration() {
return new JobSearchAPIConfigurationRepository();
}

@Bean
public JobSearchService jobSearchService() {
return new VietnamWorksJobSearchService();
}

@Bean
public TechnicalTermRepository technicalTermRepository() {
return new TechnicalTermRepository();
}

@Bean
public JsonConfigRepository jsonConfigRepository() {
return new JsonConfigRepository();
}

@Bean
public JobQueryBuilder jobQueryBuilder() {
return new JobQueryBuilderImpl();
}

@Bean
public UserService userService() {
return new UserServiceImpl();
}

@Bean
public Mapper dozerBeanMapper() {
DozerBeanMapper dozerBeanMapper = new DozerBeanMapper();
BeanMappingBuilder builder = new BeanMappingBuilder() {
protected void configure() {
mapping(FacebookProfile.class, com.techlooper.entity.FacebookProfile.class).fields("locale", "locale", FieldsMappingOptions.customConverter(LocaleConverter.class));
}
};
dozerBeanMapper.addMapping(builder);
return dozerBeanMapper;
}

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
private ApplicationContext applicationContext;

@Resource
private Environment environment;

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}

@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}

@Bean
public JobSearchAPIConfigurationRepository apiConfiguration() {
return new JobSearchAPIConfigurationRepository();
}

@Bean
public JobSearchService jobSearchService() {
return new VietnamWorksJobSearchService();
}

@Bean
public TechnicalTermRepository technicalTermRepository() {
return new TechnicalTermRepository();
}

@Bean
public JsonConfigRepository jsonConfigRepository() {
return new JsonConfigRepository();
}

@Bean
public JobQueryBuilder jobQueryBuilder() {
return new JobQueryBuilderImpl();
}

@Bean
public UserService userService() {
return new UserServiceImpl();
}

@Bean
public Mapper dozerBeanMapper() {
DozerBeanMapper dozerBeanMapper = new DozerBeanMapper();
BeanMappingBuilder builder = new BeanMappingBuilder() {
protected void configure() {
mapping(FacebookProfile.class, com.techlooper.entity.FacebookProfile.class).fields("locale", "locale", FieldsMappingOptions.customConverter(LocaleConverter.class));
}
};
dozerBeanMapper.addMapping(builder);
return dozerBeanMapper;
}

@Bean
public TextEncryptor textEncryptor() {
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword(environment.getProperty("core.textEncryptor.password"));
return textEncryptor;
}

public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
4 changes: 0 additions & 4 deletions src/test/resources/logback.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@ appender("CONSOLE", ConsoleAppender) {
}
}

logger("org.springframework", DEBUG, ["CONSOLE"])
logger("com.couchbase", ERROR, ["CONSOLE"])
logger("net.spy.memcached", ERROR, ["CONSOLE"])

root(ERROR, ["CONSOLE"])
4 changes: 3 additions & 1 deletion src/test/resources/techlooper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ couchbase.bucketPassword = 123456
# see the cron configuration table here: http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
scheduled.cron = 0 0/5 * * * *

webapp.resource.location = /public/
webapp.resource.location = /public/

core.textEncryptor.password = XR3hBZnJ6gLH

0 comments on commit 6eea1c7

Please sign in to comment.