You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pubscribe-commits@ws.apache.org by sc...@apache.org on 2005/08/02 18:41:44 UTC
svn commit: r227035 [11/12] - in /webservices/pubscribe/trunk: ./
src/java/org/apache/ws/eventing/ src/java/org/apache/ws/eventing/porttype/
src/java/org/apache/ws/eventing/porttype/impl/
src/java/org/apache/ws/eventing/pubsub/ src/java/org/apache/ws/e...
Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java?rev=227035&r1=227034&r2=227035&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java Tue Aug 2 09:41:00 2005
@@ -1,113 +1,188 @@
-package org.apache.ws.notification.base.impl;
-
-import org.apache.ws.addressing.EndpointReference;
-import org.apache.ws.resource.Resource;
-import org.apache.ws.resource.ResourceContext;
-import org.apache.ws.resource.ResourceContextException;
-import org.apache.ws.resource.ResourceException;
-import org.apache.ws.resource.ResourceUnknownException;
-import org.apache.ws.resource.impl.AbstractResourceHome;
-import org.apache.ws.notification.base.WsnNamespaceVersionHolder;
-import org.apache.ws.notification.base.v2004_06.impl.WsnNamespaceVersionHolderImpl;
-
-import javax.xml.namespace.QName;
-import java.util.Map;
-
-/**
- * @author Sal Campana
- */
-public class UnitExampleHome extends AbstractResourceHome
-{
-
- public static final String SERVICE_NAME = "UnitHome";
- public static final String TARGET_NAMESPACE = "http://unittest";
- public static final QName SERVICE_QNAME = new QName(TARGET_NAMESPACE, SERVICE_NAME);
- public static final String TARGET_NSPREFIX = "unit";
- public static final String RESOURCE_ID = "123";
- public static final QName PORT_TYPE = new QName(TARGET_NAMESPACE, "UnitTestExamples");
- public static final String SERVICE_PORT_NAME = SERVICE_NAME;
- public static final QName RESOURCE_KEY_NAME = new QName(TARGET_NAMESPACE, "ResourceIdentifier", TARGET_NSPREFIX);
- private Resource m_resource;
- public WsnNamespaceVersionHolder m_namespaceSet = new WsnNamespaceVersionHolderImpl();
-
- public UnitExampleHome()
- {
- setResourceIdentifierReferenceParameterName( RESOURCE_KEY_NAME.toString() );
- setResourceClassName( UnitResource.class.getName() );
- try
- {
- init();
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- }
- }
-
- public QName getServiceName()
- {
- return SERVICE_QNAME;
- }
-
- public QName getPortType()
- {
- return PORT_TYPE;
- }
-
- public String getServicePortName()
- {
- return SERVICE_PORT_NAME;
- }
-
- public QName getResourceKeyNameQName()
- {
- return RESOURCE_KEY_NAME;
- }
-
- public Resource getInstance(ResourceContext resourceContext) throws ResourceException, ResourceContextException, ResourceUnknownException
- {
- if(m_resource == null)
- {
- try
- {
- UnitResource myResource = new UnitResource(); //this will create the resource IF it is has default constructor
- myResource.setID(RESOURCE_ID);
- m_resource = myResource;
- myResource.init();
- EndpointReference epr = getEndpointReference(RESOURCE_ID);
- myResource.setEndpointReference(epr); //make sure to set the EPR on your new instance
- add(myResource);
- }
- catch (Exception e)
- {
- throw new ResourceException(e);
- }
- }
- return m_resource;
- }
-
- /**
- * Map containing all FilesystemResource instances - this map <em>must</em> be static for
- * compatibility with certain JNDI providers.
- */
- private static Map s_resources;
-
- /**
- * Returns a map of all FilesystemResource instances. Used by the {@link org.apache.ws.resource.impl.AbstractResourceHome}
- * superclass.
- */
- protected synchronized final Map getResourceMap()
- {
- if ( s_resources == null )
- {
- s_resources = AbstractResourceHome.createResourceMap( m_resourceIsPersistent );
- }
- return s_resources;
- }
-
- public org.apache.ws.resource.properties.NamespaceVersionHolder getNamespaceVersionHolder()
- {
- return m_namespaceSet;
- }
-
-}
+/*=============================================================================*
+ * Copyright 2004 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.ws.notification.base.impl;
+
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.notification.base.WsnNamespaceVersionHolder;
+import org.apache.ws.notification.base.v2004_06.impl.WsnNamespaceVersionHolderImpl;
+import org.apache.ws.resource.Resource;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.ResourceUnknownException;
+import org.apache.ws.resource.impl.AbstractResourceHome;
+import javax.xml.namespace.QName;
+import java.util.Map;
+
+/**
+ * @author Sal Campana
+ */
+public class UnitExampleHome
+ extends AbstractResourceHome
+{
+ /** DOCUMENT_ME */
+ public static final String SERVICE_NAME = "UnitHome";
+
+ /** DOCUMENT_ME */
+ public static final String TARGET_NAMESPACE = "http://unittest";
+
+ /** DOCUMENT_ME */
+ public static final QName SERVICE_QNAME = new QName( TARGET_NAMESPACE, SERVICE_NAME );
+
+ /** DOCUMENT_ME */
+ public static final String TARGET_NSPREFIX = "unit";
+
+ /** DOCUMENT_ME */
+ public static final String RESOURCE_ID = "123";
+
+ /** DOCUMENT_ME */
+ public static final QName PORT_TYPE = new QName( TARGET_NAMESPACE, "UnitTestExamples" );
+
+ /** DOCUMENT_ME */
+ public static final String SERVICE_PORT_NAME = SERVICE_NAME;
+
+ /** DOCUMENT_ME */
+ public static final QName RESOURCE_KEY_NAME =
+ new QName( TARGET_NAMESPACE, "ResourceIdentifier", TARGET_NSPREFIX );
+
+ /**
+ * Map containing all FilesystemResource instances - this map <em>must</em> be static for
+ * compatibility with certain JNDI providers.
+ */
+ private static Map s_resources;
+ private Resource m_resource;
+
+ /** DOCUMENT_ME */
+ public WsnNamespaceVersionHolder m_namespaceSet = new WsnNamespaceVersionHolderImpl( );
+
+ /**
+ * Creates a new {@link UnitExampleHome} object.
+ */
+ public UnitExampleHome( )
+ {
+ setResourceIdentifierReferenceParameterName( RESOURCE_KEY_NAME.toString( ) );
+ setResourceClassName( UnitResource.class.getName( ) );
+ try
+ {
+ init( );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace( );
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourceContext DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws ResourceException DOCUMENT_ME
+ * @throws ResourceContextException DOCUMENT_ME
+ * @throws ResourceUnknownException DOCUMENT_ME
+ */
+ public Resource getInstance( ResourceContext resourceContext )
+ throws ResourceException,
+ ResourceContextException,
+ ResourceUnknownException
+ {
+ if ( m_resource == null )
+ {
+ try
+ {
+ UnitResource myResource = new UnitResource( ); //this will create the resource IF it is has default constructor
+ myResource.setID( RESOURCE_ID );
+ m_resource = myResource;
+ myResource.init( );
+ EndpointReference epr = getEndpointReference( RESOURCE_ID );
+ myResource.setEndpointReference( epr ); //make sure to set the EPR on your new instance
+ add( myResource );
+ }
+ catch ( Exception e )
+ {
+ throw new ResourceException( e );
+ }
+ }
+
+ return m_resource;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public org.apache.ws.resource.properties.NamespaceVersionHolder getNamespaceVersionHolder( )
+ {
+ return m_namespaceSet;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public QName getPortType( )
+ {
+ return PORT_TYPE;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public QName getResourceKeyNameQName( )
+ {
+ return RESOURCE_KEY_NAME;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public QName getServiceName( )
+ {
+ return SERVICE_QNAME;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getServicePortName( )
+ {
+ return SERVICE_PORT_NAME;
+ }
+
+ /**
+ * Returns a map of all FilesystemResource instances. Used by the {@link org.apache.ws.resource.impl.AbstractResourceHome}
+ * superclass.
+ */
+ protected final synchronized Map getResourceMap( )
+ {
+ if ( s_resources == null )
+ {
+ s_resources = AbstractResourceHome.createResourceMap( m_resourceIsPersistent );
+ }
+
+ return s_resources;
+ }
+}
\ No newline at end of file
Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResource.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResource.java?rev=227035&r1=227034&r2=227035&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResource.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResource.java Tue Aug 2 09:41:00 2005
@@ -1,96 +1,168 @@
-package org.apache.ws.notification.base.impl;
-
-import org.apache.ws.addressing.EndpointReference;
-import org.apache.ws.notification.base.NotificationProducerResource;
-import org.apache.ws.notification.topics.impl.TopicSpaceImpl;
-import org.apache.ws.resource.PropertiesResource;
-import org.apache.ws.resource.lifetime.ResourceTerminationListener;
-import org.apache.ws.resource.properties.ResourcePropertySet;
-import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
-import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationProducerRPDocument;
-
-/**
- * @author Sal Campana
- */
-public class UnitResource implements PropertiesResource, NotificationProducerResource
-{
- ResourcePropertySet m_resourcePropertySet;
- private EndpointReference m_epr;
- private Object m_id;
- public static final String TOPIC_NAME = "test";
- org.apache.ws.notification.topics.TopicSpaceSet m_topicSpaceSet = new org.apache.ws.notification.topics.impl.TopicSpaceSetImpl(true);
-
- public ResourcePropertySet getResourcePropertySet()
- {
- return m_resourcePropertySet;
- }
-
- public void setResourcePropertySet(ResourcePropertySet resourcePropertySet)
- {
- m_resourcePropertySet = resourcePropertySet;
- }
-
- public void setID(Object resourceId)
- {
- m_id = resourceId;
- }
-
- public Object getID()
- {
- return m_id;
- }
-
- public void destroy()
- {
-
- }
-
- public void init()
- {
- NotificationProducerRPDocument notificationProducerRPDocument = NotificationProducerRPDocument.Factory.newInstance();
- notificationProducerRPDocument.addNewNotificationProducerRP();
- m_resourcePropertySet = new XmlBeansResourcePropertySet(notificationProducerRPDocument);
-
- org.apache.ws.resource.properties.ResourceProperty topicProp = getResourcePropertySet().get( org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType.PROP_QNAME_TOPIC );
- topicProp.setCallback( new org.apache.ws.notification.base.TopicResourcePropertyCallback( getTopicSpaceSet() ) );
-
- org.apache.ws.resource.properties.ResourceProperty fixedTopicSetProp = getResourcePropertySet().get( org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType.PROP_QNAME_FIXED_TOPIC_SET );
- fixedTopicSetProp.setCallback( new org.apache.ws.notification.base.FixedTopicSetResourcePropertyCallback( getTopicSpaceSet() ) );
-
- org.apache.ws.resource.properties.ResourceProperty topicExpressionDialectsProp = getResourcePropertySet().get( org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType.PROP_QNAME_TOPIC_EXPRESSION_DIALECTS );
- topicExpressionDialectsProp.setCallback( new org.apache.ws.notification.base.TopicExpressionDialectsResourcePropertyCallback() );
-
- TopicSpaceImpl topicSpace = new TopicSpaceImpl(UnitExampleHome.TARGET_NAMESPACE);
- try
- {
- topicSpace.addTopic(TOPIC_NAME);
- getTopicSpaceSet().addTopicSpace(topicSpace);
- org.apache.ws.notification.topics.util.TopicUtils.addResourcePropertyValueChangeTopics(getResourcePropertySet(), getTopicSpaceSet());
- }
- catch (Exception e)
- {
- throw new javax.xml.rpc.JAXRPCException("Unable to init the ResourceProperty Changed topics. Cause: " + e.getLocalizedMessage(), e);
- }
- }
-
- public void addTerminationListener(ResourceTerminationListener resourceTerminationListener)
- {
-
- }
-
- public EndpointReference getEndpointReference()
- {
- return m_epr;
- }
-
- public void setEndpointReference(EndpointReference epr)
- {
- m_epr = epr;
- }
-
- public org.apache.ws.notification.topics.TopicSpaceSet getTopicSpaceSet()
- {
- return m_topicSpaceSet;
- }
-
-}
+/*=============================================================================*
+ * Copyright 2004 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.ws.notification.base.impl;
+
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.notification.base.NotificationProducerResource;
+import org.apache.ws.notification.topics.impl.TopicSpaceImpl;
+import org.apache.ws.resource.PropertiesResource;
+import org.apache.ws.resource.lifetime.ResourceTerminationListener;
+import org.apache.ws.resource.properties.ResourcePropertySet;
+import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationProducerRPDocument;
+
+/**
+ * @author Sal Campana
+ */
+public class UnitResource
+ implements PropertiesResource,
+ NotificationProducerResource
+{
+ /** DOCUMENT_ME */
+ public static final String TOPIC_NAME = "test";
+
+ /** DOCUMENT_ME */
+ ResourcePropertySet m_resourcePropertySet;
+ private EndpointReference m_epr;
+ private Object m_id;
+
+ /** DOCUMENT_ME */
+ org.apache.ws.notification.topics.TopicSpaceSet m_topicSpaceSet =
+ new org.apache.ws.notification.topics.impl.TopicSpaceSetImpl( true );
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param epr DOCUMENT_ME
+ */
+ public void setEndpointReference( EndpointReference epr )
+ {
+ m_epr = epr;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public EndpointReference getEndpointReference( )
+ {
+ return m_epr;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourceId DOCUMENT_ME
+ */
+ public void setID( Object resourceId )
+ {
+ m_id = resourceId;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Object getID( )
+ {
+ return m_id;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourcePropertySet DOCUMENT_ME
+ */
+ public void setResourcePropertySet( ResourcePropertySet resourcePropertySet )
+ {
+ m_resourcePropertySet = resourcePropertySet;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public ResourcePropertySet getResourcePropertySet( )
+ {
+ return m_resourcePropertySet;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public org.apache.ws.notification.topics.TopicSpaceSet getTopicSpaceSet( )
+ {
+ return m_topicSpaceSet;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourceTerminationListener DOCUMENT_ME
+ */
+ public void addTerminationListener( ResourceTerminationListener resourceTerminationListener )
+ {
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void destroy( )
+ {
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void init( )
+ {
+ NotificationProducerRPDocument notificationProducerRPDocument =
+ NotificationProducerRPDocument.Factory.newInstance( );
+ notificationProducerRPDocument.addNewNotificationProducerRP( );
+ m_resourcePropertySet = new XmlBeansResourcePropertySet( notificationProducerRPDocument );
+
+ org.apache.ws.resource.properties.ResourceProperty topicProp =
+ getResourcePropertySet( ).get( org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType.PROP_QNAME_TOPIC );
+ topicProp.setCallback( new org.apache.ws.notification.base.TopicResourcePropertyCallback( getTopicSpaceSet( ) ) );
+
+ org.apache.ws.resource.properties.ResourceProperty fixedTopicSetProp =
+ getResourcePropertySet( ).get( org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType.PROP_QNAME_FIXED_TOPIC_SET );
+ fixedTopicSetProp.setCallback( new org.apache.ws.notification.base.FixedTopicSetResourcePropertyCallback( getTopicSpaceSet( ) ) );
+
+ org.apache.ws.resource.properties.ResourceProperty topicExpressionDialectsProp =
+ getResourcePropertySet( ).get( org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType.PROP_QNAME_TOPIC_EXPRESSION_DIALECTS );
+ topicExpressionDialectsProp.setCallback( new org.apache.ws.notification.base.TopicExpressionDialectsResourcePropertyCallback( ) );
+
+ TopicSpaceImpl topicSpace = new TopicSpaceImpl( UnitExampleHome.TARGET_NAMESPACE );
+ try
+ {
+ topicSpace.addTopic( TOPIC_NAME );
+ getTopicSpaceSet( ).addTopicSpace( topicSpace );
+ org.apache.ws.notification.topics.util.TopicUtils.addResourcePropertyValueChangeTopics( getResourcePropertySet( ),
+ getTopicSpaceSet( ) );
+ }
+ catch ( Exception e )
+ {
+ throw new javax.xml.rpc.JAXRPCException( "Unable to init the ResourceProperty Changed topics. Cause: "
+ + e.getLocalizedMessage( ), e );
+ }
+ }
+}
\ No newline at end of file
Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java?rev=227035&r1=227034&r2=227035&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java Tue Aug 2 09:41:00 2005
@@ -1,117 +1,201 @@
-package org.apache.ws.notification.base.impl;
-
-import org.apache.ws.resource.Resource;
-import org.apache.ws.resource.ResourceContext;
-import org.apache.ws.resource.ResourceException;
-import org.apache.ws.resource.ResourceHome;
-
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URI;
-import java.util.Iterator;
-
-
-/**
- * @author Sal Campana
- */
-public class UnitResourceContext implements ResourceContext
-{
-
- ResourceHome m_home = new UnitExampleHome();
- private Resource m_resource = null;
- public static final String ID_KEY = "1212";
- private String m_serviceName = UnitExampleHome.SERVICE_NAME;
- public static final String TARGET_NSPREFIX = UnitExampleHome.TARGET_NSPREFIX;
-
- public synchronized ResourceHome getResourceHome()
- {
- return m_home;
- }
-
- public SOAPMessage getSOAPMessage()
- {
- try
- {
- return MessageFactory.newInstance().createMessage();
- }
- catch ( SOAPException e )
- {
- e.printStackTrace();
- }
- return null;
- }
-
- public String getServiceName()
- {
- return m_serviceName;
- }
-
- public URL getServiceURL()
- {
- try
- {
- return new URL( "http://localhost:8080/pubscribe/" + m_serviceName );
- }
- catch ( MalformedURLException murle )
- {
- murle.printStackTrace();
- }
- return null;
- }
-
- /**
- * Gets the base URL from which service urls are based.
- *
- * @return The String representation of the base url
- */
- public String getBaseURL()
- {
- return null;
- }
-
- public boolean containsProperty( String name )
- {
- return false;
- }
-
- public void removeProperty( String name )
- {
-
- }
-
- public void setProperty( String name, Object value )
- {
-
- }
-
- public Object getProperty( String name )
- {
- return null;
- }
-
- public Iterator getPropertyNames()
- {
- return null;
- }
-
- public Resource getResource() throws ResourceException
- {
- return m_resource;
- }
-
-
- public String getRequestAction()
- {
- return null;
- }
-
- public void setResponseAction( URI uri )
- {
- return;
- }
-
-
-}
+/*=============================================================================*
+ * Copyright 2004 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.ws.notification.base.impl;
+
+import org.apache.ws.resource.Resource;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.ResourceHome;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Iterator;
+
+/**
+ * @author Sal Campana
+ */
+public class UnitResourceContext
+ implements ResourceContext
+{
+ /** DOCUMENT_ME */
+ public static final String ID_KEY = "1212";
+
+ /** DOCUMENT_ME */
+ public static final String TARGET_NSPREFIX = UnitExampleHome.TARGET_NSPREFIX;
+
+ /** DOCUMENT_ME */
+ ResourceHome m_home = new UnitExampleHome( );
+ private Resource m_resource = null;
+ private String m_serviceName = UnitExampleHome.SERVICE_NAME;
+
+ /**
+ * Gets the base URL from which service urls are based.
+ *
+ * @return The String representation of the base url
+ */
+ public String getBaseURL( )
+ {
+ return null;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ * @param value DOCUMENT_ME
+ */
+ public void setProperty( String name,
+ Object value )
+ {
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Object getProperty( String name )
+ {
+ return null;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Iterator getPropertyNames( )
+ {
+ return null;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getRequestAction( )
+ {
+ return null;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws ResourceException DOCUMENT_ME
+ */
+ public Resource getResource( )
+ throws ResourceException
+ {
+ return m_resource;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public synchronized ResourceHome getResourceHome( )
+ {
+ return m_home;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param uri DOCUMENT_ME
+ */
+ public void setResponseAction( URI uri )
+ {
+ return;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public SOAPMessage getSOAPMessage( )
+ {
+ try
+ {
+ return MessageFactory.newInstance( ).createMessage( );
+ }
+ catch ( SOAPException e )
+ {
+ e.printStackTrace( );
+ }
+
+ return null;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String getServiceName( )
+ {
+ return m_serviceName;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public URL getServiceURL( )
+ {
+ try
+ {
+ return new URL( "http://localhost:8080/pubscribe/" + m_serviceName );
+ }
+ catch ( MalformedURLException murle )
+ {
+ murle.printStackTrace( );
+ }
+
+ return null;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public boolean containsProperty( String name )
+ {
+ return false;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param name DOCUMENT_ME
+ */
+ public void removeProperty( String name )
+ {
+ }
+}
\ No newline at end of file
Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java?rev=227035&r1=227034&r2=227035&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java Tue Aug 2 09:41:00 2005
@@ -1,18 +1,18 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
+/*=============================================================================*
+ * Copyright 2004 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
+ * 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.
- */
+ * 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.ws.notification.base.v2004_06.porttype.impl;
import junit.framework.Test;
@@ -41,7 +41,6 @@
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
import org.xmlsoap.schemas.soap.envelope.Body;
import org.xmlsoap.schemas.soap.envelope.EnvelopeDocument;
-
import javax.xml.namespace.QName;
import java.util.Calendar;
@@ -50,118 +49,173 @@
*
* @author Sal Campana
*/
-public class NotificationProducerPortTypeImplTest extends TestCase
+public class NotificationProducerPortTypeImplTest
+ extends TestCase
{
+ /** DOCUMENT_ME */
+ protected static final int NOTIF_LISTENER_TIMEOUT = 20000;
+
+ /** DOCUMENT_ME */
+ protected static final int NOTIF_LISTENER_PORT = 9101;
- ResourceContext m_resourceContext;
- private NotificationProducerPortTypeImpl m_portTypeImpl;
- protected static final int NOTIF_LISTENER_TIMEOUT = 20000;
- protected static final int NOTIF_LISTENER_PORT = 9101;
- private String m_consumerURL = "http://localhost:" + Integer.toString(NOTIF_LISTENER_PORT);
- private QName m_topic = new QName(UnitExampleHome.TARGET_NAMESPACE, UnitResource.TOPIC_NAME, UnitExampleHome.TARGET_NSPREFIX);
-
- public NotificationProducerPortTypeImplTest(String name)
- {
- super(name);
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- m_resourceContext = new UnitResourceContext();
- m_portTypeImpl = new NotificationProducerPortTypeImpl(m_resourceContext);
-
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- public void testSubscribeWrapped() throws Exception
- {
- /* subscribe(true);
- PortListen listener = new PortListen(NOTIF_LISTENER_PORT, NOTIF_LISTENER_TIMEOUT);
- triggerChangeEvent();
- assertIncomingMessage(listener, true);*/
- }
-
- public void testSubscribeUnwrapped() throws Exception
- {
- /*subscribe(false);
- PortListen listener = new PortListen(NOTIF_LISTENER_PORT, NOTIF_LISTENER_TIMEOUT);
- triggerChangeEvent();
- assertIncomingMessage(listener, false);*/
- }
-
- private void triggerChangeEvent() throws ResourceContextException, ResourceException
- {
- PropertiesResource resource = (PropertiesResource) m_resourceContext.getResourceHome().find(UnitExampleHome.RESOURCE_ID);
- ResourceProperty resourceProperty = resource.getResourcePropertySet().get(NotificationProducerPortType.PROP_QNAME_TOPIC_EXPRESSION_DIALECTS);
- TopicExpressionDialectsDocument topicExpressionDialectsDocument = TopicExpressionDialectsDocument.Factory.newInstance();
- topicExpressionDialectsDocument.setTopicExpressionDialects("foo-dialect");
- resourceProperty.add(topicExpressionDialectsDocument);
- }
-
- private void assertIncomingMessage(PortListen listener, boolean isWrapped) throws XmlException
- {
- String incomingMsg = listener.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 event = null;
- if (isWrapped) //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);
- }
- else //unwrapped
- { //see what this should be
- XmlObject bodyElems[] = XmlBeanUtils.getChildElements(body,
- new QName(BaseNotificationConstants.NSURI_WSNT_SCHEMA, "Notify"));
- }
- }
-
- private XmlBeansEndpointReference subscribe(boolean isWrapped)
- {
- SubscribeDocument requestDoc = SubscribeDocument.Factory.newInstance();
- SubscribeDocument.Subscribe subscribe = requestDoc.addNewSubscribe();
- subscribe.setUseNotify(true);
- Calendar instance = Calendar.getInstance();
- instance.setTimeInMillis(instance.getTimeInMillis() + 20000);
- subscribe.setInitialTerminationTime(instance);
- org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType consumerRef = subscribe.addNewConsumerReference();
- org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI address = consumerRef.addNewAddress();
- address.setStringValue(m_consumerURL);
- TopicExpressionType topicExpr = subscribe.addNewTopicExpression();
- topicExpr.setDialect(TopicsConstants.TOPIC_EXPR_DIALECT_SIMPLE);
- XmlBeanUtils.setValueAsQName(topicExpr, m_topic);
- XmlObject response = m_portTypeImpl.subscribe(requestDoc);
- assertTrue(response instanceof SubscribeResponseDocument.SubscribeResponse);
- SubscribeResponseDocument.SubscribeResponse subscribeResponse = (SubscribeResponseDocument.SubscribeResponse) response;
- XmlBeansEndpointReference xmlBeansEndpointReference = new XmlBeansEndpointReference(subscribeResponse.getSubscriptionReference());
- return xmlBeansEndpointReference;
- }
-
- public void testGetCurrentMessage() throws Exception
- {
-
- }
-
-
- public static Test suite()
- {
- return new TestSuite(NotificationProducerPortTypeImplTest.class);
- }
-}
+ /** DOCUMENT_ME */
+ ResourceContext m_resourceContext;
+ private NotificationProducerPortTypeImpl m_portTypeImpl;
+ private String m_consumerURL = "http://localhost:" + Integer.toString( NOTIF_LISTENER_PORT );
+ private QName m_topic =
+ new QName( UnitExampleHome.TARGET_NAMESPACE, UnitResource.TOPIC_NAME, UnitExampleHome.TARGET_NSPREFIX );
+
+ /**
+ * Creates a new {@link NotificationProducerPortTypeImplTest} object.
+ *
+ * @param name DOCUMENT_ME
+ */
+ public NotificationProducerPortTypeImplTest( String name )
+ {
+ super( name );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void setUp( )
+ throws Exception
+ {
+ super.setUp( );
+
+ m_resourceContext = new UnitResourceContext( );
+ m_portTypeImpl = new NotificationProducerPortTypeImpl( m_resourceContext );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public static Test suite( )
+ {
+ return new TestSuite( NotificationProducerPortTypeImplTest.class );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void tearDown( )
+ throws Exception
+ {
+ super.tearDown( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testGetCurrentMessage( )
+ throws Exception
+ {
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testSubscribeUnwrapped( )
+ throws Exception
+ {
+ /*subscribe(false);
+ PortListen listener = new PortListen(NOTIF_LISTENER_PORT, NOTIF_LISTENER_TIMEOUT);
+ triggerChangeEvent();
+ assertIncomingMessage(listener, false);*/
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testSubscribeWrapped( )
+ throws Exception
+ {
+ /* subscribe(true);
+ PortListen listener = new PortListen(NOTIF_LISTENER_PORT, NOTIF_LISTENER_TIMEOUT);
+ triggerChangeEvent();
+ assertIncomingMessage(listener, true);*/
+ }
+
+ private void assertIncomingMessage( PortListen listener,
+ boolean isWrapped )
+ throws XmlException
+ {
+ String incomingMsg = listener.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 event = null;
+ if ( isWrapped ) //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 );
+ }
+ else //unwrapped
+ { //see what this should be
+ XmlObject[] bodyElems =
+ XmlBeanUtils.getChildElements( body,
+ new QName( BaseNotificationConstants.NSURI_WSNT_SCHEMA, "Notify" ) );
+ }
+ }
+
+ private XmlBeansEndpointReference subscribe( boolean isWrapped )
+ {
+ SubscribeDocument requestDoc = SubscribeDocument.Factory.newInstance( );
+ SubscribeDocument.Subscribe subscribe = requestDoc.addNewSubscribe( );
+ subscribe.setUseNotify( true );
+ Calendar instance = Calendar.getInstance( );
+ instance.setTimeInMillis( instance.getTimeInMillis( ) + 20000 );
+ subscribe.setInitialTerminationTime( instance );
+ org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType consumerRef =
+ subscribe.addNewConsumerReference( );
+ org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI address = consumerRef.addNewAddress( );
+ address.setStringValue( m_consumerURL );
+ TopicExpressionType topicExpr = subscribe.addNewTopicExpression( );
+ topicExpr.setDialect( TopicsConstants.TOPIC_EXPR_DIALECT_SIMPLE );
+ XmlBeanUtils.setValueAsQName( topicExpr, m_topic );
+ XmlObject response = m_portTypeImpl.subscribe( requestDoc );
+ assertTrue( response instanceof SubscribeResponseDocument.SubscribeResponse );
+ SubscribeResponseDocument.SubscribeResponse subscribeResponse =
+ (SubscribeResponseDocument.SubscribeResponse) response;
+ XmlBeansEndpointReference xmlBeansEndpointReference =
+ new XmlBeansEndpointReference( subscribeResponse.getSubscriptionReference( ) );
+ return xmlBeansEndpointReference;
+ }
+
+ private void triggerChangeEvent( )
+ throws ResourceContextException,
+ ResourceException
+ {
+ PropertiesResource resource =
+ (PropertiesResource) m_resourceContext.getResourceHome( ).find( UnitExampleHome.RESOURCE_ID );
+ ResourceProperty resourceProperty =
+ resource.getResourcePropertySet( ).get( NotificationProducerPortType.PROP_QNAME_TOPIC_EXPRESSION_DIALECTS );
+ TopicExpressionDialectsDocument topicExpressionDialectsDocument =
+ TopicExpressionDialectsDocument.Factory.newInstance( );
+ topicExpressionDialectsDocument.setTopicExpressionDialects( "foo-dialect" );
+ resourceProperty.add( topicExpressionDialectsDocument );
+ }
+}
\ No newline at end of file
Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java?rev=227035&r1=227034&r2=227035&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java Tue Aug 2 09:41:00 2005
@@ -1,91 +1,116 @@
-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.pubsub.SubscriptionEndConsumer;
-import org.apache.ws.pubsub.TopicFilter;
-import org.apache.ws.pubsub.XPathFilter;
-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;
-import java.util.StringTokenizer;
-
-
-/**
- * @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 subscriptionEndConsumer the callback Interface for SubscriptionEnd Notifications, or null if no SubscriptionEnd should be send
- * @param filters
- * @param initialTerminationTime
- * @param deliveryMode the notification delivery mode, or null to use default mode
- * @return the subscription
- */
- public Subscription subscribe(NotificationConsumer notificationConsumer, SubscriptionEndConsumer subscriptionEndConsumer, TopicFilter tf, XPathFilter xf, Calendar initialTerminationTime, boolean UseNotify)
- {
- return null; //todo *SJC* implement
- }
-
- /**
- * 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;
- }
-
- public static void main( String[] args )
- {
- StringTokenizer tok = new StringTokenizer( " / " );
- while ( tok.hasMoreElements() )
- {
- System.out.println( "[" + tok.nextElement() + "]" );
- }
- }
-
-}
+/*=============================================================================*
+ * Copyright 2004 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.ws.notification.topics;
+
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.ws.pubsub.DeliveryMode;
+import org.apache.ws.pubsub.Filter;
+import org.apache.ws.pubsub.NotificationConsumer;
+import org.apache.ws.pubsub.NotificationProducer;
+import org.apache.ws.pubsub.Subscription;
+import org.apache.ws.pubsub.SubscriptionEndConsumer;
+import org.apache.ws.pubsub.TopicFilter;
+import org.apache.ws.pubsub.XPathFilter;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+import java.util.Calendar;
+import java.util.StringTokenizer;
+
+/**
+ * @author Sal Campana
+ */
+public class NotifProducer
+ implements NotificationProducer
+{
+ /**
+ * Returns the last notification message published for the given set of filters.
+ *
+ * @param filters
+ * @return
+ */
+ public Object getCurrentMessage( Filter[] filters )
+ {
+ return null;
+ }
+
+ /**
+ * 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 );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param args DOCUMENT_ME
+ */
+ public static void main( String[] args )
+ {
+ StringTokenizer tok = new StringTokenizer( " / " );
+ while ( tok.hasMoreElements( ) )
+ {
+ System.out.println( "[" + tok.nextElement( ) + "]" );
+ }
+ }
+
+ /**
+ * Subscribe to notifications from this producer.
+ *
+ * @param notificationConsumer
+ * @param subscriptionEndConsumer the callback Interface for SubscriptionEnd Notifications, or null if no SubscriptionEnd should be send
+ * @param filters
+ * @param initialTerminationTime
+ * @param deliveryMode the notification delivery mode, or null to use default mode
+ * @return the subscription
+ */
+ public Subscription subscribe( NotificationConsumer notificationConsumer,
+ SubscriptionEndConsumer subscriptionEndConsumer,
+ TopicFilter tf,
+ XPathFilter xf,
+ Calendar initialTerminationTime,
+ boolean UseNotify )
+ {
+ return null; //todo *SJC* implement
+ }
+
+ /**
+ * 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;
+ }
+}
\ No newline at end of file
Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/SubscriptionTopicListenerTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/SubscriptionTopicListenerTestCase.java?rev=227035&r1=227034&r2=227035&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/SubscriptionTopicListenerTestCase.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/SubscriptionTopicListenerTestCase.java Tue Aug 2 09:41:00 2005
@@ -1,70 +1,90 @@
-package org.apache.ws.notification.topics;
-
-import junit.framework.TestCase;
-import org.apache.ws.addressing.EndpointReference;
-import org.apache.ws.addressing.XmlBeansEndpointReference;
-import org.apache.ws.notification.base.impl.XmlBeansTopicExpression;
-import org.apache.ws.notification.base.v2004_06.impl.SubscriptionResource;
-import org.apache.ws.notification.topics.impl.ResourcePropertyValueChangeTopicImpl;
-import org.apache.ws.notification.topics.impl.SubscriptionTopicListener;
-import org.apache.ws.resource.properties.impl.AnyResourcePropertyMetaData;
-import org.apache.ws.resource.properties.impl.XmlBeansResourceProperty;
-import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotifyDocument;
-import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
-import org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI;
-import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
-
-import javax.xml.namespace.QName;
-
-/**
- * A test case for {@link SubscriptionTopicListener}.
- *
- * @author Sal Campana
- */
-public class SubscriptionTopicListenerTestCase extends TestCase
-{
-
- public void testBuildingNotificationMessages() throws Exception
- {
- EndpointReferenceType epr1 = EndpointReferenceType.Factory.newInstance();
- AttributedURI uri = AttributedURI.Factory.newInstance();
- uri.setStringValue("http://consumer");
- 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());
- SubscriptionResource sub = new SubscriptionResource(epr,epr,null,"my/producer/home",topicExpr);
- sub.setNotificationProducer(new NotifProducer());
-
- /* EndpointReference consumerReference, EndpointReference producerReference,
- Calendar initialTerminationTime, Object policy, QueryExpression precondition,
- QueryExpression selector, ResourceKey producerKey, String producerHomeLocation,
- TopicExpression topicExpression, boolean useNotify )
- {*/
- SubscriptionTopicListener lis = new SubscriptionTopicListener(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);
- }
-
-}
+/*=============================================================================*
+ * Copyright 2004 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.ws.notification.topics;
+
+import junit.framework.TestCase;
+import org.apache.ws.addressing.EndpointReference;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.ws.notification.base.impl.XmlBeansTopicExpression;
+import org.apache.ws.notification.base.v2004_06.impl.SubscriptionResource;
+import org.apache.ws.notification.topics.impl.ResourcePropertyValueChangeTopicImpl;
+import org.apache.ws.notification.topics.impl.SubscriptionTopicListener;
+import org.apache.ws.resource.properties.impl.AnyResourcePropertyMetaData;
+import org.apache.ws.resource.properties.impl.XmlBeansResourceProperty;
+import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotifyDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+import javax.xml.namespace.QName;
+
+/**
+ * A test case for {@link SubscriptionTopicListener}.
+ *
+ * @author Sal Campana
+ */
+public class SubscriptionTopicListenerTestCase
+ extends TestCase
+{
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testBuildingNotificationMessages( )
+ throws Exception
+ {
+ EndpointReferenceType epr1 = EndpointReferenceType.Factory.newInstance( );
+ AttributedURI uri = AttributedURI.Factory.newInstance( );
+ uri.setStringValue( "http://consumer" );
+ 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( ) );
+ SubscriptionResource sub = new SubscriptionResource( epr, epr, null, "my/producer/home", topicExpr );
+ sub.setNotificationProducer( new NotifProducer( ) );
+
+ /* EndpointReference consumerReference, EndpointReference producerReference,
+ Calendar initialTerminationTime, Object policy, QueryExpression precondition,
+ QueryExpression selector, ResourceKey producerKey, String producerHomeLocation,
+ TopicExpression topicExpression, boolean useNotify )
+ {*/
+ SubscriptionTopicListener lis = new SubscriptionTopicListener( 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 );
+ }
+}
\ No newline at end of file
Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java?rev=227035&r1=227034&r2=227035&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java Tue Aug 2 09:41:00 2005
@@ -1,23 +1,33 @@
-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)
- {
-
- }
-
-
-}
+/*=============================================================================*
+ * Copyright 2004 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.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 )
+ {
+ }
+}
\ No newline at end of file
Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluatorTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluatorTestCase.java?rev=227035&r1=227034&r2=227035&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluatorTestCase.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluatorTestCase.java Tue Aug 2 09:41:00 2005
@@ -1,143 +1,157 @@
-/*=============================================================================*
- * 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.ws.notification.topics.impl;
-
-import junit.framework.TestCase;
-import org.apache.ws.notification.base.impl.XmlBeansTopicExpression;
-import org.apache.ws.notification.topics.Topic;
-import org.apache.ws.notification.topics.TopicSpace;
-import org.apache.ws.notification.topics.TopicSpaceSet;
-import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
-import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
-import org.apache.ws.notification.topics.expression.impl.ConcreteTopicExpressionEvaluator;
-import org.apache.xmlbeans.XmlObject;
-import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
-import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
-
-/**
- * Testcase for {@link ConcreteTopicExpressionEvaluator}
- */
-public class ConcreteTopicExpressionEvaluatorTestCase extends TestCase
-{
-
- private static final String NSURI1 = "http://ns1.com/";
- private static final String NSPREFIX1 = "ns1";
- private static final String NSURI2 = "http://ns2.com/";
- private static final String NSPREFIX2 = "ns2";
-
- private TopicExpressionEvaluator m_evaluator;
- private TopicSpaceSet m_topicSpaceSet;
-
- protected void setUp() throws Exception
- {
- m_evaluator = new ConcreteTopicExpressionEvaluator();
- m_topicSpaceSet = new TopicSpaceSetImpl( true );
- TopicSpace topicSpace0 = m_topicSpaceSet.addTopicSpace( new TopicSpaceImpl( "" ) );
- topicSpace0.addTopic( "celebs" );
- TopicSpace topicSpace1 = m_topicSpaceSet.addTopicSpace( new TopicSpaceImpl( NSURI1 ) );
- Topic sportsTopic = topicSpace1.addTopic( "sports" );
- Topic tennisTopic = sportsTopic.addTopic( "tennis" );
- tennisTopic.addTopic( "college" );
- Topic footballTopic = sportsTopic.addTopic( "football" );
- footballTopic.addTopic( "college" );
- Topic gamesTopic = topicSpace1.addTopic( "games" );
- gamesTopic.addTopic( "monopoly" );
- gamesTopic.addTopic( "chess" );
- }
-
- public void testEvaluateValid() throws Exception
- {
- Topic[] resultTopics = evaluate( "celebs" );
- assertEquals( 1, resultTopics.length );
-
- resultTopics = evaluate( NSPREFIX1 + ":sports" );
- assertEquals( 1, resultTopics.length );
- assertContainsTopic( resultTopics, "sports" );
-
- resultTopics = evaluate( NSPREFIX1 + ":bands" );
- assertEquals( 0, resultTopics.length );
-
- resultTopics = evaluate( NSPREFIX1 + ":sports/tennis" );
- assertEquals( 1, resultTopics.length );
- assertContainsTopic( resultTopics, "tennis" );
-
- resultTopics = evaluate( NSPREFIX1 + ":sports/baseball" );
- assertEquals( 0, resultTopics.length );
-
- ((TopicSpaceSetImpl)m_topicSpaceSet).setFixed( false );
- resultTopics = evaluate( NSPREFIX1 + ":sports/baseball" );
- assertEquals( 0, resultTopics.length );
- }
-
- public void testEvaluateInvalid() throws Exception
- {
- // check expressions that do not conform to the Concrete Topic Expression grammar defined by the WS-Topics spec
- assertExpressionIsInvalid( NSPREFIX1 + ":" );
- assertExpressionIsInvalid( ":sports" );
- assertExpressionIsInvalid( NSPREFIX1 + "::sports" );
- assertExpressionIsInvalid( NSPREFIX1 + ":sports:tennis" );
- assertExpressionIsInvalid( NSPREFIX1 + ":sports/*" );
- assertExpressionIsInvalid( NSPREFIX1 + ":sports/." );
- assertExpressionIsInvalid( NSPREFIX1 + ":sports//tennis" );
- assertExpressionIsInvalid( NSPREFIX1 + ":sports|" + NSPREFIX2 + ":bands" );
- }
-
- private void assertExpressionIsInvalid( String expr )
- throws Exception
- {
- try
- {
- evaluate( expr );
- fail();
- }
- catch ( InvalidTopicExpressionException itee )
- {
- // success!
- }
- }
-
- private void assertContainsTopic( Topic[] topics, String name )
- {
- boolean foundIt = false;
- for ( int i = 0; i < topics.length; i++ )
- {
- if ( topics[i].getName().equals( name ) )
- {
- foundIt = true;
- }
- }
- assertTrue( foundIt );
- }
-
- private Topic[] evaluate( String expr ) throws Exception
- {
- TopicExpressionType topicExpr = ( (TopicExpressionDocument) XmlObject.Factory.parse(
- "<wsnt:TopicExpression xmlns:wsnt='http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd' " +
- "xmlns:" +
- NSPREFIX1 +
- "='" +
- NSURI1 +
- "' xmlns:" +
- NSPREFIX2 +
- "='" +
- NSURI2 +
- "' Dialect='http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Full'>" +
- expr +
- "</wsnt:TopicExpression>" ) ).getTopicExpression();
- return m_evaluator.evaluate( m_topicSpaceSet, new XmlBeansTopicExpression( topicExpr ) );
- }
-
-}
+/*=============================================================================*
+ * Copyright 2004 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.ws.notification.topics.impl;
+
+import junit.framework.TestCase;
+import org.apache.ws.notification.base.impl.XmlBeansTopicExpression;
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
+import org.apache.ws.notification.topics.expression.impl.ConcreteTopicExpressionEvaluator;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
+
+/**
+ * Testcase for {@link ConcreteTopicExpressionEvaluator}
+ */
+public class ConcreteTopicExpressionEvaluatorTestCase
+ extends TestCase
+{
+ private static final String NSURI1 = "http://ns1.com/";
+ private static final String NSPREFIX1 = "ns1";
+ private static final String NSURI2 = "http://ns2.com/";
+ private static final String NSPREFIX2 = "ns2";
+ private TopicExpressionEvaluator m_evaluator;
+ private TopicSpaceSet m_topicSpaceSet;
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testEvaluateInvalid( )
+ throws Exception
+ {
+ // check expressions that do not conform to the Concrete Topic Expression grammar defined by the WS-Topics spec
+ assertExpressionIsInvalid( NSPREFIX1 + ":" );
+ assertExpressionIsInvalid( ":sports" );
+ assertExpressionIsInvalid( NSPREFIX1 + "::sports" );
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports:tennis" );
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports/*" );
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports/." );
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports//tennis" );
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports|" + NSPREFIX2 + ":bands" );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testEvaluateValid( )
+ throws Exception
+ {
+ Topic[] resultTopics = evaluate( "celebs" );
+ assertEquals( 1, resultTopics.length );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports" );
+ assertEquals( 1, resultTopics.length );
+ assertContainsTopic( resultTopics, "sports" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":bands" );
+ assertEquals( 0, resultTopics.length );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports/tennis" );
+ assertEquals( 1, resultTopics.length );
+ assertContainsTopic( resultTopics, "tennis" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports/baseball" );
+ assertEquals( 0, resultTopics.length );
+
+ ( (TopicSpaceSetImpl) m_topicSpaceSet ).setFixed( false );
+ resultTopics = evaluate( NSPREFIX1 + ":sports/baseball" );
+ assertEquals( 0, resultTopics.length );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp( )
+ throws Exception
+ {
+ m_evaluator = new ConcreteTopicExpressionEvaluator( );
+ m_topicSpaceSet = new TopicSpaceSetImpl( true );
+ TopicSpace topicSpace0 = m_topicSpaceSet.addTopicSpace( new TopicSpaceImpl( "" ) );
+ topicSpace0.addTopic( "celebs" );
+ TopicSpace topicSpace1 = m_topicSpaceSet.addTopicSpace( new TopicSpaceImpl( NSURI1 ) );
+ Topic sportsTopic = topicSpace1.addTopic( "sports" );
+ Topic tennisTopic = sportsTopic.addTopic( "tennis" );
+ tennisTopic.addTopic( "college" );
+ Topic footballTopic = sportsTopic.addTopic( "football" );
+ footballTopic.addTopic( "college" );
+ Topic gamesTopic = topicSpace1.addTopic( "games" );
+ gamesTopic.addTopic( "monopoly" );
+ gamesTopic.addTopic( "chess" );
+ }
+
+ private void assertContainsTopic( Topic[] topics,
+ String name )
+ {
+ boolean foundIt = false;
+ for ( int i = 0; i < topics.length; i++ )
+ {
+ if ( topics[i].getName( ).equals( name ) )
+ {
+ foundIt = true;
+ }
+ }
+
+ assertTrue( foundIt );
+ }
+
+ private void assertExpressionIsInvalid( String expr )
+ throws Exception
+ {
+ try
+ {
+ evaluate( expr );
+ fail( );
+ }
+ catch ( InvalidTopicExpressionException itee )
+ {
+ // success!
+ }
+ }
+
+ private Topic[] evaluate( String expr )
+ throws Exception
+ {
+ TopicExpressionType topicExpr =
+ ( (TopicExpressionDocument) XmlObject.Factory.parse( "<wsnt:TopicExpression xmlns:wsnt='http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd' "
+ + "xmlns:" + NSPREFIX1 + "='" + NSURI1 + "' xmlns:"
+ + NSPREFIX2 + "='" + NSURI2
+ + "' Dialect='http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Full'>"
+ + expr + "</wsnt:TopicExpression>" ) )
+ .getTopicExpression( );
+ return m_evaluator.evaluate( m_topicSpaceSet,
+ new XmlBeansTopicExpression( topicExpr ) );
+ }
+}
\ No newline at end of file