You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by jg...@apache.org on 2006/02/11 07:38:21 UTC

svn commit: r376936 - in /incubator/servicemix/trunk: servicemix-components/src/test/java/org/apache/servicemix/components/jca/ servicemix-components/src/test/java/org/apache/servicemix/components/net/ servicemix-components/src/test/java/org/apache/ser...

Author: jgapuz
Date: Fri Feb 10 22:38:20 2006
New Revision: 376936

URL: http://svn.apache.org/viewcvs?rev=376936&view=rev
Log:
- added Optional Axis Queries Test (in this case preceding sibling).
- added option to send messages using a custom xml to TestSupport.java

Added:
    incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/xslt/OptionalAxisQueriesTest.java
    incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis-example.xml
    incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis.xsl
Modified:
    incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/jca/JmsOverJcaWithFullXATest.java
    incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/net/FTPPollTest.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/TestSupport.java

Modified: incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/jca/JmsOverJcaWithFullXATest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/jca/JmsOverJcaWithFullXATest.java?rev=376936&r1=376935&r2=376936&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/jca/JmsOverJcaWithFullXATest.java (original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/jca/JmsOverJcaWithFullXATest.java Fri Feb 10 22:38:20 2006
@@ -29,7 +29,7 @@
     public void testSendMessagesToJmsThenOutofJmsToReceiver() throws Exception {
         QName service = new QName("http://servicemix.org/cheese/", "myJmsSender");
 
-        sendMessages(service, messageCount, false);
+        sendMessages(service, messageCount, false, null);
         assertMessagesReceived(messageCount);
     }
 

Modified: incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/net/FTPPollTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/net/FTPPollTest.java?rev=376936&r1=376935&r2=376936&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/net/FTPPollTest.java (original)
+++ incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/net/FTPPollTest.java Fri Feb 10 22:38:20 2006
@@ -29,7 +29,7 @@
     public void testSendMessagesToFTPThenPollThemAgain() throws Exception {
         QName service = new QName("http://servicemix.org/cheese/", "ftpSender");
 
-        sendMessages(service, messageCount, false);
+        sendMessages(service, messageCount, false, null);
         assertMessagesReceived(messageCount);
     }
 

Added: incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/xslt/OptionalAxisQueriesTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/xslt/OptionalAxisQueriesTest.java?rev=376936&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/xslt/OptionalAxisQueriesTest.java (added)
+++ incubator/servicemix/trunk/servicemix-components/src/test/java/org/apache/servicemix/components/xslt/OptionalAxisQueriesTest.java Fri Feb 10 22:38:20 2006
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.components.xslt;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.apache.servicemix.tck.TestSupport;
+import org.apache.servicemix.tck.MessageList;
+
+import javax.xml.namespace.QName;
+
+
+public class OptionalAxisQueriesTest extends TestSupport {
+
+    public void testOptionalAxisQuery() throws Exception {
+        QName service = new QName("http://servicemix.org/cheese/", "transformer");
+
+       String message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+               "    <prod:resolveItemXrefResponse " +
+               "           xmlns:prod=\"http://foo.org/prod\" " +
+               "           xmlns:xsi=\"http://foo.org/msi\"" +
+               "           xmlns:ms=\"http://foo.org/ms\">" +
+               "      <prod:response xsi:type=\"wn4:HashMap\">" +
+               "        <ms:Keys>" +
+               "          <ms:Item xsi:type=\"d:string\">DESCR</ms:Item>" +
+               "          <ms:Item xsi:type=\"d:string\">LIST</ms:Item>" +
+               "          <ms:Item xsi:type=\"d:string\">XREF</ms:Item>" +
+               "          <ms:Item xsi:type=\"d:string\">MSTR</ms:Item>" +
+               "        </ms:Keys>" +
+               "        <ms:Values>" +
+               "          <ms:Item xsi:type=\"d:string\">PPR,CPY,20#,84B,LGL,WE</ms:Item>" +
+               "          <ms:Item xsi:type=\"d:double\">17.25</ms:Item>" +
+               "          <ms:Item xsi:type=\"d:string\">EXP8514</ms:Item>" +
+               "          <ms:Item xsi:type=\"d:string\">10040300</ms:Item>" +
+               "        </ms:Values>" +
+               "      </prod:response>" +
+               "    </prod:resolveItemXrefResponse>";
+
+        // send a custom xml message
+        sendMessages(service, 1, message);
+        assertMessagesReceived(1);
+
+        MessageList messageList1 = assertMessagesReceived("service1", 1);
+        MessageList messageList2 = assertMessagesReceived("service2", 1);
+        MessageList messageList3 = assertMessagesReceived("service3", 1);
+        MessageList messageList4 = assertMessagesReceived("service4", 1);
+        MessageList messageList5 = assertMessagesReceived("service5", 1);
+        MessageList messageList6 = assertMessagesReceived("service6", 1);
+
+        assertMessageHeader(messageList1, 0, "foo", "PPR,CPY,20#,84B,LGL,WE");
+        assertMessageHeader(messageList2, 0, "foo", "17.25");
+        assertMessageHeader(messageList3, 0, "foo", "EXP8514");
+        assertMessageHeader(messageList4, 0, "foo", "10040300");
+        assertMessageHeader(messageList5, 0, "foo", "4");
+        assertMessageHeader(messageList6, 0, "foo", "PPR,CPY,20#,84B,LGL,WE");
+
+    }
+
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext("org/apache/servicemix/components/xslt/optional-axis-example.xml");
+    }
+
+}

Added: incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis-example.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis-example.xml?rev=376936&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis-example.xml (added)
+++ incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis-example.xml Fri Feb 10 22:38:20 2006
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+    xmlns:foo="http://servicemix.org/cheese/">
+
+    <sm:container id="jbi" embedded="true">
+        <sm:activationSpecs>
+
+            <sm:activationSpec componentName="transformer" service="foo:transformer">
+                <sm:component>
+                    <bean class="org.apache.servicemix.components.xslt.XsltComponent">
+                        <property name="xsltResource" value="classpath:org/apache/servicemix/components/xslt/optional-axis.xsl"/>
+
+                        <!-- lets disable automatic output of the result of the transform; only if we perform
+                            an invoke in the XSLT will we invoke another endpoint -->
+                        <property name="disableOutput" value="true"/>
+                    </bean>
+                </sm:component>
+            </sm:activationSpec>
+
+
+            <sm:activationSpec componentName="service1" service="foo:service1">
+                <sm:component>
+                    <bean class="org.apache.servicemix.tck.ReceiverComponent"/>
+                </sm:component>
+            </sm:activationSpec>
+
+            <sm:activationSpec componentName="service2" service="foo:service2">
+               <sm:component><bean class="org.apache.servicemix.tck.ReceiverComponent"/></sm:component>
+            </sm:activationSpec>
+
+            <sm:activationSpec componentName="service3" service="foo:service3">
+               <sm:component><bean class="org.apache.servicemix.tck.ReceiverComponent"/></sm:component>
+            </sm:activationSpec>
+
+            <sm:activationSpec componentName="service4" service="foo:service4">
+               <sm:component><bean class="org.apache.servicemix.tck.ReceiverComponent"/></sm:component>
+            </sm:activationSpec>
+
+            <sm:activationSpec componentName="service5" service="foo:service5">
+               <sm:component><bean class="org.apache.servicemix.tck.ReceiverComponent"/></sm:component>
+            </sm:activationSpec>
+
+            <sm:activationSpec componentName="service6" service="foo:service6">
+               <sm:component><bean class="org.apache.servicemix.tck.ReceiverComponent"/></sm:component>
+            </sm:activationSpec>
+
+            <sm:activationSpec componentName="receiver" service="foo:receiver">
+                <sm:component>
+                    <bean class="org.apache.servicemix.tck.ReceiverComponent"/>
+                </sm:component>
+            </sm:activationSpec>
+
+
+            <sm:activationSpec componentName="trace" service="foo:trace">
+                <sm:component>
+                    <bean class="org.apache.servicemix.components.util.TraceComponent"/>
+                </sm:component>
+            </sm:activationSpec>
+
+        </sm:activationSpecs>
+    </sm:container>
+
+    <bean id="client" class="org.apache.servicemix.client.DefaultServiceMixClient">
+        <constructor-arg ref="jbi"/>
+    </bean>
+
+</beans>

Added: incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis.xsl
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis.xsl?rev=376936&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis.xsl (added)
+++ incubator/servicemix/trunk/servicemix-components/src/test/resources/org/apache/servicemix/components/xslt/optional-axis.xsl Fri Feb 10 22:38:20 2006
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!-- START SNIPPET: route -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:jbi="xalan://org.apache.servicemix.components.xslt.XalanExtension"
+    extension-element-prefixes="jbi"
+
+    xmlns:foo="http://servicemix.org/cheese/"
+
+    xmlns:prod="http://foo.org/prod" xmlns:ms="http://foo.org/ms" xmlns:xsi="http://foo.org/msi"
+
+    version="1.0">
+
+    <!--xsl:strip-space elements="*"/-->
+    <xsl:template match="/">
+
+        <jbi:invoke service="foo:service1">
+            <jbi:copyProperties/>
+            <jbi:setOutProperty name="foo" select="prod:resolveItemXrefResponse/prod:response/ms:Values/ms:Item[position() = 1]"/>
+            <xsl:copy-of select="/"/>
+        </jbi:invoke>
+
+        <jbi:invoke service="foo:service2">
+            <jbi:copyProperties/>
+            <jbi:setOutProperty name="foo" select="prod:resolveItemXrefResponse/prod:response/ms:Values/ms:Item[position() = 2]"/>
+            <xsl:copy-of select="/"/>
+        </jbi:invoke>
+
+        <jbi:invoke service="foo:service3">
+            <jbi:copyProperties/>
+            <jbi:setOutProperty name="foo" select="prod:resolveItemXrefResponse/prod:response/ms:Values/ms:Item[position() = 3]"/>
+            <xsl:copy-of select="/"/>
+        </jbi:invoke>
+
+        <jbi:invoke service="foo:service4">
+            <jbi:copyProperties/>
+            <jbi:setOutProperty name="foo" select="prod:resolveItemXrefResponse/prod:response/ms:Values/ms:Item[position() = 4]"/>
+            <xsl:copy-of select="/"/>
+        </jbi:invoke>
+
+        <jbi:invoke service="foo:service5">
+            <jbi:copyProperties/>
+            <jbi:setOutProperty name="foo" select="count(prod:resolveItemXrefResponse/prod:response/ms:Keys/ms:Item[text()='MSTR']/preceding-sibling::*) + 1"/>
+            <xsl:copy-of select="/"/>
+        </jbi:invoke>
+
+        <jbi:invoke service="foo:service6">
+            <jbi:copyProperties/>
+            <jbi:setOutProperty name="foo" select="prod:resolveItemXrefResponse/prod:response/ms:Values/ms:Item[position() = count(prod:resolveItemXrefResponse/prod:response/ms:Keys/ms:Item[text()='MSTR']/preceding-sibling::*) + 1]"/>
+            <xsl:copy-of select="/"/>
+        </jbi:invoke>
+
+        <jbi:invoke service="foo:receiver">
+            <jbi:copyProperties/>
+            <jbi:setOutProperty name="bar" select="/"/>
+            <xsl:copy-of select="/"/>
+        </jbi:invoke>
+
+    </xsl:template>
+    <!-- /prod:resolveItemXrefResponse/prod:response/ms:Values/ms:Item[position()=count(/prod:resolveItemXrefResponse/prod:response/ms:Keys/ms:Item[text()='MSTR']/preceding-sibling::*) + 1])-->
+</xsl:stylesheet>
+<!-- END SNIPPET: route -->
\ No newline at end of file

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/TestSupport.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/TestSupport.java?rev=376936&r1=376935&r2=376936&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/TestSupport.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/tck/TestSupport.java Fri Feb 10 22:38:20 2006
@@ -60,16 +60,20 @@
     }
 
     protected void sendMessages(QName service, int messageCount) throws Exception {
-    	sendMessages(service, messageCount, true);
+    	sendMessages(service, messageCount, true, null);
     }
-    
+
+    protected void sendMessages(QName service, int messageCount, String message) throws Exception {
+    	sendMessages(service, messageCount, true, message);
+    }
+
     /**
      * Sends the given number of messages to the given service
      *
      * @param service
      * @throws javax.jbi.messaging.MessagingException
      */
-    protected void sendMessages(QName service, int messageCount, boolean sync) throws Exception {
+    protected void sendMessages(QName service, int messageCount, boolean sync, String msg) throws Exception {
         for (int i = 1; i <= messageCount; i++) {
             InOnly exchange = client.createInOnlyExchange();
 
@@ -77,7 +81,11 @@
             message.setProperty("name", "James");
             message.setProperty("id", new Integer(i));
             message.setProperty("idText", "" + i);
-            message.setContent(new StringSource(createMessageXmlText(i)));
+            if (msg != null && msg.length() > 0) {
+                message.setContent(new StringSource(msg));
+            } else {
+                message.setContent(new StringSource(createMessageXmlText(i)));
+            }
 
             exchange.setService(service);
             if (sync) {