From 4321b9255e0a3c342607f585d1f1763a7d5ae5c2 Mon Sep 17 00:00:00 2001 From: geek Date: Tue, 8 Aug 2017 17:51:46 +0900 Subject: [PATCH] test config --- .../java/com/loafle/overflow/spring/AppConfig.java | 6 ++---- .../overflow/module/member/dao/MemberDAOTest.java | 10 +++++----- .../module/member/service/MemberServiceTest.java | 9 ++++++--- src/test/resources/database.properties | 11 +++++++++++ src/test/resources/mail.properties | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 src/test/resources/database.properties create mode 100644 src/test/resources/mail.properties diff --git a/src/main/java/com/loafle/overflow/spring/AppConfig.java b/src/main/java/com/loafle/overflow/spring/AppConfig.java index e454293..7a0c8a2 100644 --- a/src/main/java/com/loafle/overflow/spring/AppConfig.java +++ b/src/main/java/com/loafle/overflow/spring/AppConfig.java @@ -1,10 +1,7 @@ package com.loafle.overflow.spring; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.*; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -13,6 +10,7 @@ import org.springframework.core.io.Resource; */ @Configuration @ComponentScan(basePackages = {"com.loafle.overflow"}, excludeFilters = @ComponentScan.Filter({Configuration.class})) +@Import({JdbcConfiguration.class, MailConfiguration.class}) @PropertySource({"classpath:database.properties","classpath:mail.properties"}) public class AppConfig { @Bean diff --git a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java index 8154f7a..cfe3c28 100644 --- a/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java +++ b/src/test/java/com/loafle/overflow/module/member/dao/MemberDAOTest.java @@ -2,14 +2,13 @@ package com.loafle.overflow.module.member.dao; import com.loafle.overflow.module.member.model.Member; import com.loafle.overflow.module.meta.model.MetaMemberStatus; -import com.loafle.overflow.spring.AppConfig; -import com.loafle.overflow.spring.JdbcConfiguration; -import com.loafle.overflow.spring.MailConfiguration; +import com.loafle.overflow.spring.*; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -17,9 +16,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * Created by geek on 17. 6. 28. */ -@Ignore +//@Ignore @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class}) +@ActiveProfiles("test") +@ContextConfiguration(classes = {AppConfig.class, AppConfigTest.class}) public class MemberDAOTest { @Autowired diff --git a/src/test/java/com/loafle/overflow/module/member/service/MemberServiceTest.java b/src/test/java/com/loafle/overflow/module/member/service/MemberServiceTest.java index f0c4dd9..6bab822 100644 --- a/src/test/java/com/loafle/overflow/module/member/service/MemberServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/member/service/MemberServiceTest.java @@ -3,12 +3,14 @@ package com.loafle.overflow.module.member.service; import com.loafle.overflow.module.member.model.Member; import com.loafle.overflow.module.meta.model.MetaMemberStatus; import com.loafle.overflow.spring.AppConfig; +import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.JdbcConfiguration; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -17,14 +19,15 @@ import java.util.Date; /** * Created by insanity on 17. 6. 28. */ -@Ignore +//@Ignore @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +@ActiveProfiles("test") +@ContextConfiguration(classes = {AppConfig.class, AppConfigTest.class}) public class MemberServiceTest { @Autowired MemberService memberService; - @Ignore + @Test public void regist() throws Exception { Member m = new Member(); diff --git a/src/test/resources/database.properties b/src/test/resources/database.properties new file mode 100644 index 0000000..0b6c454 --- /dev/null +++ b/src/test/resources/database.properties @@ -0,0 +1,11 @@ +datasource.url=jdbc:postgresql://192.168.1.209:5432/overflow +datasource.username=overflow +datasource.password=qwer5795 +datasource.driver-class-name=org.postgresql.Driver + +jpa.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +jpa.database=postgresql +jpa.hibernate.ddl-auto=create +#jpa.hibernate.ddl-auto=update +jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy +jpa.show-sql=true diff --git a/src/test/resources/mail.properties b/src/test/resources/mail.properties new file mode 100644 index 0000000..99f696d --- /dev/null +++ b/src/test/resources/mail.properties @@ -0,0 +1,14 @@ +# Naver SMTP +mail.host=smtp.worksmobile.com +mail.port=465 +mail.username=geek@loafle.com +mail.password=@loafle@5795 +mail.protocol=smtps + +mail.properties.mail.smtp.auth=true +mail.transport.protocol=smtp +mail.properties.mail.smtp.starttls.enable=true +mail.smtps.ssl.checkserveridentity=true +mail.smtps.ssl.trust=* + +