2011-06-26 12 views
0

私はかなりEasyMockを使い慣れています。私はSpring WSエンドポイントのためのEasyMockテストを書こうとしていて、問題に走り続けています。詳細は以下の通りです:EasyMock - モックされたオブジェクトの期待

エンドポイント:

​​

テスト:

@Before<BR> 
    public void setUp() throws JDOMException {<BR> 
     xPath = createNiceMock(XPath.class);<BR> 
     payload = createNiceMock(Element.class);<BR> 
     managementService = createStrictMock(UserManagementService.class);<BR> 

     serviceEndpoint = new UserManagementServiceEndpoint(managementService); 
    } 
@Test 
    public void testUserCreationHandler() throws JDOMException { 

     expect(xPath.valueOf(payload)).andReturn("userName"); 
     expect(xPath.valueOf(payload)).andReturn("loginName"); 
     expect(xPath.valueOf(payload)).andReturn("eMail"); 
     expect(xPath.valueOf(payload)).andReturn("region"); 
     expect(xPath.valueOf(payload)).andReturn("department"); 
     expect(xPath.valueOf(payload)).andReturn("businessUnit"); 
     managementService.userCreate("userName", "loginName", "eMail", 
       "region", "department", "businessUnit"); 
     expectLastCall(); 
     replayAll(); 

     serviceEndpoint.handleUserCreationRequest(payload); 
     verifyAll(); 
    } 

エラーメッセージ:

Failed tests: 
    testUserCreationHandler(com.xxx.usermanagement.endpoint.UserManagementServiceEndpoint 
Test): 
    Expectation failure on verify: 
    valueOf(EasyMock for class org.jdom.Element): expected: 6, actual: 0 

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0<BR><BR> 

私はwoul誰かが私にこれを助けることができれば感謝します。前もって感謝します。

答えて

1

問題は、XPathモックオブジェクトがUserManagementServiceEndpointオブジェクトに設定されていないことです。 XPathパラメータを受け入れるようにコンストラクタを変更するか、またはXPathパラメータ用のセッタを作成する必要があります。

関連する問題