/*
 * TestClientAPI.java
 *
 * Created on 25 marzo 2004, 15.59
 */

package test;
import qms.client.*;
import qms.messages.*;
import java.net.*;
import java.io.*;
import java.util.*;
/**
 *
 * @author  Enrico
 */
public class Test {
            
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            String queue = "aaa";            
            URL sap = new URL("http://localhost/node1/UserInterface");
            String body = "ciao a tutti!";
            System.out.println("Service Access Point "+sap);
            System.out.println("Queue:"+queue);            
            
            QMSClient client = new QMSClient();
            client.setAccessPoint(sap);                     
            
            System.out.println("Posting a message");
            System.out.println("Body:"+body);
            for (int i=0; i < 100; i++) {
                client.postMessage("enrico", queue, body+" "+i);                                 
                System.out.println("Sent "+i);
                Thread.sleep(1000);
            }
             
            
           /* System.out.println("Waiting...");
            Thread.sleep(10000);
            
            List list = client.listMessages(queue);
            System.out.println("Message ids:"+list);
            
            for (Iterator i = list.iterator(); i.hasNext();) {
                String mid = (String) i.next();
                Message m = client.getMessage(queue, mid);
                System.out.println("Message:\n"+m);
                System.out.println("Deleting...");
                client.deleteMessage(queue,mid);
                System.out.println("OK");
            }
            */
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
    
}
