-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds `bats` versions of the old Aruba test scripts.
- Loading branch information
Showing
4 changed files
with
175 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bats | ||
|
||
setup() { | ||
BATS_TMPDIR=`mktemp --directory` | ||
cd test/sampleBin | ||
java echoserver.EchoServer & | ||
cd ../.. | ||
} | ||
|
||
teardown() { | ||
rm -rf "$BATS_TMPDIR" | ||
kill %1 | ||
# This sleep is crucial to ensure that the server shuts down completely | ||
# and relinquishes the port before we move on to the next test. | ||
sleep 1 | ||
} | ||
|
||
@test "Your client code compiles" { | ||
cd src | ||
rm -f echoserver/EchoClient.class | ||
run javac echoserver/EchoClient.java | ||
cd .. | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your client runs successfully" { | ||
cd src | ||
java echoserver.EchoClient < ../test/etc/textTest.txt | ||
status=$? | ||
cd .. | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your client handles a small bit of text" { | ||
cd src | ||
rm -f echoserver/*.class | ||
javac echoserver/EchoClient.java | ||
java echoserver.EchoClient < ../test/etc/textTest.txt > "$BATS_TMPDIR"/textTest.txt | ||
run diff ../test/etc/textTest.txt "$BATS_TMPDIR"/textTest.txt | ||
cd .. | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your client handles a large chunk of text" { | ||
cd src | ||
rm -f echoserver/*.class | ||
javac echoserver/EchoClient.java | ||
java echoserver.EchoClient < ../test/etc/words.txt > "$BATS_TMPDIR"/words.txt | ||
run diff ../test/etc/words.txt "$BATS_TMPDIR"/words.txt | ||
cd .. | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your client handles binary content" { | ||
cd src | ||
rm -f echoserver/*.class | ||
javac echoserver/EchoClient.java | ||
java echoserver.EchoClient < ../test/etc/pumpkins.jpg > "$BATS_TMPDIR"/pumpkins.jpg | ||
run diff ../test/etc/pumpkins.jpg "$BATS_TMPDIR"/pumpkins.jpg | ||
cd .. | ||
|
||
[ "$status" -eq 0 ] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,71 @@ | ||
#!/usr/bin/env bats | ||
|
||
Scenario: Sending text: premade client, your server | ||
Given a server from "../bin/echoserver/EchoServer.class" and a client from "sampleBin/echoserver/EchoClient.class" | ||
When I run the echo client with the file "etc/textTest.txt" outputting to "output.txt" | ||
Then the file "output.txt" exists | ||
And the file "output.txt" should differ from "etc/textTest.txt" only by whitespace | ||
|
||
Scenario: Sending images: premade client, your server | ||
Given a server from "../bin/echoserver/EchoServer.class" and a client from "sampleBin/echoserver/EchoClient.class" | ||
When I run the echo client with the file "etc/pumpkins.jpg" outputting to "output.jpg" | ||
Then the file "output.jpg" exists | ||
And the file "output.jpg" should differ from "etc/pumpkins.jpg" only by whitespace | ||
|
||
@setup { | ||
mktemp | ||
setup() { | ||
BATS_TMPDIR=`mktemp --directory` | ||
} | ||
|
||
@test { | ||
teardown() { | ||
rm -rf "$BATS_TMPDIR" | ||
} | ||
|
||
@test "Your server code compiles" { | ||
cd src | ||
rm -f echoserver/EchoServer.class | ||
run javac echoserver/EchoServer.java | ||
cd .. | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your server starts successfully" { | ||
cd src | ||
java echoserver.EchoServer & | ||
status=$? | ||
kill %1 | ||
cd .. | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your server handles a small bit of text" { | ||
cd src | ||
rm -f echoserver/*.class | ||
javac echoserver/EchoServer.java | ||
java echoserver.EchoServer & | ||
cd .. | ||
|
||
cd test/sampleBin | ||
java echoserver.EchoClient < ../etc/textTest.txt > "$BATS_TMPDIR"/textTest.txt | ||
run diff ../etc/textTest.txt "$BATS_TMPDIR"/textTest.txt | ||
cd ../.. | ||
kill %1 | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your server handles a large chunk of text" { | ||
cd src | ||
rm -f echoserver/*.class | ||
javac echoserver/EchoServer.java | ||
java echoserver.EchoServer & | ||
cd .. | ||
|
||
cd test/sampleBin | ||
java echoserver.EchoClient < ../etc/words.txt > "$BATS_TMPDIR"/words.txt | ||
run diff ../etc/words.txt "$BATS_TMPDIR"/words.txt | ||
cd ../.. | ||
kill %1 | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your server handles binary content" { | ||
cd src | ||
rm -f echoserver/*.class | ||
javac echoserver/EchoServer.java | ||
java echoserver.EchoServer & | ||
cd .. | ||
|
||
cd test/sampleBin | ||
java echoserver.EchoClient < ../etc/pumpkins.jpg > "$BATS_TMPDIR"/pumpkins.jpg | ||
run diff ../etc/pumpkins.jpg "$BATS_TMPDIR"/pumpkins.jpg | ||
cd ../.. | ||
kill %1 | ||
[ "$status" -eq 0 ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bats | ||
|
||
setup() { | ||
BATS_TMPDIR=`mktemp --directory` | ||
cd src | ||
rm -f echoserver/EchoServer.class | ||
javac echoserver/*.java | ||
java echoserver.EchoServer & | ||
cd .. | ||
} | ||
|
||
teardown() { | ||
rm -rf "$BATS_TMPDIR" | ||
kill %1 | ||
# This sleep is crucial to ensure that the server shuts down completely | ||
# and relinquishes the port before we move on to the next test. | ||
sleep 1 | ||
} | ||
|
||
@test "Your client/server pair handles a small bit of text" { | ||
cd src | ||
java echoserver.EchoClient < ../test/etc/textTest.txt > "$BATS_TMPDIR"/textTest.txt | ||
run diff ../test/etc/textTest.txt "$BATS_TMPDIR"/textTest.txt | ||
cd .. | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your client/server pair handles a large chunk of text" { | ||
cd src | ||
java echoserver.EchoClient < ../test/etc/words.txt > "$BATS_TMPDIR"/words.txt | ||
run diff ../test/etc/words.txt "$BATS_TMPDIR"/words.txt | ||
cd .. | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Your client/server pair handles binary content" { | ||
cd src | ||
java echoserver.EchoClient < ../test/etc/pumpkins.jpg > "$BATS_TMPDIR"/pumpkins.jpg | ||
run diff ../test/etc/pumpkins.jpg "$BATS_TMPDIR"/pumpkins.jpg | ||
cd .. | ||
|
||
[ "$status" -eq 0 ] | ||
} |