// Path: pooled-jms/src/test/java/org/messaginghub/pooled/jms/mock/MockJMSQueueReceiver.java
// public class MockJMSQueueReceiver extends MockJMSMessageConsumer implements AutoCloseable, QueueReceiver {
// 
//     protected MockJMSQueueReceiver(MockJMSSession session, String consumerId, MockJMSDestination destination, String messageSelector) throws JMSException {
//         super(session, consumerId, destination, messageSelector, false);
//     }
// 
//     @Override
//     public Queue getQueue() throws IllegalStateException {
//         checkClosed();
//         return (Queue) this.destination;
//     }
// }


import org.messaginghub.pooled.jms.mock.MockJMSQueueReceiver;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import javax.jms.IllegalStateException;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueReceiver;
import javax.jms.QueueSession;
import javax.jms.Session;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.messaginghub.pooled.jms;




/**
 * Tests for the JMS Pool QueueReceiver wrapper
 */
@Timeout(60)
public class JmsPoolQueueReceiverTest extends JmsPoolTestSupport {

    @Test
    public void testToString() throws JMSException {
        JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
        QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createTemporaryQueue();
        QueueReceiver receiver = session.createReceiver(queue);

        assertNotNull(receiver.toString());
    }

    @Test
    public void testGetQueue() throws JMSException {
        JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
        QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createTemporaryQueue();
        QueueReceiver receiver = session.createReceiver(queue);

        assertNotNull(receiver.getQueue());
        assertSame(queue, receiver.getQueue());

        receiver.close();

        try {
            receiver.getQueue();
            fail("Cannot read topic on closed receiver");
// Path: pooled-jms/src/test/java/org/messaginghub/pooled/jms/mock/MockJMSQueueReceiver.java
// public class MockJMSQueueReceiver extends MockJMSMessageConsumer implements AutoCloseable, QueueReceiver {
// 
//     protected MockJMSQueueReceiver(MockJMSSession session, String consumerId, MockJMSDestination destination, String messageSelector) throws JMSException {
//         super(session, consumerId, destination, messageSelector, false);
//     }
// 
//     @Override
//     public Queue getQueue() throws IllegalStateException {
//         checkClosed();
//         return (Queue) this.destination;
//     }
// }


// Path: pooled-jms/src/test/java/org/messaginghub/pooled/jms/JmsPoolQueueReceiverTest.java
import org.messaginghub.pooled.jms.mock.MockJMSQueueReceiver;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import javax.jms.IllegalStateException;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueReceiver;
import javax.jms.QueueSession;
import javax.jms.Session;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.messaginghub.pooled.jms;




/**
 * Tests for the JMS Pool QueueReceiver wrapper
 */
@Timeout(60)
public class JmsPoolQueueReceiverTest extends JmsPoolTestSupport {

    @Test
    public void testToString() throws JMSException {
        JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
        QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createTemporaryQueue();
        QueueReceiver receiver = session.createReceiver(queue);

        assertNotNull(receiver.toString());
    }

    @Test
    public void testGetQueue() throws JMSException {
        JmsPoolConnection connection = (JmsPoolConnection) cf.createQueueConnection();
        QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createTemporaryQueue();
        QueueReceiver receiver = session.createReceiver(queue);

        assertNotNull(receiver.getQueue());
        assertSame(queue, receiver.getQueue());

        receiver.close();

        try {
            receiver.getQueue();
            fail("Cannot read topic on closed receiver");
        } catch (IllegalStateException ise) {}