From 6eea1c7436e6c5b92022a005352c3c9d183b5848 Mon Sep 17 00:00:00 2001 From: Phuong H Date: Fri, 9 Jan 2015 16:03:29 +0700 Subject: [PATCH] Fix test case --- .../techlooper/config/ConfigurationTest.java | 135 ++++++++++-------- src/test/resources/logback.groovy | 4 - src/test/resources/techlooper.properties | 4 +- 3 files changed, 75 insertions(+), 68 deletions(-) diff --git a/src/test/java/com/techlooper/config/ConfigurationTest.java b/src/test/java/com/techlooper/config/ConfigurationTest.java index a26a57acc..639907937 100644 --- a/src/test/java/com/techlooper/config/ConfigurationTest.java +++ b/src/test/java/com/techlooper/config/ConfigurationTest.java @@ -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; @@ -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; @@ -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; + } } diff --git a/src/test/resources/logback.groovy b/src/test/resources/logback.groovy index 3abc88e0f..8119c5b95 100644 --- a/src/test/resources/logback.groovy +++ b/src/test/resources/logback.groovy @@ -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"]) \ No newline at end of file diff --git a/src/test/resources/techlooper.properties b/src/test/resources/techlooper.properties index 63bdb59e1..ef0de2007 100644 --- a/src/test/resources/techlooper.properties +++ b/src/test/resources/techlooper.properties @@ -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/ \ No newline at end of file +webapp.resource.location = /public/ + +core.textEncryptor.password = XR3hBZnJ6gLH \ No newline at end of file