Mock Servers
A mock server imitates a real server by providing realistic responses to requests.
It is simulated to work as a real server so that we can test our APIs and check the response or errors. A mock server behaves like a real server which is used for testing and development purpose.
For unit tests, mock ILS server(s) simulate API calls to and from each library.
Receives calls from test code
Replies with fake responses, initialized by test code
Triggered from unit test code
Test Servers
Test servers are used for integration tests, in which ILS test server(s) receive and send real API calls as if they are real live systems, but without modifying a production ILS ensuring that the connections between systems are working properly.
Both types of servers are necessary to properly test whether any changes to the code will work in production.
Receives ILS calls from integration test code
Replies with valid responses
Maintains internal database of test data, initialized by the test suite
Mock services & test servers needed
NYPL
Sierra ILS
Millenium Patron API
SIP2
Columbia
Voyager
CLIO
Blacklight
Princeton
Voyager
ILLiad
Blacklight
ReCAP GFA LAS
Basic Setup
Mock servers are located on the client network. For mock servers to work, Gateway and CIRC server should be working. Mock servers are running in the Docker containers.
Dataflow
Princeton University (PUL) and Columbia University (CL) have SIP2 servers.
NewYork public library (NYPL) has exposed REST API’s
Hence below Mock servers are built:
PUL/CUL SIP2 Mock Server
When Request is placed to SIP2 server it will convert the request to string and while passing the response it will convert string to the response
NYPL REST Mock Server
For getting the request and sending the response it uses RESTful Services.
LAS Mock Server
It uses ActiveMQ. When a request is placed in the gateway, gateway passes it to the CIRC server and the CIRC server will call the LAS server, from LAS, the response is sent to CIRC and in turn, CIRC passes it to the gateway.
Property Files
Mock Server Connections
ils.nypl.sip.server.url=172.17.0.4
ils.nypl.sip.server.port=8012
ils.princeton.port=8012
ils.columbia.port=8012
ils.princeton=172.17.0.4
ils.columbia=172.17.0.4
ils.nypl.data.api = http://172.17.0.5:8090/rest
gfa.item.status = http://172.17.0.7:8080/lasapi/rest/lasapiSvc/itemStatus
PUL Credentials informations
ils.princeton.operator.user.id= recap
ils.princeton.operator.password= recap
ils.princeton.operator.location= location
CUL Credentials informations
ils.columbia.operator.user.id= recap
ils.columbia.operator.password= recap
ils.columbia.operator.location= CIRCrecap
NYPL Credentials informations
ils.nypl.operator.user.id= htc_scsb
ils.nypl.operator.password= m0Fg7xbm3ZPq5djD3gBHTu3mQYrBpf6U
ils.nypl.oauth.token.api= https://isso.nypl.org/oauth/token
ils.nypl.bibdata= https://qa-platform.nypl.org/api
ils.nypl.bibdata.parameter= /v0.1/-recap/nypl-bibs?barcode={barcode}&customercode={customercode}
Docker Commands
SIP2 Mock Server
sudo docker run --name phase4-sip2-mock-server --restart always -v /data:/recap-vol -p 8012:8012 -e "ENV=-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/recap-vol/phase4-scsb-mock-nypl-server/heapdump/ -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*" -Dspring.config.location=/recap-vol/config/external-application.properties" -d phase4-sip2-mock-server
NYPL Mock Server
sudo docker build -t phase4-scsb-mock-nypl-server .
sudo docker run --name phase4-scsb-mock-nypl-server -p 8090:8090 -e "DB_HOST=172.17.0.2" -e "DB_USERNAME=recap" -e "DB_PASSWORD=recap" -e "DB_PORT=3306" -d phase4-scsb-mock-nypl-server
sudo docker inspect phase4-scsb-mock-nypl-server | grep IPAddress
LAS Mock Server
sudo docker build -t phase4-scsb-mock-las-server .
docker images | grep none | awk '{ print $3; }' | xargs docker rmi
sudo docker run --name phase4-scsb-mock-las-server --restart always -v /data:/recap-vol -p 9103:9103 -e "ENV=-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/recap-vol/phase4-scsb-mock-las-server/heapdump/ -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*" -Dspring.config.location=/recap-vol/config/external-application.properties" -d phase4-scsb-mock-las-server
Example -
Request For Request Item
{ "author": "Mathematische Poetik ", "bibId": "15", "callNumber": "P311.xM315", "chapterTitle": "Mathematische Poetik / von Solomon Marcus ; aus dem Rumaenichen uebertragen von Edith Mandroiu.", "deliveryLocation": "PA", "emailAddress": "test@gmail.com", "endPage": "", "issue": "", "itemBarcodes": [ "32101074849843" ], "itemOwningInstitution": "PUL", "patronBarcode": "45678912", "requestNotes": "Test", "requestType": "RETRIEVAL", "requestingInstitution": "PUL", "startPage": "", "titleIdentifier": "", "trackingId": "", "username": "", "volume": "" }
Response for Request Item
{ "patronBarcode": "45678912", "itemBarcodes": [ "32101074849843" ], "requestType": "RETRIEVAL", "deliveryLocation": "PA", "requestingInstitution": "PUL", "bibliographicId": null, "expirationDate": null, "screenMessage": "Message received, your request will be processed", "success": true, "emailAddress": "test@gmail.com", "titleIdentifier": "" }