You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-dev@ws.apache.org by sc...@apache.org on 2005/06/09 21:58:51 UTC

svn commit: r189804 - /incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java

Author: scamp
Date: Thu Jun  9 12:58:50 2005
New Revision: 189804

URL: http://svn.apache.org/viewcvs?rev=189804&view=rev
Log: (empty)

Modified:
    incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java

Modified: 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=189804&r1=189803&r2=189804&view=diff
==============================================================================
--- incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java (original)
+++ incubator/muse/trunk/src/ieeedemo/src/test/WeatherStationNotifTest.java Thu Jun  9 12:58:50 2005
@@ -73,31 +73,15 @@
 
         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];
-            ComponentType sourceComponent = manEvt.getSourceComponent();
-            ComponentAddressType sourceCompAddr = sourceComponent.getComponentAddressArray(0);
+            //parse out the managementevent
+            ManagementEventTypeImpl manEvt = parseManagementEvent(messageText);
 
-            //get the epr.....or the address from the epr...
             //here is the epr and the address of the source of the event....this is the weatherstation which caused the event.
-            EndpointReferenceType sourceEpr = (EndpointReferenceType) XmlBeanUtils.getChildElements(sourceCompAddr)[0];
+            EndpointReferenceType sourceEpr = parseSourceEpr(manEvt);
             String sourceAddress = sourceEpr.getAddress().getStringValue();
 
-
             //get the current operational status.....
-            XmlObject[] childElements = XmlBeanUtils.getChildElements(manEvt);
-            ResourcePropertyValueChangeNotificationType propChange = (ResourcePropertyValueChangeNotificationType) childElements[3];
-            ResourcePropertyValueChangeNotificationType.NewValue newValue = propChange.getNewValue();
-            XmlObject operationalStatus = XmlBeanUtils.getChildElements(newValue)[0];
-            XmlCursor xmlCursor = operationalStatus.newCursor();
-            String currentStatus = xmlCursor.getTextValue();
+            String currentOperationalStatus = parseCurrentOperationalStatus(manEvt);
 
 
             //try again to get the available message
@@ -109,5 +93,37 @@
         {
             e.printStackTrace();
         }
+    }
+
+    private String parseCurrentOperationalStatus(ManagementEventTypeImpl manEvt)
+    {
+        XmlObject[] childElements = XmlBeanUtils.getChildElements(manEvt);
+        ResourcePropertyValueChangeNotificationType propChange = (ResourcePropertyValueChangeNotificationType) childElements[3];
+        ResourcePropertyValueChangeNotificationType.NewValue newValue = propChange.getNewValue();
+        XmlObject operationalStatus = XmlBeanUtils.getChildElements(newValue)[0];
+        XmlCursor xmlCursor = operationalStatus.newCursor();
+        return xmlCursor.getTextValue();
+    }
+
+    private EndpointReferenceType parseSourceEpr(ManagementEventTypeImpl manEvt)
+    {
+        ComponentType sourceComponent = manEvt.getSourceComponent();
+        ComponentAddressType sourceCompAddr = sourceComponent.getComponentAddressArray(0);
+        EndpointReferenceType sourceEpr = (EndpointReferenceType) XmlBeanUtils.getChildElements(sourceCompAddr)[0];
+        return sourceEpr;
+    }
+
+    private ManagementEventTypeImpl parseManagementEvent(String messageText)
+            throws XmlException
+    {
+        EnvelopeDocument ed = (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];
+        return manEvt;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-dev-help@ws.apache.org