1 |
mojays |
2 |
package appl.parallel.test; |
2 |
|
|
|
3 |
|
|
import java.rmi.Naming; |
4 |
|
|
import java.rmi.RemoteException; |
5 |
|
|
|
6 |
|
|
import junit.framework.Test; |
7 |
|
|
import junit.framework.TestCase; |
8 |
|
|
import junit.framework.TestSuite; |
9 |
alfonx |
60 |
import appl.parallel.server.XuluServer; |
10 |
mojays |
2 |
|
11 |
|
|
/** |
12 |
|
|
* Generated code for the test suite <b>XuluServerTest</b> located at |
13 |
|
|
* <i>/XuluSVN/javasrc/appl/parallel/test/XuluServerTest.testsuite</i>. |
14 |
|
|
* |
15 |
|
|
* Tests the Server functionality |
16 |
|
|
*/ |
17 |
|
|
public class XuluServerTest extends TestCase { |
18 |
|
|
public final String IP = "192.168.18.238"; |
19 |
|
|
XuluServer server; |
20 |
|
|
|
21 |
|
|
/** |
22 |
|
|
* @see junit.framework.TestCase#setUp() |
23 |
|
|
*/ |
24 |
|
|
protected void setUp() throws Exception { |
25 |
|
|
String name = "rmi://" + IP + "/XuluServer"; |
26 |
|
|
|
27 |
|
|
server = (XuluServer) Naming.lookup(name); |
28 |
|
|
|
29 |
|
|
|
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
/** |
33 |
|
|
* Constructor for XuluServerTest. |
34 |
|
|
* @param whatsthis |
35 |
|
|
*/ |
36 |
|
|
public XuluServerTest(String whatsthis) { |
37 |
|
|
super(whatsthis); |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
/** |
41 |
|
|
* Returns the JUnit test suite that implements the <b>XuluServerTest</b> |
42 |
|
|
* definition. |
43 |
|
|
*/ |
44 |
|
|
public static Test suite() { |
45 |
|
|
TestSuite xuluServerTest = new TestSuite("XuluServerTest"); |
46 |
|
|
// xuluServerTest.setArbiter(DefaultTestArbiter.INSTANCE).setId( |
47 |
|
|
// "F534D0796F99AD6BA80D9B00A9AA11DB"); |
48 |
|
|
|
49 |
|
|
return xuluServerTest; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
/** |
54 |
|
|
* @see junit.framework.TestCase#tearDown() |
55 |
|
|
*/ |
56 |
|
|
protected void tearDown() throws Exception { |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
/** |
60 |
|
|
* testServer |
61 |
|
|
* @throws Exception |
62 |
|
|
*/ |
63 |
|
|
public void testPingServer() |
64 |
|
|
throws Exception |
65 |
|
|
{ |
66 |
|
|
try{ |
67 |
|
|
Object data; |
68 |
|
|
PingTestObject pingObj = new PingTestObject(32); |
69 |
|
|
// do 10 pings |
70 |
|
|
long sum1 = 0; |
71 |
|
|
for (int i = 0; i < 10; i++) { |
72 |
|
|
long mstime = System.currentTimeMillis(); |
73 |
|
|
data = server.ping(pingObj); |
74 |
|
|
long mstimediff = System.currentTimeMillis() - mstime; |
75 |
|
|
sum1 += mstimediff; |
76 |
|
|
// Thread.sleep(100); |
77 |
|
|
} |
78 |
|
|
long sum2 = 0; |
79 |
|
|
for (int i = 0; i < 10; i++) { |
80 |
|
|
long nanotime = System.nanoTime(); |
81 |
|
|
data = server.ping(pingObj); |
82 |
|
|
long nanolatency = System.nanoTime() - nanotime; |
83 |
|
|
double timediff = (double)nanolatency / 1000000.0; |
84 |
|
|
sum2+= nanolatency; |
85 |
|
|
//Thread.sleep(100); |
86 |
|
|
} |
87 |
|
|
System.out.println("Average MS: " + sum1/10 + " Average nano: " + (double)sum2 / 10000000.0 ); |
88 |
|
|
|
89 |
|
|
|
90 |
|
|
} catch (RemoteException e) { |
91 |
|
|
// TODO Auto-generated catch block |
92 |
|
|
e.printStackTrace(); |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
|
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
/** |
99 |
|
|
* sendModel |
100 |
|
|
* @throws Exception |
101 |
|
|
*/ |
102 |
|
|
public void testSendModel() |
103 |
|
|
throws Exception |
104 |
|
|
{ |
105 |
|
|
System.out.println("fu"); |
106 |
|
|
// Enter your code here |
107 |
|
|
} |
108 |
|
|
|
109 |
|
|
} |