package com.dovesoftware.clocksimplejee3.mock.dao; import junit.framework.Assert; import junit.framework.TestCase; import org.jmock.integration.junit4.JUnit4Mockery; import org.jmock.Expectations; import org.jmock.Mockery; import org.junit.Before; import org.junit.Test; import com.dovesoftware.clocksimplejee3.dao.UserDao; import com.dovesoftware.clocksimplejee3.domain.User; public class ClockDaoMock extends TestCase { private Mockery context = new JUnit4Mockery(); private UserDao clockDao; @Before public void setUp() throws Exception { // set up clockDao = context.mock(UserDao.class); } /** * Test method for * {@link org.hook.jmock.firstcase.HelloServiceImpl#sayHelloToSomebody(java.lang.String)}. */ @Test public void testGetUserByUsername() throws Exception { final User user = new User(); user.setUsername("jerry"); // expectations context.checking(new Expectations() { { oneOf(clockDao).getUserByUsername(user); will(returnValue(user)); } }); // execute String username = clockDao.getUserByUsername(user).getUsername(); // verify context.assertIsSatisfied(); Assert.assertEquals("jerry", username); System.out.println(username); } }

balabalawuyu LV6
2022年11月17日
hu10086 LV1
2022年5月21日
xaiozhu LV7
2022年4月10日
liugtnb LV2
2022年3月24日
1819615780 LV1
2021年12月25日
kk1031 LV8
2021年9月6日
LYS_myheart LV2
2021年7月24日
monkalon LV14
2021年7月10日
weijiajun LV1
2021年6月29日
15038811780 LV2
2021年6月2日

微信网友_7467320429481984
4月14日
暂无贡献等级
叉烧君 LV3
3月26日
嘲讽脸 LV5
1月15日
xianyu091012 LV5
2024年12月26日
xiquyiyuan LV10
2024年12月3日
gxh666857 LV1
2024年11月27日
黄志琴 LV1
2024年9月29日
255921158 LV5
2024年7月17日
gidfsgs
2024年6月3日
暂无贡献等级
ma406805131 LV19
2024年5月9日