01: package org.objectweb.celtix.systest.stress.concurrency;
02:
03: import java.util.logging.Level;
04: import java.util.logging.Logger;
05:
06: import javax.xml.ws.Endpoint;
07:
08: import org.objectweb.celtix.systest.common.TestServerBase;
09: import static org.objectweb.celtix.systest.stress.concurrency.ConcurrentInvokerTest.EXPECTED_CALLS;
10:
11: public class Server extends TestServerBase {
12:
13: private GreeterImpl implementor;
14:
15: protected void run() {
16: implementor = new GreeterImpl();
17: String address = "http://localhost:9009/SoapContext/SoapPort";
18: Endpoint.publish(address, implementor);
19: }
20:
21: public static void main(String[] args) {
22: try {
23: Server s = new Server();
24: s.start();
25: } catch (Exception ex) {
26: ex.printStackTrace();
27: System.exit(-1);
28: } finally {
29: System.out.println("done!");
30: }
31: }
32:
33: /**
34: * Used to facilitate assertions on server-side behaviour.
35: *
36: * @param log logger to use for diagnostics if assertions fail
37: * @return true if assertions hold
38: */
39: protected boolean verify(Logger log) {
40: boolean verified = implementor.greetMeCount.get() == EXPECTED_CALLS
41: && implementor.greetMeOneWayCount.get() == EXPECTED_CALLS
42: && implementor.sayHiCount.get() == EXPECTED_CALLS
43: && implementor.docLitFaultCount.get() == EXPECTED_CALLS;
44: if (!verified) {
45: warn(log, "greetMe", implementor.greetMeCount.get());
46: warn(log, "greetMeOneWay", implementor.greetMeOneWayCount
47: .get());
48: warn(log, "sayHi", implementor.sayHiCount.get());
49: warn(log, "docLitFault", implementor.docLitFaultCount.get());
50: }
51: return verified;
52: }
53:
54: private void warn(Logger log, String method, int received) {
55: log.log(Level.WARNING, "{0} received {1} calls, expected {2}",
56: new Object[] { method, received, EXPECTED_CALLS });
57: }
58: }
|