You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by hi...@apache.org on 2010/09/27 06:27:58 UTC

svn commit: r1001584 - in /synapse/branches/2.0: modules/core/src/main/java/org/apache/synapse/config/xml/ modules/core/src/test/java/org/apache/synapse/config/xml/ src/site/xdoc/

Author: hiranya
Date: Mon Sep 27 04:27:57 2010
New Revision: 1001584

URL: http://svn.apache.org/viewvc?rev=1001584&view=rev
Log:
Message store test case (SYNAPSE-618)


Added:
    synapse/branches/2.0/modules/core/src/test/java/org/apache/synapse/config/xml/MessageStoreSerializationTest.java
Modified:
    synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/MessageStoreSerializer.java
    synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigConstants.java
    synapse/branches/2.0/src/site/xdoc/Synapse_Samples.xml

Modified: synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/MessageStoreSerializer.java
URL: http://svn.apache.org/viewvc/synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/MessageStoreSerializer.java?rev=1001584&r1=1001583&r2=1001584&view=diff
==============================================================================
--- synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/MessageStoreSerializer.java (original)
+++ synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/MessageStoreSerializer.java Mon Sep 27 04:27:57 2010
@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.synapse.SynapseConstants;
 import org.apache.synapse.SynapseException;
 import org.apache.synapse.message.store.MessageStore;
+import org.apache.synapse.message.store.InMemoryMessageStore;
 
 import javax.xml.namespace.QName;
 import java.util.Iterator;
@@ -53,30 +54,30 @@ public class MessageStoreSerializer {
 
     public static OMElement serializeMessageStore(OMElement parent, MessageStore messageStore) {
 
-        OMElement store = fac.createOMElement(XMLConfigConstants.MESSAGE_STORE_ELT);
+        OMElement store = fac.createOMElement("messageStore", synNS);
 
         if (messageStore.getProviderClass() != null) {
-            store.addAttribute(fac.createOMAttribute("class", nullNS,
-                    messageStore.getProviderClass()));
+            if (!messageStore.getProviderClass().equals(InMemoryMessageStore.class.getName())) {
+                store.addAttribute(fac.createOMAttribute("class", nullNS,
+                        messageStore.getProviderClass()));
+            }
         } else {
             handleException("Invalid MessageStore. Provider is required");
         }
 
         if (messageStore.getSequence() != null) {
-            store.addAttribute(fac.createOMAttribute("sequence", nullNS,
-                    messageStore.getSequence()));
+            store.addAttribute(fac.createOMAttribute("sequence", nullNS, messageStore.getSequence()));
         }
 
         if (messageStore.getName() != null) {
-            store.addAttribute(fac.createOMAttribute("name", nullNS,
-                    messageStore.getSequence()));
+            store.addAttribute(fac.createOMAttribute("name", nullNS, messageStore.getName()));
         } else {
             handleException("Message store Name not specified");
         }
 
         //Redelivery processor
         OMElement redilevery = fac.createOMElement("redelivery", synNS);
-        int reDeliveryDelay = messageStore.getRedeliveryProcessor().getRedeliveryDelay()/1000;
+        int reDeliveryDelay = messageStore.getRedeliveryProcessor().getRedeliveryDelay() / 1000;
 
         OMElement delay = fac.createOMElement("interval", synNS);
         delay.setText(String.valueOf(reDeliveryDelay));

Modified: synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigConstants.java
URL: http://svn.apache.org/viewvc/synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigConstants.java?rev=1001584&r1=1001583&r2=1001584&view=diff
==============================================================================
--- synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigConstants.java (original)
+++ synapse/branches/2.0/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigConstants.java Mon Sep 27 04:27:57 2010
@@ -63,7 +63,7 @@ public class XMLConfigConstants {
     public static final QName REGISTRY_ELT    = new QName(SYNAPSE_NAMESPACE, "registry");
     public static final QName PROXY_ELT       = new QName(SYNAPSE_NAMESPACE, "proxy");
     public static final QName EVENT_SOURCE_ELT = new QName(SYNAPSE_NAMESPACE, "eventSource");
-    public static final QName MESSAGE_STORE_ELT = new QName(SYNAPSE_NAMESPACE,"messageStore");
+    public static final QName MESSAGE_STORE_ELT = new QName(SYNAPSE_NAMESPACE, "messageStore");
     public static final String NULL_NAMESPACE = "";
     public static final Object QUARTZ_QNAME   =
         new QName("http://www.opensymphony.com/quartz/JobSchedulingData", "quartz");

Added: synapse/branches/2.0/modules/core/src/test/java/org/apache/synapse/config/xml/MessageStoreSerializationTest.java
URL: http://svn.apache.org/viewvc/synapse/branches/2.0/modules/core/src/test/java/org/apache/synapse/config/xml/MessageStoreSerializationTest.java?rev=1001584&view=auto
==============================================================================
--- synapse/branches/2.0/modules/core/src/test/java/org/apache/synapse/config/xml/MessageStoreSerializationTest.java (added)
+++ synapse/branches/2.0/modules/core/src/test/java/org/apache/synapse/config/xml/MessageStoreSerializationTest.java Mon Sep 27 04:27:57 2010
@@ -0,0 +1,66 @@
+/*
+ *  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.synapse.config.xml;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.message.store.MessageStore;
+
+import java.util.Properties;
+
+public class MessageStoreSerializationTest extends AbstractTestCase {
+
+    MessageStoreFactory messageStoreFactory;
+
+    MessageStoreSerializer messageStoreSerializer;
+
+    public MessageStoreSerializationTest() {
+        super(MessageStoreSerializationTest.class.getName());
+        this.messageStoreSerializer = new MessageStoreSerializer();
+    }
+
+    public void testMessageStoreSerialization() throws Exception {
+        String messageStoreConfiguration = "<syn:messageStore xmlns:syn=\"" +
+                "http://synapse.apache.org/ns/2010/04/configuration\"" +
+                " name=\"foo\" sequence=\"seq1\" >" +
+                "<syn:redelivery>" +
+                "<syn:interval>1</syn:interval>" +
+                "<syn:maximumRedeliveries>5</syn:maximumRedeliveries>" +
+                "<syn:exponentialBackoff>true</syn:exponentialBackoff>" +
+                "<syn:backoffMutiplier>2</syn:backoffMutiplier>" +
+                "</syn:redelivery>" +
+                "</syn:messageStore>";
+
+        OMElement messageStoreElement = createOMElement(messageStoreConfiguration);
+        MessageStore messageStore = MessageStoreFactory.createMessageStore(messageStoreElement,
+                new Properties());
+        OMElement serializedElement = MessageStoreSerializer.serializeMessageStore(null,
+                messageStore);
+
+        try {
+            assertTrue(compare(messageStoreElement, serializedElement));
+        } catch (Exception e) {
+            fail("Exception in test.");
+        }
+        
+    }
+
+   
+
+}

Modified: synapse/branches/2.0/src/site/xdoc/Synapse_Samples.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.0/src/site/xdoc/Synapse_Samples.xml?rev=1001584&r1=1001583&r2=1001584&view=diff
==============================================================================
--- synapse/branches/2.0/src/site/xdoc/Synapse_Samples.xml (original)
+++ synapse/branches/2.0/src/site/xdoc/Synapse_Samples.xml Mon Sep 27 04:27:57 2010
@@ -2506,11 +2506,11 @@ Transfer-Encoding: chunked
 <strong>Objective: Using the mail transport with Proxy services</strong> </p>
 <p>
 <strong>Prerequisites:</strong>
-<br/> You will need access to an email account </p>
-<p>Start the Axis2 server and deploy the SimpleStockQuoteService if not already done </p>
-<p>Enable mail transport sender in the Synapse axis2.xml. See 
-<a href="Synapse_Samples_Setup.html#mailsender">Setting up mail transport sender</a> </p>
-<p>Start the Synapse configuration numbered 256: i.e. synapse -sample 256 </p>
+<br/> You will need access to an email account
+<br/>Start the Axis2 server and deploy the SimpleStockQuoteService if not already done
+<br/>Enable mail transport sender in the Synapse axis2.xml. See
+<a href="Synapse_Samples_Setup.html#mailsender">Setting up mail transport sender</a>
+<br/>Start the Synapse configuration numbered 256: i.e. synapse -sample 256 </p>
 <p>Send an email with the following body and any custom Subject from your mail account. </p>
 <pre xml:space="preserve">&lt;getQuote xmlns=&quot;http://services.samples&quot;&gt;
    &lt;request xmlns=&quot;http://services.samples/xsd&quot;&gt;