You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pubscribe-dev@ws.apache.org by sc...@apache.org on 2005/02/03 21:38:18 UTC

svn commit: r151227 - in incubator/hermes/trunk/src/test/org/apache/ws/notification/topics: NotifProducer.java SimpleSubscriptionTopicListenerTest.java TopicListenerTestObj.java

Author: scamp
Date: Thu Feb  3 12:38:17 2005
New Revision: 151227

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


Added:
    incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java
    incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/SimpleSubscriptionTopicListenerTest.java
    incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java

Added: incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java?view=auto&rev=151227
==============================================================================
--- incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java (added)
+++ incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java Thu Feb  3 12:38:17 2005
@@ -0,0 +1,62 @@
+package org.apache.ws.notification.topics;
+
+import org.apache.ws.pubsub.NotificationProducer;
+import org.apache.ws.pubsub.Filter;
+import org.apache.ws.pubsub.Subscription;
+import org.apache.ws.pubsub.NotificationConsumer;
+import org.apache.ws.pubsub.DeliveryMode;
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI;
+
+import java.util.Calendar;
+
+
+/**
+ * @author Sal Campana
+ */
+public class NotifProducer implements NotificationProducer
+{
+
+
+    /**
+     * Returns this producer's endpoint reference.
+     *
+     * @return this producer's endpoint reference
+     */
+    public EndpointReference getEPR()
+    {
+        EndpointReferenceType epr = EndpointReferenceType.Factory.newInstance();
+        AttributedURI attributedURI = AttributedURI.Factory.newInstance();
+        attributedURI.setStringValue("http://foo");
+        epr.setAddress(attributedURI);
+        return new XmlBeansEndpointReference(epr);
+    }
+
+    /**
+     * Subscribe to notifications from this producer.
+     *
+     * @param notificationConsumer
+     * @param filters
+     * @param initialTerminationTime
+     * @param deliveryMode           the notification delivery mode, or null to use default mode
+     * @param policy                 a policy to be associated with the subscription, or null if no policy should be used
+     * @return the subscription
+     */
+    public Subscription subscribe(NotificationConsumer notificationConsumer, Filter filters[], Calendar initialTerminationTime, DeliveryMode deliveryMode, Object policy)
+    {
+        return null;
+    }
+
+    /**
+     * Returns the last notification message published for the given set of filters.
+     *
+     * @param filters
+     * @return
+     */
+    public Object getCurrentMessage(Filter filters[])
+    {
+        return null;
+    }
+}

Added: incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/SimpleSubscriptionTopicListenerTest.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/SimpleSubscriptionTopicListenerTest.java?view=auto&rev=151227
==============================================================================
--- incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/SimpleSubscriptionTopicListenerTest.java (added)
+++ incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/SimpleSubscriptionTopicListenerTest.java Thu Feb  3 12:38:17 2005
@@ -0,0 +1,78 @@
+package org.apache.ws.notification.topics;
+
+import junit.framework.TestCase;
+import org.apache.ws.notification.topics.impl.SimpleSubscriptionTopicListener;
+import org.apache.ws.notification.topics.impl.ResourcePropertyValueChangeTopicImpl;
+import org.apache.ws.notification.base.v1_2.impl.Subscription1_2Resource;
+import org.apache.ws.notification.base.v1_2.porttype.impl.NotificationProducerPortTypeImpl;
+import org.apache.ws.notification.base.impl.XmlBeansTopicExpression;
+import org.apache.ws.pubsub.Subscription;
+import org.apache.ws.resource.properties.impl.XmlBeansResourceProperty;
+import org.apache.ws.resource.properties.impl.AnyResourcePropertyMetaData;
+import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
+import org.apache.ws.resource.properties.ResourcePropertyMetaData;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlException;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotifyDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
+
+import javax.xml.namespace.QName;
+import javax.naming.directory.SchemaViolationException;
+import java.util.Calendar;
+
+
+/**
+ * @author Sal Campana
+ */
+public class SimpleSubscriptionTopicListenerTest extends TestCase
+{
+
+    public void testBuildingNotificationMessages() throws SchemaViolationException
+    {
+        EndpointReferenceType epr1 = EndpointReferenceType.Factory.newInstance();
+        AttributedURI uri = AttributedURI.Factory.newInstance();
+        uri.setStringValue("http://cunsumer");
+        epr1.setAddress(uri);
+        EndpointReference epr = new XmlBeansEndpointReference(epr1);
+        TopicExpressionDocument topicExprType = null;
+        try
+        {
+            topicExprType = (TopicExpressionDocument) XmlObject.Factory.parse("<wsnt:TopicExpression xmlns:wsnt=\"http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd\" Dialect=\"http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Simple\">fs:MountPointDirectory</wsnt:TopicExpression>");
+        }
+        catch (XmlException e)
+        {
+            e.printStackTrace();
+        }
+        //topicExprType.setDialect("http://foobar");
+
+        XmlBeansTopicExpression topicExpr = new XmlBeansTopicExpression(topicExprType.getTopicExpression());
+        Subscription1_2Resource sub = new Subscription1_2Resource(epr,epr,Calendar.getInstance(),null,null,null,null,"",topicExpr,false);
+        sub.setNotificationProducer(new NotifProducer());
+
+       /* EndpointReference consumerReference, EndpointReference producerReference,
+                                    Calendar initialTerminationTime, Object policy, QueryExpression precondition,
+                                    QueryExpression selector, ResourceKey producerKey, String producerHomeLocation,
+                                    TopicExpression topicExpression, boolean useNotify )
+    {*/
+        SimpleSubscriptionTopicListener lis = new SimpleSubscriptionTopicListener(sub);
+        AnyResourcePropertyMetaData anyMeta = new AnyResourcePropertyMetaData(new QName("foo"));
+
+        //need some sort of documenttype
+        NotifyDocument doc = NotifyDocument.Factory.newInstance();
+        XmlBeansResourcePropertySet set = new XmlBeansResourcePropertySet(doc);
+        XmlBeansResourceProperty prop = new XmlBeansResourceProperty(anyMeta,set);
+        ResourcePropertyValueChangeTopicImpl topic = new ResourcePropertyValueChangeTopicImpl(prop);
+        TopicListenerTestObj testListenr = new TopicListenerTestObj();
+        topic.addTopicListener(testListenr);
+        lis.topicChanged(topic);
+
+    }
+
+}

Added: incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java?view=auto&rev=151227
==============================================================================
--- incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java (added)
+++ incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java Thu Feb  3 12:38:17 2005
@@ -0,0 +1,41 @@
+package org.apache.ws.notification.topics;
+
+
+/**
+ * @author Sal Campana
+ */
+public class TopicListenerTestObj implements TopicListener
+
+{
+
+
+    /**
+     * Called when the value of the topic changes
+     *
+     * @param topic The topic that changed
+     */
+    public void topicChanged(Topic topic)
+    {
+
+    }
+
+    /**
+     * Called when a topic is added
+     *
+     * @param topic The topic being added
+     */
+    public void topicAdded(Topic topic)
+    {
+
+    }
+
+    /**
+     * Called when a topic is removed
+     *
+     * @param topic The topic being removed
+     */
+    public void topicRemoved(Topic topic)
+    {
+
+    }
+}



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