You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2014/02/25 14:16:40 UTC

svn commit: r1571678 - in /axis/axis1/java/trunk: interop-mock/src/main/resources/xmethods/ interop-mock/src/main/webapp/WEB-INF/ samples/jaxm-sample/ samples/jaxm-sample/src/main/java/samples/jaxm/ samples/jaxm-sample/src/test/java/test/functional/

Author: veithen
Date: Tue Feb 25 13:16:40 2014
New Revision: 1571678

URL: http://svn.apache.org/r1571678
Log:
Avoid connections to remote resources during unit tests, especially if they are no longer available.

Added:
    axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/
    axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/README.txt
    axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-request.xml   (with props)
    axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-response.xml   (with props)
Modified:
    axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml
    axis/axis1/java/trunk/samples/jaxm-sample/pom.xml
    axis/axis1/java/trunk/samples/jaxm-sample/src/main/java/samples/jaxm/DelayedStockQuote.java
    axis/axis1/java/trunk/samples/jaxm-sample/src/test/java/test/functional/TestJAXMSamples.java

Added: axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/README.txt
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/README.txt?rev=1571678&view=auto
==============================================================================
--- axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/README.txt (added)
+++ axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/README.txt Tue Feb 25 13:16:40 2014
@@ -0,0 +1,3 @@
+* delayed-quotes-request.xml is basically the request produced by the JAXM sample.
+* delayed-quotes-response.xml is a response constructed from samples found on the Web
+  (the original SOAP endpoint is no longer availalbe).
\ No newline at end of file

Added: axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-request.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-request.xml?rev=1571678&view=auto
==============================================================================
--- axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-request.xml (added)
+++ axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-request.xml Tue Feb 25 13:16:40 2014
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
+              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <env:Body>
+    <ns:getQuote xmlns:ns="urn:xmethods-delayed-quotes">
+      <symbol>SUNW</symbol>
+    </ns:getQuote>
+  </env:Body>
+</env:Envelope>

Propchange: axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-request.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-response.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-response.xml?rev=1571678&view=auto
==============================================================================
--- axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-response.xml (added)
+++ axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-response.xml Tue Feb 25 13:16:40 2014
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
+              xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <env:Body>
+    <ns:getQuoteResponse xmlns:ns="urn:xmethods-delayed-quotes" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+      <Result xsi:type="xsd:float">3.67</Result>
+    </ns:getQuoteResponse>
+  </env:Body>
+</env:Envelope>

Propchange: axis/axis1/java/trunk/interop-mock/src/main/resources/xmethods/delayed-quotes-response.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml?rev=1571678&r1=1571677&r2=1571678&view=diff
==============================================================================
--- axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml (original)
+++ axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml Tue Feb 25 13:16:40 2014
@@ -293,4 +293,17 @@
             </list>
         </property>
     </bean>
+    
+    <!-- Mock for XMethods stock quote service (http://64.124.140.30/soap) -->
+    
+    <bean name="/xmethods/delayed-quotes" class="org.apache.axis.test.interop.mock.MockPostHandler">
+        <property name="exchanges">
+            <list>
+                <bean class="org.apache.axis.test.interop.mock.Exchange">
+                    <property name="request" value="classpath:xmethods/delayed-quotes-request.xml"/>
+                    <property name="response" value="classpath:xmethods/delayed-quotes-response.xml"/>
+                </bean>
+            </list>
+        </property>
+    </bean>
 </beans>

Modified: axis/axis1/java/trunk/samples/jaxm-sample/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/jaxm-sample/pom.xml?rev=1571678&r1=1571677&r2=1571678&view=diff
==============================================================================
--- axis/axis1/java/trunk/samples/jaxm-sample/pom.xml (original)
+++ axis/axis1/java/trunk/samples/jaxm-sample/pom.xml Tue Feb 25 13:16:40 2014
@@ -38,5 +38,121 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>interop-mock</artifactId>
+            <version>${project.version}</version>
+            <type>war</type>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-test</id>
+                        <configuration>
+                            <skip>true</skip>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>reserve-network-port</id>
+                        <goals>
+                            <goal>reserve-network-port</goal>
+                        </goals>
+                        <phase>pre-integration-test</phase>
+                        <configuration>
+                            <portNames>
+                                <portName>jetty.httpPort</portName>
+                                <portName>jetty.stopPort</portName>
+                            </portNames>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}</outputDirectory>
+                            <includeTypes>war</includeTypes>
+                            <stripVersion>true</stripVersion>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.mortbay.jetty</groupId>
+                <artifactId>jetty-maven-plugin</artifactId>
+                <configuration>
+                    <war>${project.build.directory}/interop-mock.war</war>
+                    <stopKey>foo</stopKey>
+                    <stopPort>${jetty.stopPort}</stopPort>
+                    <connectors>
+                        <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
+                            <port>${jetty.httpPort}</port>
+                            <maxIdleTime>60000</maxIdleTime>
+                        </connector>
+                    </connectors>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>start-jetty</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>deploy-war</goal>
+                        </goals>
+                        <configuration>
+                            <daemon>true</daemon>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>stop-jetty</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>stop</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                        <configuration>
+                            <includes>
+                                <include>**/Test*.java</include>
+                            </includes>
+                            <systemPropertyVariables>
+                                <jetty.httpPort>${jetty.httpPort}</jetty.httpPort>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>

Modified: axis/axis1/java/trunk/samples/jaxm-sample/src/main/java/samples/jaxm/DelayedStockQuote.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/jaxm-sample/src/main/java/samples/jaxm/DelayedStockQuote.java?rev=1571678&r1=1571677&r2=1571678&view=diff
==============================================================================
--- axis/axis1/java/trunk/samples/jaxm-sample/src/main/java/samples/jaxm/DelayedStockQuote.java (original)
+++ axis/axis1/java/trunk/samples/jaxm-sample/src/main/java/samples/jaxm/DelayedStockQuote.java Tue Feb 25 13:16:40 2014
@@ -30,6 +30,16 @@ import javax.xml.soap.SOAPPart;
 import java.util.Iterator;
 
 public class DelayedStockQuote {
+    private final String url;
+    
+    public DelayedStockQuote() {
+        this("http://64.124.140.30/soap");
+    }
+    
+    public DelayedStockQuote(String url) {
+        this.url = url;
+    }
+    
     public static void main(String[] args) throws Exception {
         DelayedStockQuote stockQuote = new DelayedStockQuote();
         System.out.print("The last price for SUNW is " + stockQuote.getStockQuote("SUNW"));
@@ -57,7 +67,7 @@ public class DelayedStockQuote {
         SOAPElement symbol = gltp.addChildElement(name);
         symbol.addTextNode(tickerSymbol);
 
-        URLEndpoint endpoint = new URLEndpoint("http://64.124.140.30/soap");
+        URLEndpoint endpoint = new URLEndpoint(url);
         SOAPMessage response = con.call(message, endpoint);
         con.close();
 

Modified: axis/axis1/java/trunk/samples/jaxm-sample/src/test/java/test/functional/TestJAXMSamples.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/samples/jaxm-sample/src/test/java/test/functional/TestJAXMSamples.java?rev=1571678&r1=1571677&r2=1571678&view=diff
==============================================================================
--- axis/axis1/java/trunk/samples/jaxm-sample/src/test/java/test/functional/TestJAXMSamples.java (original)
+++ axis/axis1/java/trunk/samples/jaxm-sample/src/test/java/test/functional/TestJAXMSamples.java Tue Feb 25 13:16:40 2014
@@ -17,24 +17,10 @@
 package test.functional;
 
 import junit.framework.TestCase;
-import org.apache.axis.AxisFault;
 import org.apache.axis.components.logger.LogFactory;
 import org.apache.commons.logging.Log;
 import samples.jaxm.DelayedStockQuote;
 
-import javax.xml.messaging.URLEndpoint;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPBodyElement;
-import javax.xml.soap.SOAPConnection;
-import javax.xml.soap.SOAPConnectionFactory;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPMessage;
-import java.net.SocketException;
-
-
 /**
  * Test the JAX-RPC compliance samples.
  */
@@ -76,32 +62,8 @@ public class TestJAXMSamples extends Tes
 //    } // testGetQuote
 
     public void testDelayedStockQuote() throws Exception {
-        try {
-            log.info("Testing JAXM DelayedStockQuote sample.");
-            DelayedStockQuote stockQuote = new DelayedStockQuote();
-            System.out.print("The last price for SUNW is " + stockQuote.getStockQuote("SUNW"));
-            log.info("Test complete.");
-        } catch (javax.xml.soap.SOAPException e) {
-            Throwable t = e.getCause();
-            if (t != null) {
-                t.printStackTrace();
-                if (t instanceof AxisFault) {
-                  AxisFault af = (AxisFault) t;
-                  if ((af.detail instanceof SocketException)
-							|| (af.getFaultCode().getLocalPart().equals("HTTP"))) {
-						System.out.println("Connect failure caused JAXM DelayedStockQuote to be skipped.");
-						return;
-					}
-                }
-                throw new Exception("Fault returned from test: " + t);
-            } else {
-                e.printStackTrace();
-                throw new Exception("Exception returned from test: " + e);
-            }
-        } catch (Throwable t) {
-            t.printStackTrace();
-            throw new Exception("Fault returned from test: " + t);
-        }
+        DelayedStockQuote stockQuote = new DelayedStockQuote("http://localhost:" + System.getProperty("jetty.httpPort") + "/xmethods/delayed-quotes");
+        assertEquals("3.67", stockQuote.getStockQuote("SUNW"));
     } // testGetQuote
     
     public static void main(String args[]) throws Exception {