실행 결과는 Connection 객체가 만들어지는 것을 확인할 수 있어야 함.

package test;

import java.sql.Connection;

import javax.inject.Inject;
import javax.sql.DataSource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/spring/**/*.xml"})
public class DataSourceTest {
	

	@Inject
	private DataSource ds;
	
	@Test
	public void testConnection() throws Exception{
		
		try (Connection con = ds.getConnection()){
			System.out.println(con);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}


반응형

+ Recent posts