GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
mark.george
/
democall3
Browse code
Added some additional testing classes.
master
1 parent
3832c34
commit
829c71363fcdcba4ef33707a6830bb124afede3f
Mark
authored
on 7 Aug 2012
Patch
Showing
2 changed files
tests/Calm.java
tests/StressTest.java
Ignore Space
Show notes
View
tests/Calm.java
0 → 100644
import network.MessageGenerator; import network.RequestSender; /** * Simulates an entire lab canceling their request at the same time. * * Tests threading and queue overflow. * */ public class Calm { public static void main(String[] args) { final RequestSender requestSender = new RequestSender("127.0.0.1"); final MessageGenerator generator = new MessageGenerator(); // using 2 to 30 since those are numbers that all lab layouts have for (int i = 2; i <= 30; i++) { final int x = i; new Thread(new Runnable() { public void run() { requestSender.sendRequest(generator.cancelRequest(String.valueOf(x))); } }).start(); } } }
Ignore Space
Show notes
View
tests/StressTest.java
0 → 100644
import network.MessageGenerator; import network.RequestSender; /** * Simulates everyone toggling their help status at the same time. * * Tests concurrency, and ability to handle load. * */ public class StressTest { public static void main(String[] args) throws InterruptedException { final RequestSender requestSender = new RequestSender("127.0.0.1"); final MessageGenerator generator = new MessageGenerator(); final int sleepCount = 5; // using 2 to 30 since those are numbers that all lab layouts have for (int i = 2; i <= 30; i++) { final int x = i; new Thread(new Runnable() { public void run() { requestSender.sendRequest(generator.requestHelp(String.valueOf(x))); } }).start(); Thread.sleep(sleepCount); new Thread(new Runnable() { public void run() { requestSender.sendRequest(generator.cancelRequest(String.valueOf(x))); } }).start(); Thread.sleep(sleepCount); } } }
Show line notes below