Package org.apache.ws.notification.topics

Source Code of org.apache.ws.notification.topics.SubscriptionTopicListenerTestCase

/*=============================================================================*
*  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 );
   }
}
TOP

Related Classes of org.apache.ws.notification.topics.SubscriptionTopicListenerTestCase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.