使用SpringJUnit4ClassRunner進行單元測試

package com.youwin.yws.services.impl;java

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;git

import javax.annotation.Resource;github

import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;spring

import com.github.pagehelper.PageInfo;
import com.youwin.yws.services.o2o.IAppCommonService;sql

/**
 *
 * 類 名: ConsultantSuperrvisorServiceTest
 * 描 述: 描述類完成的主要功能
 * 做 者: sunqc@youwinedu.com
 * 創 建:2016年2月25日
 * 版 本:
 *
 * 歷 史: (版本) 做者 時間 註釋
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/applicationContext-test.xml")
@Transactional  
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
public class AppCommonServiceTest{apache

    /**
     * Instance to test.
     */
    @Autowired
    private IAppCommonService service;session

    /**
     * The session.
     */
    @Resource(name = "sqlSessionTemplate")
    private SqlSession session;
    
     
    @Before
    public void before() throws Exception {
        session.clearCache();
         
    }app

    /**
     * Tears down.
     * @throws Exception if anything goes wrong
     */
    @After
    public void after() throws Exception {
         
    }
     
    /**
     *
     * 描 述:簽約量[區分不一樣角色]
     * 做 者: sunqc@youwinedu.com
     * 歷 史: (版本) 做者 時間 註釋
     * @throws Exception
     */
    //@Test
    public void testGetTeacherCourseCommentForPageByFilter() throws Exception {
        Map<String,Object> filter = new HashMap<String, Object>();
        Integer pageNum = 1;
        Integer pageSize = 10;
        Long teacherId = 70283L;
        filter.put("pageNum", pageNum);
        filter.put("pageSize", pageSize);
        filter.put("teacherId", teacherId);
        PageInfo<Map<String, Object>> result = service.getTeacherCourseCommentForPageByFilter(filter);
        System.out.println("over");
        //System.out.println(result.getList());
        //Assert.notNull(result.get("qianYue"));
        
    }
    
    /** 描 述:
     * 做 者: sunqc@youwinedu.com
     * 歷 史: (版本) 做者 時間 註釋
     * @param args
     */
    public static void main(String[] args) {
        
       BigDecimal totalMoney1 = new BigDecimal("0.0");
       BigDecimal totalMoney = totalMoney1.divide(new BigDecimal("1"),2);
//       BigDecimal totalMoney = new BigDecimal("0E-10");
       System.out.println(totalMoney.compareTo(BigDecimal.ZERO) == 0);
       System.out.println(totalMoney.toEngineeringString());
       System.out.println(totalMoney.doubleValue());
       System.out.println(totalMoney);
       
         //問題:如何將數字41.261505067E8轉換成字符串4126150506.7 ?
         // 解決方案:
         /*double dValue=41.261505067E8;
         DecimalFormat df=new DecimalFormat("#.#");
         String result=df.format(dValue);
         System.out.println(result);*/
       
       String peroidString = "2015.1--";
       String reString = peroidString.substring(peroidString.indexOf("--")+2);
       System.out.println(StringUtils.isEmpty(reString));
       System.out.println(peroidString +"至今");
    }
}ide

相關文章
相關標籤/搜索