
package org.apache.camel.component.jms.temp;

import javax.jms.TemporaryQueue;
import javax.jms.TemporaryTopic;
import javax.naming.Context;

import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.activemq.command.ActiveMQTempQueue;
import org.apache.activemq.command.ActiveMQTempTopic;
import org.apache.camel.component.jms.JmsConfiguration;
import org.apache.camel.component.jms.JmsEndpoint;
import org.apache.camel.component.jms.JmsProviderMetadata;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

/**
 * @version 
 */
public class JmsProviderTest extends CamelTestSupport {
    @Test
    public void testTemporaryDestinationTypes() throws Exception {
        JmsEndpoint endpoint = getMandatoryEndpoint("activemq:test.queue", JmsEndpoint.class);
        JmsConfiguration configuration = endpoint.getConfiguration();
        JmsProviderMetadata providerMetadata = configuration.getProviderMetadata();
        assertNotNull("provider", providerMetadata);

        Class<? extends TemporaryQueue> queueType = endpoint.getTemporaryQueueType();
        Class<? extends TemporaryTopic> topicType = endpoint.getTemporaryTopicType();

        log.info("Found queue type: " + queueType);
        log.info("Found topic type: " + topicType);

        assertNotNull("queueType", queueType);
        assertNotNull("topicType", topicType);

        assertEquals("queueType", ActiveMQTempQueue.class, queueType);
        assertEquals("topicType", ActiveMQTempTopic.class, topicType);
    }

    @Override
    protected Context createJndiContext() throws Exception {
        Context context = super.createJndiContext();
        context.bind("activemq", ActiveMQComponent.activeMQComponent("vm://localhost"));
        return context;
    }
}
