ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲欧美日本精品,樱花在线免费观看,午夜精品免费视频http://www.aygfsteel.com/stevenjohn/category/53242.html那些青春的岁æœ?/description>zh-cnMon, 06 May 2013 11:59:56 GMTMon, 06 May 2013 11:59:56 GMT60JMOCK2.6 ‹¹‹è¯•¾cÕd’ŒæŽ¥å£http://www.aygfsteel.com/stevenjohn/archive/2013/05/06/398851.htmlabinabinMon, 06 May 2013 04:42:00 GMThttp://www.aygfsteel.com/stevenjohn/archive/2013/05/06/398851.htmlhttp://www.aygfsteel.com/stevenjohn/comments/398851.htmlhttp://www.aygfsteel.com/stevenjohn/archive/2013/05/06/398851.html#Feedback0http://www.aygfsteel.com/stevenjohn/comments/commentRss/398851.htmlhttp://www.aygfsteel.com/stevenjohn/services/trackbacks/398851.html

package com.abin.lee.mock.jmock;

/**
 * Created with IntelliJ IDEA.
 * User: abin
 * Date: 13-5-6
 * Time: 下午12:23
 * To change this template use File | Settings | File Templates.
 */
public interface UserService {
    public String getMessage(String message);
}





package com.abin.lee.mock.jmock;

/**
 * Created with IntelliJ IDEA.
 * User: abin
 * Date: 13-5-6
 * Time: 下午12:24
 * To change this template use File | Settings | File Templates.
 */
public class UserServiceImpl implements UserService {
    @Override
    public String getMessage(String message) {
        String result="";
        result="hello "+message;
        return result;
    }
}





package com.abin.lee.mock.jmock;

import junit.framework.TestCase;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * Created with IntelliJ IDEA.
 * User: abin
 * Date: 13-5-6
 * Time: 下午12:29
 * To change this template use File | Settings | File Templates.
 */
public class UserManageTest {
    @Test
    public void testUserManage(){
        Mockery mockery= new Mockery();
        final UserService userService=mockery.mock(UserService.class);
        final String message="abin";
        final String expectValue="hello abin";
         mockery.checking(new Expectations(){{
             oneOf(userService).getMessage(message);
             will(returnValue(expectValue));
         }});
        String actual=userService.getMessage(message);
        System.out.println("actual="+actual);
        TestCase.assertEquals(expectValue,actual);
        mockery.assertIsSatisfied();
    }
}








½W¬äºŒéƒ¨åˆ†åQšJMOCK‹¹‹è¯•普通类

package com.abin.lee.mock.jmock;

/**
 * Created with IntelliJ IDEA.
 * User: abin
 * Date: 13-5-6
 * Time: 下午12:43
 * To change this template use File | Settings | File Templates.
 */
public class UserManage {
    public String getMessage(String message){
       String result="hello "+message;
        System.out.println("result="+result);
        return result;
    }
}

 






package com.abin.lee.mock.jmock;

import junit.framework.TestCase;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.Test;

/**
 * Created with IntelliJ IDEA.
 * User: abin
 * Date: 13-5-6
 * Time: 下午12:47
 * To change this template use File | Settings | File Templates.
 */
public class UserManageTest {
    @Test
    public void testUserManage(){
        Mockery mockery=new Mockery();
        mockery.setImposteriser(ClassImposteriser.INSTANCE);
        final UserManage userManage=mockery.mock(UserManage.class);
        final String message="abin";
        final String expectValue="hello abin";
        mockery.checking(new Expectations(){{
            oneOf(userManage).getMessage(message);
            will(returnValue(expectValue));
        }});
        String expect=userManage.getMessage(message);
        System.out.println("expect="+expect);
        TestCase.assertEquals(expectValue,expect);
        mockery.assertIsSatisfied();
    }
}









]]>
Jmock 初步学习(f¨¤n)用例åQˆä¸€åQ?/title><link>http://www.aygfsteel.com/stevenjohn/archive/2013/04/23/398262.html</link><dc:creator>abin</dc:creator><author>abin</author><pubDate>Tue, 23 Apr 2013 03:29:00 GMT</pubDate><guid>http://www.aygfsteel.com/stevenjohn/archive/2013/04/23/398262.html</guid><wfw:comment>http://www.aygfsteel.com/stevenjohn/comments/398262.html</wfw:comment><comments>http://www.aygfsteel.com/stevenjohn/archive/2013/04/23/398262.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/stevenjohn/comments/commentRss/398262.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/stevenjohn/services/trackbacks/398262.html</trackback:ping><description><![CDATA[<div>//UserDao.java<br /> <p>package com.abin.lee.jmock;</p> <p>/**<br /> * Created with IntelliJ IDEA.<br /> * User: abin<br /> * Date: 13-4-23<br /> * Time: 上午11:07<br /> * To change this template use File | Settings | File Templates.<br /> */<br />public interface UserDao {<br />    public String getMessage(String message);<br />}<br /></p><br /><br /><br /><br />//UserService.java<br /> <p>package com.abin.lee.jmock;</p> <p>/**<br /> * Created with IntelliJ IDEA.<br /> * User: abin<br /> * Date: 13-4-23<br /> * Time: 上午11:06<br /> * To change this template use File | Settings | File Templates.<br /> */<br />public class UserService {<br />   private UserDao userDao;</p> <p>   public String findMessage(String message){<br />       return this.userDao.getMessage(message);<br />   }</p> <p>    public void setUserDao(UserDao userDao){<br />        this.userDao=userDao;<br />    }<br />}<br /></p><br /><br /><br /><br />//UserManageTest.java<br /> <p>package com.abin.lee.jmock;</p> <p>import junit.framework.TestCase;<br />import org.jmock.Expectations;<br />import org.jmock.Mockery;<br />import org.junit.Test;</p> <p>/**<br /> * Created with IntelliJ IDEA.<br /> * User: abin<br /> * Date: 13-4-23<br /> * Time: 上午11:08<br /> * To change this template use File | Settings | File Templates.<br /> */<br />public class UserManageTest {<br />    @Test<br />    public void testUserManage(){<br />        // 建立一个test上下文对象ã€?br />        Mockery mockery=new Mockery();<br />        // 生成一个mock对象<br />        final UserDao userDao=mockery.mock(UserDao.class);<br />        // 讄¡½®æœŸæœ›ã€?br />        mockery.checking(new Expectations(){<br />                {<br />                    // 当参æ•îCØ“(f¨´)"abin"的时候,userDao对象的getMessageæ–ÒŽ(gu¨©)³•被调用一‹Æ¡ï¼Œòq¶ä¸”˜q”回西安ã€?br />                    oneOf(userDao).getMessage("abin");<br />                    will(returnValue("abin"));<br />                }<br />        });<br />        UserService userService=new UserService();<br />        userService.setUserDao(userDao);<br />        String message=userService.findMessage("abin");<br />        System.out.println("message="+message);<br />        TestCase.assertEquals("abin",message);</p> <p>    }<br />}<br /></p></div><img src ="http://www.aygfsteel.com/stevenjohn/aggbug/398262.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/stevenjohn/" target="_blank">abin</a> 2013-04-23 11:29 <a href="http://www.aygfsteel.com/stevenjohn/archive/2013/04/23/398262.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jmock Examplehttp://www.aygfsteel.com/stevenjohn/archive/2013/01/18/394434.htmlabinabinFri, 18 Jan 2013 15:47:00 GMThttp://www.aygfsteel.com/stevenjohn/archive/2013/01/18/394434.htmlhttp://www.aygfsteel.com/stevenjohn/comments/394434.htmlhttp://www.aygfsteel.com/stevenjohn/archive/2013/01/18/394434.html#Feedback0http://www.aygfsteel.com/stevenjohn/comments/commentRss/394434.htmlhttp://www.aygfsteel.com/stevenjohn/services/trackbacks/394434.htmlhttp://www.aygfsteel.com/alex0927/archive/2008/06/20/209474.html
http://blog.sina.com.cn/s/blog_4fb27fd80100ohyr.html

]]>
Ö÷Õ¾Ö©Öë³ØÄ£°å£º ±±³½Çø| Î÷ÏçÏØ| ÉÏÓÝÊÐ| Ë«ÁÉÊÐ| ÕòÔ¶ÏØ| Ã×ÁÖÏØ| ÅíË®| ʱÉÐ| µÂÇÕÏØ| ÃÖ¶ÉÏØ| ÙðÖÝÊÐ| ÀèÆ½ÏØ| ÑïÖÝÊÐ| ËçÀâÏØ| ¸ï¼ªÏØ| ½ºÖÝÊÐ| ¿Ëʲ¿ËÌÚÆì| ÑôË·ÏØ| ¸·³ÇÏØ| ½­Î÷Ê¡| нòÏØ| °ö²ºÊÐ| ÉîÛÚÊÐ| Ó¡½­| ¶«ÏçÏØ| ÕѾõÏØ| ÀË¿¨×ÓÏØ| ƼÏçÊÐ| ºì°²ÏØ| ¼òÑôÊÐ| ÍòÄþÊÐ| ÑÓ´¨ÏØ| ×ÓÖÞÏØ| ÇúË®ÏØ| ±±íÕÇø| ¹ÅÕÉÏØ| ÓÀÐÂÏØ| »³ÈÊÏØ| Î÷¹±Çø| μÄÏÊÐ| ÐÂÉÛÏØ|