/**
 *
 * Copyright 2004 Protique Ltd
 *
 * 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.activemq.broker.impl;
import junit.framework.TestCase;

import org.activemq.message.ActiveMQDestination;
import org.activemq.message.ActiveMQTopic;
import org.activemq.message.ConnectionInfo;
import org.activemq.message.ConsumerInfo;
import org.activemq.message.ProducerInfo;

/**
 *
 * AdvisorySupportTest
 */
public class AdvisorySupportTest extends TestCase {
    /*
     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
    }

    /*
     * @see TestCase#tearDown()
     */
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Constructor for AdvisorySupportTest.
     * @param arg0
     */
    public AdvisorySupportTest(String arg0) {
        super(arg0);
    }

    public void testMatchConsumer(){
        String destName = "foo.bar";
        ActiveMQTopic topic = new ActiveMQTopic(destName);
        ConsumerInfo info = new ConsumerInfo();
        info.setDestination(topic);
        
        ActiveMQTopic advisoryDest = topic.getTopicForConsumerAdvisory();
        ConsumerInfo advisory = new ConsumerInfo();
        advisory.setDestination(advisoryDest);
        AdvisorySupport test = new AdvisorySupport(null);
        assertTrue(test.matchConsumer(advisory, info));
    }
    
    public void testMatchProducer(){
        String destName = "foo.bar";
        ActiveMQTopic topic = new ActiveMQTopic(destName);
        ProducerInfo info = new ProducerInfo();
        info.setDestination(topic);
        
        ActiveMQTopic advisoryDest = topic.getTopicForProducerAdvisory();
        ConsumerInfo advisory = new ConsumerInfo();
        advisory.setDestination(advisoryDest);
        AdvisorySupport test = new AdvisorySupport(null);
        assertTrue(test.matchProducer(advisory, info));
    }
    
    public void testMatchConnection(){
        
        ConnectionInfo info = new ConnectionInfo();
        
        
        ActiveMQTopic advisoryDest = new ActiveMQTopic(ActiveMQDestination.CONNECTION_ADVISORY_PREFIX);
        ConsumerInfo advisory = new ConsumerInfo();
        advisory.setDestination(advisoryDest);
        AdvisorySupport test = new AdvisorySupport(null);
        assertTrue(test.matchConnection(advisory, info));
    }
}
