ws-pubscribe-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject svn commit: r292768 [2/2] - in /webservices/pubscribe/trunk/src: examples/filesystem/src/java/org/apache/ws/resource/example/filesystem/ java/org/apache/ws/notification/base/ java/org/apache/ws/notification/base/impl/ java/org/apache/ws/notification/ba...
Date Fri, 30 Sep 2005 15:16:28 GMT
Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEngine.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEngine.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEngine.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEngine.java Fri Sep 30 08:16:05 2005
@@ -16,9 +16,6 @@
 package org.apache.ws.notification.topics.expression;
 
 import org.apache.ws.notification.topics.Topic;
-import org.apache.ws.notification.topics.TopicNamespaceRegistry;
-
-import java.net.URI;
 
 /**
  * The <code>TopicExpressionEngine</code> interface is used to map queries on a
@@ -45,13 +42,12 @@
     *
     * @return the list of supported dialects
     */
-   URI[] getSupportedDialects(  );
+   String[] getSupportedDialects(  );
 
    /**
     * Resolves a topic expression using the passed topic list. The appropraite
     * TopicExpressionEvaluator is used based on the dialect element.
     *
-    * @param topicNsRegistry       the topic list to apply the expression to
     * @param topicExpr topic expression
     * @return the set of topics the expression evaluated to
     * @throws org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException
@@ -64,8 +60,7 @@
     *                                  if the topic expression is invalid
     * @throws TopicExpressionException if any other error occurs
     */
-   Topic[] evaluateTopicExpression( TopicNamespaceRegistry   topicNsRegistry,
-                                    TopicExpression topicExpr )
+   Topic[] evaluateTopicExpression( TopicExpression topicExpr )
    throws TopicPathDialectUnknownException, 
           TopicExpressionResolutionException, 
           InvalidTopicExpressionException, 

Copied: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpression.java (from r292052, webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionImpl.java)
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpression.java?p2=webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpression.java&p1=webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionImpl.java&r1=292052&r2=292768&rev=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionImpl.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpression.java Fri Sep 30 08:16:05 2005
@@ -15,22 +15,21 @@
  *=============================================================================*/
 package org.apache.ws.notification.topics.expression.impl;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.ws.notification.topics.expression.TopicExpression;
-import org.apache.ws.util.NameUtils;
-
-import javax.xml.namespace.QName;
 
 /**
- * TODO
+ * An abstract implementation of <code>TopicExpression</code> that
+ * can be extended by dialect-specific implementations.
+ *
+ * @author Ian Springer
  */
-public class TopicExpressionImpl implements TopicExpression
+public abstract class AbstractTopicExpression implements TopicExpression
 {
 
     private String m_dialect;
     private Object m_content;
 
-    public TopicExpressionImpl( String dialect, Object content )
+    public AbstractTopicExpression( String dialect, Object content )
     {
         m_dialect = dialect;
         m_content = content;
@@ -46,30 +45,9 @@
         return m_dialect;
     }
 
-    protected static String toString( QName topicPath )
-    {
-        StringBuffer strBuf = new StringBuffer( );
-        if ( StringUtils.isNotEmpty( topicPath.getNamespaceURI() ) )
-        {
-            strBuf.append( getPrefix( topicPath ) );
-            strBuf.append( ':' );
-        }
-        strBuf.append( topicPath.getLocalPart() );
-        return strBuf.toString();
-    }
-
-    protected static String getPrefix( QName qName )
+    public String toString()
     {
-        String prefix;
-        if ( StringUtils.isNotEmpty( qName.getPrefix() ) )
-        {
-            prefix = qName.getPrefix();
-        }
-        else
-        {
-            prefix = NameUtils.getNamespacePrefix( qName.getNamespaceURI() );
-        }
-        return prefix;
+        return m_content.toString();
     }
 
 }

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java Fri Sep 30 08:16:05 2005
@@ -18,7 +18,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.notification.topics.Topic;
-import org.apache.ws.notification.topics.TopicNamespaceRegistry;
 import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
 import org.apache.ws.notification.topics.expression.TopicExpression;
 import org.apache.ws.notification.topics.expression.TopicExpressionEngine;
@@ -34,7 +33,6 @@
 import javax.naming.NameClassPair;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import java.net.URI;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -106,15 +104,14 @@
      *
      * @return DOCUMENT_ME
      */
-    public synchronized URI[] getSupportedDialects()
+    public synchronized String[] getSupportedDialects()
     {
-        return (URI[]) m_evaluators.keySet().toArray( new URI[m_evaluators.size()] );
+        return (String[]) m_evaluators.keySet().toArray( new String[m_evaluators.size()] );
     }
 
     /**
      * DOCUMENT_ME
      *
-     * @param topicNsRegistry DOCUMENT_ME
      * @param topicExpr       DOCUMENT_ME
      *
      * @return DOCUMENT_ME
@@ -129,9 +126,8 @@
      * @throws TopicPathDialectUnknownException
      *                                  DOCUMENT_ME
      */
-    public synchronized Topic[] evaluateTopicExpression( TopicNamespaceRegistry topicNsRegistry,
-                                                         TopicExpression topicExpr )
-            throws org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException,
+    public synchronized Topic[] evaluateTopicExpression( TopicExpression topicExpr )
+            throws TopicPathDialectUnknownException,
             TopicExpressionResolutionException,
             InvalidTopicExpressionException,
             TopicExpressionException

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/ResourcePropertyValueChangeListenerImpl.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/ResourcePropertyValueChangeListenerImpl.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/ResourcePropertyValueChangeListenerImpl.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/ResourcePropertyValueChangeListenerImpl.java Fri Sep 30 08:16:05 2005
@@ -18,7 +18,7 @@
 import org.apache.ws.XmlObjectWrapper;
 import org.apache.ws.notification.base.NotificationProducerResource;
 import org.apache.ws.notification.base.impl.MessageTypeNotSupportedException;
-import org.apache.ws.notification.topics.TopicsTypeFactory;
+import org.apache.ws.notification.topics.expression.SimpleTopicExpression;
 import org.apache.ws.notification.topics.expression.TopicExpression;
 import org.apache.ws.notification.topics.expression.TopicExpressionException;
 import org.apache.ws.resource.properties.ResourceProperty;
@@ -45,7 +45,7 @@
                                                     ResourceProperty prop )
     {
         m_producerResource = producerResource;
-        m_topicExpr = TopicsTypeFactory.newInstance().createSimpleTopicExpression( prop.getMetaData().getName() );
+        m_topicExpr = new SimpleTopicExpression( prop.getMetaData().getName() );
     }
 
     /**

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/ResourceTerminationListenerImpl.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/ResourceTerminationListenerImpl.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/ResourceTerminationListenerImpl.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/ResourceTerminationListenerImpl.java Fri Sep 30 08:16:05 2005
@@ -17,7 +17,6 @@
 
 import org.apache.ws.notification.base.NotificationProducerResource;
 import org.apache.ws.notification.base.impl.MessageTypeNotSupportedException;
-import org.apache.ws.notification.topics.TopicsTypeFactory;
 import org.apache.ws.notification.topics.expression.SimpleTopicExpression;
 import org.apache.ws.notification.topics.expression.TopicExpressionException;
 import org.apache.ws.resource.lifetime.ResourceTerminationEvent;
@@ -55,7 +54,7 @@
         m_producerResource = producerResource;
         m_namespaceSet = namespaceSet;
         m_topicExpr =
-                TopicsTypeFactory.newInstance().createSimpleTopicExpression(
+                new SimpleTopicExpression(
                         new QName( m_namespaceSet.getLifetimeXsdNamespace(),
                                    ResourceTerminationListenerImpl.TOPIC_NAME,
                                    NSPREFIX_WSRL ) );

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java Fri Sep 30 08:16:05 2005
@@ -16,7 +16,6 @@
 package org.apache.ws.notification.topics.impl;
 
 import org.apache.ws.notification.topics.Topic;
-import org.apache.ws.notification.topics.TopicNamespaceRegistry;
 import org.apache.ws.notification.topics.TopicSet;
 import org.apache.ws.notification.topics.expression.TopicExpression;
 import org.apache.ws.notification.topics.expression.TopicExpressionEngine;
@@ -92,8 +91,7 @@
 
     public void addTopicExpression( TopicExpression topicExpr ) throws TopicExpressionException
     {
-        Topic[] topics = TOPIC_EXPRESSION_ENGINE.evaluateTopicExpression( TopicNamespaceRegistry.getInstance(),
-                topicExpr );
+        Topic[] topics = TOPIC_EXPRESSION_ENGINE.evaluateTopicExpression( topicExpr );
         m_topicExprs.add( topicExpr );
         for ( int i = 0; i < topics.length; i++ )
         {
@@ -108,8 +106,7 @@
 
     public Topic[] evaluateTopicExpression( TopicExpression topicExpr ) throws TopicExpressionException
     {
-        Topic[] topics = TOPIC_EXPRESSION_ENGINE.evaluateTopicExpression( TopicNamespaceRegistry.getInstance(),
-                topicExpr );
+        Topic[] topics = TOPIC_EXPRESSION_ENGINE.evaluateTopicExpression( topicExpr );
         return getSupportedTopics( topics );
     }
 

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeFactoryImpl.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeFactoryImpl.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeFactoryImpl.java Fri Sep 30 08:16:05 2005
@@ -17,37 +17,13 @@
 
 import org.apache.ws.notification.topics.TopicNamespace;
 import org.apache.ws.notification.topics.TopicsTypeFactory;
-import org.apache.ws.notification.topics.expression.ConcreteTopicExpression;
-import org.apache.ws.notification.topics.expression.FullTopicExpression;
-import org.apache.ws.notification.topics.expression.SimpleTopicExpression;
-import org.apache.ws.notification.topics.expression.impl.ConcreteTopicExpressionImpl;
-import org.apache.ws.notification.topics.expression.impl.FullTopicExpressionImpl;
-import org.apache.ws.notification.topics.expression.impl.SimpleTopicExpressionImpl;
 import org.apache.ws.notification.topics.impl.TopicNamespaceImpl;
-import org.apache.ws.util.xml.NamespaceContext;
-
-import javax.xml.namespace.QName;
 
 /**
  * TODO
  */
 public class TopicsTypeFactoryImpl extends TopicsTypeFactory
 {
-
-    public SimpleTopicExpression createSimpleTopicExpression( QName topicPath )
-    {
-        return new SimpleTopicExpressionImpl( topicPath );
-    }
-
-    public ConcreteTopicExpression createConcreteTopicExpression( QName topicPath )
-    {
-        return new ConcreteTopicExpressionImpl( topicPath );
-    }
-
-    public FullTopicExpression createFullTopicExpression( QName[] topicPaths )
-    {
-        return new FullTopicExpressionImpl( topicPaths );
-    }
 
     public TopicNamespace createTopicNamespace( String targetNamespace )
     {

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeReaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeReaderImpl.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeReaderImpl.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeReaderImpl.java Fri Sep 30 08:16:05 2005
@@ -21,7 +21,13 @@
 import org.apache.ws.notification.topics.TopicsTypeFactory;
 import org.apache.ws.notification.topics.TopicsTypeReader;
 import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.SimpleTopicExpression;
+import org.apache.ws.notification.topics.expression.ConcreteTopicExpression;
+import org.apache.ws.notification.topics.expression.FullTopicExpression;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
 import org.apache.ws.util.XmlBeanUtils;
+import org.apache.ws.util.xml.NamespaceContext;
+import org.apache.ws.util.xml.impl.XmlBeansNamespaceContext;
 import org.apache.xmlbeans.XmlObject;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
@@ -30,6 +36,7 @@
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSTopics12Draft01.TopicType;
 
 import javax.xml.namespace.QName;
+import java.util.StringTokenizer;
 
 /**
  * A topics type reader for the 2004/06 version of the WS-Topics specification.
@@ -37,7 +44,7 @@
 public class TopicsTypeReaderImpl extends TopicsTypeReader
 {
 
-    public TopicExpression toTopicExpression( XmlObject xBean )
+    public TopicExpression toTopicExpression( XmlObject xBean ) throws InvalidTopicExpressionException
     {
         TopicExpressionType topicExprType = toTopicExpressionType( xBean );
         if ( !topicExprType.isSetDialect() )
@@ -48,22 +55,23 @@
         TopicExpression topicExpr;
         if ( dialect.equals( TopicsConstants.TOPIC_EXPR_DIALECT_SIMPLE ) )
         {
-            topicExpr =
-                    TopicsTypeFactory.newInstance().createSimpleTopicExpression(
-                            XmlBeanUtils.getValueAsQName( topicExprType ) );
+            topicExpr = new SimpleTopicExpression( XmlBeanUtils.getValueAsQName( topicExprType ) );
         }
         else if ( dialect.equals( TopicsConstants.TOPIC_EXPR_DIALECT_CONCRETE ) )
         {
-            topicExpr =
-                    TopicsTypeFactory.newInstance().createConcreteTopicExpression(
-                            XmlBeanUtils.getValueAsQName( topicExprType ) );
+            topicExpr = new ConcreteTopicExpression( XmlBeanUtils.getValueAsQName( topicExprType ) );
         }
         else if ( dialect.equals( TopicsConstants.TOPIC_EXPR_DIALECT_FULL ) )
         {
-            topicExpr =
-                    TopicsTypeFactory.newInstance().createFullTopicExpression(
-                            new QName[0]                             );
-            // TODO: finish this...
+            String expr = XmlBeanUtils.getValue( topicExprType );
+            StringTokenizer tokenizer = new StringTokenizer( expr, "|" );
+            QName[] topicPaths = new QName[tokenizer.countTokens()];
+            int i = 0;
+            while ( tokenizer.hasMoreTokens() )
+            {
+                topicPaths[i++] = toQName( tokenizer.nextToken(), new XmlBeansNamespaceContext( topicExprType ) );
+            }
+            topicExpr = new FullTopicExpression( topicPaths );
         }
         else
         {
@@ -135,5 +143,41 @@
             importTopics( topicType.getTopicArray(), topic );  // recurse
         }
     }
+
+    private QName toQName( String           topicPath,
+                             NamespaceContext nsContext )
+    throws InvalidTopicExpressionException
+    {
+       String prefix;
+       String localPart;
+       int    i = topicPath.indexOf( ':' );
+       if ( i == -1 ) // no prefix
+       {
+          prefix       = "";
+          localPart    = topicPath;
+       }
+       else if ( i == 0 )
+       {
+          throw new InvalidTopicExpressionException( "Topic path '" + topicPath + "' starts with a colon." );
+       }
+       else if ( i == ( topicPath.length(  ) - 1 ) )
+       {
+          throw new InvalidTopicExpressionException( "Topic path '" + topicPath + "' ends with a colon." );
+       }
+       else
+       {
+          prefix       = topicPath.substring( 0, i );
+          localPart    = topicPath.substring( i + 1 );
+          if ( localPart.indexOf( ':' ) != -1 )
+          {
+             throw new InvalidTopicExpressionException( "Local part of topic path '" + topicPath
+                                                        + "' contains a colon." );
+          }
+       }
+
+       String nsURI = nsContext.getNamespaceURI( prefix );
+       return new QName( nsURI, localPart, prefix );
+    }
+
 
 }

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeWriterImpl.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeWriterImpl.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeWriterImpl.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/topics/v2004_06/TopicsTypeWriterImpl.java Fri Sep 30 08:16:05 2005
@@ -15,12 +15,14 @@
  *=============================================================================*/
 package org.apache.ws.notification.topics.v2004_06;
 
+import org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType;
 import org.apache.ws.notification.topics.TopicNamespace;
 import org.apache.ws.notification.topics.TopicsTypeWriter;
 import org.apache.ws.notification.topics.expression.TopicExpression;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicDocument;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSTopics12Draft01.TopicSpaceDocument;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSTopics12Draft01.TopicSpaceType;
 
@@ -34,9 +36,17 @@
 
     public XmlObject toXmlObject( TopicExpression topicExpr, QName elemName )
     {
-        TopicExpressionDocument topicExpressionDoc = TopicExpressionDocument.Factory.newInstance(
-                new XmlOptions().setLoadReplaceDocumentElement( elemName ) );
-        org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType topicExprType = topicExpressionDoc.addNewTopicExpression();
+        TopicExpressionType topicExprType;
+        if ( elemName.equals( NotificationProducerPortType.PROP_QNAME_TOPIC ) )
+        {
+            TopicDocument topicDoc = TopicDocument.Factory.newInstance();
+            topicExprType = topicDoc.addNewTopic();
+        }
+        else
+        {
+            TopicExpressionDocument topicExprDoc = TopicExpressionDocument.Factory.newInstance();
+            topicExprType = topicExprDoc.addNewTopicExpression();
+        }
         topicExprType.setDialect( topicExpr.getDialect().toString() );
         copyContent( topicExpr, topicExprType );
         return topicExprType;

Copied: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/RuntimeTester.java (from r292052, webservices/pubscribe/trunk/src/test/org/apache/ws/notification/RuntimeTestCase.java)
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/RuntimeTester.java?p2=webservices/pubscribe/trunk/src/test/org/apache/ws/notification/RuntimeTester.java&p1=webservices/pubscribe/trunk/src/test/org/apache/ws/notification/RuntimeTestCase.java&r1=292052&r2=292768&rev=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/RuntimeTestCase.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/RuntimeTester.java Fri Sep 30 08:16:05 2005
@@ -17,25 +17,15 @@
 
 import junit.framework.TestCase;
 import org.apache.naming.java.javaURLContextFactory;
-import org.apache.ws.notification.base.v2004_06.impl.SubscriptionHome;
-import org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType;
-import org.apache.ws.notification.topics.expression.impl.SimpleTopicExpressionImpl;
 import org.apache.ws.resource.WsrfRuntime;
-import org.apache.ws.resource.example.filesystem.FilesystemHome;
-import org.apache.ws.resource.example.filesystem.FilesystemResource;
-import org.apache.ws.resource.properties.ResourceProperty;
-import org.apache.ws.util.XmlBeanUtils;
-import org.apache.xmlbeans.XmlObject;
 
 import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.xml.namespace.QName;
 import java.util.Properties;
 
 /**
  * @author Ian Springer
  */
-public class RuntimeTestCase extends TestCase
+public class RuntimeTester extends TestCase
 {
 
     static
@@ -56,26 +46,34 @@
         initProps.setProperty( WsrfRuntime.JNDI_CONFIG_DIALECT, WsrfRuntime.CONFIG_DIALECT_SPRING_BEANS );
         initProps.setProperty( WsrfRuntime.JNDI_CONFIG_LOCATION, "spring-jndi-config.xml" );
         runtime.init( initProps );
-        InitialContext initialContext = new InitialContext();
-        Object obj = initialContext.lookup( "wsrf/services/home/SubscriptionManager" );
+        /*InitialContext initialContext = new InitialContext();
+        Object obj = initialContext.lookup( runtime.getHomeJndiName( "SubscriptionManager" ) );
         assertNotNull( obj );
         assertTrue( obj instanceof SubscriptionHome );
-        //SubscriptionHome subHome = (SubscriptionHome) obj;
-        obj = initialContext.lookup( "wsrf/services/home/filesystem" );
+        SubscriptionHome subHome = (SubscriptionHome) obj;
+        obj = initialContext.lookup( runtime.getHomeJndiName( "filesystem" ) );
         assertNotNull( obj );
         assertTrue( obj instanceof FilesystemHome );
         FilesystemHome fsHome = (FilesystemHome) obj;
         assertTrue( fsHome.isInitialized() );
         FilesystemResource fsResource = (FilesystemResource) fsHome.find( FilesystemHome.LVOL1_ID );
+        assertEquals( 3, fsResource.getTopicSet().getTopicExpressions().length );
         ResourceProperty prop = fsResource.getResourcePropertySet().get( NotificationProducerPortType.PROP_QNAME_TOPIC );
         assertEquals( 3, prop.size() );
-        SimpleTopicExpressionImpl topic1 = new SimpleTopicExpressionImpl( QName.valueOf( "{http://example.org/topicSpace/example1}t1" ) );
+        SimpleTopicExpression topic1 = new SimpleTopicExpression( QName.valueOf( "{http://example.org/topicSpace/example1}t1" ) );
+        EndpointReference consumerEPR = new XmlBeansEndpointReference( "http://foo/foo", AddressingConstants.NSURI_ADDRESSING_SCHEMA );
+        EndpointReference subscriptionEPR = fsResource.subscribe( consumerEPR, topic1, null, null, null, null, null );
+        assertNotNull( subscriptionEPR );
+        Object subId = subHome.extractResourceIdentifier( subscriptionEPR );
+        Resource resource = subHome.find( subId );
+        assertNotNull( resource );
+        assertTrue( resource instanceof Subscription );
         fsResource.publish( topic1, XmlObject.Factory.parse( "<Notif>yo!</Notif>" ) );
         Object currentMsg = fsResource.getCurrentMessage( topic1 );
         assertNotNull( currentMsg );
         assertTrue( currentMsg instanceof XmlObject );
         XmlObject msgXBean = (XmlObject) currentMsg;
-        assertEquals( new QName( "Notif" ), XmlBeanUtils.getName( msgXBean ) );
+        assertEquals( new QName( "Notif" ), XmlBeanUtils.getName( msgXBean ) );*/
     }
 
 }

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=292768&r1=292767&r2=292768&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 Fri Sep 30 08:16:05 2005
@@ -74,7 +74,7 @@
    public UnitExampleHome(  )
    {
       setResourceIdentifierReferenceParameterName( RESOURCE_KEY_NAME.toString(  ) );
-      setResourceClassName( UnitResource.class.getName(  ) );
+      setResourceClass( UnitResource.class );
       try
       {
          init(  );

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=292768&r1=292767&r2=292768&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 Fri Sep 30 08:16:05 2005
@@ -17,15 +17,19 @@
 
 import org.apache.ws.addressing.EndpointReference;
 import org.apache.ws.notification.base.NotificationProducerResource;
-import org.apache.ws.notification.topics.Topic;
 import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException;
 import org.apache.ws.resource.PropertiesResource;
 import org.apache.ws.resource.ResourceHome;
 import org.apache.ws.resource.lifetime.ResourceTerminationListener;
 import org.apache.ws.resource.properties.ResourcePropertySet;
+import org.apache.ws.resource.properties.query.QueryExpression;
 import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationProducerRPDocument;
 
+import java.util.Calendar;
+
 /**
  * @author Sal Campana
  */
@@ -168,7 +172,7 @@
         // TODO
     }
 
-    public Object getCurrentMessage( Topic topic )
+    public Object getCurrentMessage( TopicExpression topicExpr )
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
@@ -177,4 +181,13 @@
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
+
+    public EndpointReference subscribe( EndpointReference consumerEPR, TopicExpression topicExpr, Boolean useNotify,
+                                        QueryExpression precondition, QueryExpression selector,
+                                        Object subscriptionPolicy, Calendar initialTerminationtime )
+            throws SubscribeCreationFailedException, InvalidTopicExpressionException, TopicPathDialectUnknownException
+    {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+    
 }

Added: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/AbstractTopicExpressionEvaluatorTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/AbstractTopicExpressionEvaluatorTestCase.java?rev=292768&view=auto
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/AbstractTopicExpressionEvaluatorTestCase.java (added)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/AbstractTopicExpressionEvaluatorTestCase.java Fri Sep 30 08:16:05 2005
@@ -0,0 +1,99 @@
+/*=============================================================================*
+ *  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.topics.Topic;
+import org.apache.ws.notification.topics.TopicNamespace;
+import org.apache.ws.notification.topics.TopicNamespaceRegistry;
+import org.apache.ws.notification.topics.TopicsTypeReader;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
+import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
+import org.apache.xmlbeans.XmlObject;
+
+import java.net.URI;
+
+/**
+ * Abstract test case for various {@link TopicExpressionEvaluator} impls.
+ */
+public abstract class AbstractTopicExpressionEvaluatorTestCase
+   extends TestCase
+{
+   protected static final URI      NSURI1    = URI.create( "http://ns1.com/" );
+   protected static final String      NSPREFIX1 = "ns1";
+   protected static final URI      NSURI2    = URI.create( "http://ns2.com/" );
+   protected static final String      NSPREFIX2 = "ns2";
+   protected TopicExpressionEvaluator m_evaluator;
+
+   /**
+    * DOCUMENT_ME
+    *
+    * @throws Exception DOCUMENT_ME
+    */
+   protected void setUp(  )
+   throws Exception
+   {
+       TopicNamespaceRegistry topicNsRegistry = TopicNamespaceRegistry.getInstance();
+
+       XmlObject topicNsXBean = XmlObject.Factory.parse( this.getClass().getClassLoader().getResourceAsStream( "org/apache/ws/notification/test-topicSpace.xml" ) );
+       TopicNamespace topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace( topicNsXBean );
+       topicNsRegistry.addTopicNamespace( topicNs );
+       
+       topicNsXBean = XmlObject.Factory.parse( this.getClass().getClassLoader().getResourceAsStream( "org/apache/ws/notification/test2-topicSpace.xml" ) );
+       topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace( topicNsXBean );
+       topicNsRegistry.addTopicNamespace( topicNs );
+
+       topicNsXBean = XmlObject.Factory.parse( this.getClass().getClassLoader().getResourceAsStream( "org/apache/ws/notification/adHoc-topicSpace.xml" ) );
+       topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace( topicNsXBean );
+       topicNsRegistry.addTopicNamespace( topicNs );
+
+       m_evaluator = createTopicExpressionEvaluator();
+   }
+
+    protected abstract TopicExpressionEvaluator createTopicExpressionEvaluator();
+
+    protected 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 );
+   }
+
+   protected void assertExpressionIsInvalid( String expr )
+   throws Exception
+   {
+      try
+      {
+         evaluate( expr );
+         fail(  );
+      }
+      catch ( InvalidTopicExpressionException itee )
+      {
+         // success!
+      }
+   }
+
+   protected abstract Topic[] evaluate( String expr ) throws Exception;
+
+}
\ 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=292768&r1=292767&r2=292768&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 Fri Sep 30 08:16:05 2005
@@ -15,137 +15,86 @@
  *=============================================================================*/
 package org.apache.ws.notification.topics.impl;
 
-import junit.framework.TestCase;
 import org.apache.ws.notification.topics.Topic;
-import org.apache.ws.notification.topics.TopicNamespace;
-import org.apache.ws.notification.topics.TopicNamespaceRegistry;
 import org.apache.ws.notification.topics.TopicsTypeReader;
-import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
-import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
 import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
 import org.apache.ws.notification.topics.expression.impl.ConcreteTopicExpressionEvaluator;
 import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
 import org.apache.xmlbeans.XmlObject;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
 
-import java.net.URI;
-
 /**
  * Test case for {@link ConcreteTopicExpressionEvaluator}.
  */
 public class ConcreteTopicExpressionEvaluatorTestCase
-   extends TestCase
+        extends AbstractTopicExpressionEvaluatorTestCase
 {
-   private static final URI      NSURI1    = URI.create( "http://ns1.com/" );
-   private static final String      NSPREFIX1 = "ns1";
-   private static final URI      NSURI2    = URI.create( "http://ns2.com/" );
-   private static final String      NSPREFIX2 = "ns2";
-   private TopicExpressionEvaluator m_evaluator;
-
-   /**
-    * 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 );
-   }
-
-   /**
-    * DOCUMENT_ME
-    *
-    * @throws Exception DOCUMENT_ME
-    */
-   protected void setUp(  )
-   throws Exception
-   {
-       TopicNamespaceRegistry topicNsRegistry = TopicNamespaceRegistry.getInstance();
-       XmlObject topicNsXBean = XmlObject.Factory.parse( this.getClass().getClassLoader().getResourceAsStream( "org/apache/ws/notification/test-topicSpace.xml" ) );
-       TopicNamespace topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace( topicNsXBean );
-       topicNsRegistry.addTopicNamespace( topicNs );
-       topicNsXBean = XmlObject.Factory.parse( this.getClass().getClassLoader().getResourceAsStream( "org/apache/ws/notification/adHoc-topicSpace.xml" ) );
-       topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace( topicNsXBean );
-       topicNsRegistry.addTopicNamespace( topicNs );
-       m_evaluator = new ConcreteTopicExpressionEvaluator(  );
-   }
-
-   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 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' "
-                                                              + "xmlns:" + NSPREFIX1 + "='" + NSURI1 + "' xmlns:"
-                                                              + NSPREFIX2 + "='" + NSURI2
-                                                              + "' Dialect='http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Concrete'>"
-                                                              + expr + "</wsnt:TopicExpression>" ) )
-         .getTopicExpression(  );
-      TopicExpression topicExpr = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicExpression( topicExprType );
-      return m_evaluator.evaluate( topicExpr );
-   }
+
+    /**
+     * 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( "candy/nerds" );  // topic from ad-hoc ns
+        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 );
+    }
+
+    protected Topic[] evaluate( String expr )
+            throws Exception
+    {
+        TopicExpressionType 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' "
+                + "xmlns:" + NSPREFIX1 + "='" + NSURI1 +
+                "' xmlns:"
+                + NSPREFIX2 + "='" + NSURI2
+                + "' Dialect='http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Concrete'>"
+                + expr + "</wsnt:TopicExpression>" ) )
+                .getTopicExpression();
+        TopicExpression topicExpr = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA )
+                .toTopicExpression( topicExprType );
+        return m_evaluator.evaluate( topicExpr );
+    }
+
+    protected TopicExpressionEvaluator createTopicExpressionEvaluator()
+    {
+        return new ConcreteTopicExpressionEvaluator();
+    }
 }

Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluatorTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluatorTestCase.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluatorTestCase.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluatorTestCase.java Fri Sep 30 08:16:05 2005
@@ -15,50 +15,23 @@
  *=============================================================================*/
 package org.apache.ws.notification.topics.impl;
 
-import junit.framework.TestCase;
 import org.apache.ws.notification.topics.Topic;
-import org.apache.ws.notification.topics.TopicNamespace;
-import org.apache.ws.notification.topics.TopicNamespaceRegistry;
 import org.apache.ws.notification.topics.TopicsTypeReader;
-import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
-import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
 import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
 import org.apache.ws.notification.topics.expression.impl.FullTopicExpressionEvaluator;
 import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
 import org.apache.xmlbeans.XmlObject;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
 
-import java.net.URI;
-
 /**
  * Test case for {@link FullTopicExpressionEvaluator}.
  */
 public class FullTopicExpressionEvaluatorTestCase
-        extends TestCase
+        extends AbstractTopicExpressionEvaluatorTestCase
 {
 
-    private static final URI NSURI1 = URI.create( "http://ns1.com/" );
-    private static final String NSPREFIX1 = "ns1";
-    private static final URI NSURI2 = URI.create( "http://ns2.com/" );
-    private static final String NSPREFIX2 = "ns2";
-    private TopicExpressionEvaluator m_evaluator;
-
-    /**
-     * 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
      *
@@ -85,6 +58,31 @@
      *
      * @throws Exception DOCUMENT_ME
      */
+    public void testEvaluateSimple()
+            throws Exception
+    {
+        Topic[] resultTopics;
+
+        resultTopics = evaluate( "candy/nerds" );
+        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" );
+
+        resultTopics = evaluate( NSPREFIX1 + ":sports/baseball" );
+        assertEquals( 0, resultTopics.length );
+    }
+
+    /**
+     * DOCUMENT_ME
+     *
+     * @throws Exception DOCUMENT_ME
+     */
     public void testEvaluateRecursive()
             throws Exception
     {
@@ -121,33 +119,15 @@
      *
      * @throws Exception DOCUMENT_ME
      */
-    public void testEvaluateSimple()
+    public void testEvaluateWildcard()
             throws Exception
     {
-        Topic[] resultTopics = evaluate( "celebs" );
-        assertEquals( 1, resultTopics.length );
+        Topic[] resultTopics;
 
-        resultTopics = evaluate( NSPREFIX1 + ":sports" );
-        assertEquals( 1, resultTopics.length );
-        assertContainsTopic( resultTopics, "sports" );
-
-        resultTopics = evaluate( NSPREFIX1 + ":sports/tennis" );
-        assertEquals( 1, resultTopics.length );
-        assertContainsTopic( resultTopics, "tennis" );
-
-        resultTopics = evaluate( NSPREFIX1 + ":sports/baseball" );
-        assertEquals( 0, resultTopics.length );
-    }
+        resultTopics = evaluate( "candy/*" );
+        assertEquals( 2, resultTopics.length );
 
-    /**
-     * DOCUMENT_ME
-     *
-     * @throws Exception DOCUMENT_ME
-     */
-    public void testEvaluateWildcard()
-            throws Exception
-    {
-        Topic[] resultTopics = evaluate( NSPREFIX1 + ":*" );
+        resultTopics = evaluate( NSPREFIX1 + ":*" );
         assertEquals( 2, resultTopics.length );
         assertContainsTopic( resultTopics, "sports" );
         assertContainsTopic( resultTopics, "games" );
@@ -192,59 +172,17 @@
      *
      * @throws Exception DOCUMENT_ME
      */
-    protected void setUp()
+    public void testEvaluateConjoined()
             throws Exception
     {
-        TopicNamespaceRegistry topicNsRegistry = TopicNamespaceRegistry.getInstance();
-        XmlObject topicNsXBean = XmlObject.Factory.parse(
-                this.getClass().getClassLoader().getResourceAsStream( "org/apache/ws/notification/test-topicSpace.xml" ) );
-        TopicNamespace topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace(
-                topicNsXBean );
-        topicNsRegistry.addTopicNamespace( topicNs );
-        topicNsXBean =
-                XmlObject.Factory.parse(
-                        this.getClass().getClassLoader().getResourceAsStream(
-                                "org/apache/ws/notification/test2-topicSpace.xml" ) );
-        topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace( topicNsXBean );
-        topicNsRegistry.addTopicNamespace( topicNs );
-        topicNsXBean =
-                XmlObject.Factory.parse( this.getClass().getClassLoader().getResourceAsStream(
-                        "org/apache/ws/notification/adHoc-topicSpace.xml" ) );
-        topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace( topicNsXBean );
-        topicNsRegistry.addTopicNamespace( topicNs );
-        m_evaluator = new FullTopicExpressionEvaluator();
-    }
-
-    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!
-        }
+        Topic[] resultTopics = evaluate( NSPREFIX1 + ":sports/tennis|" + NSPREFIX2 + ":bands/*" );
+        assertEquals( 3, resultTopics.length );
+        assertContainsTopic( resultTopics, "tennis" );
+        assertContainsTopic( resultTopics, "beatles" );
+        assertContainsTopic( resultTopics, "kinks" );
     }
 
-    private Topic[] evaluate( String expr )
+    protected Topic[] evaluate( String expr )
             throws Exception
     {
         TopicExpressionType topicExprType =
@@ -255,7 +193,14 @@
                 + "' Dialect='http://docs.oasis-open.org/wsn/2004/06/TopicExpression/Full'>"
                 + expr + "</wsnt:TopicExpression>" ) )
                 .getTopicExpression();
-        TopicExpression topicExpr = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicExpression( topicExprType );
+        TopicExpression topicExpr = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA )
+                .toTopicExpression( topicExprType );
         return m_evaluator.evaluate( topicExpr );
     }
+
+    protected TopicExpressionEvaluator createTopicExpressionEvaluator()
+    {
+        return new FullTopicExpressionEvaluator();
+    }
+
 }

Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluatorTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluatorTestCase.java?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluatorTestCase.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluatorTestCase.java Fri Sep 30 08:16:05 2005
@@ -15,33 +15,22 @@
  *=============================================================================*/
 package org.apache.ws.notification.topics.impl;
 
-import junit.framework.TestCase;
 import org.apache.ws.notification.topics.Topic;
-import org.apache.ws.notification.topics.TopicNamespace;
-import org.apache.ws.notification.topics.TopicNamespaceRegistry;
 import org.apache.ws.notification.topics.TopicsTypeReader;
-import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
-import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
 import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
 import org.apache.ws.notification.topics.expression.impl.SimpleTopicExpressionEvaluator;
 import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
 import org.apache.xmlbeans.XmlObject;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDocument;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
 
-import java.net.URI;
-
 /**
  * Test case for {@link SimpleTopicExpressionEvaluator}.
  */
 public class SimpleTopicExpressionEvaluatorTestCase
-        extends TestCase
+        extends AbstractTopicExpressionEvaluatorTestCase
 {
-    private static final URI NSURI1 = URI.create( "http://ns1.com/" );
-    private static final String NSPREFIX1 = "ns1";
-    private static final URI NSURI2 = URI.create( "http://ns2.com/" );
-    private static final String NSPREFIX2 = "ns2";
-    private TopicExpressionEvaluator m_evaluator;
 
     /**
      * DOCUMENT_ME
@@ -71,7 +60,7 @@
     public void testEvaluateValid()
             throws Exception
     {
-        Topic[] resultTopics = evaluate( "celebs" );
+        Topic[] resultTopics = evaluate( "candy" );
         assertEquals( 1, resultTopics.length );
 
         resultTopics = evaluate( NSPREFIX1 + ":sports" );
@@ -82,58 +71,7 @@
         assertEquals( 0, resultTopics.length );
     }
 
-    /**
-     * DOCUMENT_ME
-     *
-     * @throws Exception DOCUMENT_ME
-     */
-    protected void setUp()
-            throws Exception
-    {
-        TopicNamespaceRegistry topicNsRegistry = TopicNamespaceRegistry.getInstance();
-        XmlObject topicNsXBean = XmlObject.Factory.parse(
-                this.getClass().getClassLoader().getResourceAsStream( "org/apache/ws/notification/test-topicSpace.xml" ) );
-        TopicNamespace topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace(
-                topicNsXBean );
-        topicNsRegistry.addTopicNamespace( topicNs );
-        topicNsXBean =
-                XmlObject.Factory.parse(
-                        this.getClass().getClassLoader().getResourceAsStream(
-                                "org/apache/ws/notification/adHoc-topicSpace.xml" ) );
-        topicNs = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicNamespace( topicNsXBean );
-        topicNsRegistry.addTopicNamespace( topicNs );
-        m_evaluator = new SimpleTopicExpressionEvaluator();
-    }
-
-    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 )
+    protected Topic[] evaluate( String expr )
             throws Exception
     {
         TopicExpressionType topicExprType =
@@ -147,4 +85,10 @@
         TopicExpression topicExpr = TopicsTypeReader.newInstance( TopicsConstants.NSURI_WSTOP_SCHEMA ).toTopicExpression( topicExprType );
         return m_evaluator.evaluate( topicExpr );
     }
+
+    protected TopicExpressionEvaluator createTopicExpressionEvaluator()
+    {
+        return new SimpleTopicExpressionEvaluator();
+    }
+
 }

Modified: webservices/pubscribe/trunk/src/test/spring-jndi-config.xml
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/spring-jndi-config.xml?rev=292768&r1=292767&r2=292768&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/spring-jndi-config.xml (original)
+++ webservices/pubscribe/trunk/src/test/spring-jndi-config.xml Fri Sep 30 08:16:05 2005
@@ -53,15 +53,15 @@
     </constructor-arg>
   </bean>
 
-  <bean name="services/home/SubscriptionManager" class="org.apache.ws.notification.base.v2004_06.impl.SubscriptionHome">
-    <property name="serviceClassName"><value>org.apache.ws.notification.base.v2004_06.impl.SubscriptionService</value></property>
-    <property name="resourceClassName"><value>org.apache.ws.notification.base.v2004_06.impl.SubscriptionResource</value></property>
+  <bean name="resource/SubscriptionManager" class="org.apache.ws.notification.base.v2004_06.impl.SubscriptionHome" init-method="init">
+    <property name="serviceClass"><value>org.apache.ws.notification.base.v2004_06.impl.SubscriptionService</value></property>
+    <property name="resourceClass"><value>org.apache.ws.notification.base.v2004_06.impl.SubscriptionResource</value></property>
     <property name="resourceIdentifierReferenceParameterName"><value>{http://ws.apache.org/notification/base/service/SubscriptionManager}ResourceIdentifier</value></property>
   </bean>
 
-  <bean name="services/home/filesystem" class="org.apache.ws.resource.example.filesystem.FilesystemHome" init-method="init">
-    <property name="serviceClassName"><value>org.apache.ws.resource.example.filesystem.FilesystemService</value></property>
-    <property name="resourceClassName"><value>org.apache.ws.resource.example.filesystem.FilesystemResource</value></property>
+  <bean name="resource/filesystem" class="org.apache.ws.resource.example.filesystem.FilesystemHome" init-method="init">
+    <property name="serviceClass"><value>org.apache.ws.resource.example.filesystem.FilesystemService</value></property>
+    <property name="resourceClass"><value>org.apache.ws.resource.example.filesystem.FilesystemResource</value></property>
     <property name="resourceIdentifierReferenceParameterName"><value>{http://ws.apache.org/resource/example/filesystem}ResourceIdentifier</value></property>
   </bean>
 
@@ -70,13 +70,13 @@
       <bean class="org.apache.ws.notification.topics.impl.TopicSetImpl">
         <constructor-arg>
           <set>
-            <bean class="org.apache.ws.notification.topics.expression.impl.SimpleTopicExpressionImpl">
+            <bean class="org.apache.ws.notification.topics.expression.SimpleTopicExpression">
               <constructor-arg><value>{http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd}ResourceTermination</value></constructor-arg>
             </bean>
-            <bean class="org.apache.ws.notification.topics.expression.impl.SimpleTopicExpressionImpl">
+            <bean class="org.apache.ws.notification.topics.expression.SimpleTopicExpression">
               <constructor-arg><value>{http://example.org/topicSpace/example1}t1</value></constructor-arg>
             </bean>
-            <bean class="org.apache.ws.notification.topics.expression.impl.ConcreteTopicExpressionImpl">
+            <bean class="org.apache.ws.notification.topics.expression.ConcreteTopicExpression">
               <constructor-arg><value>{http://example.org/topicSpace/example1}t4/t5</value></constructor-arg>
             </bean>
           </set>



Mime
View raw message