????userFoundResponse???????XML??????а???????????????XmlEndPoint???????????????????IdentityService?????????????Customer?????????????????IdentityService??????????????????????????????

??????????????“????????”????????????????

@Test
public void shouldReturnNullWhenUserDoesNotExist() throws Exception {
    when(xmlEndPoint.get(anyString())).thenReturn(
         new XmlEndPointResponse(STATUS_NO_CONTENT?? null));
    Customer nonExistCustomer =
         identityService.findByEmail("not.exist@gmail.com");
    assertThat(nonExistCustomer?? nullValue());
}

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

???????????

???????????????????????????????????????????????????????????????????????????????????????????п????????????????????????????????????????????????????????е???????

????1???????????????URL??

????2???????????????????????????????

?????????????????????????????????????????????????????????棬?????????????????????????????????????????????????????仯???????????????÷?????????????????????????????????????????????????崻?????????????????????????????????????????????????????????????????????????????????????????????????????е????????????

?????????????????????????????????????t????????????ó??????????????????????????IdentityService???????????????????????????????????????????????????????????????????????????????д????????????????????????????????????????????

System.out.println("=== 2. Find that user out ===");
GetMethod getToSearchUser = new GetMethod(
         configuration.getUrlForSearchUser("gigix1980@gmail.com"));
getToSearchUser.setRequestHeader("Accept"?? "application/xml");
httpClient.executeMethod(getToSearchUser);
assertThat(getToSearchUser.getStatusCode()?? equalTo(200));
System.out.println(getResponseBody(getToSearchUser));

?????????????????β????У???????????Apache Commons HTTP Client????????????????????????????????????????????????????á?????????????XML??????????????????ο?????????????????????????????????????????????????????????????????????????????????“????????”?????????

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

?????????????????????У???м??????????????????????????????????????????????????????????????????????????????????????????е????????????????????????Moco????????????????????и???????????????????????????????????????С?

????Maven???????????????????????Maven?????????????????У?????????????“test”??“integration-test”??????Σ?phase??????????Maven?????????????????????????“Failsafe”?????????е?????????????

The Failsafe Plugin is designed to run integration tests while the Surefire Plugins is designed to run unit tests. The name (failsafe) was chosen both because it is a synonym of surefire and because it implies that when it fails?? it does so in a safe way.

????????Maven????????????????Surefire????????е?????????Failsafe????????м???????????????????????м?????????“integration”?????????pom.xml??????Surefire?????????????????????

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>${maven-surefire-plugin.version}</version>
  <executions>
    <execution>
      <id>default-test</id>
      <phase>test</phase>
      <goals>
        <goal>test</goal>
      </goals>
      <configuration>
        <excludes>
          <exclude>**/integration/**/*Test.java</exclude>
        </excludes>
      </configuration>
    </execution>
  </executions>
</plugin>