01: package org.syrup.services;
02:
03: import java.io.ByteArrayInputStream;
04: import java.io.ByteArrayOutputStream;
05:
06: /**
07: * Provides functionality to test the concurrent behaviour of a BlobServer.
08: *
09: * @author Robbert van Dalen
10: */
11: public class BlobTest extends Thread {
12: static final String COPYRIGHT = "Copyright 2005 Robbert van Dalen."
13: + "At your option, you may copy, distribute, or make derivative works under "
14: + "the terms of The Artistic License. This License may be found at "
15: + "http://www.opensource.org/licenses/artistic-license.php. "
16: + "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK.";
17:
18: /**
19: * The main program for the BlobTest class
20: *
21: * @param args
22: * The command line arguments Description of the Exception
23: */
24: public static void main(String[] args) throws Exception {
25: for (int i = 0; i < 32; i++) {
26: BlobTest t = new BlobTest();
27: }
28: }
29:
30: /** Constructor for the BlobTest object */
31: public BlobTest() {
32: this .start();
33: }
34:
35: /** Main processing method for the BlobTest object */
36: public void run() {
37: try {
38: for (int i = 0; i < 64; i++) {
39: /*
40: * try { Thread.sleep((long)(Math.random() * 2000.0)); } catch
41: * (Exception e) { }
42: */
43: ByteArrayInputStream in = new ByteArrayInputStream(
44: new byte[1024]);
45: ByteArrayOutputStream out = new ByteArrayOutputStream();
46:
47: BlobClient client = new BlobClient("localhost:6666");
48:
49: client.write(in, out);
50: client.read(
51: new ByteArrayInputStream(out.toByteArray()),
52: new ByteArrayOutputStream());
53:
54: }
55: } catch (Exception e) {
56: e.printStackTrace();
57: }
58: }
59: }
|