Author: scamp
Date: Thu Jun 9 10:30:30 2005
New Revision: 189780
URL: http://svn.apache.org/viewcvs?rev=189780&view=rev
Log: (empty)
Added:
incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java
Modified:
incubator/muse/trunk/src/ieeedemo/client/src/org/apache/ws/muws/interop/client/ServiceStub.java
Modified:
incubator/muse/trunk/src/ieeedemo/client/src/org/apache/ws/muws/interop/client/ServiceStub.java
URL:
http://svn.apache.org/viewcvs/incubator/muse/trunk/src/ieeedemo/client/src/org/apache/ws/muws/interop/client/ServiceStub.java?rev=189780&r1=189779&r2=189780&view=diff
==============================================================================
---
incubator/muse/trunk/src/ieeedemo/client/src/org/apache/ws/muws/interop/client/ServiceStub.java
(original)
+++
incubator/muse/trunk/src/ieeedemo/client/src/org/apache/ws/muws/interop/client/ServiceStub.java
Thu Jun 9 10:30:30 2005
@@ -71,7 +71,7 @@
return envelopeDoc;
}
- protected XmlObject sendRequest(XmlObject requestDoc, String action, URL
url)
+ public XmlObject sendRequest(XmlObject requestDoc, String action, URL url)
{
EnvelopeDocument requestEnvelopeDoc = createEnvelope();
Envelope requestEnvelope = requestEnvelopeDoc.getEnvelope();
Added: incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java
URL:
http://svn.apache.org/viewcvs/incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java?rev=189780&view=auto
==============================================================================
--- incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java
(added)
+++ incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java Thu
Jun 9 10:30:30 2005
@@ -0,0 +1,86 @@
+
+import junit.framework.TestCase;
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.ws.muws.interop.client.FaultException;
+import org.apache.ws.muws.interop.client.ResourceStub;
+import org.apache.ws.muws.interop.client.ServiceStub;
+import org.apache.ws.muws.v1_0.MuwsConstants;
+import org.apache.ws.muws.v1_0.capability.OperationalStatusCapability;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.test.PortListen;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
+import
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
+import
org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationMessageHolderType;
+import
org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotifyDocument;
+import org.wsdmdemo.service.InteropConstants;
+import org.wsdmdemo.service.InteropRequestUtils;
+import org.wsdmdemo.service.weatherStation.RecalibrateDocument;
+import org.xmlsoap.schemas.soap.envelope.Body;
+import org.xmlsoap.schemas.soap.envelope.EnvelopeDocument;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument;
+
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * @author Sal Campana
+ */
+public class WeatherStationNotifTest extends TestCase
+{
+ private static final String WEATHER_STATION_1_EPR_URL =
System.getProperty(InteropConstants.SYSPROP_WS1_EPR_URL,
"http://localhost:8080/muse/epr/weather-station-1-epr.xml");
+ private ResourceStub m_resource;
+ private static EndpointReferenceDocument WEATHER_STATION_1_EPR_DOC;
+ private PortListen m_listener;
+
+
+ protected void setUp() throws Exception
+ {
+ WEATHER_STATION_1_EPR_DOC =
InteropRequestUtils.getEndpointReference(new URL(WEATHER_STATION_1_EPR_URL));
+ }
+
+ public void testNotif() throws FaultException, IOException, XmlException
+ {
+ //subscribe for op status change.....notice the QName I use for the
topic.
+ XmlBeansEndpointReference xepr = new
XmlBeansEndpointReference(WEATHER_STATION_1_EPR_DOC.getEndpointReference());
+ m_resource = new ResourceStub(xepr);
+ EndpointReference subscriptionEndpointReference =
m_resource.subscribe("http://12.35.246.160:8001", new
QName(MuwsConstants.NSURI_MUWS_PART2_TOPICS,
OperationalStatusCapability.TOPIC_NAME));
+
+ //setup listener
+ m_listener = new PortListen(80, 600000);
+
+ //call recalibrate (after noticing erratic behavior) to trigger the
status change evennt
+ ServiceStub sstub = new ServiceStub(new URL(xepr.getAddress()));
+ RecalibrateDocument recalibrateDocument =
RecalibrateDocument.Factory.newInstance();
+ recalibrateDocument.addNewRecalibrate();
+ sstub.sendRequest(recalibrateDocument, "http://kickme", new
URL(xepr.getAddress()));
+
+
+ //listen for operational change notif ...this will actually capture
any message that comes in...
+ String messageText = m_listener.waitForIncomingMessage();
+
+ //upon notification.......
+ System.out.println(messageText);
+
+ try
+ {
+ //parse out the value we need....I've done no checking, it assumes
all is correct, else will cause an exception!
+ EnvelopeDocument ed =
(org.xmlsoap.schemas.soap.envelope.EnvelopeDocument)
XmlObject.Factory.parse(messageText);
+ org.xmlsoap.schemas.soap.envelope.Envelope env = ed.getEnvelope();
+ Body body = env.getBody();
+ XmlObject[] arryStuff = XmlBeanUtils.getChildElements(body);
+ NotifyDocument.Notify ele = (NotifyDocument.Notify) arryStuff[0];
+ NotificationMessageHolderType noteMess =
ele.getNotificationMessageArray(0);
+ XmlAnyTypeImpl mess = (XmlAnyTypeImpl) noteMess.getMessage();
+ ManagementEventTypeImpl manEvt = (ManagementEventTypeImpl)
XmlBeanUtils.getChildElements(mess)[0];
+ //todo...get the epr.....or the address from the epr...
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]