import junit.framework.TestCase;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import com.gt.langhamplace.service.FetchService;
import java.io.UnsupportedEncodingException;
public class TestFetchService extends TestCase { //TestCase是spring 里面的一个测试抽象类,该方法实现JUNIT
public ApplicationContext ctx = null;
private static String[] CONFIG_FILES = {"*.xml"};
protected void setUp() throws Exception {
ctx = new FileSystemXmlApplicationContext(CONFIG_FILES);
//或者 ctx=new ClassPathXmlApplicationContext(CONFIG_FILES);读取classpath的文件
}
public void testFetchServiceImpl() throws UnsupportedEncodingException, JSONException {
FetchService fetchService = (FetchService) ctx.getBean("fetchService");//去容器里面去对象回来
}
}