Author: dkulp
Date: Thu Oct 24 16:37:15 2013
New Revision: 1535433

URL: http://svn.apache.org/r1535433
Log:
Add a test case to make sure multiple messages coming back are received and 
processed.

Added:
    
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg1.xml
   (with props)
    
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg2.xml
   (with props)
    
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg3.xml
   (with props)
Modified:
    cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml
    
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml?rev=1535433&r1=1535432&r2=1535433&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml (original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/pom.xml Thu Oct 24 
16:37:15 2013
@@ -56,6 +56,22 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-testutils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
        
        <build>

Modified: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java?rev=1535433&r1=1535432&r2=1535433&view=diff
==============================================================================
--- 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
 (original)
+++ 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
 Thu Oct 24 16:37:15 2013
@@ -19,6 +19,12 @@
 
 package org.apache.cxf.ws.discovery;
 
+import java.io.InputStream;
+import java.net.DatagramPacket;
+import java.net.InetAddress;
+import java.net.MulticastSocket;
+import java.net.SocketAddress;
+
 import javax.jws.WebMethod;
 import javax.jws.WebService;
 import javax.xml.ws.Endpoint;
@@ -27,6 +33,8 @@ import javax.xml.ws.wsaddressing.W3CEndp
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.feature.LoggingFeature;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl;
 import org.apache.cxf.ws.discovery.wsdl.HelloType;
 import org.apache.cxf.ws.discovery.wsdl.ProbeMatchType;
@@ -35,17 +43,74 @@ import org.apache.cxf.ws.discovery.wsdl.
 import org.apache.cxf.ws.discovery.wsdl.ResolveMatchType;
 import org.apache.cxf.ws.discovery.wsdl.ScopesType;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 
 /**
  * 
  */
 public final class WSDiscoveryClientTest {
-
-    private WSDiscoveryClientTest() {
+    public static final String PORT = 
TestUtil.getPortNumber(WSDiscoveryClientTest.class);
+   
+    
+    @Test
+    public void testMultiResponses() throws Exception {
+        new Thread(new Runnable() {
+            public void run() {
+                try {
+                    //fake a discovery server to send back some canned 
messages.
+                    InetAddress address = 
InetAddress.getByName("239.255.255.250");
+                    MulticastSocket s = new 
MulticastSocket(Integer.parseInt(PORT));
+                    s.setBroadcast(true);
+                    s.joinGroup(address);
+                    s.setReceiveBufferSize(64 * 1024);
+                    s.setSoTimeout(5000);
+                    byte[] bytes = new byte[64 * 1024];
+                    DatagramPacket p = new DatagramPacket(bytes, bytes.length, 
address, Integer.parseInt(PORT));
+                    s.receive(p);
+                    SocketAddress sa = p.getSocketAddress();
+                    String incoming = new String(p.getData(), 0, 
p.getLength(), "UTF-8");
+                    int idx = incoming.indexOf("MessageID>");
+                    incoming = incoming.substring(idx + 10);
+                    idx = incoming.indexOf("</");
+                    incoming = incoming.substring(0, idx);
+                    for (int x = 1; x < 4; x++) {
+                        InputStream ins = 
WSDiscoveryClientTest.class.getResourceAsStream("msg" + x + ".xml");
+                        String msg = IOUtils.readStringFromStream(ins);
+                        msg = 
msg.replace("urn:uuid:883d0d53-92aa-4066-9b6f-9eadb1832366",
+                                          incoming);
+                        byte out[] = msg.getBytes("UTF-8");
+                        DatagramPacket outp = new DatagramPacket(out, 0, 
out.length, sa);
+                        s.send(outp);
+                    }
+                    
+                    s.close();
+                } catch (Throwable t) {
+                    t.printStackTrace();
+                }
+            }
+        }).start();
+        
         
+        Bus bus  = BusFactory.newInstance().createBus();
+        new LoggingFeature().initialize(bus);
+        WSDiscoveryClient c = new WSDiscoveryClient(bus);
+        c.setVersion10();
+        c.setAddress("soap.udp://239.255.255.250:" + PORT);
+
+        ProbeType pt = new ProbeType();
+        ScopesType scopes = new ScopesType();
+        pt.setScopes(scopes);
+        ProbeMatchesType pmts = c.probe(pt, 1000);
+
+        Assert.assertEquals(2, pmts.getProbeMatch().size());
+        c.close();
+        bus.shutdown(true);        
     }
     
     
+    //this is a standalone test
     public static void main(String[] arg) throws Exception {
         try {
             Bus bus = BusFactory.getDefaultBus();
@@ -62,8 +127,6 @@ public final class WSDiscoveryClientTest
             };
             s2.startup();
             HelloType h = service.register(ep.getEndpointReference());
-
-            
             
             bus  = BusFactory.newInstance().createBus();
             new LoggingFeature().initialize(bus);

Added: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg1.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg1.xml?rev=1535433&view=auto
==============================================================================
--- 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg1.xml
 (added)
+++ 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg1.xml
 Thu Oct 24 16:37:15 2013
@@ -0,0 +1 @@
+<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing";><s:Header><a:Action 
s:mustUnderstand="1">http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</a:Action><a:MessageID>urn:uuid:95fde407-eb4e-4624-975b-152635da9bac</a:MessageID></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Receiver</s:Value><s:Subcode><s:Value
 
xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher";>a:InternalServiceFault</s:Value></s:Subcode></s:Code><s:Reason><s:Text
 xml:lang="it-IT">The server was unable to process the request due to an 
internal error.  For more information about the error, either turn on 
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from 
the &lt;serviceDebug&gt; configuration behavior) on the server in order to send 
the exception information back to the client, or turn on tracing as per the 
Microsoft .NET Framework SDK documentati
 on and inspect the server trace 
logs.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope><s:Envelope 
xmlns:s="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:a="http://www.w3.org/2005/08/addressing";><s:Header><a:Action 
s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action><a:MessageID>urn:uuid:f7a89c38-b81c-4e65-9033-102396e82ecf</a:MessageID></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value>a:DestinationUnreachable</s:Value></s:Subcode></s:Code><s:Reason><s:Text
 xml:lang="it-IT">The message with To '' cannot be processed at the receiver, 
due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the 
sender and receiver's EndpointAddresses 
agree.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope><s:Envelope 
xmlns:s="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:a="http://www.w3.org/2005/08/addressing";><s:Header><a:Action 
s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action><a:MessageID>
 
urn:uuid:f7a89c38-b81c-4e65-9033-102396e82ecf</a:MessageID></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value>a:DestinationUnreachable</s:Value></s:Subcode></s:Code><s:Reason><s:Text
 xml:lang="it-IT">The message with To '' cannot be processed at the receiver, 
due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the 
sender and receiver's EndpointAddresses 
agree.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope><s:Envelope 
xmlns:s="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing";><s:Header><a:Action 
s:mustUnderstand="1">http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</a:Action><a:MessageID>urn:uuid:95fde407-eb4e-4624-975b-152635da9bac</a:MessageID></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Receiver</s:Value><s:Subcode><s:Value
 
xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher";>a:InternalServiceFau
 lt</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="it-IT">The server 
was unable to process the request due to an internal error.  For more 
information about the error, either turn on IncludeExceptionDetailInFaults 
(either from ServiceBehaviorAttribute or from the &lt;serviceDebug&gt; 
configuration behavior) on the server in order to send the exception 
information back to the client, or turn on tracing as per the Microsoft .NET 
Framework SDK documentation and inspect the server trace 
logs.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
\ No newline at end of file

Propchange: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg1.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg2.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg2.xml?rev=1535433&view=auto
==============================================================================
--- 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg2.xml
 (added)
+++ 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg2.xml
 Thu Oct 24 16:37:15 2013
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:wsa5="http://www.w3.org/2005/08/addressing"; 
xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#"; 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
 xmlns:ds="http://www.w3.org/2000/09/xmldsig#"; 
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
 xmlns:tt="http://www.onvif.org/ver10/schema"; 
xmlns:xsm="http://www.w3.org/2005/05/xmlmime"; 
xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2"; 
xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"; 
xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2"; 
xmlns:ns10="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding"; 
xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl"; 
xmlns:ns11="http://www.onvif.org/ver20/analytics/wsdl/A
 nalyticsEngineBinding" 
xmlns:ns2="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding"; 
xmlns:ns3="http://www.onvif.org/ver10/events/wsdl/EventBinding"; 
xmlns:tev="http://www.onvif.org/ver10/events/wsdl"; 
xmlns:ns4="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding"; 
xmlns:ns5="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding"; 
xmlns:ns6="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding"; 
xmlns:ns7="http://www.onvif.org/ver10/events/wsdl/PullPointBinding"; 
xmlns:ns8="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding"; 
xmlns:ns9="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding";
 xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"; 
xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl"; 
xmlns:tds="http://www.onvif.org/ver10/device/wsdl"; 
xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl"; 
xmlns:timg10="http://www.onvif.org/ver10/imaging/wsdl"; 
xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"; xmlns:
 trt="http://www.onvif.org/ver10/media/wsdl"; 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"; 
xmlns:wsd="http://schemas.xmlsoap.org/ws/2005/04/discovery"; 
xmlns:ter="http://www.onvif.org/ver10/error"; 
xmlns:tns1="http://www.onvif.org/ver10/topics"; 
xmlns:tns2="http://www.siqura.com/onvif/topic"; 
xmlns:dn="http://www.onvif.org/ver10/network/wsdl";><SOAP-ENV:Header><wsa:MessageID>urn:uuid:d0dca7c4-8c62-46b8-8502-fd511765a3a9</wsa:MessageID><wsa:RelatesTo>urn:uuid:883d0d53-92aa-4066-9b6f-9eadb1832366</wsa:RelatesTo><wsa:To
 
SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsa:Action
 
SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsa:Action><wsd:AppSequence
 MessageNumber="2871" 
InstanceId="1379153401"></wsd:AppSequence></SOAP-ENV:Header><SOAP-ENV:Body><wsd:ProbeMatches><wsd:ProbeMatch><wsa:EndpointReference><wsa:Address>urn:uuid:dd38638d-26c0-1ad8-82ee-00047e01d3a5</wsa:Address></ws
 
a:EndpointReference><wsd:Types>dn:NetworkVideoTransmitter</wsd:Types><wsd:Scopes>onvif://www.onvif.org/type/video_encoder
 onvif://www.onvif.org/type/audio_encoder 
onvif://www.onvif.org/hardware/S-60%20E-SFP 
onvif://www.onvif.org/location/origin/Netherlands 
onvif://www.onvif.org/name/Siqura 
onvif://www.onvif.org/Profile/Streaming</wsd:Scopes><wsd:XAddrs>http://172.19.121.187/onvif/device_service</wsd:XAddrs><wsd:MetadataVersion>1379153402</wsd:MetadataVersion></wsd:ProbeMatch></wsd:ProbeMatches></SOAP-ENV:Body></SOAP-ENV:Envelope>
\ No newline at end of file

Propchange: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg2.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg3.xml
URL: 
http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg3.xml?rev=1535433&view=auto
==============================================================================
--- 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg3.xml
 (added)
+++ 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg3.xml
 Thu Oct 24 16:37:15 2013
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"; 
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"; 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"; 
xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"; 
xmlns:dn="http://www.onvif.org/ver10/network/wsdl";><SOAP-ENV:Header><wsa:MessageID>uuid:5a34c3b0-3641-11e3-bfa9-00408cc64a8b</wsa:MessageID><wsa:RelatesTo>urn:uuid:883d0d53-92aa-4066-9b6f-9eadb1832366</wsa:RelatesTo><wsa:To
 
SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsa:Action
 
SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsa:Action><d:AppSequence
 SOAP-ENV:mustUnderstand="true" MessageNumber="857" 
InstanceId="1380516848"></d:AppSequence></SOAP-ENV:Header><SOAP-ENV:Body><d:ProbeMatches><d:ProbeMatch><wsa:EndpointReference><wsa:Address>urn:uuid:2a4f0d00-0093-11d5-b87c-00408cc64a8b</wsa:Address></wsa:EndpointReference><d:Types>dn:Ne
 
tworkVideoTransmitter</d:Types><d:Scopes>onvif://www.onvif.org/type/video_encoder
 onvif://www.onvif.org/Profile/Streaming 
onvif://www.onvif.org/type/audio_encoder onvif://www.onvif.org/hardware/Q1921 
onvif://www.onvif.org/name/AXIS%20Q1921 onvif://www.onvif.org/location/ 
</d:Scopes><d:XAddrs>http://169.254.86.150/onvif/device_service 
http://172.19.121.117/onvif/device_service</d:XAddrs><d:MetadataVersion>1</d:MetadataVersion></d:ProbeMatch></d:ProbeMatches></SOAP-ENV:Body></SOAP-ENV:Envelope>

Propchange: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg3.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/msg3.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to