mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:35:50 +00:00
Add functional test for Petclimic web service
Tests uses Grid Dynamics JBehave framework. They access the same pages but in XML form and test XML content.
This commit is contained in:
parent
93a7142fb1
commit
c34fb90cd8
6 changed files with 135 additions and 3 deletions
|
@ -1,10 +1,10 @@
|
||||||
Requisites:
|
Requisites:
|
||||||
- Binary repository for GD JBehave Framework
|
- Binary repository for GD JBehave Framework
|
||||||
https://nexus.griddynamics.net/nexus/content/repositories/gd_jbehave_framework-snapshots
|
https://nexus.griddynamics.net/nexus/content/repositories/gd_jbehave_framework-snapshots
|
||||||
should be added to Maven repositories in `settings.xml`.
|
should be added to Maven repositories in `settings.xml`.
|
||||||
It requires authentication so it should be configured properly.
|
It requires authentication so it should be configured properly.
|
||||||
|
|
||||||
Run test against a remote WebDriver:
|
Run UI test against a remote WebDriver:
|
||||||
|
|
||||||
mvn -P runTests clean test -Dthreads=1 \
|
mvn -P runTests clean test -Dthreads=1 \
|
||||||
-Dsuite.all=**/*Suite.java -Dsuite.list=UITestsExampleSuite \
|
-Dsuite.all=**/*Suite.java -Dsuite.list=UITestsExampleSuite \
|
||||||
|
@ -13,3 +13,12 @@ Run test against a remote WebDriver:
|
||||||
-DREMOTE_WEBDRIVER_URL=http://localhost:4444/wd/hub -Dbrowser.version= \
|
-DREMOTE_WEBDRIVER_URL=http://localhost:4444/wd/hub -Dbrowser.version= \
|
||||||
-Dpetclinic.url=http://localhost:9966/petclinic
|
-Dpetclinic.url=http://localhost:9966/petclinic
|
||||||
|
|
||||||
|
Run web service tests:
|
||||||
|
|
||||||
|
mvn -P runTests clean test -Dthreads=1 \
|
||||||
|
-Dsuite.all=**/*Suite.java -Dsuite.list=WebServicesExampleSuite \
|
||||||
|
-Dmeta.filters=-not_impl,-not_in_func,-blocked,-non_ci \
|
||||||
|
-Dpetclinic.url=http://localhost:9966/petclinic
|
||||||
|
|
||||||
|
(`suite.list` property is `UITestsExampleSuite` for Selenium tests and
|
||||||
|
`WebServicesExampleSuite` - for direct tests of web service API)
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.griddynamics.webservices.steps;
|
||||||
|
|
||||||
|
import com.griddynamics.web.PetClinicStoreHost;
|
||||||
|
import com.jayway.restassured.response.Response;
|
||||||
|
import org.jbehave.core.annotations.Then;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import static com.jayway.restassured.RestAssured.given;
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lzakharova
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope("thread")
|
||||||
|
public class WebServicesSteps {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PetClinicStoreHost petClinicStoreHost;
|
||||||
|
|
||||||
|
private Response response;
|
||||||
|
|
||||||
|
@Then("vets webservice responds with $code code")
|
||||||
|
public void checkResponseCode(int code) {
|
||||||
|
setResponse();
|
||||||
|
assertThat(response.getStatusCode(), equalTo(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Then("response from vets webservice contains parameter $parameter with value $value")
|
||||||
|
public void checkParamInResponse(String parameter, String value) {
|
||||||
|
setResponse();
|
||||||
|
assertThat(response.getBody().xmlPath().getString(parameter), equalTo(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setResponse() {
|
||||||
|
response = given().header("Content-Type", "application/xml").
|
||||||
|
when().get(petClinicStoreHost.getPetClinicUrl() + "/vets.xml").andReturn();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.griddynamics.webservices.suits;
|
||||||
|
|
||||||
|
|
||||||
|
import com.griddynamics.qa.framework.BaseStoriesRunner;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lzakharova
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class WebServicesExampleSuite extends BaseStoriesRunner {
|
||||||
|
protected static String contextPath = "/com/griddynamics/context/webServicesApplicationContext.xml";
|
||||||
|
|
||||||
|
public WebServicesExampleSuite() {
|
||||||
|
super(contextPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> excludeStories() {
|
||||||
|
return new ArrayList<String>() {
|
||||||
|
{
|
||||||
|
add("**/web/**/*Given*.story");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> includeStories() {
|
||||||
|
return new ArrayList<String>() {
|
||||||
|
{
|
||||||
|
add("**/stories/webservice/**/**.story");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeRun() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
|
<context:component-scan base-package="com.griddynamics.webservices.steps"/>
|
||||||
|
<context:annotation-config/>
|
||||||
|
|
||||||
|
|
||||||
|
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
|
||||||
|
<property name="scopes">
|
||||||
|
<map>
|
||||||
|
<entry key="thread">
|
||||||
|
<bean class="org.springframework.context.support.SimpleThreadScope"/>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<bean id="petClinicStoreHost" class="com.griddynamics.web.PetClinicStoreHost" >
|
||||||
|
<property name="petClinicUrl">
|
||||||
|
<value>${petclinic.url}</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
|
@ -0,0 +1,3 @@
|
||||||
|
Scenario: Check response body for vets webservice
|
||||||
|
Then response from vets webservice contains parameter vets.vetList.id[0] with value 1
|
||||||
|
Then response from vets webservice contains parameter vets.vetList.firstName[0] with value James
|
|
@ -0,0 +1,5 @@
|
||||||
|
Meta:
|
||||||
|
@smoke
|
||||||
|
|
||||||
|
Scenario: Check response code for vets webservice
|
||||||
|
Then vets webservice responds with 200 code
|
Loading…
Reference in a new issue