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 sc...@apache.org on 2006/06/02 19:33:13 UTC
svn commit: r411218 [27/34] - in /webservices/muse: branches/1.0/
branches/1.0/src/examples/broker/ branches/1.0/src/examples/broker/WEB-INF/
branches/1.0/src/examples/consumer/ branches/1.0/src/examples/consumer/epr/
branches/1.0/src/examples/consumer...
Added: webservices/muse/branches/1.0/src/templates/v2004_11/InsertResourceProp.txt
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/templates/v2004_11/InsertResourceProp.txt?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/templates/v2004_11/InsertResourceProp.txt (added)
+++ webservices/muse/branches/1.0/src/templates/v2004_11/InsertResourceProp.txt Fri Jun 2 10:32:46 2006
@@ -0,0 +1,11 @@
+ /**
+ * DOCUMENT_ME
+ *
+ * @param requestDoc DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.InsertResourcePropertiesResponseDocument insertResourceProperties( org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.InsertResourcePropertiesDocument requestDoc )
+ {
+ return new org.apache.ws.resource.properties.v2004_11.porttype.impl.InsertResourcePropertiesPortTypeImpl( getResourceContext( ) ).insertResourceProperties( requestDoc );
+ }
Added: webservices/muse/branches/1.0/src/templates/v2004_11/Query-ExpressionDialect_init.txt
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/templates/v2004_11/Query-ExpressionDialect_init.txt?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/templates/v2004_11/Query-ExpressionDialect_init.txt (added)
+++ webservices/muse/branches/1.0/src/templates/v2004_11/Query-ExpressionDialect_init.txt Fri Jun 2 10:32:46 2006
@@ -0,0 +1,5 @@
+ // initialize wsrp:QueryExpressionDialect property
+ org.apache.ws.resource.properties.ResourceProperty queryProp = m_propSet.get( org.apache.ws.resource.properties.v2004_11.porttype.QueryResourcePropertiesPortType.PROP_QNAME_QUERY_EXPRESSION_DIALECT );
+ org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.QueryExpressionDialectDocument queryExpressionDialectDocument = org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.QueryExpressionDialectDocument.Factory.newInstance();
+ queryExpressionDialectDocument.setQueryExpressionDialect(org.apache.ws.resource.properties.query.QueryConstants.DIALECT_URI__XPATH1_0.toString());
+ queryProp.add( queryExpressionDialectDocument );
Added: webservices/muse/branches/1.0/src/templates/v2004_11/Query.txt
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/templates/v2004_11/Query.txt?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/templates/v2004_11/Query.txt (added)
+++ webservices/muse/branches/1.0/src/templates/v2004_11/Query.txt Fri Jun 2 10:32:46 2006
@@ -0,0 +1,11 @@
+ /**
+ * DOCUMENT_ME
+ *
+ * @param requestDoc DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.QueryResourcePropertiesResponseDocument queryResourceProperties( org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.QueryResourcePropertiesDocument requestDoc )
+ {
+ return new org.apache.ws.resource.properties.v2004_11.porttype.impl.QueryResourcePropertiesPortTypeImpl( getResourceContext( ) ).queryResourceProperties( requestDoc );
+ }
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/templates/v2004_11/ScheduledResourceTermination-AbstractResource_init.txt
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/templates/v2004_11/ScheduledResourceTermination-AbstractResource_init.txt?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/templates/v2004_11/ScheduledResourceTermination-AbstractResource_init.txt (added)
+++ webservices/muse/branches/1.0/src/templates/v2004_11/ScheduledResourceTermination-AbstractResource_init.txt Fri Jun 2 10:32:46 2006
@@ -0,0 +1,14 @@
+ // initialize wsrl:CurrentTime property
+ org.apache.ws.resource.properties.ResourceProperty prop = m_propSet.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_CURRENT_TIME );
+ org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.CurrentTimeDocument currTime = org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.CurrentTimeDocument.Factory.newInstance();
+ currTime.setCurrentTime( java.util.Calendar.getInstance() );
+ prop.add( currTime );
+ prop.setCallback( new org.apache.ws.resource.lifetime.callback.CurrentTimeCallback() );
+
+ // initialize wsrl:TerminationTime property
+ prop = m_propSet.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME );
+ org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.TerminationTimeDocument termTime = org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.TerminationTimeDocument.Factory.newInstance();
+ termTime.setNilTerminationTime();
+ prop.add( termTime );
+
+
Added: webservices/muse/branches/1.0/src/templates/v2004_11/ScheduledResourceTerminationResource.txt
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/templates/v2004_11/ScheduledResourceTerminationResource.txt?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/templates/v2004_11/ScheduledResourceTerminationResource.txt (added)
+++ webservices/muse/branches/1.0/src/templates/v2004_11/ScheduledResourceTerminationResource.txt Fri Jun 2 10:32:46 2006
@@ -0,0 +1,31 @@
+ /**
+ * DOCUMENT_ME
+ *
+ * @param time DOCUMENT_ME
+ */
+ public void setTerminationTime( java.util.Calendar time )
+ {
+ org.apache.ws.resource.properties.XmlBeansResourcePropertyUtils.setDateTimePropertyValue( (org.apache.ws.resource.properties.impl.XmlBeansResourceProperty) getResourcePropertySet().get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME ),
+ time );
+ }
+
+ /**
+ * Returns the current time from the prop set.
+ *
+ * @return java.util.Calendar
+ */
+ public java.util.Calendar getCurrentTime()
+ {
+ return org.apache.ws.resource.properties.XmlBeansResourcePropertyUtils.getDateTimePropertyValue( (org.apache.ws.resource.properties.impl.XmlBeansResourceProperty) m_propSet.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_CURRENT_TIME ) );
+ }
+
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public java.util.Calendar getTerminationTime()
+ {
+ return org.apache.ws.resource.properties.XmlBeansResourcePropertyUtils.getDateTimePropertyValue( (org.apache.ws.resource.properties.impl.XmlBeansResourceProperty) m_propSet.get( org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME ) );
+ }
Added: webservices/muse/branches/1.0/src/templates/v2004_11/Set.txt
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/templates/v2004_11/Set.txt?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/templates/v2004_11/Set.txt (added)
+++ webservices/muse/branches/1.0/src/templates/v2004_11/Set.txt Fri Jun 2 10:32:46 2006
@@ -0,0 +1,11 @@
+ /**
+ * DOCUMENT_ME
+ *
+ * @param requestDoc DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.SetResourcePropertiesResponseDocument setResourceProperties( org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.SetResourcePropertiesDocument requestDoc )
+ {
+ return new org.apache.ws.resource.properties.v2004_11.porttype.impl.SetResourcePropertiesPortTypeImpl( getResourceContext( ) ).setResourceProperties( requestDoc );
+ }
Added: webservices/muse/branches/1.0/src/templates/v2004_11/SetTerminationTime.txt
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/templates/v2004_11/SetTerminationTime.txt?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/templates/v2004_11/SetTerminationTime.txt (added)
+++ webservices/muse/branches/1.0/src/templates/v2004_11/SetTerminationTime.txt Fri Jun 2 10:32:46 2006
@@ -0,0 +1,11 @@
+ /**
+ * DOCUMENT_ME
+ *
+ * @param requestDoc DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.SetTerminationTimeResponseDocument setTerminationTime( org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceLifetime12Draft04.SetTerminationTimeDocument requestDoc )
+ {
+ return new org.apache.ws.resource.lifetime.v2004_11.porttype.impl.ScheduledResourceTerminationPortTypeImpl( getResourceContext( ) ).setTerminationTime( requestDoc );
+ }
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/templates/v2004_11/UpdateResourceProp.txt
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/templates/v2004_11/UpdateResourceProp.txt?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/templates/v2004_11/UpdateResourceProp.txt (added)
+++ webservices/muse/branches/1.0/src/templates/v2004_11/UpdateResourceProp.txt Fri Jun 2 10:32:46 2006
@@ -0,0 +1,11 @@
+ /**
+ * DOCUMENT_ME
+ *
+ * @param requestDoc DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.UpdateResourcePropertiesResponseDocument updateResourceProperties( org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.UpdateResourcePropertiesDocument requestDoc )
+ {
+ return new org.apache.ws.resource.properties.v2004_11.porttype.impl.UpdateResourcePropertiesPortTypeImpl( getResourceContext( ) ).updateResourceProperties( requestDoc );
+ }
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,188 @@
+/*=============================================================================*
+ * 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitResource.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitResource.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitResource.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitResource.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,168 @@
+/*=============================================================================*
+ * 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,201 @@
+/*=============================================================================*
+ * 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,221 @@
+/*=============================================================================*
+ * 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.v2004_06.porttype.impl;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.ws.addressing.XmlBeansEndpointReference;
+import org.apache.ws.notification.base.impl.UnitExampleHome;
+import org.apache.ws.notification.base.impl.UnitResource;
+import org.apache.ws.notification.base.impl.UnitResourceContext;
+import org.apache.ws.notification.base.v2004_06.BaseNotificationConstants;
+import org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType;
+import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
+import org.apache.ws.resource.PropertiesResource;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.test.PortListen;
+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.SubscribeDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.SubscribeResponseDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDialectsDocument;
+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;
+
+/**
+ * Test case for {@link NotificationProducerPortTypeImpl}.
+ *
+ * @author Sal Campana
+ */
+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;
+
+ /** 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/NotifProducer.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/NotifProducer.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/NotifProducer.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/NotifProducer.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,116 @@
+/*=============================================================================*
+ * 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/SubscriptionTopicListenerTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/SubscriptionTopicListenerTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/SubscriptionTopicListenerTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/SubscriptionTopicListenerTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,90 @@
+/*=============================================================================*
+ * 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/TopicListenerTestObj.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,33 @@
+/*=============================================================================*
+ * 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluatorTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluatorTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluatorTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluatorTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,157 @@
+/*=============================================================================*
+ * 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluatorTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluatorTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluatorTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluatorTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,257 @@
+/*=============================================================================*
+ * 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.FullTopicExpressionEvaluator;
+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 FullTopicExpressionEvaluator}
+ */
+public class FullTopicExpressionEvaluatorTestCase
+ 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 testEvaluateConjoined( )
+ throws Exception
+ {
+ Topic[] resultTopics = evaluate( NSPREFIX1 + ":sports/tennis|" + NSPREFIX2 + ":bands/*" );
+ assertEquals( 3, resultTopics.length );
+ assertContainsTopic( resultTopics, "tennis" );
+ assertContainsTopic( resultTopics, "beatles" );
+ assertContainsTopic( resultTopics, "kinks" );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testEvaluateInvalid( )
+ throws Exception
+ {
+ // first check expressions that do not conform to the Full Topic Expression grammar defined by the WS-Topics spec
+ assertExpressionIsInvalid( NSPREFIX1 + ":" );
+ assertExpressionIsInvalid( ":sports" );
+ assertExpressionIsInvalid( NSPREFIX1 + "::sports" );
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports:tennis" );
+ assertExpressionIsInvalid( NSPREFIX1 + ":." );
+ assertExpressionIsInvalid( NSPREFIX1 + "://." );
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports///tennis" );
+
+ // now check expressions that violate other validity constraints defined by the spec
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports/baseball" ); // fixed topic set but empty result set
+ assertExpressionIsInvalid( NSPREFIX1 + ":bands|" + NSPREFIX2 + ":bands" ); // undefined root topic
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testEvaluateRecursive( )
+ throws Exception
+ {
+ Topic[] resultTopics = evaluate( NSPREFIX1 + ":sports//college" );
+ assertEquals( 2, resultTopics.length );
+ assertContainsTopic( resultTopics, "college" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports//*" );
+ assertEquals( 4, resultTopics.length );
+ assertContainsTopic( resultTopics, "tennis" );
+ assertContainsTopic( resultTopics, "football" );
+ assertContainsTopic( resultTopics, "college" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports//." );
+ assertEquals( 5, resultTopics.length );
+ assertContainsTopic( resultTopics, "sports" );
+ assertContainsTopic( resultTopics, "tennis" );
+ assertContainsTopic( resultTopics, "football" );
+ assertContainsTopic( resultTopics, "college" );
+
+ resultTopics = evaluate( NSPREFIX1 + "://*" );
+ assertEquals( 8, resultTopics.length );
+ assertContainsTopic( resultTopics, "sports" );
+ assertContainsTopic( resultTopics, "tennis" );
+ assertContainsTopic( resultTopics, "football" );
+ assertContainsTopic( resultTopics, "college" );
+ assertContainsTopic( resultTopics, "games" );
+ assertContainsTopic( resultTopics, "monopoly" );
+ assertContainsTopic( resultTopics, "chess" );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testEvaluateSimple( )
+ throws Exception
+ {
+ Topic[] resultTopics = evaluate( "celebs" );
+ assertEquals( 1, resultTopics.length );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports" );
+ assertEquals( 1, resultTopics.length );
+ assertContainsTopic( resultTopics, "sports" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports/tennis" );
+ assertEquals( 1, resultTopics.length );
+ assertContainsTopic( resultTopics, "tennis" );
+
+ ( (TopicSpaceSetImpl) m_topicSpaceSet ).setFixed( false );
+ resultTopics = evaluate( NSPREFIX1 + ":sports/baseball" );
+ assertEquals( 0, resultTopics.length );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testEvaluateWildcard( )
+ throws Exception
+ {
+ Topic[] resultTopics = evaluate( NSPREFIX1 + ":*" );
+ assertEquals( 2, resultTopics.length );
+ assertContainsTopic( resultTopics, "sports" );
+ assertContainsTopic( resultTopics, "games" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":*/tennis" );
+ assertEquals( 1, resultTopics.length );
+ assertContainsTopic( resultTopics, "tennis" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports/*" );
+ assertEquals( 2, resultTopics.length );
+ assertContainsTopic( resultTopics, "tennis" );
+ assertContainsTopic( resultTopics, "football" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports/." );
+ assertEquals( 3, resultTopics.length );
+ assertContainsTopic( resultTopics, "sports" );
+ assertContainsTopic( resultTopics, "tennis" );
+ assertContainsTopic( resultTopics, "football" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports/./college" );
+ assertEquals( 2, resultTopics.length );
+ assertContainsTopic( resultTopics, "college" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":sports/*/college" );
+ assertEquals( 2, resultTopics.length );
+ assertContainsTopic( resultTopics, "college" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":*/*" );
+ assertEquals( 4, resultTopics.length );
+ assertContainsTopic( resultTopics, "tennis" );
+ assertContainsTopic( resultTopics, "football" );
+ assertContainsTopic( resultTopics, "monopoly" );
+ assertContainsTopic( resultTopics, "chess" );
+
+ resultTopics = evaluate( NSPREFIX1 + ":*/*/college" );
+ assertEquals( 2, resultTopics.length );
+ assertContainsTopic( resultTopics, "college" );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp( )
+ throws Exception
+ {
+ m_evaluator = new FullTopicExpressionEvaluator( );
+ 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" );
+ TopicSpace topicSpace2 = m_topicSpaceSet.addTopicSpace( new TopicSpaceImpl( NSURI2 ) );
+ Topic bandsTopic = topicSpace2.addTopic( "bands" );
+ bandsTopic.addTopic( "beatles" );
+ bandsTopic.addTopic( "kinks" );
+ }
+
+ 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluatorTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluatorTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluatorTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluatorTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,147 @@
+/*=============================================================================*
+ * 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.SimpleTopicExpressionEvaluator;
+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 SimpleTopicExpressionEvaluator}
+ */
+public class SimpleTopicExpressionEvaluatorTestCase
+ 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 Simple Topic Expression grammar defined by the WS-Topics spec
+ assertExpressionIsInvalid( NSPREFIX1 + ":" );
+ assertExpressionIsInvalid( ":sports" );
+ assertExpressionIsInvalid( NSPREFIX1 + "::sports" );
+ assertExpressionIsInvalid( NSPREFIX1 + ":sports:tennis" );
+ 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 );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp( )
+ throws Exception
+ {
+ m_evaluator = new SimpleTopicExpressionEvaluator( );
+ 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
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/resource/TestFixtureFactory.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/resource/TestFixtureFactory.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/resource/TestFixtureFactory.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/resource/TestFixtureFactory.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,56 @@
+/*=============================================================================*
+ * 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.resource;
+
+import org.apache.axis.MessageContext;
+import org.apache.axis.message.addressing.Action;
+import org.apache.axis.message.addressing.AddressingHeaders;
+import org.apache.axis.message.addressing.To;
+import org.apache.axis.server.AxisServer;
+import org.apache.axis.types.URI;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+
+/**
+ * Factory for various test fixture objects.
+ */
+public abstract class TestFixtureFactory
+{
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public static SOAPMessageContext createSOAPMessageContext( )
+ throws Exception
+ {
+ SOAPMessageContext msgContext = new MessageContext( new AxisServer( ) );
+ AddressingHeaders wsaHeaders = createAddressingHeaders( );
+ msgContext.setProperty( org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_REQUEST_HEADERS,
+ wsaHeaders );
+ return msgContext;
+ }
+
+ private static AddressingHeaders createAddressingHeaders( )
+ throws URI.MalformedURIException
+ {
+ AddressingHeaders wsaHeaders = new AddressingHeaders( );
+ wsaHeaders.setTo( new To( "http://localhost:8080/wsrf/services/sushi" ) );
+ wsaHeaders.setAction( new Action( new URI( "urn:action" ) ) );
+ return wsaHeaders;
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org