Skip to content

Commit

Permalink
Test support: allow running multiple wiremocks concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanhill committed Jun 9, 2018
1 parent 00facc3 commit 136f853
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -4,6 +4,7 @@ composer.phar
composer.lock
/wiremock/*.jar
/wiremock/*.log
/wiremock/mappings
/wiremock/1
/wiremock/2
/wiremock/exec_test.pid
*.iml
5 changes: 0 additions & 5 deletions test/WireMock/Integration/StubbingIntegrationTest.php
Expand Up @@ -8,11 +8,6 @@

class StubbingIntegrationTest extends WireMockIntegrationTest
{
public function clearMappings()
{
exec('rm -f ../wiremock/mappings/*');
}

public function setUp()
{
parent::setUp();
Expand Down
5 changes: 5 additions & 0 deletions test/WireMock/Integration/WireMockIntegrationTest.php
Expand Up @@ -45,4 +45,9 @@ public function setUp()
$this->_testClient = new TestClient();
self::$_wireMock->reset();
}

public function clearMappings()
{
exec('rm -f ../wiremock/1/mappings/*');
}
}
1 change: 0 additions & 1 deletion wiremock/__files/someFile.html

This file was deleted.

19 changes: 14 additions & 5 deletions wiremock/start.sh
Expand Up @@ -4,9 +4,18 @@
# Change to the wiremock directory
cd ../wiremock

instance=1
port=8080
if [ $# -gt 0 ]; then
instance=$1
port=$2
fi
pidFile=wiremock.$instance.pid
logFile=wiremock.$instance.log

# Ensure WireMock isn't already running
if [ -e wiremock.pid ]; then
echo WireMock is already started: see process `cat wiremock.pid` 1>&2
if [ -e $pidFile ]; then
echo WireMock is already started: see process `cat $pidFile` 1>&2
exit 1
fi

Expand All @@ -22,7 +31,7 @@ if ! [ -e wiremock-standalone.jar ]; then
fi

# Start WireMock in standalone mode (in a background process) and save its output to a log
java -jar wiremock-standalone.jar -verbose &> wiremock.log 2>&1 &
echo $! > wiremock.pid
java -jar wiremock-standalone.jar --port $port --root-dir $instance --verbose &> $logFile 2>&1 &
echo $! > $pidFile

echo WireMock started
echo WireMock $instance started on port $port
15 changes: 11 additions & 4 deletions wiremock/stop.sh
Expand Up @@ -4,12 +4,19 @@
# Change to the wiremock directory
cd ../wiremock

if [ -e wiremock.pid ]; then
kill -9 `cat wiremock.pid`
rm wiremock.pid
instance=1
if [ $# -gt 0 ]; then
instance=$1
fi
pidFile=wiremock.$instance.pid


if [ -e $pidFile ]; then
kill -9 `cat $pidFile`
rm $pidFile
else
echo WireMock is not started 2>&1
exit 1
fi

echo WireMock stopped
echo WireMock $instance stopped

0 comments on commit 136f853

Please sign in to comment.