????????????????
???????????? ???????[ 2013/5/20 11:29:10 ] ????????
????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>
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11