You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by wi...@apache.org on 2005/09/21 16:12:17 UTC
svn commit: r290706 - in
/webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification:
./ NotificationImplTest.java NotifyableResourceTest.java
Author: wire
Date: Wed Sep 21 07:12:14 2005
New Revision: 290706
URL: http://svn.apache.org/viewcvs?rev=290706&view=rev
Log:
Updated classes in prepatation for receiving patch from Sim.
Added:
webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/
webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotificationImplTest.java
webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceTest.java
Added: webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotificationImplTest.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotificationImplTest.java?rev=290706&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotificationImplTest.java (added)
+++ webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotificationImplTest.java Wed Sep 21 07:12:14 2005
@@ -0,0 +1,105 @@
+package org.apache.ws.client.muse.client.impl.notification;
+
+import java.util.Calendar;
+
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.ws.client.muse.client.model.Notification;
+import org.apache.ws.client.muse.client.model.TopicExpression;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ComponentAddressType;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ComponentType;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
+
+import junit.framework.TestCase;
+
+public class NotificationImplTest extends TestCase {
+ String message="<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Header><wsa03:To soapenv:actor=\"http://schemas.xmlsoap.org/soap/actor/next\" soapenv:mustUnderstand=\"0\" xmlns:wsa03=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\">http://localhost:8089/endpoint/wsmgr?a=/11310</wsa03:To><wsa03:Action soapenv:actor=\"http://schemas.xmlsoap.org/soap/actor/next\" soapenv:mustUnderstand=\"0\" xmlns:wsa03=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\">http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl/Notify</wsa03:Action></soapenv:Header><soapenv:Body><wsn:Notify xmlns:wsn=\"http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd\"><wsn:NotificationMessage><wsn:Topic xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2-events.xml\" Dialect=\"http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Simple\">wsdm:OperationalStatusCapability</wsn:Topic><wsn:ProducerReference><add:Address xmlns:add=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\">http://192.168.1.241:8080/muse/services/weather-station</add:Address><add:ReferenceProperties xmlns:add=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\"><weat:ResourceIdentifier xmlns:weat=\"http://wsdmdemo.org/service/weather-station\">weather-station-1</weat:ResourceIdentifier></add:ReferenceProperties><add:PortType xmlns:weat=\"http://wsdmdemo.org/service/weather-station\" xmlns:add=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\">weat:WeatherStationPortType</add:PortType><add:ServiceName xmlns:weat=\"http://wsdmdemo.org/service/weather-station\" xmlns:add=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\" PortName=\"weather-station\">weat:weather-station</add:ServiceName></wsn:ProducerReference><wsn:Message><wsdm:ManagementEvent xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part1.xsd\" ReportTime=\"2005-09-19T11:50:31.660-04:00\"><wsdm:EventId>40d8345e-7e7f-4a60-b544-67e77c2ea6ad</wsdm:EventId><wsdm:SourceComponent/><wsdm:ReporterComponent/><wsdm:Situation xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd\"><wsdm:SituationCategory><muws-p2-xs:OtherSituation xmlns:muws-p2-xs=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd\"/></wsdm:SituationCategory></wsdm:Situation><wsrf:ResourcePropertyValueChangeNotification xmlns:wsrf=\"http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd\"><wsrf:OldValue><wsdm:OperationalStatus xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd\">Available</wsdm:OperationalStatus></wsrf:OldValue><wsrf:NewValue><wsdm:OperationalStatus xmlns:wsdm=\"http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2.xsd\">Unavailable</wsdm:OperationalStatus></wsrf:NewValue></wsrf:ResourcePropertyValueChangeNotification></wsdm:ManagementEvent></wsn:Message></wsn:NotificationMessage></wsn:Notify></soapenv:Body></soapenv:Envelope>";
+ private Notification notification;
+ protected void setUp() throws Exception {
+ super.setUp();
+ Notification[] notifications = NotificationImpl.createNotifications(message,null);
+ assertNotNull(notifications);
+ assertTrue(notifications.length>0);
+ this.notification=notifications[0];
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testGetTopic() {
+ TopicExpression topic=this.notification.getTopic();
+ assertNotNull(topic);
+ assertNotNull(topic.getDialect());
+ assertEquals("http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Simple",topic.getDialect());
+ assertNotNull(topic.getName());
+ assertEquals("http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part2-events.xml",topic.getName().getNamespaceURI());
+ assertEquals("OperationalStatusCapability",topic.getName().getLocalPart());
+ }
+
+ public void testGetProducerReference(){
+ EndpointReference reference = this.notification.getProducerReference();
+ assertNotNull(reference);
+ assertEquals("http://192.168.1.241:8080/muse/services/weather-station",reference.getAddress());
+ }
+
+ public void testGetNotificationMessage(){
+ XmlObject noteMessage = this.notification.getNotificationMessage();
+ assertNotNull(noteMessage);
+ }
+
+ public void testGetManagementEvent(){
+ ManagementEventTypeImpl manEvt = this.notification.getManagementEvent();
+ assertNotNull(manEvt);
+ }
+
+ public void testGetEventId(){
+ String evtId = this.notification.getEventId();
+ assertNotNull(evtId);
+ assertEquals("40d8345e-7e7f-4a60-b544-67e77c2ea6ad",evtId);
+
+ }
+
+ public void testGetReportTime(){
+ Calendar reportTime = this.notification.getReportTime();
+ assertNotNull(reportTime);
+ assertEquals("2005-09-19T11:50:31.660-04:00",reportTime.toString());
+ }
+
+ public void testGetSource(){
+ ComponentType source = this.notification.getSourceComponent();
+ assertNotNull(source);
+ }
+
+ public void testGetSourceComponentId(){
+ String sourceId = this.notification.getSourceComponentId();
+ assertNull(sourceId);
+ }
+
+ public void testGetSourceComponentAddresses(){
+ ComponentAddressType[] sourceEprArry = this.notification.getSourceComponentAddresses();
+ assertNotNull(sourceEprArry);
+ //assertTrue(sourceEprArry.length>0);
+
+ }
+
+ public void testGetReporter(){
+ ComponentType reporter = this.notification.getReporter();
+ assertNotNull(reporter);
+ }
+
+ public void testGetReporterId(){
+ String reporterId = this.notification.getReporterId();
+ assertNull(reporterId);
+ }
+
+ public void testGetReporterEndpointReferences(){
+ ComponentAddressType[] reporterEpr = this.notification.getReporterComponentAddresses();
+ assertNotNull(reporterEpr);
+ //assertTrue(reporterEpr.length>0);
+
+ }
+
+}
Added: webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceTest.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceTest.java?rev=290706&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceTest.java (added)
+++ webservices/muse/trunk/src/examples/client/src/test/org/apache/ws/client/muse/client/impl/notification/NotifyableResourceTest.java Wed Sep 21 07:12:14 2005
@@ -0,0 +1,100 @@
+package org.apache.ws.client.muse.client.impl.notification;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.apache.ws.client.muse.client.ManageableResource;
+import org.apache.ws.client.muse.client.NotificationConsumer;
+import org.apache.ws.client.muse.client.impl.exceptions.FaultException;
+import org.apache.ws.client.muse.client.impl.exceptions.UnexpectedServerResponseException;
+import org.apache.ws.client.muse.client.model.TopicExpression;
+import org.apache.ws.util.test.axis.MuseClientTestCase;
+import org.apache.xmlbeans.XmlException;
+
+public class NotifyableResourceTest extends MuseClientTestCase implements Observer {
+ private static String id="0001";
+ private String eprTxt;
+ private URL testAddress;
+ private NotifyableResourceImpl testResource;
+ private Thread unit_test_thread;
+ private Object notificationRecived;
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.testAddress=new URL(getAxisBaseUrl().toExternalForm()+"TestResource");
+ this.eprTxt = eprFromAddessandId(this.testAddress.toString(),id);
+ this.testResource = new NotifyableResourceImpl(
+ eprTxt);
+
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testGetTopics() throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+ TopicExpression[] topics = testResource.getTopics();
+ assertNotNull(topics);
+ assertTrue(topics.length>0);
+ assertEquals("http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Simple",topics[0].getDialect());
+ assertNotNull(topics[0].getName());
+ }
+
+ public void testIsFixedTopicSet() throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+ boolean propValue=testResource.isFixedTopicSet();
+ assertTrue(propValue);
+ }
+
+ public void testGetTopicExpressionDialects() throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+ String[] dialects = testResource.getTopicExpressionDialects();
+ assertNotNull(dialects);
+ assertTrue(dialects.length>2);
+ assertEquals("http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Full",dialects[0]);
+ assertEquals("http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Concrete",dialects[1]);
+ assertEquals("http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Simple",dialects[2]);
+ }
+
+ /**
+ * Do simplest possible subscription and verify that it returns
+ * a new managed resource for the subscription.
+ * @throws URISyntaxException
+ * @throws IOException
+ * @throws XmlException
+ * @throws UnexpectedServerResponseException
+ * @throws FaultException
+ */
+ public void testSimpleSubscribe() throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException, FaultException{
+ TopicExpression[] topics = testResource.getTopics();
+
+ NotificationConsumer testConsumer=new NotificationConsumerImpl(8085,20000);
+ testConsumer.addObserver(this);
+ testConsumer.start();
+ ManageableResource subscriptionResource = testResource.subscribe(topics[0],testConsumer.getEndpointReference());
+ assertNotNull(subscriptionResource);
+
+ // Wait for notification
+ unit_test_thread=Thread.currentThread();
+ try {
+ unit_test_thread.wait(10000);
+ } catch (InterruptedException e) {
+ // Wait for notification
+ e.printStackTrace();
+ }
+ testConsumer.deleteObserver(this);
+ assertNotNull(notificationRecived);
+
+ }
+
+
+ public void testGetCurrentMessage(){
+ fail("This test cannot complete until a wrapper class for notifications is developed");
+ }
+
+ public void update(Observable o, Object arg) {
+ notificationRecived=arg;
+ // Singal receipt of a notification
+ unit_test_thread.interrupt();
+ }
+}