01: /*
02: * Main.java
03: *
04: * Created on January 13, 2007, 7:25 AM
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package helloca.client;
11:
12: import caclient.ejbws.Account;
13: import com.sun.ejte.ccl.reporter.SimpleReporterAdapter;
14: import java.util.Iterator;
15: import javax.xml.ws.Holder;
16: import javax.xml.ws.soap.SOAPFaultException;
17:
18: /**
19: *
20: * @author Sony Manuel
21: */
22: public class Client {
23:
24: static SimpleReporterAdapter reporter = new SimpleReporterAdapter();
25:
26: /** Creates a new instance of Main */
27: public Client() {
28: }
29:
30: /**
31: * @param args the command line arguments
32: */
33: public static void main(String[] args) {
34: reporter.addDescription("Hello Composite App Test");
35: // TODO code application logic here
36: Client m = new Client();
37: m.testPing();
38: m.testInOut();
39: //m.testFault();
40: reporter.printSummary("HelloCa Test");
41: }
42:
43: public void testPing() {
44: String testId = "jbi.helloca.testapp.testPing";
45: try { // Call Web Service Operation
46: caclient.ejbws.MiscService service = new caclient.ejbws.MiscService();
47: caclient.ejbws.Misc port = service.getMiscPort();
48: port.ping();
49: reporter.addStatus(testId, reporter.PASS);
50: } catch (Exception ex) {
51: reporter.addStatus(testId, reporter.FAIL);
52: ex.printStackTrace();
53: }
54: }
55:
56: public void testInOut() {
57: String testId = "jbi.helloca.testapp.testInOut";
58: Account acc = new Account();
59: Holder<Account> holder = new Holder<Account>();
60: holder.value = acc;
61: try { // Call Web Service Operation
62: caclient.ejbws.MiscService service = new caclient.ejbws.MiscService();
63: caclient.ejbws.Misc port = service.getMiscPort();
64: port.createAccount("Foo", 100.00, holder);
65: if (holder.value.getId() == 1000
66: && holder.value.getName().equals("Foo")
67: && holder.value.getBalance() == 100.00)
68: reporter.addStatus(testId, reporter.PASS);
69: else
70: reporter.addStatus(testId, reporter.FAIL);
71: } catch (Exception ex) {
72: reporter.addStatus(testId, reporter.FAIL);
73: ex.printStackTrace();
74: }
75: }
76:
77: public void testFault() {
78: String testId = "jbi.helloca.testapp.testFault";
79: Account acc = new Account();
80: Holder<Account> holder = new Holder<Account>();
81: holder.value = acc;
82: try { // Call Web Service Operation
83: caclient.ejbws.MiscService service = new caclient.ejbws.MiscService();
84: caclient.ejbws.Misc port = service.getMiscPort();
85: port.createAccount("Bar", 0.0, holder);
86: reporter.addStatus(testId, reporter.FAIL);
87: } catch (SOAPFaultException sfe) {
88: reporter.addStatus(testId, reporter.PASS);
89: } catch (Exception ex) {
90: ex.printStackTrace();
91: reporter.addStatus(testId, reporter.FAIL);
92: }
93: }
94: }
|