????????????????????post??put??????????????????Moco??????£????????????????????????????????????????HTTP????????????λ??localhost??Moco?????????????????????????????GET/POST/PUT??????????????????????

????Moco?????????

??????ThoughtWorks?????????????????????????????????á???????????????????????????????????COBOL???????????У??????????????????????д??????????????????????鷢??????????????????????????????????????????????????????????????????λ???????????Moco??????????????????????

?????????????????????API??????????????????Moco????API??????Moco?????standalone????????????????????????????????????????????λ?????“foo.json”??????У????????????????HTTP????????

[
  {
    "response" :   {   
      "text" : "Hello?? Moco" 
    }
  }
]

?????????????????????????

java -jar moco-runner-<version>-standalone.jar -p 12306 foo.json

?????????“http://localhost:12306”?????????URL????????“Hello?? Moco”????????????????????????????????????????????????????????????????????????

??????л??????????????????????????Garrett Heel??Moco?????????Maven???????????????????????????????????Moco??????????????????Cucumber????????????Moco????????????????????????????????????Moco?????????????С?

??????Moco?????ThoughtWorks????????????????????????????Щ???????????????????????????????????????????????????????????????????????飬???????????????????????????

????????????????

???????????????????????????????????????????????????????????????????????????????????????????е??????????????????????????????????????????????????????????????Ч???????????????????????????????????????????ɡ?

??????????????????????????????????????façade????IdentityService?????в???????????IdentityService??????????mock[7]????????XmlEndPoint?????????“????????????”???????

xmlEndPoint = mock(XmlEndPoint.class);
identityService = new IdentityServiceImpl(xmlEndPoint);

??????????????mock??XmlEndPoint???????????????????????????IdentityService?????????????????????????Щ????????????????????????“???????”?????XmlEndPoint?????????????OpenPTK????????????????

????1??????????HTTP?????“200 FOUND”??????????????????????XML??

????2????????????HTTP?????“204 NO CONTENT”?????????????

????????????“??????”????????????mock??XmlEndPoint????????????????????get??????????????????????HTTP??????????з??????200???????????????????XML??

when(xmlEndPoint.get(anyString())).thenReturn(
         new XmlEndPointResponse(STATUS_SUCCESS?? userFoundResponse));

??????mock??XmlEndPoint????????????????????“???????”???????????????????????????????????

Customer customer = identityService.findByEmail("gigix1980@gmail.com");
assertThat(customer.getFirstName()?? equalTo("Jeff"));
assertThat(customer.getLastName()?? equalTo("Xiong"));