import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import com.ncss.bean.auditmana.WebsiteQuery;
import com.ncss.bean.logmana.LogSubmitBlackQuery;
import com.ncss.util.DateUtil;
public class ReportServiceTest {
private static ReportService f=null;
// @BeforeClass
public static void sss() throws Exception
{
//编译项目的跟路径
String string = "D:/Tomcat 6.0/webapps/ncss/WEB-INF/classes/config/";
//匹配配置文件
String s1 = string+"*Context.xml";
ApplicationContext ac = new FileSystemXmlApplicationContext(s1);
f = (ReportService) ac.getBean("reportService");
}
// @Test
public void testHourHostStart() {
//写要测试的方法
// WebsiteQuery websitequery =new WebsiteQuery();
// websitequery.setEndTime("2011-07-06");
// websitequery.setHostName("a.com");
// f.hourHostStart(websitequery);
//
// f.doment("a.com");
LogSubmitBlackQuery logsubmitblackquery = new LogSubmitBlackQuery();
logsubmitblackquery.setStartTime("2011-07-05 00:00:00");
logsubmitblackquery.setEndTime("2011-07-15 23:59:59");
f.badSitesToDeterminePublic(logsubmitblackquery, 1);
}
junit4

本文展示了一个使用Spring框架和JUnit进行单元测试的例子。通过加载配置文件,获取所需的Bean,并调用其方法来验证功能是否按预期工作。该示例涉及了依赖注入、配置文件加载及具体业务逻辑测试。
1431

被折叠的 条评论
为什么被折叠?



