servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r783187 - in /servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon: ./ src/test/java/org/apache/servicemix/saxon/ src/test/java/org/apache/servicemix/saxon/packaging/ src/test/resources/
Date Wed, 10 Jun 2009 02:54:32 GMT
Author: ffang
Date: Wed Jun 10 02:54:31 2009
New Revision: 783187

URL: http://svn.apache.org/viewvc?rev=783187&view=rev
Log:
[SMXCOMP-552]Improve test coverage - ServiceMix :: Saxon

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/packaging/
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/packaging/SaxonServiceUnitAnalyzerTest.java
  (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/parameter-test-query.xq
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/pom.xml
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java
    servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/spring.xml

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/pom.xml?rev=783187&r1=783186&r2=783187&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/pom.xml
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/pom.xml
Wed Jun 10 02:54:31 2009
@@ -38,6 +38,11 @@
       <artifactId>servicemix-shared</artifactId>      
     </dependency>
     <dependency>
+      <groupId>org.easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.apache.servicemix</groupId>
       <artifactId>servicemix-core</artifactId>
       <scope>provided</scope>
@@ -97,6 +102,18 @@
           </execution>
         </executions>
       </plugin>
+      <!-- exclude generated DefaultBootstrap class from Cobertura reports -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>cobertura-maven-plugin</artifactId>
+        <configuration>
+          <instrumentation>
+            <excludes>
+              <exclude>org/apache/servicemix/common/DefaultBootstrap.class</exclude>
+            </excludes>
+          </instrumentation>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java?rev=783187&r1=783186&r2=783187&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java
Wed Jun 10 02:54:31 2009
@@ -59,6 +59,27 @@
         assertEquals("2005", textValueOfXPath(el, "/transformed/bookstore/book[1]/year"));
         client.done(me);
     }
+    
+    public void testXsltString() throws Exception {
+        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+        InOut me = client.createInOutExchange();
+        me.setService(new QName("urn:test", "xslt-string"));
+        me.getInMessage().setContent(new StreamSource(getClass().getResourceAsStream("/books.xml")));
+        client.sendSync(me);
+        if (me.getStatus() == ExchangeStatus.ERROR) {
+            if (me.getError() != null) {
+                throw me.getError();
+            } else {
+                fail("Received ERROR status");
+            }
+        } else if (me.getFault() != null) {
+            fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
+        }
+        log.info(transformer.toString(me.getOutMessage().getContent()));
+        Element el = transformer.toDOMElement(me.getOutMessage());
+        assertEquals("2005", textValueOfXPath(el, "/transformed/bookstore/book[1]/year"));
+        client.done(me);
+    }
 
     public void testXsltWithElement() throws Exception {
         DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
@@ -128,6 +149,26 @@
         assertEquals("cheeseyCheese", textValueOfXPath(el, "//param"));
         assertEquals("4002", textValueOfXPath(el, "//integer"));
     }
+    
+    public void testXQueryWithParam() throws Exception {
+        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+        InOut me = client.createInOutExchange();
+        me.setService(new QName("urn:test", "xquery-params"));
+        me.getInMessage().setContent(new StringSource("<sample id='777888' sent='"
+                + new Date() + "'>hello world!</sample>"));
+        client.sendSync(me);
+        if (me.getStatus() == ExchangeStatus.ERROR) {
+            if (me.getError() != null) {
+                throw me.getError();
+            } else {
+                fail("Received ERROR status");
+            }
+        } else if (me.getFault() != null) {
+            fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
+        }
+        log.info(transformer.toString(me.getOutMessage().getContent()));
+        client.done(me);
+    }
 
     public void testXsltWithDocCall() throws Exception {
         DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
@@ -167,6 +208,28 @@
         assertEquals("XQuery Kick Start", textValueOfXPath(el, "/titles/title[1]"));
         client.done(me);
     }
+    
+    public void testXQueryString() throws Exception {
+        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+        InOut me = client.createInOutExchange();
+        me.setService(new QName("urn:test", "xquery-string"));
+        me.getInMessage().setContent(new StreamSource(getClass().getResourceAsStream("/books.xml")));
+        client.sendSync(me);
+        if (me.getStatus() == ExchangeStatus.ERROR) {
+            if (me.getError() != null) {
+                throw me.getError();
+            } else {
+                fail("Received ERROR status");
+            }
+        } else if (me.getFault() != null) {
+            fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
+        }
+        log.info(transformer.toString(me.getOutMessage().getContent()));
+        Element el = transformer.toDOMElement(me.getOutMessage());
+        assertEquals("XQuery Kick Start", textValueOfXPath(el, "/titles/title[1]"));
+        client.done(me);
+    }
+    
 
     public void testXQueryInline() throws Exception {
         DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
@@ -219,5 +282,5 @@
     protected AbstractXmlApplicationContext createBeanFactory() {
         return new ClassPathXmlApplicationContext("spring.xml");
     }
-
+    
 }

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/packaging/SaxonServiceUnitAnalyzerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/packaging/SaxonServiceUnitAnalyzerTest.java?rev=783187&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/packaging/SaxonServiceUnitAnalyzerTest.java
(added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/packaging/SaxonServiceUnitAnalyzerTest.java
Wed Jun 10 02:54:31 2009
@@ -0,0 +1,49 @@
+/*
+ * 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.servicemix.saxon.packaging;
+
+import javax.jbi.JBIException;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.saxon.XQueryEndpoint;
+import org.apache.servicemix.saxon.XsltEndpoint;
+
+public class SaxonServiceUnitAnalyzerTest extends TestCase {
+
+    private SaxonServiceUnitAnalyzer analyzer;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        analyzer = new SaxonServiceUnitAnalyzer();
+    }
+
+    public void testGetConsumes() throws JBIException {
+        assertNotNull("Collection should not be null", analyzer.getConsumes(new XsltEndpoint()));
+        assertTrue("Collection should be empty", analyzer.getConsumes().isEmpty());
+    }
+
+    public void testGetXBeanFile() throws Exception {
+        assertEquals("xbean.xml", analyzer.getXBeanFile());
+    }
+
+    public void testIsValidEndpoint() throws Exception {
+        assertTrue(analyzer.isValidEndpoint(new XsltEndpoint()));
+        assertTrue(analyzer.isValidEndpoint(new XQueryEndpoint()));
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/packaging/SaxonServiceUnitAnalyzerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/packaging/SaxonServiceUnitAnalyzerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/parameter-test-query.xq
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/parameter-test-query.xq?rev=783187&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/parameter-test-query.xq
(added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/parameter-test-query.xq
Wed Jun 10 02:54:31 2009
@@ -0,0 +1,26 @@
+(:
+
+    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.
+
+:)
+declare variable $max_price as xs:integer external;
+<titles>
+{
+  for $x in /bookstore/book
+  where $x/price > $max_price
+  return $x/title
+}
+</titles>
\ No newline at end of file

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/spring.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/spring.xml?rev=783187&r1=783186&r2=783187&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/spring.xml
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-saxon/src/test/resources/spring.xml
Wed Jun 10 02:54:31 2009
@@ -49,7 +49,14 @@
       	          </map>
       	        </property>
       	      </saxon:xslt>
-      	      <!-- END SNIPPET: xslt-params --> 
+      	      <!-- END SNIPPET: xslt-params --> 
+
+       
+              <!-- START SNIPPET: xslt-string -->
+              <saxon:xslt service="test:xslt-string" endpoint="endpoint" 
+                          resource="classpath:transform.xsl" result="string" />
+              <!-- END SNIPPET: xslt-string -->
+  
       	      
       	      <!-- START SNIPPET: xslt-dynamic -->
       	      <saxon:xslt service="test:xslt-dynamic" endpoint="endpoint">
@@ -67,10 +74,31 @@
                           useDomSourceForContent="false"
                           result="bytes" />
 
-              <!-- START SNIPPET: xquery -->
-      	      <saxon:xquery service="test:xquery" endpoint="endpoint"
-      	                    resource="classpath:query.xq" />
-      	      <!-- END SNIPPET: xquery --> 
+		     <!-- START SNIPPET: xquery -->
+		     <saxon:xquery service="test:xquery" endpoint="endpoint"
+		                   resource="classpath:query.xq" />
+		     <!-- END SNIPPET: xquery -->
+		       
+		     <!-- START SNIPPET: xquery-string -->
+		     <saxon:xquery service="test:xquery-string" endpoint="endpoint"
+		                   resource="classpath:query.xq" result="string" />
+		     <!-- END SNIPPET: xquery-string -->
+		       
+		     <!-- START SNIPPET: xquery-params -->
+		     <saxon:xquery service="test:xquery-params" endpoint="endpoint"
+		                   resource="classpath:parameter-test-query.xq" result="bytes" >
+		         <property name="parameters">
+		           <map>
+		             <entry key="max_price">
+		               <bean class="java.lang.Integer">
+		                 <constructor-arg index="0" value="30"/>
+		               </bean>
+		             </entry>
+		           </map>
+		         </property>
+		      </saxon:xquery>
+		      <!-- END SNIPPET: xquery-params -->
+    
       	      
       	      <!-- START SNIPPET: xquery-inline --> 
       	      <saxon:xquery service="test:xquery-inline" endpoint="endpoint">



Mime
View raw message