1 package org.gforge.soapclient;
3 import javax.xml.rpc.ServiceException;
4 import java.rmi.RemoteException;
6 public class AcceptanceTest {
8 private static final String USERID = "tom";
9 private static final String PASSWD = "tomtom";
11 public void run() throws Exception {
12 Client client = new Client("192.168.10.202", "othello");
14 System.out.println("projects = " + client.getNumberOfHostedProjects());
15 System.out.println("users = " + client.getNumberOfActiveUsers());
17 System.out.print("Testing: login/logout...");
19 System.out.println("OK");
21 System.out.print("Testing: bad login...");
23 System.out.println("OK");
25 System.out.print("Testing: adding a bug...");
26 String summary = "random summary " + System.currentTimeMillis();
27 String bugID = testBugAdd(client, summary);
28 System.out.println("OK");
30 System.out.print("Testing: fetching details of one bug...");
31 testBugFetch(client, bugID, summary);
32 System.out.println("OK");
34 System.out.print("Testing: fetching a list of bugs (and ensuring the bug we just added is there)...");
35 testBugList(client, bugID);
36 System.out.println("OK");
38 System.out.println("ALL IS WELL");
41 private void testBugFetch(Client client, String targetID, String summary) throws ServiceException, RemoteException {
42 client.login(USERID, PASSWD);
43 Bug bug = client.bugFetch(targetID);
44 if (!bug.getSummary().equals(summary)) {
45 throw new RuntimeException("Summaries didn't match!");
50 private void testBugList(Client client, String targetID) throws ServiceException, RemoteException {
51 client.login(USERID, PASSWD);
52 String[] bugs = client.bugList();
53 boolean found = false;
54 for (int i=0; i<bugs.length; i++) {
55 if (bugs[i].equals(targetID)) {
60 if (!found) throw new RuntimeException("Couldn't find the bug!");
65 private String testBugAdd(Client client, String summary) throws ServiceException, RemoteException {
66 client.login(USERID, PASSWD);
67 String id = client.bugAdd(summary, "random comment " + System.currentTimeMillis());
72 private void testLogin(Client client) throws Exception {
73 client.login(USERID, PASSWD);
77 private void testBadLogin(Client client) throws Exception {
79 client.login(USERID, PASSWD + System.currentTimeMillis());
80 throw new RuntimeException("Should have thrown an exception!");
81 } catch (Exception ex) {
85 public static void main(String[] args) throws Exception {
86 AcceptanceTest test = new AcceptanceTest();