package test.hospital;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.alibaba.fastjson.JSONObject;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = { "classpath:app-context.xml"
// ,
// "classpath:app-datasource.xml",
// "classpath:app-tx.xml",
// "classpath:app-mail.xml"
})
public class BaseTest extends AbstractTransactionalJUnit4SpringContextTests {
protected MockHttpServletRequest request;
protected MockHttpSession session;
protected MockHttpServletResponse response;
protected MockMvc mockMvc;
@Autowired
private WebApplicationContext webApplicationContext;
@Before
public void setup() throws Exception {
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
session = new MockHttpSession();
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
protected void outPrint(Object obj) {
System.err.println(obj);
}
protected void outJson(Object obj) {
System.err.println(JSONObject.toJSONString(obj));
}
}