Author: wire
Date: Fri Aug 12 07:05:51 2005
New Revision: 232301
URL: http://svn.apache.org/viewcvs?rev=232301&view=rev
Log: (empty)
Added:
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/AbstractWsdmInteropTestCase.java
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/TestWcConfigAccess.java
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/WebServicesMgmtTestCase.java
Added:
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/AbstractWsdmInteropTestCase.java
URL:
http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/AbstractWsdmInteropTestCase.java?rev=232301&view=auto
==============================================================================
---
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/AbstractWsdmInteropTestCase.java
(added)
+++
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/AbstractWsdmInteropTestCase.java
Fri Aug 12 07:05:51 2005
@@ -0,0 +1,220 @@
+/*=============================================================================*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.interop.client;
+
+import org.apache.interop.client.FaultException;
+import org.apache.interop.client.ResourceStub;
+import org.apache.ws.muws.v1_0.MuwsConstants;
+import org.apache.ws.muws.v1_0.capability.IdentityCapability;
+import
org.apache.ws.muws.v1_0.capability.ManageabilityCharacteristicsCapability;
+import org.apache.ws.muws.v1_0.capability.OperationalStatusCapability;
+import org.apache.ws.notification.base.v2004_06.BaseNotificationConstants;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.jndi.XmlBeanJndiUtils;
+import org.apache.ws.util.test.PortListen;
+import org.apache.ws.util.test.axis.AbstractOneAxisTestCase;
+import org.apache.xmlbeans.XmlAnyURI;
+import org.apache.xmlbeans.XmlError;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManagementEventType;
+import
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.OperationalStatusDocument;
+import
org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationMessageHolderType;
+import
org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotifyDocument;
+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.net.InetAddress;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * TODO
+ */
+public abstract class AbstractWsdmInteropTestCase extends
AbstractOneAxisTestCase
+{
+
+ protected static final int NOTIF_LISTENER_TIMEOUT = 20000;
+ protected static final int NOTIF_LISTENER_PORT = 9101;
+ protected static String s_consumerURL;
+
+ private static final boolean RUN_AXIS_SERVER = Boolean.getBoolean(
"runAxis" );
+ static final boolean DEBUG = true;//Boolean.getBoolean( "debug" );
+
+ public AbstractWsdmInteropTestCase()
+ {
+ super( RUN_AXIS_SERVER );
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ s_consumerURL = "http://" +
InetAddress.getLocalHost().getHostAddress() + ":" + NOTIF_LISTENER_PORT + "/";
+ if ( RUN_AXIS_SERVER )
+ {
+ //init jndi from config
+ XmlBeanJndiUtils.initFromInputStream(
Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream(
XmlBeanJndiUtils.JNDI_CONFIG_FILENAME ) );
+ }
+ }
+
+ protected void performMuwsIdentityCharacteristicsAct( ResourceStub
resource ) throws FaultException
+ {
+ XmlObject idPropElem = getSingleProperty( resource,
IdentityCapability.PROP_NAME_RESOURCE_ID );
+ assertTrue( idPropElem instanceof XmlAnyURI );
+ XmlObject[] capabilityElems = resource.getResourceProperty(
+
ManageabilityCharacteristicsCapability.PROP_NAME_MANAGEABILITY_CAPABILITY );
+ assertContainsURI( capabilityElems, IdentityCapability.URI );
+ }
+
+ protected void performMuwsStatusAct( ResourceStub resource ) throws
FaultException
+ {
+ XmlObject[] capabilityPropElems = resource.getResourceProperty(
+
ManageabilityCharacteristicsCapability.PROP_NAME_MANAGEABILITY_CAPABILITY );
+ assertContainsURI( capabilityPropElems,
OperationalStatusCapability.URI );
+ XmlObject[] statusPropElems = resource.getResourceProperty(
+ OperationalStatusCapability.PROP_NAME_OPERATIONAL_STATUS );
+ assertEquals( 1, statusPropElems.length );
+ assertTrue( statusPropElems[0] instanceof
OperationalStatusDocument.OperationalStatus );
+ }
+
+ protected XmlObject getSingleProperty( ResourceStub resource, QName
propName )
+ throws FaultException
+ {
+ XmlObject[] propElems = resource.getResourceProperty( propName );
+ assertEquals(
+ "Incorrect number of " + propName.getPrefix() + ":" +
propName.getLocalPart() + " property elements -",
+ 1, propElems.length );
+ return propElems[0];
+ }
+
+ protected void setSingleProperty( ResourceStub resource, XmlObject
propElem )
+ throws FaultException
+ {
+ resource.updateResourceProperty( new XmlObject[]{propElem} );
+ }
+
+ protected void assertContainsURI( XmlObject[] capabilityPropElems, String
uri )
+ {
+ boolean result = false;
+ for ( int i = 0; i < capabilityPropElems.length; i++ )
+ {
+ XmlAnyURI capabilityElem = (XmlAnyURI) capabilityPropElems[i];
+ if ( capabilityElem.getStringValue().equals( uri ) )
+ {
+ result = true;
+ break;
+ }
+ }
+ assertTrue( "List of manageability capabilities does not include the
URI: " + uri, result );
+ }
+
+ /**
+ * Reads a wsa03:EndpointReference XML document from the specified URL.
+ *
+ * @param url
+ *
+ * @return
+ *
+ * @throws Exception
+ */
+ protected EndpointReferenceDocument getEndpointReference( URL url ) throws
Exception
+ {
+ XmlObject stuff=XmlObject.Factory.parse( url );
+ return (EndpointReferenceDocument)stuff;
+ }
+
+ protected ManagementEventType waitForManagementEvent( PortListen
notifListener ) throws XmlException
+ {
+ String incomingMsg = notifListener.waitForIncomingMessage();
+ assertTrue( incomingMsg, incomingMsg.indexOf( "ERROR" ) == -1 );
+
+ //get envelope
+ XmlObject xmlObject = XmlObject.Factory.parse( incomingMsg );
+ assertTrue( "The returned message was not a SOAP Envelope.", xmlObject
instanceof EnvelopeDocument );
+ EnvelopeDocument envelope = (EnvelopeDocument) xmlObject;
+ Body body = envelope.getEnvelope().getBody();
+
+ XmlObject mgmtEventElem = null;
+ if ( ResourceStub.USE_WRAPPED_NOTIFICATIONS ) //wrapped
+ {
+ //get notify
+ XmlObject bodyElems[] = XmlBeanUtils.getChildElements( body,
+ new QName( BaseNotificationConstants.NSURI_WSNT_SCHEMA,
"Notify" ) );
+ assertEquals( "The SOAP Body does not contain exactly one
wsnt:Notify element.", 1, bodyElems.length );
+ XmlObject notifyDoc = bodyElems[0];
+ assertTrue( "The SOAP Body does not contain a wrapped notification
with a Notify element.",
+ notifyDoc instanceof NotifyDocument.Notify );
+ NotifyDocument.Notify notify = (NotifyDocument.Notify) notifyDoc;
+
+ //get contained management event
+ NotificationMessageHolderType notificationMessageType =
notify.getNotificationMessageArray( 0 );
+ XmlObject message = notificationMessageType.getMessage();
+
+ XmlObject mgmtEventElems[] = XmlBeanUtils.getChildElements(
message,
+ new QName( MuwsConstants.NSURI_MUWS_PART1_SCHEMA,
"ManagementEvent" ) );
+ assertEquals( "The Notify element does not contain exactly one
muws-p1-xs:ManagementEvent element.", 1,
+ mgmtEventElems.length );
+ mgmtEventElem = mgmtEventElems[0];
+ assertTrue( "The Notify element does not contain a
ManagementEvent.",
+ mgmtEventElem instanceof ManagementEventType );
+ }
+ else //unwrapped
+ {
+ XmlObject mgmtEventElems[] = XmlBeanUtils.getChildElements( body,
+ new QName( MuwsConstants.NSURI_MUWS_PART1_SCHEMA,
"ManagementEvent" ) );
+ assertEquals( "The SOAP Body does not contain exactly one
muws-p1-xs:ManagementEvent element.", 1,
+ mgmtEventElems.length );
+ mgmtEventElem = mgmtEventElems[0];
+ assertTrue( "The SOAP Body did not contain an unwrapped
ManagementEvent.",
+ mgmtEventElem instanceof ManagementEventType );
+ }
+ ManagementEventType mgmtEvent = (ManagementEventType) mgmtEventElem;
+ return mgmtEvent;
+ }
+
+ protected static boolean validate( XmlObject xBean )
+ {
+ // Create an XmlOptions instance and set the error listener.
+ XmlOptions validateOptions = new XmlOptions();
+ List errorList = new ArrayList();
+ validateOptions.setErrorListener( errorList );
+
+ // Validate the XML.
+ boolean isValid = xBean.validate( validateOptions );
+
+ // If the XML isn't valid, loop through the listener's contents,
+ // printing contained messages.
+ if ( !isValid )
+ {
+ for ( int i = 0; i < errorList.size(); i++ )
+ {
+ XmlError error = (XmlError) errorList.get( i );
+
+ System.out.println( "\n" );
+ System.out.println( "Message: " + error.getMessage() + "\n" );
+ System.out.println( "Location of invalid XML: " +
+ error.getCursorLocation().xmlText() + "\n" );
+ }
+ }
+ return isValid;
+ }
+
+}
Added:
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/TestWcConfigAccess.java
URL:
http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/TestWcConfigAccess.java?rev=232301&view=auto
==============================================================================
---
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/TestWcConfigAccess.java
(added)
+++
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/TestWcConfigAccess.java
Fri Aug 12 07:05:51 2005
@@ -0,0 +1,71 @@
+/*
+ * Created on Jun 6, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.interop.client;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.interop.client.ResourceStub;
+import org.apache.interop.client.ServiceStub;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.xmlbeans.XmlObject;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
+
+import junit.framework.TestCase;
+
+/**
+ * @author wire
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class TestWcConfigAccess extends AbstractWsdmInteropTestCase {
+
+ private static final String WEATHER_STATION_CONF_EPR_URL =
"http://12.35.246.160:8080/muse/epr/weather-client-config-epr.xml";
+ private static final String WEATHER_STATION_CONFIG_URL =
"http://12.35.246.160:8080/muse/services/WeatherClientConfig";
+ private ServiceStub m_service;
+ private EndpointReferenceDocument weatherStationEprDoc;
+ private ResourceStub m_resource;
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ weatherStationEprDoc = getEndpointReference( new URL(
WEATHER_STATION_CONF_EPR_URL ) );
+ //if ( DEBUG ) { System.out.println( "*** Using Weather Station
EPR:\n" + weatherStationEprDoc ); }
+ //m_service = new ServiceStub( new URL( WEATHER_STATION_CONFIG_URL ) );
+ m_resource = new ResourceStub( new XmlBeansEndpointReference(
weatherStationEprDoc.getEndpointReference() ) );
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Objective: Get the current weather station reference
+ * @throws MalformedURLException
+ * @throws Exception
+ */
+ public void testStuff() throws MalformedURLException, Exception{
+
+ XmlObject[] Ws=m_resource.getResourceProperty(new
QName("http://wsdmdemo.org/service/weather-client-config","WeatherStationReference"));
+ assertEquals(1,Ws.length);
+ XmlObject xWs=Ws[0];
+ assertTrue(xWs instanceof EndpointReferenceType);
+ System.out.println("Holy!");
+ }
+
+
+
+}
Added:
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/WebServicesMgmtTestCase.java
URL:
http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/WebServicesMgmtTestCase.java?rev=232301&view=auto
==============================================================================
---
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/WebServicesMgmtTestCase.java
(added)
+++
webservices/muse/trunk/src/examples/ieeedemo/client/test/org/apache/interop/client/WebServicesMgmtTestCase.java
Fri Aug 12 07:05:51 2005
@@ -0,0 +1,289 @@
+/*=============================================================================*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.interop.client;
+
+import org.apache.interop.client.FaultException;
+import org.apache.interop.client.ResourceStub;
+import org.apache.interop.client.ServiceStub;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.ws.mows.v1_0.MowsConstants;
+import org.apache.ws.mows.v1_0.capability.IdentificationCapability;
+import org.apache.ws.mows.v1_0.capability.MetricsCapability;
+import org.apache.ws.mows.v1_0.capability.RequestProcessingStateCapability;
+import org.apache.ws.muws.v1_0.MuwsConstants;
+import org.apache.ws.muws.v1_0.capability.CorrelatablePropertiesCapability;
+import org.apache.ws.muws.v1_0.capability.IdentityCapability;
+import
org.apache.ws.muws.v1_0.capability.ManageabilityCharacteristicsCapability;
+import org.apache.ws.muws.v1_0.capability.RelationshipsCapability;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.test.PortListen;
+import org.apache.xmlbeans.XmlAnyURI;
+import org.apache.xmlbeans.XmlDateTime;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlQName;
+import org.apache.xmlbeans.XmlString;
+import org.apache.xmlbeans.XmlOptions;
+//import
org.everestWeather.wsdm.samples.x2005.x04.schema.WeatherstationPropertyQNames;
+//import
org.everestWeather.wsdm.samples.x2005.x04.schema.WeatherstationResource;
+import org.oasisOpen.docs.wsdm.x2004.x12.mows.wsdmMows.DurationMetric;
+import
org.oasisOpen.docs.wsdm.x2004.x12.mows.wsdmMows.EndpointDescriptionsDocument;
+import org.oasisOpen.docs.wsdm.x2004.x12.mows.wsdmMows.IntegerCounter;
+import
org.oasisOpen.docs.wsdm.x2004.x12.mows.wsdmMows.RequestProcessingNotificationDocument;
+import
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.CorrelatablePropertiesType;
+import
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManagementEventType;
+import
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.RelationshipParticipantType;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.RelationshipType;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * A test case containing a test for each act in the "Web Services Management"
+ * playbook, as defined in the WSDM 1.0 interop scenarios doc.
+ *
+ * @author Ian Springer
+ */
+public class WebServicesMgmtTestCase extends AbstractWsdmInteropTestCase
+{
+
+ public static final String SYSPROP_WEATHER_STATION_URL =
"weather_station.url"; // this is the Weather Station business Web service
+ public static final String SYSPROP_WEATHER_STATION_EPR_URL =
"weather_station.epr";
+ public static final String SYSPROP_WEATHER_STATION_2_EPR_URL =
"weather_station_2.epr";
+
+ private static final String HP_WEATHER_STATION_EPR_URL =
"http://people.apache.org/~ips/interop/weather_station-epr.xml";
+ private static final String HP_WEATHER_STATION_2_EPR_URL =
"http://people.apache.org/~ips/interop/weather_station_2-epr.xml";
+ private static final String HP_WEATHER_STATION_URL =
"http://localhost:8080/muse/services/WeatherStationSoap";
+
+ private static final String IBM_WEATHER_STATION_EPR_URL =
"http://24.211.145.38:4400/ettk/wsdm/InteropServlet?getepr=true";
+ private static final String IBM_WEATHER_STATION_URL =
"http://24.211.145.38:4400/ettk/wsdm/services/WeatherStationSoap";
+
+ private static final String WEATHER_STATION_EPR_URL = System.getProperty(
SYSPROP_WEATHER_STATION_EPR_URL, HP_WEATHER_STATION_EPR_URL );
+ private static final String WEATHER_STATION_2_EPR_URL =
System.getProperty( SYSPROP_WEATHER_STATION_2_EPR_URL,
HP_WEATHER_STATION_2_EPR_URL );
+ private static final String WEATHER_STATION_URL = System.getProperty(
SYSPROP_WEATHER_STATION_URL, HP_WEATHER_STATION_URL );
+
+ private ServiceStub m_service;
+ private ResourceStub m_resource;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ EndpointReferenceDocument weatherStationEprDoc = getEndpointReference(
new URL( WEATHER_STATION_EPR_URL ) );
+ if ( DEBUG ) { System.out.println( "*** Using Weather Station EPR:\n"
+ weatherStationEprDoc ); }
+ m_service = new ServiceStub( new URL( WEATHER_STATION_URL ) );
+ m_resource = new ResourceStub( new XmlBeansEndpointReference(
weatherStationEprDoc.getEndpointReference() ) );
+ }
+
+ public void testMuwsIdentityCharacteristics() throws FaultException
+ {
+ performMuwsIdentityCharacteristicsAct( m_resource );
+ }
+
+ public void testMowsIdentification() throws FaultException, WSDLException
+ {
+ XmlObject[] capabilityElems = m_resource.getResourceProperty(
ManageabilityCharacteristicsCapability.PROP_NAME_MANAGEABILITY_CAPABILITY );
+ assertContainsURI( capabilityElems, IdentificationCapability.URI );
+ XmlObject eprPropElem = getSingleProperty( m_resource,
IdentificationCapability.PROP_NAME_ENDPOINT_REFERENCE );
+ assertTrue( eprPropElem instanceof EndpointReferenceType );
+ EndpointReferenceType epr = (EndpointReferenceType) eprPropElem;
+ assertTrue( "mows-xs:EndpointReference element is not valid",
epr.validate() );
+ String address = epr.getAddress().getStringValue();
+ XmlObject epDescsPropElem = getSingleProperty( m_resource,
IdentificationCapability.PROP_NAME_ENDPOINT_DESCRIPTIONS );
+ assertTrue( epDescsPropElem instanceof
EndpointDescriptionsDocument.EndpointDescriptions );
+ EndpointDescriptionsDocument.EndpointDescriptions epDescs =
(EndpointDescriptionsDocument.EndpointDescriptions)epDescsPropElem;
+ assertTrue( "mows-xs:EndpointDescriptions element is not valid",
epDescs.validate() );
+ String[] wsdlURLs = epDescs.getDescriptionArray();
+ for (int i = 0; i < wsdlURLs.length; i++)
+ {
+ String wsdlURL = wsdlURLs[i];
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ Definition definition = wsdlReader.readWSDL(wsdlURL);
+ assertNotNull("WSDL at location: " + wsdlURL + " was
null.",definition);//valid wsdls
+ assertEquals("There must only be exactly one service in the WSDL
file.", 1, definition.getServices().size()); //single service
+ Service service = (Service)
definition.getServices().values().iterator().next();
+ assertEquals("There must only be exactly one port associated with
the service in the WSDL file.", 1, service.getPorts().size()); //single port
+ Port port = (Port) service.getPorts().values().iterator().next();
+ SOAPAddress soapAddress = (SOAPAddress)
port.getExtensibilityElements().get(0);
+ assertEquals("The soap:address in WSDL at " + wsdlURL + " did not
match the EPR address.", address, soapAddress.getLocationURI()); //EPR address
matches that contained in soap:address
+ }
+ }
+
+ public void testMowsManageabilityReferences() throws FaultException
+ {
+ EndpointReferenceType[] mgmtEPRs =
m_service.getManageabilityReferences();
+ assertTrue( "Response to GetManageabilityReferences operation did not
contain any EPRs.", mgmtEPRs.length != 0 );
+ for ( int i = 0; i < mgmtEPRs.length; i++ )
+ {
+ ResourceStub mgmtResource = new ResourceStub( new
XmlBeansEndpointReference( mgmtEPRs[i] ) );
+ XmlObject idPropElem = getSingleProperty( mgmtResource,
IdentityCapability.PROP_NAME_RESOURCE_ID );
+ assertTrue( idPropElem instanceof XmlAnyURI );
+ XmlObject[] capabilityElems = mgmtResource.getResourceProperty(
+
ManageabilityCharacteristicsCapability.PROP_NAME_MANAGEABILITY_CAPABILITY );
+ assertContainsURI( capabilityElems, IdentificationCapability.URI );
+ }
+ }
+
+ public void testMowsMetrics() throws FaultException
+ {
+ XmlObject[] capabilityElems = m_resource.getResourceProperty(
ManageabilityCharacteristicsCapability.PROP_NAME_MANAGEABILITY_CAPABILITY );
+ assertContainsURI( capabilityElems,
org.apache.ws.muws.v1_0.capability.MetricsCapability.URI );
+ assertContainsURI( capabilityElems, MetricsCapability.URI );
+ XmlObject currentTimePropElem = getSingleProperty( m_resource,
org.apache.ws.muws.v1_0.capability.MetricsCapability.PROP_NAME_CURRENT_TIME );
+ assertTrue( currentTimePropElem instanceof XmlDateTime );
+ XmlObject numRequestsPropElem = getSingleProperty( m_resource,
MetricsCapability.PROP_NAME_NUMBER_OF_REQUESTS );
+ assertTrue( numRequestsPropElem instanceof IntegerCounter );
+ IntegerCounter numRequestsMetric =
((IntegerCounter)numRequestsPropElem);
+ long numRequests = numRequestsMetric.getBigIntegerValue().longValue();
+ assertTrue( "ResetAt metadata attribute is not set",
numRequestsMetric.isSetResetAt() );
+ assertFalse( "Duration metadata attribute is set",
numRequestsMetric.isSetDuration() );
+ XmlObject numFailedRequestsPropElem = getSingleProperty( m_resource,
MetricsCapability.PROP_NAME_NUMBER_OF_FAILED_REQUESTS );
+ assertTrue( numFailedRequestsPropElem instanceof IntegerCounter );
+ IntegerCounter numFailedRequestsMetric =
((IntegerCounter)numFailedRequestsPropElem);
+ long numFailedRequests =
numFailedRequestsMetric.getBigIntegerValue().longValue();
+ assertTrue( "ResetAt metadata attribute is not set",
numFailedRequestsMetric.isSetResetAt() );
+ assertFalse( "Duration metadata attribute is set",
numFailedRequestsMetric.isSetDuration() );
+ XmlObject numSuccessfulRequestsPropElem = getSingleProperty(
m_resource, MetricsCapability.PROP_NAME_NUMBER_OF_SUCCESSFUL_REQUESTS );
+ assertTrue( numSuccessfulRequestsPropElem instanceof IntegerCounter );
+ IntegerCounter numSuccessfulRequestsMetric =
((IntegerCounter)numSuccessfulRequestsPropElem);
+ long numSuccessfulRequests =
numSuccessfulRequestsMetric.getBigIntegerValue().longValue();
+ assertTrue( "ResetAt metadata attribute is not set",
numSuccessfulRequestsMetric.isSetResetAt() );
+ assertFalse( "Duration metadata attribute is set",
numSuccessfulRequestsMetric.isSetDuration() );
+ assertTrue( numRequests >= numFailedRequests + numSuccessfulRequests );
+ XmlObject serviceTimePropElem = getSingleProperty( m_resource,
MetricsCapability.PROP_NAME_SERVICE_TIME );
+ assertTrue( serviceTimePropElem instanceof DurationMetric );
+ DurationMetric serviceTimeMetric =
((DurationMetric)serviceTimePropElem);
+ assertTrue( "Duration metadata attribute is not set",
serviceTimeMetric.isSetDuration() );
+ XmlObject maxResponseTimePropElem = getSingleProperty( m_resource,
MetricsCapability.PROP_NAME_MAX_RESPONSE_TIME );
+ assertTrue( maxResponseTimePropElem instanceof DurationMetric );
+ DurationMetric maxResponseTimeMetric =
((DurationMetric)maxResponseTimePropElem);
+ assertTrue( "Duration metadata attribute is not set",
maxResponseTimeMetric.isSetDuration() );
+ XmlObject lastResponseTimePropElem = getSingleProperty( m_resource,
MetricsCapability.PROP_NAME_LAST_RESPONSE_TIME );
+ assertTrue( lastResponseTimePropElem instanceof DurationMetric );
+ }
+
+ public void testMuwsStatus() throws FaultException
+ {
+ performMuwsStatusAct( m_resource );
+ }
+
+// public void testMowsRequestProcessingNotification() throws
FaultException, XmlException
+// {
+// XmlObject[] capabilityElems = m_resource.getResourceProperty(
ManageabilityCharacteristicsCapability.PROP_NAME_MANAGEABILITY_CAPABILITY );
+// assertContainsURI( capabilityElems,
RequestProcessingStateCapability.URI );
+//
+// m_resource.subscribe( s_consumerURL, new QName(
MowsConstants.NSURI_MOWS_TOPICS, "RequestProcessingObservations",
MowsConstants.NSPREFIX_MOWS_TOPICS ) );
+//
+// PortListen notifListener = new PortListen( NOTIF_LISTENER_PORT,
NOTIF_LISTENER_TIMEOUT );
+//
+// m_service.getCurrentTemperature();
+//
+// ManagementEventType mgmtEvent = waitForManagementEvent(
notifListener );
+// if ( DEBUG ) { System.out.println( "Received ManagementEvent:\n" +
mgmtEvent.xmlText( new XmlOptions().setSaveOuter().setSavePrettyPrint() ) ); }
+//
+// XmlObject[] requestProcessingNotifElems =
XmlBeanUtils.getChildElements(mgmtEvent, new
QName(MowsConstants.NSURI_MOWS_SCHEMA, "RequestProcessingNotification",
MowsConstants.NSPREFIX_MOWS_SCHEMA));
+// assertEquals( 1, requestProcessingNotifElems.length );
+// assertTrue( requestProcessingNotifElems[0] instanceof
RequestProcessingNotificationDocument.RequestProcessingNotification );
+// RequestProcessingNotificationDocument.RequestProcessingNotification
requestProcessingNotif =
(RequestProcessingNotificationDocument.RequestProcessingNotification)
requestProcessingNotifElems[0];
+//
+// System.out.println( requestProcessingNotif.xmlText( new
XmlOptions().setSaveOuter().setSavePrettyPrint() ) );
+// assertTrue( validate( requestProcessingNotif ) );
+// }
+
+// public void testMuwsRelationships() throws FaultException
+// {
+// XmlObject[] capabilityElems = m_resource.getResourceProperty(
ManageabilityCharacteristicsCapability.PROP_NAME_MANAGEABILITY_CAPABILITY );
+// assertContainsURI( capabilityElems, RelationshipsCapability.URI );
+// XmlObject[] idElems = m_resource.getResourceProperty(
IdentityCapability.PROP_NAME_RESOURCE_ID );
+// assertEquals( 1, idElems.length );
+// assertTrue( idElems[0] instanceof XmlAnyURI );
+// XmlObject[] relationshipPropElems = m_resource.getResourceProperty(
RelationshipsCapability.PROP_NAME_RELATIONSHIP );
+// assertTrue( "muws-p2-xs:Relationship property does not contain any
elements", relationshipPropElems.length >= 1 );
+// for ( int i = 0; i < relationshipPropElems.length; i++ )
+// {
+// XmlObject relationshipPropElem = relationshipPropElems[i];
+// assertTrue( relationshipPropElem instanceof RelationshipType );
+// RelationshipType relationship =
(RelationshipType)relationshipPropElem;
+// assertTrue( "muws-p2-xs:Relationship element is not valid",
relationship.validate() );
+// RelationshipParticipantType[] participantArray =
relationship.getParticipantArray();
+// for (int j = 0; j < participantArray.length; j++)
+// {
+// RelationshipParticipantType relationshipParticipantType =
participantArray[j];
+// EndpointReferenceType[] manageabilityEndpointReferenceArray
= relationshipParticipantType.getManageabilityEndpointReferenceArray();
+// for (int k = 0; k <
manageabilityEndpointReferenceArray.length; k++)
+// {
+// EndpointReferenceType endpointReferenceType =
manageabilityEndpointReferenceArray[k];
+// ResourceStub resource = new ResourceStub(new
XmlBeansEndpointReference(endpointReferenceType));
+// XmlObject[] resourceProperty =
resource.getResourceProperty(WeatherstationPropertyQNames.FCCID);
+// assertTrue("Unable to invoke operation on
resource.",resourceProperty.length == 1);
+// }
+// }
+// }
+// }
+
+// public void testWeatherStationCorrelateableProperties() throws
Exception, MalformedURLException
+// {
+// XmlObject[] capabilityElems = m_resource.getResourceProperty(
ManageabilityCharacteristicsCapability.PROP_NAME_MANAGEABILITY_CAPABILITY );
+// assertContainsURI( capabilityElems,
CorrelatablePropertiesCapability.URI );
+// XmlObject correlatablePropertiesPropElem = getSingleProperty(
m_resource, CorrelatablePropertiesCapability.PROP_NAME_CORRELATABLE_PROPERTIES
);
+// assertTrue( correlatablePropertiesPropElem instanceof
CorrelatablePropertiesType );
+// CorrelatablePropertiesType correlatableProperties =
(CorrelatablePropertiesType)correlatablePropertiesPropElem;
+// assertEquals( "Incorrect dialect", MuwsConstants.PBM_DIALECT,
correlatableProperties.getDialect() );
+// XmlObject[] matchElems = XmlBeanUtils.getChildElements(
correlatableProperties, new QName( MuwsConstants.NSURI_PBM, "Match",
MuwsConstants.NSPREFIX_PBM ) );
+// assertEquals( "muws-p1-xs:CorrelatableProperties element does not
contain exactly one pbm:Match element.", 1, matchElems.length );
+// assertTrue( matchElems[0] instanceof XmlQName );
+// XmlQName match = (XmlQName) matchElems[0];
+// assertEquals( WeatherstationPropertyQNames.FCCID,
match.getQNameValue() );
+//
+// // get weather station resource #2
+// EndpointReferenceDocument weatherStation2EprDoc =
getEndpointReference( new URL( WEATHER_STATION_2_EPR_URL ) );
+// ResourceStub resource2 = new ResourceStub(new
XmlBeansEndpointReference( weatherStation2EprDoc.getEndpointReference()) );
//resource2
+//
+// assertEquals("FCCIDs did not match.", getFCCID(m_resource),
getFCCID(resource2));
+// }
+
+// public void testQueryRelationshipsByType() throws FaultException,
MalformedURLException, XmlException
+// {
+// RelationshipType[] relationshipTypes =
m_service.queryRelationshipsByType(WeatherstationResource.RELATIONSHIP_RELATION);
+// assertNotNull(relationshipTypes);
+// assertTrue(relationshipTypes.length == 1);
+// XmlObject[] childElements =
XmlBeanUtils.getChildElements(relationshipTypes[0].getType());
+//
+// XmlObject childElement = childElements[0];
+// QName typeName = XmlBeanUtils.getName(childElement);
+//
+// assertEquals(WeatherstationResource.RELATIONSHIP_RELATION, typeName);
+// }
+//
+// private String getFCCID(ResourceStub resource)
+// throws FaultException
+// {
+// XmlObject fccIdPropElem = getSingleProperty(resource,
WeatherstationPropertyQNames.FCCID);
+// assertTrue("FCCID was not an xs:String", fccIdPropElem instanceof
XmlString);
+// XmlString fccId = (XmlString) fccIdPropElem;
+// return fccId.getStringValue();
+// }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]