/**
* feifei
* 2013-8-20 下午02:01:13
*/
package com.teamsun.test.JunitAnnocation;
import java.sql.SQLException;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author feifei
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:jdbc-context.xml")
public class testDB {
@Resource
private JdbcTemplate jdbcTemplate;
@Before
public void init(){
System.out.println("------------init-------------");
}
@Test
public void testDb() throws SQLException{
System.out.println("jdbcTemplate==>"+jdbcTemplate.getDataSource().getConnection().toString());
}
@Test
public void testRequest(){
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("GET");
request.setRequestURI("");
request.addParameter("id", "1");
}
@After
public void after(){
System.out.println("----------------after---------------");
}
}
* feifei
* 2013-8-20 下午02:01:13
*/
package com.teamsun.test.JunitAnnocation;
import java.sql.SQLException;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author feifei
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:jdbc-context.xml")
public class testDB {
@Resource
private JdbcTemplate jdbcTemplate;
@Before
public void init(){
System.out.println("------------init-------------");
}
@Test
public void testDb() throws SQLException{
System.out.println("jdbcTemplate==>"+jdbcTemplate.getDataSource().getConnection().toString());
}
@Test
public void testRequest(){
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("GET");
request.setRequestURI("");
request.addParameter("id", "1");
}
@After
public void after(){
System.out.println("----------------after---------------");
}
}