일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- java
- CentOS
- error
- laravel
- larravel
- curl
- 안드로이드
- tomcat
- properties
- input
- junit
- File
- html
- JSON
- Android
- Linux
- 리눅스
- Spring
- ajax
- 와일드카드
- SeLinux
- DB
- NetBeans
- php
- 이클립스
- javascript
- 정규식
- MySQL
- jquery
- 톰캣
- Today
- Total
합쭈기 programming
jUnit DB 테스트 본문
spring xml 참조를 위해 spring-test를 추가한다.
pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
view 테스트는 제외 했으니까 test/resource에 간략화된 설정 xml을 추가한다.
servlet.-test.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
<annotation-driven />
<task:annotation-driven />
<aop:aspectj-autoproxy/>
<context:component-scan base-package="{패키지}" />
</beans:beans>
mybatis-test.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="mybatis.lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="{url}" />
<property name="username" value="{username}" />
<property name="password" value="{password}" />
</bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocations" value="{sql config xml}" />
<property name="lobHandler" ref="mybatis.lobHandler"/>
</bean>
</beans>
url 에러 시 '&' 다음에 amp; 추가
※ properties 참조 안되니까 박아넣음..
test에 @Runwith 셋팅
DatabasesTest.java
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:/spring/servlet-test.xml",
"classpath:/spring/mybatis-test.xml"})
public class DatabasesTest {
@test
public void testDB(){
{test code}
}
}
'Java > Spring' 카테고리의 다른 글
log4j 로그 출력이 안될때 (0) | 2015.06.10 |
---|---|
log4j path 설정 (0) | 2015.06.07 |
tiles 와일드카드 적용할때 (0) | 2015.06.04 |
이클립스 - DBIO Search (0) | 2015.05.19 |
이클립스 플러그인 - JVM explorer (0) | 2015.05.19 |