You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by pa...@apache.org on 2011/09/15 00:56:20 UTC

svn commit: r1170887 [3/3] - in /incubator/airavata/trunk/modules/ws-messenger/client: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/airavata/ src/main/java/org/apache/airavata/wsmg/ src/main/jav...

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,328 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.gui;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.border.Border;
+
+import org.apache.airavata.wsmg.client.ConsumerServer;
+import org.apache.airavata.wsmg.client.WsntMsgBrokerClient;
+import org.apache.axis2.AxisFault;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NotificationViewerFrame extends JFrame {
+
+    private static final long serialVersionUID = -4924241323165353343L;
+
+    private static final Logger logger = LoggerFactory.getLogger(NotificationViewerFrame.class);
+
+    JPanel contentPane;
+
+    BorderLayout borderLayout1 = new BorderLayout();
+
+    JPanel jPanel1 = new JPanel();
+
+    Border border1 = BorderFactory.createLineBorder(Color.gray, 2);
+
+    JLabel jLabel1 = new JLabel();
+
+    JButton jButtonStart = new JButton();
+
+    JLabel jLabel2 = new JLabel();
+
+    JTextField jTextBrokerUrl = new JTextField();
+
+    JLabel jLabel3 = new JLabel();
+
+    JTextField jTextPort = new JTextField();
+
+    JLabel jLabel4 = new JLabel();
+
+    JTextField jTextTopic = new JTextField();
+
+    JTabbedPane jTabbedPane1 = new JTabbedPane();
+
+    JScrollPane jScrollPane1 = new JScrollPane();
+
+    JTextArea jTextAreaBrief = new JTextArea();
+
+    JScrollPane jScrollPane2 = new JScrollPane();
+
+    JTextArea jTextAreaWhole = new JTextArea();
+
+    JButton jButtonClear = new JButton();
+
+    ConsumerServer consumerServer = null;
+
+    WsntMsgBrokerClient client;
+
+    String subId = null;
+
+    JButton jButtonStop = new JButton();
+
+    GridBagLayout gridBagLayout1 = new GridBagLayout();
+
+    public NotificationViewerFrame() {
+        try {
+            setDefaultCloseOperation(EXIT_ON_CLOSE);
+            jbInit();
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+
+        client = new WsntMsgBrokerClient();
+
+    }
+
+    /**
+     * Component initialization.
+     * 
+     * @throws java.lang.Exception
+     */
+    private void jbInit() throws Exception {
+        contentPane = (JPanel) getContentPane();
+        contentPane.setLayout(borderLayout1);
+        setSize(new Dimension(547, 429));
+        setTitle("WS-Notification Viewer");
+        jPanel1.setBackground(Color.white);
+        jPanel1.setBorder(border1);
+        jPanel1.setMaximumSize(new Dimension(180000, 180000));
+        jPanel1.setLayout(gridBagLayout1);
+        jLabel1.setFont(new java.awt.Font("Serif", Font.BOLD | Font.ITALIC, 28));
+        jLabel1.setForeground(Color.blue);
+        jLabel1.setText("WS-Notification Listener");
+        jButtonStart.setToolTipText("Subscribe to the topic and start listening");
+        jButtonStart.setText("Start");
+        jButtonStart.addActionListener(new NotificationViewerFrame_jButton1_actionAdapter(this));
+        jLabel2.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
+        jLabel2.setText("BrokerURL");
+        jTextBrokerUrl.setToolTipText("Enter Broker URL here.");
+        jTextBrokerUrl.setText("http://localhost:8080/axis2/services/NotificationService");
+        jLabel3.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
+        jLabel3.setText("Listening Port");
+        jTextPort.setToolTipText("Enter the port this listener will be listening to.");
+        jTextPort.setText("19999");
+        jLabel4.setFont(new java.awt.Font("Dialog", Font.BOLD, 11));
+        jLabel4.setText("Topic");
+        jTextTopic.setToolTipText("Enter the topic to subscribe.");
+        jTextTopic.setText("topic");
+        jTextAreaBrief.setToolTipText("Summary of the messages received.");
+        jTextAreaBrief.setLineWrap(true);
+        // jTextAreaWhole.setMinimumSize(new Dimension(490, 17));
+        // jTextAreaWhole.setPreferredSize(new Dimension(490, 17));
+        jTextAreaWhole.setToolTipText("Full content of the SOAP messages.");
+        // jTextAreaWhole.setText("");
+        jButtonClear.setToolTipText("Clear messages in the two message panes.");
+        jButtonClear.setText("Clear Messages");
+        jButtonClear.addActionListener(new NotificationViewerFrame_jButtonClear_actionAdapter(this));
+        jButtonStop.setEnabled(false);
+        jButtonStop.setToolTipText("Unsubscribe to the topic and stop listening.");
+        jButtonStop.setText("Stop");
+        jButtonStop.addActionListener(new NotificationViewerFrame_jButtonStop_actionAdapter(this));
+        jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+        jScrollPane1.setAutoscrolls(true);
+        jScrollPane1.setToolTipText("Summary of the messages received.");
+        jScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+        jScrollPane2.setAutoscrolls(true);
+        jScrollPane2.setToolTipText("Full content of the SOAP messages.");
+        jTabbedPane1.add(jScrollPane1, "Brief Messages");
+        jTabbedPane1.add(jScrollPane2, "Whole Messages");
+        jPanel1.add(jLabel1, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.WEST,
+                GridBagConstraints.NONE, new Insets(7, 10, 0, 107), 20, -5));
+        jPanel1.add(jButtonStop, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+                GridBagConstraints.NONE, new Insets(0, 48, 0, 80), 55, -4));
+        jPanel1.add(jLabel4, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+                GridBagConstraints.NONE, new Insets(0, 36, 0, 8), 43, 4));
+        jPanel1.add(jLabel3, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
+                GridBagConstraints.NONE, new Insets(0, 36, 0, 0), 1, 4));
+        jPanel1.add(jTextPort, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
+                GridBagConstraints.HORIZONTAL, new Insets(7, 0, 0, 0), 144, -1));
+        jPanel1.add(jButtonClear, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+                GridBagConstraints.NONE, new Insets(0, 46, 0, 78), 3, -4));
+        jPanel1.add(jTextTopic, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST,
+                GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 149, -1));
+        jPanel1.add(jTextBrokerUrl, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
+                GridBagConstraints.HORIZONTAL, new Insets(6, -1, 5, 1), 10, -1));
+        jPanel1.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
+                GridBagConstraints.NONE, new Insets(6, 37, 5, 0), 21, 4));
+        jPanel1.add(jButtonStart, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
+                GridBagConstraints.NONE, new Insets(8, 47, 0, 79), 57, -4));
+        jScrollPane2.getViewport().add(jTextAreaWhole);
+        jScrollPane1.getViewport().add(jTextAreaBrief);
+
+        jPanel1.add(jTabbedPane1, new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
+                GridBagConstraints.BOTH, new Insets(0, 18, 57, 30), 0, 206));
+        contentPane.add(jPanel1, java.awt.BorderLayout.CENTER);
+    }
+
+    public void jButtonStart_actionPerformed(ActionEvent event) {
+        // jLabel1.setForeground(new Color(255,0,0));
+        String brokerUrl = jTextBrokerUrl.getText().trim();
+        String topic = jTextTopic.getText();
+
+        String listeningPort = jTextPort.getText();
+
+        int port = -1;
+
+        try {
+            port = Integer.parseInt(listeningPort);
+        } catch (NumberFormatException nfe) {
+
+            JOptionPane.showMessageDialog(this, nfe, "invalid port specified", JOptionPane.ERROR_MESSAGE);
+            return;
+        }
+
+        client.init(brokerUrl);// important
+        // Create a handler to handle the notifications arrived
+        WsntViewerConsumerNotificationHandler handler = new WsntViewerConsumerNotificationHandler(this);
+
+        String consumerUrl = null;
+
+        try {
+            String[] eprs = client.startConsumerService(port, handler);
+
+            if (eprs.length > 0) {
+                consumerUrl = eprs[0];
+            } else {
+                throw new AxisFault("no consumer url given by wse client api");
+            }
+
+        } catch (Exception e) {
+            JOptionPane.showMessageDialog(this, e, "Unable to start consumer service", JOptionPane.ERROR_MESSAGE);
+            return;
+        }
+
+        try {
+            subId = client.subscribe(consumerUrl, topic, null);
+        } catch (Exception e) {
+
+            JOptionPane.showMessageDialog(this, e, "Unable to subscribe to topic", JOptionPane.ERROR_MESSAGE);
+
+            client.shutdownConsumerService();
+            return;
+        }
+
+        jButtonStart.setEnabled(false);
+        jTextBrokerUrl.setEnabled(false);
+        jTextTopic.setEnabled(false);
+        jTextPort.setEnabled(false);
+        jButtonStop.setEnabled(true);
+        jTextAreaBrief.append("Listener started...\n");
+        jTextAreaWhole.append("Listener started...\n");
+
+    }
+
+    public void jButtonStop_actionPerformed(ActionEvent e) {
+        if (subId != null) {
+            try {
+                client.init(jTextBrokerUrl.getText().trim());
+                client.unSubscribe(subId);
+            } catch (Exception e1) {
+                JOptionPane.showMessageDialog(this, e, "Unable to unsubscribe from topic", JOptionPane.ERROR_MESSAGE);
+            }// TODO: add with replyTo URL
+            subId = null;
+        }
+
+        client.shutdownConsumerService();
+
+        jButtonStop.setEnabled(false);
+        jButtonStart.setEnabled(true);
+        jTextBrokerUrl.setEnabled(true);
+        jTextTopic.setEnabled(true);
+        jTextPort.setEnabled(true);
+        jTextAreaBrief.append("Listener stoped.\n");
+        jTextAreaWhole.append("Listener stoped.\n");
+
+    }
+
+    public void addBriefMessage(String message) {
+        jTextAreaBrief.append(message + "\n");
+        jTextAreaBrief.selectAll();
+    }
+
+    public void addWholeMessage(String message) {
+        jTextAreaWhole.append(message + "\n");
+        jTextAreaWhole.selectAll();
+    }
+
+    public void jButtonClear_actionPerformed(ActionEvent e) {
+        jTextAreaBrief.setText("");
+        jTextAreaWhole.setText("");
+    }
+}
+
+class NotificationViewerFrame_jButtonStop_actionAdapter implements ActionListener {
+    private NotificationViewerFrame adaptee;
+
+    NotificationViewerFrame_jButtonStop_actionAdapter(NotificationViewerFrame adaptee) {
+        this.adaptee = adaptee;
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButtonStop_actionPerformed(e);
+    }
+}
+
+class NotificationViewerFrame_jButtonClear_actionAdapter implements ActionListener {
+    private NotificationViewerFrame adaptee;
+
+    NotificationViewerFrame_jButtonClear_actionAdapter(NotificationViewerFrame adaptee) {
+        this.adaptee = adaptee;
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButtonClear_actionPerformed(e);
+    }
+}
+
+class NotificationViewerFrame_jButton1_actionAdapter implements ActionListener {
+    private NotificationViewerFrame adaptee;
+
+    NotificationViewerFrame_jButton1_actionAdapter(NotificationViewerFrame adaptee) {
+        this.adaptee = adaptee;
+    }
+
+    public void actionPerformed(ActionEvent e) {
+        adaptee.jButtonStart_actionPerformed(e);
+
+    }
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt Wed Sep 14 22:56:19 2011
@@ -0,0 +1,15 @@
+USING Notification Listener GUI.
+
+It is designed for Airavata project. The expected message XML schema in Airavata Workflow Management schema. It can also accept String messages.
+ 
+ 1, Use ant to compile the package. 
+  2, Then run
+source setenv.sh
+Or setenv.bat in Windows.
+ to setup CLASSPATH. It looks better in Windows.
+
+  3, Then run: 
+ java wsnt.wsntviewapp.NotificationViewer 
+ to start the GUI.
+
+You need to enter Broker URL, topic and listening port. 

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,114 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.gui;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.airavata.wsmg.client.ConsumerNotificationHandler;
+import org.apache.airavata.wsmg.commons.WsmgNameSpaceConstants;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class WsntViewerConsumerNotificationHandler implements ConsumerNotificationHandler {
+    private final static Logger logger = LoggerFactory.getLogger(WsntViewerConsumerNotificationHandler.class);
+
+    public NotificationViewerFrame frame = null;
+
+    public WsntViewerConsumerNotificationHandler() {
+    }
+
+    public WsntViewerConsumerNotificationHandler(NotificationViewerFrame f) {
+        this.frame = f;
+    }
+
+    public void handleNotification(SOAPEnvelope msgEnvelope) {
+        logger.debug("*******lead message handler Received message********");
+        logger.debug(msgEnvelope.toString());
+        try {
+            addBriefMsg(msgEnvelope);
+            addWholeMsg(msgEnvelope);
+        } catch (XMLStreamException e) {
+            logger.error("invalid message received", e);
+            throw new RuntimeException("invalid message recieved", e);
+        }
+    }
+
+    private void addBriefMsg(SOAPEnvelope env) throws XMLStreamException {
+
+        QName notify = new QName(WsmgNameSpaceConstants.WSNT_NS.getNamespaceURI(), "Notify",
+                WsmgNameSpaceConstants.WSNT_NS.getPrefix());
+
+        QName notifyMsg = new QName(WsmgNameSpaceConstants.WSNT_NS.getNamespaceURI(), "NotificationMessage",
+                WsmgNameSpaceConstants.WSNT_NS.getPrefix());
+
+        QName msg = new QName(WsmgNameSpaceConstants.WSNT_NS.getNamespaceURI(), "Message",
+                WsmgNameSpaceConstants.WSNT_NS.getPrefix());
+
+        if (env.getBody() == null) {
+            throw new RuntimeException("invalid soap envelope - no soap body");
+        }
+
+        Iterator ite = env.getBody().getChildrenWithName(notify);
+
+        if (!ite.hasNext()) {
+            throw new RuntimeException(notify.getLocalPart() + " tag is not found");
+        }
+
+        OMElement ele = (OMElement) ite.next();
+        ite = ele.getChildrenWithName(notifyMsg);
+
+        if (!ite.hasNext()) {
+            throw new RuntimeException(notifyMsg.getLocalPart() + " tag is not found");
+        }
+
+        ele = (OMElement) ite.next();
+
+        ite = ele.getChildrenWithName(msg);
+
+        if (!ite.hasNext()) {
+            throw new RuntimeException(msg.getLocalPart() + " tags are not found");
+        }
+
+        while (ite.hasNext()) {
+            ele = (OMElement) ite.next();
+
+            if (ele.getFirstElement() != null) {
+                frame.addBriefMessage(ele.getFirstElement().toString());
+            } else {
+                throw new RuntimeException("raw message is not found");
+            }
+
+        }
+
+    }
+
+    private void addWholeMsg(SOAPEnvelope envelope) throws XMLStreamException {
+        frame.addWholeMessage(envelope.toStringWithConsume());
+
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,117 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.msgbox.client;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.wsmg.client.util.ClientUtil;
+import org.apache.airavata.wsmg.commons.MsgBoxNameSpConsts;
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class can be used to invoke createMsgBox operation of msgBoxService and returns the resultant messageBoxId
+ * as EndpointReference
+ */
+public class CreateMsgBox {
+    private static final Logger logger = LoggerFactory.getLogger(CreateMsgBox.class);
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+    protected String msgBoxEndPointReference;
+    protected long timeoutInMilliSeconds;
+    private String msgBoxId;
+    private OMElement responseEl;
+
+    public CreateMsgBox(String msgBoxLocation, long timeout) {
+        this.msgBoxEndPointReference = msgBoxLocation;
+        responseEl = OMAbstractFactory.getOMFactory().createOMElement(
+                new QName("http://org.apache.airavata/xgws/msgbox/2004/", "MsgBoxId"));
+
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public EndpointReference execute() throws AxisFault {
+        ServiceClient serviceClient = createServiceClient();
+        OMElement responseMessage = null;
+        try {
+            responseMessage = serviceClient.sendReceive(createMessageEl());
+        } finally {
+            serviceClient.cleanupTransport();
+        }
+
+        if (responseMessage == null) {
+            throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+        }
+        String response = responseMessage.getFirstElement().getText();
+        this.responseEl.setText(response);
+        this.msgBoxEndPointReference = ClientUtil.formatMessageBoxUrl(this.msgBoxEndPointReference, response);
+        return new EndpointReference(this.msgBoxEndPointReference);
+    }
+
+    private OMElement createMessageEl() throws AxisFault {
+        OMElement message = factory.createOMElement("createMsgBox", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement msgBoxId = factory.createOMElement("MsgBoxId", MsgBoxNameSpConsts.MSG_BOX);
+        msgBoxId.setText("Create message box");
+        message.addChild(msgBoxId);
+        message.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+        return message;
+    }
+
+    private ServiceClient createServiceClient() throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(new EndpointReference(this.msgBoxEndPointReference));
+        opts.setMessageId(uuid);
+        opts.setAction(MsgBoxNameSpConsts.MSG_BOX.getNamespaceURI() + "/" + "createMsgBox");
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        ServiceClient client = new ServiceClient();
+        try {
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module engaged");
+        } catch (AxisFault e) {
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module not engaged :" + e);
+        }
+        client.setOptions(opts);
+        return client;
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,118 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.msgbox.client;
+
+import org.apache.airavata.wsmg.commons.MsgBoxNameSpConsts;
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+/**
+ * This class can be used to invoke destroyMsgBox operation of msgBoxService and returns the resultant messageBoxId
+ * as EndpointReference
+ */
+public class DestroyMsgBox {
+    private static final Logger logger = LoggerFactory.getLogger(DestroyMsgBox.class);
+    
+    private EndpointReference msgBoxEndPointReference = null;
+    private long timeoutInMilliSeconds = 0;    
+    private String msgBoxId = null;
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+
+    public DestroyMsgBox(EndpointReference msgBoxEpr, long timeout) throws AxisFault {
+        this.msgBoxEndPointReference = msgBoxEpr;
+        this.timeoutInMilliSeconds = timeout;
+        String address = msgBoxEpr.getAddress();
+        int biginIndex = address.indexOf("clientid");
+        if (biginIndex != -1) {
+            msgBoxId = address.substring(biginIndex + "clientid".length() + 1);
+        } else {
+            throw new AxisFault("Invalid Message Box EPR cannot find message box ID");
+        }
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public String execute() throws AxisFault {
+        OMElement message = createMessageEl(this.msgBoxId);
+        ServiceClient serviceClient = createServiceClient(message);
+
+        OMElement responseMessage = null;
+        try {
+            responseMessage = serviceClient.sendReceive(message);
+        } finally {
+            serviceClient.cleanupTransport();
+        }
+
+        responseMessage = serviceClient.sendReceive(message);
+        if (responseMessage == null) {
+            throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+        }
+        return responseMessage.getFirstElement().getText();
+    }
+
+    private OMElement createMessageEl(String msgboxid) throws AxisFault {
+        OMElement message = factory.createOMElement("destroyMsgBox", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement msgBoxId = factory.createOMElement("MsgBoxId", MsgBoxNameSpConsts.MSG_BOX);
+        msgBoxId.setText(msgboxid);
+        message.addChild(msgBoxId);
+        message.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+        return message;
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(msgBoxEndPointReference);
+        opts.setMessageId(uuid);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+
+        ServiceClient client = new ServiceClient();
+        try {
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module engaged");
+        } catch (AxisFault e) {
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module not engaged :" + e);
+        }
+
+        client.setOptions(opts);
+        return client;
+    }
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,63 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.msgbox.client;
+
+import java.rmi.RemoteException;
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.addressing.EndpointReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This is the client class to invoke MsgBoxService this is using four separate classes to invoke four methods
+ * createMsgBox,destroyMsgBox,takeMessages and storeMessages operations of the service.
+ */
+public class MsgBoxClient {
+
+    int msgsAtOnce = 10;
+    static Logger logger = LoggerFactory.getLogger(MsgBoxClient.class);
+
+    public MsgBoxClient() {
+    }
+
+    public EndpointReference createMessageBox(String msgBoxLocation, long timeout) throws RemoteException {
+        CreateMsgBox msgBox = new CreateMsgBox(msgBoxLocation, timeout);
+        return msgBox.execute();
+    }
+
+    public String storeMessage(EndpointReference msgBoxEpr, long timeout, OMElement messageIn) throws RemoteException {
+        StoreMessage strMsg = new StoreMessage(msgBoxEpr, timeout);
+        return strMsg.execute(messageIn);
+    }
+
+    public Iterator<OMElement> takeMessagesFromMsgBox(EndpointReference msgBoxEpr, long timeout) throws RemoteException {
+        TakeMessages takeMsgs = new TakeMessages(msgBoxEpr, timeout);
+        return takeMsgs.execute();
+    }
+
+    public String deleteMsgBox(EndpointReference msgBoxEpr, long timeout) throws RemoteException {
+        DestroyMsgBox destroyMsgBox = new DestroyMsgBox(msgBoxEpr, timeout);
+        return destroyMsgBox.execute();
+    }
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,119 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.msgbox.client;
+
+import org.apache.airavata.wsmg.commons.MsgBoxNameSpConsts;
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+/**
+ * This class can be used to invoke destroyMsgBox operation of msgBoxService and returns the resultant operation status
+ * as EndpointReference
+ */
+public class StoreMessage {
+    private static final Logger logger = LoggerFactory.getLogger(StoreMessage.class);
+    
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+    protected EndpointReference msgBoxEndPointReference;
+    protected long timeoutInMilliSeconds;    
+    private String msgBoxId;
+
+    public StoreMessage(EndpointReference msgBoxEpr, long timeout) throws AxisFault {
+        this.msgBoxEndPointReference = msgBoxEpr;
+        this.timeoutInMilliSeconds = timeout;
+        String address = msgBoxEpr.getAddress();
+        int biginIndex = address.indexOf("clientid");
+        if (biginIndex != -1) {
+            msgBoxId = address.substring(biginIndex + "clientid".length() + 1);
+        } else {
+            throw new AxisFault("Invalid Message Box EPR cannot find message box ID");
+        }
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public String execute(OMElement messageIn) throws AxisFault {
+        // OMElement message = createMessageEl(this.msgBoxId, messageIn);
+        ServiceClient serviceClient = createServiceClient();
+
+        OMElement responseMessage = null;
+
+        try {
+            responseMessage = serviceClient.sendReceive(messageIn);
+        } finally {
+            serviceClient.cleanupTransport();
+        }
+
+        if (responseMessage == null) {
+            throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+        }
+        return responseMessage.getFirstElement().getText();
+    }
+
+    private OMElement createMessageEl(String msgboxid, OMElement messageIn) throws AxisFault {
+        OMElement message = factory.createOMElement("storeMessages", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement messageElement = factory.createOMElement("message", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement msgBoxId = factory.createOMElement("MsgBoxId", MsgBoxNameSpConsts.MSG_BOX);
+        msgBoxId.setText(msgboxid);
+        message.addChild(msgBoxId);
+        messageElement.addChild(messageIn);
+        message.addChild(messageElement);
+        message.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+        return message;
+    }
+
+    private ServiceClient createServiceClient() throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(msgBoxEndPointReference);
+        opts.setMessageId(uuid);
+        opts.setAction(MsgBoxNameSpConsts.MSG_BOX.getNamespaceURI() + "/" + "storeMessages");
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        ServiceClient client = new ServiceClient();
+        try {
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module engaged");
+        } catch (AxisFault e) {
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module not engaged :" + e);
+        }
+        client.setOptions(opts);
+        return client;
+    }
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,124 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.msgbox.client;
+
+import java.util.Iterator;
+
+import org.apache.airavata.wsmg.commons.MsgBoxNameSpConsts;
+import org.apache.airavata.wsmg.commons.WsmgCommonConstants;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class can be used to invoke takeMessages operation of msgBoxService and returns the resultant operation status
+ *
+ */
+public class TakeMessages {
+    private static final Logger logger = LoggerFactory.getLogger(TakeMessages.class);
+    private final OMFactory factory = OMAbstractFactory.getOMFactory();
+    protected EndpointReference msgBoxEndPointReference;
+    protected long timeoutInMilliSeconds;
+    private String msgBoxId;
+    
+
+    public TakeMessages(EndpointReference msgBoxEpr, long timeout) throws AxisFault {
+        this.msgBoxEndPointReference = msgBoxEpr;
+        this.timeoutInMilliSeconds = timeout;
+        String address = msgBoxEpr.getAddress();
+        int biginIndex = address.indexOf("clientid");
+        if (biginIndex != -1) {
+            msgBoxId = address.substring(biginIndex + "clientid".length() + 1);
+        } else {
+            throw new AxisFault("Invalid Message Box EPR cannot find message box ID");
+        }
+    }
+
+    public long getTimeoutInMilliSeconds() {
+        return timeoutInMilliSeconds;
+    }
+
+    public void setTimeoutInMilliSeconds(long timeout) {
+        timeoutInMilliSeconds = timeout;
+    }
+
+    public Iterator<OMElement> execute() throws AxisFault {
+        OMElement message = createMessageEl(this.msgBoxId);
+        ServiceClient serviceClient = createServiceClient(message);
+
+        OMElement responseMessage = null;
+        try {
+            responseMessage = serviceClient.sendReceive(message);
+
+            if (responseMessage == null) {
+                throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message"));
+            }
+
+            responseMessage.build(); // free the input stream.
+
+        } finally {
+            serviceClient.cleanupTransport();
+        }
+
+        Iterator<OMElement> children = responseMessage.getFirstElement().getChildren();
+        return children;
+    }
+
+    private OMElement createMessageEl(String msgboxid) throws AxisFault {
+        OMElement message = factory.createOMElement("takeMessages", MsgBoxNameSpConsts.MSG_BOX);
+        OMElement msgBoxId = factory.createOMElement("MsgBoxId", MsgBoxNameSpConsts.MSG_BOX);
+        msgBoxId.setText(msgboxid);
+        message.addChild(msgBoxId);
+        message.declareNamespace(MsgBoxNameSpConsts.MSG_BOX);
+        return message;
+    }
+
+    private ServiceClient createServiceClient(OMElement message) throws AxisFault {
+        String uuid = UUIDGenerator.getUUID();
+        Options opts = new Options();
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+        opts.setTo(msgBoxEndPointReference);
+        opts.setMessageId(uuid);
+        opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName());
+
+        opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds());
+        ServiceClient client = new ServiceClient();
+        try {
+            client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING);
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module engaged");
+        } catch (AxisFault e) {
+            if (logger.isDebugEnabled())
+                logger.debug("Addressing module not engaged :" + e);
+        }
+
+        client.setOptions(opts);
+        return client;
+    }
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ClientUtilTest.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,39 @@
+package org.apache.airavata.wsmg.client.util;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class ClientUtilTest {
+
+    /**
+     * Test method for {@link org.apache.airavata.wsmg.util.WsmgUtil#formatURLString(java.lang.String)}.
+     */
+    @Test
+    public void testFormatURLString() {
+
+        String url = "http://www.test.com/unit_test";
+
+        assertSame(url, ClientUtil.formatURLString(url));
+
+        url = "scp://test/test";
+
+        assertSame(url, ClientUtil.formatURLString(url));
+
+        url = "test/test";
+
+        assertTrue(ClientUtil.formatURLString(url).startsWith("http://"));
+
+    }
+    
+    /**
+     * Test method for {@link org.apache.airavata.wsmg.util.WsmgUtil#getHostIP()}.
+     */
+    @Test
+    public void testGetHostIP() {
+        assertNotNull(ClientUtil.getHostIP());
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/ConfigKeys.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,37 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client.util;
+
+public interface ConfigKeys {
+
+    String CONFIG_FILE_NAME = "unit_tests.properties";
+
+    String BROKER_EVENTING_SERVICE_EPR = "broker.eventing.service.epr";
+    String BROKER_NOTIFICATIONS_SERVICE_EPR = "broker.notification.service.epr";
+
+    String CONSUMER_EPR = "consumer.location";
+    String CONSUMER_PORT = "consumer.port";
+    String TOPIC_SIMPLE = "topic.simple";
+    String TOPIC_XPATH = "topic.xpath";
+    String AXIS2_REPO = "axis2.repo";
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/util/TestDcDate.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,106 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.client.util;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+public class TestDcDate extends TestCase {
+
+    @Test
+    public void testDcDate() {
+        DcDate d;
+
+        // d = new DcDate("1997-07-16T19:20:30.45+01:00");
+
+        d = new DcDate(TimeZone.getDefault());
+
+        String dc = d.getDcDate();
+
+        // System.out.println(getClass()+" dc="+dc);
+
+        new DcDate(dc);
+        Calendar loc = new GregorianCalendar();
+        assertEquals(d.getYear(), loc.get(Calendar.YEAR));
+        assertEquals(d.getMonth(), loc.get(Calendar.MONTH) + 1);
+        assertEquals(d.getDay(), loc.get(Calendar.DAY_OF_MONTH));
+        assertEquals(d.getHour(), loc.get(Calendar.HOUR_OF_DAY));
+        assertEquals(d.getMinute(), loc.get(Calendar.MINUTE));
+
+        int tzOffset = TimeZone.getDefault().getRawOffset() / (60 * 1000);
+        int tzOffsetHours = tzOffset / 60;
+        assertEquals(tzOffset, d.getTimeZoneOffset());
+
+        DcDate dZ = new DcDate(TimeZone.getTimeZone("GMT"));
+
+        // System.out.println(getClass()+" dZ="+dZ);
+
+        assertEquals(0, dZ.getTimeZoneOffset());
+        // assertEquals(d.getDay() + tzOffset, dZ.getDay()); //may fail!
+        int localHour = dZ.getHour() + tzOffsetHours;
+        if (localHour > 24) {
+            localHour -= 24;
+        }
+        if (localHour < 0) {
+            localHour += 24;
+        }
+        // assertEquals(d.getHour(), localHour);
+
+        //
+        d = new DcDate("1997");
+        assertEquals(1997, d.getYear());
+        //
+        d = new DcDate("1997-07");
+        assertEquals(1997, d.getYear());
+        assertEquals(7, d.getMonth());
+        //
+        d = new DcDate("1997-07-16");
+        assertEquals(1997, d.getYear());
+        assertEquals(7, d.getMonth());
+        assertEquals(16, d.getDay());
+
+        // 1997-07-16T19:20+01:00
+        d = new DcDate("1997-07-16T19:20+01:00");
+        assertEquals(1997, d.getYear());
+        assertEquals(7, d.getMonth());
+        assertEquals(16, d.getDay());
+        assertEquals(19, d.getHour());
+        assertEquals(20, d.getMinute());
+        assertEquals(1 * 60, d.getTimeZoneOffset());
+        // 1997-07-16T19:20:30+01:00
+        d = new DcDate("1997-07-16T19:20:30+01:00");
+        // 1997-07-16T19:20:30.45+01:00
+        d = new DcDate("1997-07-16T19:20:30.45+01:00");
+        assertEquals("45", d.getDecimalFraction());
+        // Ex: 2004-04-13T11:53:15.4362784-04:00
+        d = new DcDate("2004-04-13T11:53:15.4362784-04:00");
+        assertEquals(13, d.getDay());
+        assertEquals("4362784", d.getDecimalFraction());
+
+    }
+
+}

Added: incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java?rev=1170887&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java (added)
+++ incubator/airavata/trunk/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/gui/GUITest.java Wed Sep 14 22:56:19 2011
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.wsmg.gui;
+
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.airavata.wsmg.client.util.ConfigKeys;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GUITest {
+
+    static Properties configs = new Properties();
+
+    @Before
+    public void setUp() throws Exception {
+        URL configURL = ClassLoader.getSystemResource(ConfigKeys.CONFIG_FILE_NAME);
+        configs.load(configURL.openStream());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testGUI() {
+        String[] args = new String[] { configs.getProperty(ConfigKeys.AXIS2_REPO) };
+
+        NotificationViewer.main(args);
+
+    }
+
+}