You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2011/12/20 21:04:28 UTC

svn commit: r1221464 - in /incubator/airavata/trunk/modules/xbaya-gui/src: main/java/org/apache/airavata/xbaya/wf/ test/java/org/apache/airavata/xbaya/interpreter/ test/java/org/apache/airavata/xbaya/interpreter/utils/ test/resources/conf/

Author: lahiru
Date: Tue Dec 20 20:04:28 2011
New Revision: 1221464

URL: http://svn.apache.org/viewvc?rev=1221464&view=rev
Log:
dding tests to xbaya to test workflow tracking.

Added:
    incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java
    incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java
    incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowTrackingTest.java
    incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/ConfigKeys.java
    incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/TestUtilServer.java
    incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/conf/
    incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/conf/msgBroker.properties
Modified:
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java?rev=1221464&r1=1221463&r2=1221464&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java Tue Dec 20 20:04:28 2011
@@ -149,7 +149,7 @@ public class Workflow implements Cloneab
 
     private QName qname;
 
-    private XBayaExecutionState executionState = XBayaExecutionState.NONE;
+    private volatile XBayaExecutionState executionState = XBayaExecutionState.NONE;
 
     private WsdlDefinitions tridentWSDL;
 

Added: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java?rev=1221464&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java Tue Dec 20 20:04:28 2011
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.xbaya.interpreter;
+
+import org.apache.airavata.wsmg.client.NotificationHandler;
+
+public class Listener implements NotificationHandler {
+
+    public void handleNotification(String message) {
+       System.out.println("MessageRecieved: " + message);
+   }
+
+}

Added: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java?rev=1221464&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java Tue Dec 20 20:04:28 2011
@@ -0,0 +1,204 @@
+/*
+ *
+ * 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.xbaya.interpreter;
+
+
+import org.apache.airavata.workflow.tracking.NotifierFactory;
+import org.apache.airavata.workflow.tracking.WorkflowNotifier;
+import org.apache.airavata.workflow.tracking.common.InvocationContext;
+import org.apache.airavata.workflow.tracking.common.InvocationEntity;
+import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext;
+import org.apache.axis2.addressing.EndpointReference;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.net.URI;
+import java.util.Properties;
+
+public class NotificationSender {
+
+    protected WorkflowNotifier notifier;
+
+    protected String brokerURL;
+
+    protected String topic;
+
+    protected URI workflowID;
+
+    protected InvocationEntity initiator;
+
+    protected InvocationEntity receiver;
+
+    protected InvocationContext invocationContext;
+
+    protected EndpointReference eventSink;
+
+    protected WorkflowTrackingContext context;
+
+    /**
+     * Constructs a NotificationSender.
+     *
+     * @param brokerURL
+     * @param topic
+     */
+    public NotificationSender(URI brokerURL, String topic) {
+        this(brokerURL.toString(), topic);
+    }
+
+    /**
+     * Creates a NotificationSender.
+     *
+     * @param brokerURL The location of notification brokerUrl.
+     * @param topic     The notification topic.
+     */
+    public NotificationSender(String brokerURL, String topic) {
+        this.topic = topic;
+        this.brokerURL = brokerURL;
+        this.workflowID = URI.create(this.convertToJavaIdentifier(this.topic));
+        this.eventSink = new EndpointReference(this.brokerURL);
+        Properties props = new Properties();
+
+        this.notifier = NotifierFactory.createNotifier();
+        URI initiatorWorkflowID = null;
+        URI initiatorServiceID = URI.create(this.convertToJavaIdentifier(topic));
+        String initiatorWorkflowNodeID = null;
+        Integer initiatorWorkflowTimeStep = null;
+        this.context = this.notifier.createTrackingContext(props, brokerURL, initiatorWorkflowID,
+                initiatorServiceID, initiatorWorkflowNodeID, initiatorWorkflowTimeStep);
+        this.context.setTopic(topic);
+        this.initiator = this.notifier.createEntity(initiatorWorkflowID, initiatorServiceID, initiatorWorkflowNodeID,
+                initiatorWorkflowTimeStep);
+
+        URI receiverWorkflowID = this.workflowID;
+        URI receiverServiceID = this.workflowID;
+        String receiverWorkflowNodeID = null;
+        Integer receiverWorkflowTimeStep = null;
+        this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID,
+                receiverWorkflowTimeStep);
+    }
+
+    /**
+     * @return The event sink EPR.
+     */
+    public EndpointReference getEventSink() {
+        return this.eventSink;
+    }
+
+
+    public void workflowStarted(String message) {
+        this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator, message);
+    }
+
+
+    public void workflowFinished(String message) {
+        this.notifier.sendingResult(context, this.invocationContext, message);
+        this.notifier.workflowTerminated(context, this.workflowID, "Workflow finished successfully.");
+    }
+
+    public void sendingPartialResults(Object[] args, String[] keywords) {
+        String message = "";
+        for (int i = 0; i < args.length; i++) {
+            if (i != 0) {
+                message += ", ";
+            }
+            message += keywords[i] + "=" + args[i];
+        }
+        this.notifier.sendingResult(context, this.invocationContext, message);
+    }
+
+
+    public void workflowTerminated() {
+        this.notifier.workflowTerminated(context, this.workflowID, "Workflow finished successfully.");
+    }
+
+    /**
+     * Sends a START_INCOMPLETED notification message.
+     *
+     * @param message The message to send
+     */
+    public void workflowFailed(String message) {
+        workflowFailed(message, null);
+    }
+
+    /**
+     * Sends a START_INCOMPLETED notification message.
+     *
+     * @param e
+     */
+    public void workflowFailed(Throwable e) {
+        workflowFailed(null, e);
+    }
+
+    /**
+     * Sends a START_INCOMPLETED notification message.
+     *
+     * @param message The message to send
+     * @param e
+     */
+    public void workflowFailed(String message, Throwable e) {
+        this.notifier.sendingFault(context, this.invocationContext, message);
+    }
+
+    public void info(String message) {
+        this.notifier.info(context, message);
+    }
+
+    /**
+     * @param throwable
+     * @return The stackTrace in String
+     */
+    public static String getStackTraceInString(Throwable throwable) {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        PrintStream printStream = new PrintStream(byteArrayOutputStream);
+        throwable.printStackTrace(printStream);
+        printStream.flush();
+        return byteArrayOutputStream.toString();
+    }
+
+    public static String convertToJavaIdentifier(String name) {
+
+        final char REPLACE_CHAR = '_';
+
+        if (name == null || name.length() == 0) {
+            return "" + REPLACE_CHAR;
+        }
+
+        StringBuilder buf = new StringBuilder();
+
+        char c = name.charAt(0);
+        if (!Character.isJavaIdentifierStart(c)) {
+            // Add _ at the beggining instead of replacing it to _. This is
+            // more readable if the name is like 3D_Model.
+            buf.append(REPLACE_CHAR);
+        }
+
+        for (int i = 0; i < name.length(); i++) {
+            c = name.charAt(i);
+            if (Character.isJavaIdentifierPart(c)) {
+                buf.append(c);
+            } else {
+                buf.append(REPLACE_CHAR);
+            }
+        }
+
+        return buf.toString();
+    }
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowTrackingTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowTrackingTest.java?rev=1221464&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowTrackingTest.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowTrackingTest.java Tue Dec 20 20:04:28 2011
@@ -0,0 +1,100 @@
+/*
+ *
+ * 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.xbaya.interpreter;
+
+
+import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.airavata.wsmg.client.ConsumerNotificationHandler;
+import org.apache.airavata.wsmg.client.WseMsgBrokerClient;
+import org.apache.airavata.xbaya.interpreter.utils.ConfigKeys;
+import org.apache.airavata.xbaya.interpreter.utils.TestUtilServer;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+
+import org.apache.airavata.wsmg.client.msgbox.MessagePuller;
+import org.apache.axis2.addressing.EndpointReference;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import java.io.*;
+
+import org.junit.Test;
+
+public class WorkflowTrackingTest implements ConsumerNotificationHandler{
+
+       public void handleNotification(SOAPEnvelope msgEnvelope) {
+        System.out.println("Received " + msgEnvelope);
+        String message = "<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header><wsa:Action xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">http://org.apache.airavata/WseNotification</wsa:Action><wsa:MessageID xmlns:wsa=\"http://www.w3.org/2005/08/addressing\" /><wsa:To xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">http://140.182.151.20:61436/axis2/services/ConsumerService/</wsa:To><wsnt:Topic xmlns:wsnt=\"http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification\" xmlns:ns2=\"http://tutorial.globus.org/auction\" Dialect=\"http://www.ibm.com/xmlns/stdwip/web-services/WS-Topics/TopicExpression/simple\">ns2:abc</wsnt:Topic></soapenv:Header><soapenv:Body><wor:workflowInvoked xmlns:wor=\"http://airavata.apache.org/schemas/workflow_tracking_types\" infoModelVersion=\"2.6\"><wor:notificationSource wor:serviceID=\"abc\" /><wor:timestamp>2011-12-20T14:47:33.736-05:00</wor:timestamp><wor:desc
 ription>Workflow Started</wor:description><wor:annotation /><wor:initiator wor:serviceID=\"abc\" /></wor:workflowInvoked></soapenv:Body></soapenv:Envelope>";
+        Assert.assertEquals(message,msgEnvelope);
+    }
+
+    private static Properties getDefaults() {
+            Properties defaults = new Properties();
+            defaults.setProperty(ConfigKeys.MSGBOX_SERVICE_URL,
+                    "http://localhost:8080/axis2/services/MsgBoxService");
+            defaults.setProperty(ConfigKeys.MSGBROKER_SERVICE_URL,
+                    "http://localhost:8080/axis2/services/EventingService");
+            defaults.setProperty(ConfigKeys.TOPIC, "abc");
+            return defaults;
+        }
+
+    protected void setUp() throws Exception {
+        TestUtilServer.start(null, null);
+    }
+
+    protected void tearDown() throws Exception {
+            TestUtilServer.stop();
+    }
+
+    @Test
+    public void WorkflowTrackingtest() throws Exception{
+        setUp();
+        Properties configurations = new Properties(getDefaults());
+        WseMsgBrokerClient brokerClient = new WseMsgBrokerClient();
+        String brokerLocation = "http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/EventingService";
+        brokerClient.init(brokerLocation);
+        String topic = configurations.getProperty(ConfigKeys.TOPIC);
+        NotificationSender sender = null;
+        sender = new NotificationSender(brokerLocation, topic);
+
+        int consumerPort = TestUtilServer.getAvailablePort();
+
+            String[] consumerEPRs = brokerClient.startConsumerService(consumerPort, this);
+        // subscribing to the above created messsage box with configured topic
+        String subscriptionID = brokerClient.subscribe(consumerEPRs[0], topic, null);
+
+        sender.workflowStarted("Workflow Started");
+
+        //Here we simply assume the workflow invocation is the invoke of the subscribe operation of EventingService and result
+        // Is considered as the subscriptionID got from subscribe operation
+        try {
+            Thread.sleep(10000L);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        brokerClient.unSubscribe(subscriptionID);
+        Assert.assertEquals(brokerLocation,"http://localhost:" + TestUtilServer.TESTING_PORT + "/axis2/services/EventingService");
+        tearDown();
+    }
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/ConfigKeys.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/ConfigKeys.java?rev=1221464&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/ConfigKeys.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/ConfigKeys.java Tue Dec 20 20:04:28 2011
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.xbaya.interpreter.utils;
+
+
+public class ConfigKeys {
+
+	public static final String AXIS2_REPO = "axis2.repository";
+	public static final String CONFIG_FILE_NAME = "configuration.properties";
+	public static final String MSGBOX_SERVICE_URL = "msgbox.service.url";
+    public static final String MSGBROKER_SERVICE_URL = "msgbroker.service.url";
+	public static final String MSGBOX_ID = "msgbox.id";
+    public static final String TOPIC = "abc";
+
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/TestUtilServer.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/TestUtilServer.java?rev=1221464&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/TestUtilServer.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/utils/TestUtilServer.java Tue Dec 20 20:04:28 2011
@@ -0,0 +1,243 @@
+/*
+ *
+ * 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.xbaya.interpreter.utils;
+
+/*
+ *
+ * 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.
+ *
+*/
+
+import org.apache.airavata.wsmg.broker.BrokerServiceLifeCycle;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.engine.ServiceLifeCycle;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.net.ServerSocket;
+
+public class TestUtilServer {
+    private static int count = 0;
+
+    private static SimpleHTTPServer receiver;
+
+    public static int TESTING_PORT = 5555;
+
+    public static final String FAILURE_MESSAGE = "Intentional Failure";
+
+    public static synchronized void deployService(AxisService service) throws AxisFault {
+        receiver.getConfigurationContext().getAxisConfiguration().addService(service);
+    }
+
+    public static synchronized void unDeployService(QName service) throws AxisFault {
+        receiver.getConfigurationContext().getAxisConfiguration().removeService(service.getLocalPart());
+    }
+
+    public static synchronized void unDeployClientService() throws AxisFault {
+        if (receiver.getConfigurationContext().getAxisConfiguration() != null) {
+            receiver.getConfigurationContext().getAxisConfiguration().removeService("AnonymousService");
+        }
+    }
+
+    public static synchronized void start(String repository, String axis2xml) throws Exception {
+        if (count == 0) {
+            ConfigurationContext er = getNewConfigurationContext(repository, axis2xml);
+            TESTING_PORT = getAvailablePort();
+            receiver = new SimpleHTTPServer(er, TESTING_PORT);
+
+            try {
+                receiver.start();
+                System.out.print("Server started on port " + TESTING_PORT + ".....");
+            } catch (Exception e) {
+                throw AxisFault.makeFault(e);
+            }
+
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e1) {
+                throw new AxisFault("Thread interuptted", e1);
+            }
+            startBroker();
+        }
+        count++;
+    }
+
+    public static void startBroker() throws Exception {
+
+        ServiceLifeCycle brokerLifeCycle = new BrokerServiceLifeCycle();
+
+        final String configFileParam = "configuration.file.name";
+        final String configFileValue = "conf/msgBroker.properties";
+
+        AxisService notificationService = getNotificationService();
+        notificationService.addParameter(configFileParam, configFileValue);
+        notificationService.setServiceLifeCycle(brokerLifeCycle);
+        TestUtilServer.deployService(notificationService);
+        brokerLifeCycle.startUp(TestUtilServer.getConfigurationContext(), notificationService);
+
+        AxisService eventingService = getEventingService();
+        eventingService.addParameter(configFileParam, configFileValue);
+        eventingService.setServiceLifeCycle(brokerLifeCycle);
+        TestUtilServer.deployService(eventingService);
+        brokerLifeCycle.startUp(TestUtilServer.getConfigurationContext(), eventingService);
+
+    }
+
+    public static AxisService getEventingService() {
+
+        AxisService eventingService = new AxisService("EventingService");
+
+        createOperation(eventingService, "renew",
+                new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(),
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew",
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/RenewResponse");
+        createOperation(eventingService, "getStatus",
+                new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(),
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus",
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatusResponse");
+
+        createOperation(eventingService, "subscriptionEnd",
+                new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(),
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscriptionEnd", null);
+
+        createOperation(eventingService, "subscribe",
+                new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(),
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe",
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscribeResponse");
+        createOperation(eventingService, "unsubscribe",
+                new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(),
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe",
+                "http://schemas.xmlsoap.org/ws/2004/08/eventing/UnsubscribeResponse");
+        createOperation(eventingService, "publish",
+                new org.apache.airavata.wsmg.broker.wseventing.WSEventingPublishMsgReceiver(),
+                "http://org.apache.airavata/WseNotification", null);
+
+        return eventingService;
+    }
+
+    public static AxisService getNotificationService() {
+
+        AxisService notificationService = new AxisService("NotificationService");
+
+        createOperation(notificationService, "notify",
+                new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(),
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/Notify",
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/NotifyResponse");
+
+        createOperation(notificationService, "subscribe",
+                new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(),
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/SubscribeRequest",
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/SubscribeRequestResponse");
+
+        createOperation(notificationService, "getCurrentMessage",
+                new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(),
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/GetCurrentMessageRequest",
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/GetCurrentMessageResponse");
+
+        createOperation(notificationService, "pauseSubscription",
+                new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(),
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/PauseSubsriptionRequest",
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/PauseSubscriptionResponse");
+
+        createOperation(notificationService, "resumeSubscription",
+                new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(),
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/ResumeSubsriptionRequest",
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/ResumeSubscriptionResponse");
+
+        createOperation(notificationService, "unsubscribe",
+                new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(),
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/UnsubsribeRequest",
+                "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/UnsubscribeResponse");
+
+        return notificationService;
+
+    }
+
+    public static void createOperation(AxisService axisService, String name, MessageReceiver messageReceiver,
+            String inputAction, String outputAction) {
+        InOutAxisOperation operation1 = new InOutAxisOperation(new QName(name));
+        operation1.setMessageReceiver(messageReceiver);
+        operation1.setOutputAction(outputAction);
+        axisService.addOperation(operation1);
+        if (inputAction != null) {
+            axisService.mapActionToOperation(inputAction, operation1);
+        }
+    }
+
+    public static ConfigurationContext getNewConfigurationContext(String repository, String axis2xml) throws Exception {
+        return ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository, axis2xml);
+    }
+
+    public static synchronized void stop() throws AxisFault {
+        if (count == 1) {
+            receiver.stop();
+            while (receiver.isRunning()) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e1) {
+                    // nothing to do here
+                }
+            }
+            count = 0;
+            // tp.doStop();
+            System.out.print("Server stopped .....");
+        } else {
+            count--;
+        }
+        receiver.getConfigurationContext().terminate();
+    }
+
+    public static ConfigurationContext getConfigurationContext() {
+        return receiver.getConfigurationContext();
+    }
+
+    public static int getAvailablePort(){
+        ServerSocket serverSocket = null;
+        try {
+             serverSocket = new ServerSocket(0);
+             serverSocket.close();
+        } catch (IOException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        return serverSocket.getLocalPort();
+    }
+}

Added: incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/conf/msgBroker.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/conf/msgBroker.properties?rev=1221464&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/conf/msgBroker.properties (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/test/resources/conf/msgBroker.properties Tue Dec 20 20:04:28 2011
@@ -0,0 +1,64 @@
+#
+# 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.
+#
+
+#Sample configuration file for broker
+
+
+#database realted settings (only applicable if 'broker.storage.type=persistent')
+#For mysql database configuration
+#broker.jdbc.driver=com.mysql.jdbc.Driver
+#broker.jdbc.url=jdbc:mysql://localhost:3306/wsmg?user=airavata&password=airavata
+
+#Default derby database configuration
+broker.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
+broker.jdbc.url=jdbc:derby:wsmg;create=true;user=airavata;password=airavata
+
+#socket time out in milliseconds for sending messages. (defaults is 20000)
+broker.socket.timeout=60000
+
+
+#broker.storage.type=persistent
+broker.storage.type=memory
+
+#specifies wether delivery component should be started or not.
+broker.start.delivery.thread=true
+
+
+#fixed thread pool based delivery
+#broker.delivery.method=pcrew
+
+#dynamic thread pool based delivery
+#broker.delivery.method=parallel
+
+#single thread delivery
+broker.delivery.method=serial
+
+#number of message delivery failures before a url become black listed (default is 2)
+#broker.msg.delivery.retries=2
+
+#time period (in seconds) a url will be kept blacklisted (default is 5 seconds)
+#consumer.expiration.time.gap=5
+
+#maximum number of messages to be send to a one consumer/url at time.
+#applicable if 'broker.delivery.method' is 'pcrew' . (default is 10)
+
+#sending.batch.size=10
+
+#size of the thread pool. only applicable if 'broker.delivery.method' is 'pcrew'. (default is 4)
+#sending.thread.pool.size=4