/*
 * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

/*
 * $Id$
 */
package com.sun.ts.tests.jms.core.closedQueueSession;

import java.lang.System.Logger;
import java.util.ArrayList;
import java.util.Properties;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.sun.ts.lib.util.TestUtil;
import com.sun.ts.tests.jms.common.JmsTool;
import com.sun.ts.tests.jms.common.MessageTestImpl;

import jakarta.jms.BytesMessage;
import jakarta.jms.MapMessage;
import jakarta.jms.Message;
import jakarta.jms.ObjectMessage;
import jakarta.jms.Queue;
import jakarta.jms.QueueBrowser;
import jakarta.jms.QueueReceiver;
import jakarta.jms.QueueSender;
import jakarta.jms.StreamMessage;
import jakarta.jms.TemporaryQueue;
import jakarta.jms.TextMessage;

/**
 * JMS TS tests. Testing method calls on closed QueueSession objects.
 */

public class ClosedQueueSessionTestsIT {
	private static final String TestName = "com.sun.ts.tests.jms.core.closedQueueSession.ClosedQueueSessionTestsIT";

	private static final String testDir = System.getProperty("user.dir");

	private static final long serialVersionUID = 1L;

	private static final Logger logger = (Logger) System.getLogger(ClosedQueueSessionTestsIT.class.getName());

	// JMS objects
	private transient JmsTool tool = null;

	// Harness req's
	private Properties props = null;

	// properties read
	long timeout;

	String user;

	String password;

	String mode;

	ArrayList queues = null;

	ArrayList connections = null;

	/* Utility methods for tests */

	/**
	 * Used by tests that need a closed session for testing. Passes any exceptions
	 * up to caller.
	 * 
	 * @param int The type of session that needs to be created and closed
	 */
	private void createAndCloseSession(int type, String user, String password) throws Exception {
		if ((type == JmsTool.QUEUE) || (type == JmsTool.TX_QUEUE)) {
			tool = new JmsTool(type, user, password, mode);
			tool.getDefaultQueueConnection().start();
			logger.log(Logger.Level.INFO, "Closing QueueSession");
			tool.getDefaultQueueSession().close();

		} else if (type == JmsTool.COMMON_QTX) {
			tool = new JmsTool(type, user, password, mode);
			tool.getDefaultConnection().start();
			logger.log(Logger.Level.INFO, "Closing Session");
			tool.getDefaultSession().close();
		} else {
			logger.log(Logger.Level.ERROR, "Unspecified type");
		}
	}

	/* Test setup: */

	/*
	 * setup() is called before each test
	 * 
	 * Creates Administrator object and deletes all previous Destinations.
	 * Individual tests create the JmsTool object with one default QueueConnection,
	 * as well as a default Queue. Tests that require multiple Destinations create
	 * the extras within the test
	 * 
	 * 
	 * @class.setup_props: jms_timeout; user; password; platform.mode;
	 * 
	 * @exception Fault
	 */

	@BeforeEach
	public void setup() throws Exception {
		try {

			// get props
			timeout = Long.parseLong(System.getProperty("jms_timeout"));
			user = System.getProperty("user");
			password = System.getProperty("password");
			mode = System.getProperty("platform.mode");

			// check props for errors
			if (timeout < 1) {
				throw new Exception("'jms_timeout' (milliseconds) in must be > 0");
			}
			if (user == null) {
				throw new Exception("'user' is null");
			}
			if (password == null) {
				throw new Exception("'password' is null");
			}
			if (mode == null) {
				throw new Exception("'platform.mode' is null");
			}
			queues = new ArrayList(2);

			// get ready for new test
		} catch (Exception e) {
			TestUtil.printStackTrace(e);
			throw new Exception("Setup failed!", e);
		}
	}

	/* cleanup */

	/*
	 * cleanup() is called after each test
	 * 
	 * Closes the default connections that are created by setup(). Any separate
	 * connections made by individual tests should be closed by that test.
	 * 
	 * @exception Fault
	 */

	@AfterEach
	public void cleanup() throws Exception {
		try {
			if (tool != null) {
				logger.log(Logger.Level.INFO, "Cleanup: Closing QueueConnection");
				tool.doClientQueueTestCleanup(connections, queues);
			}

		} catch (Exception e) {
			TestUtil.printStackTrace(e);
			logger.log(Logger.Level.ERROR, "An error occurred while cleaning");
			throw new Exception("Cleanup failed!", e);
		}
	}

	/* Tests */

	/*
	 * @testName: closedQueueSessionCloseTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:229;
	 * 
	 * @test_Strategy: Close default session and call close method on it.
	 */
	@Test
	public void closedQueueSessionCloseTest() throws Exception {
		try {
			logger.log(Logger.Level.TRACE, "Before create and close");
			createAndCloseSession(JmsTool.QUEUE, user, password);

			logger.log(Logger.Level.INFO, "Try to call close on closed session.");
			tool.getDefaultQueueSession().close();
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, "fault " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCloseTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateBrowserTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:190;
	 * 
	 * @test_Strategy: Close default session and call createBrowser on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionCreateBrowserTest() throws Exception {
		String testName = "closedQueueSessionCreateBrowserTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create QueueBrowser with closed session.");
			try {
				QueueBrowser qB = tool.getDefaultQueueSession().createBrowser(tool.getDefaultQueue());
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			throw new Exception("closedQueueSessionCreateBrowserTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionCreateBrowserMsgSelectorTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:192;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateBrowserMsgSelectorTest() throws Exception {
		String testName = "closedQueueSessionCreateBrowserMsgSelectorTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create QueueBrowser with closed session.");
			try {
				QueueBrowser qB = tool.getDefaultQueueSession().createBrowser(tool.getDefaultQueue(), "TEST = 'test'");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateBrowserMsgSelectorTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateQueueTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:182;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateQueueTest() throws Exception {
		String testName = "closedQueueSessionCreateQueueTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create queue with closed session.");
			try {
				Queue q = tool.getDefaultQueueSession().createQueue(testName);
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateQueueTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateReceiverTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:184;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateReceiverTest() throws Exception {
		String testName = "closedQueueSessionCreateReceiverTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create Receiver with closed session.");
			try {
				QueueReceiver qR = tool.getDefaultQueueSession().createReceiver(tool.getDefaultQueue());
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateReceiverTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateReceiverMsgSelectorTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:186;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateReceiverMsgSelectorTest() throws Exception {
		String testName = "closedQueueSessionCreateReceiverMsgSelectorTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create Receiver with closed session.");
			try {
				QueueReceiver qR = tool.getDefaultQueueSession().createReceiver(tool.getDefaultQueue(),
						"TEST = 'test'");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateReceiverMsgSelectorTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateSenderTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:188;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateSenderTest() throws Exception {
		String testName = "closedQueueSessionCreateSenderTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create Sender with closed session.");
			try {
				QueueSender qS = tool.getDefaultQueueSession().createSender(tool.getDefaultQueue());
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateSenderTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateTempQueueTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:194;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateTempQueueTest() throws Exception {
		String testName = "closedQueueSessionCreateTempQueueTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create TemporaryQueue with closed session.");
			try {
				TemporaryQueue tQ = tool.getDefaultQueueSession().createTemporaryQueue();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateTempQueueTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateMessageTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:213;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateMessageTest() throws Exception {
		String testName = "closedQueueSessionCreateMessageTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create message with closed session.");
			try {
				Message m = tool.getDefaultQueueSession().createMessage();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateMessageTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateBytesMessageTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:209;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateBytesMessageTest() throws Exception {
		String testName = "closedQueueSessionCreateBytesMessageTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create BytesMessage with closed session.");
			try {
				BytesMessage m = tool.getDefaultQueueSession().createBytesMessage();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateBytesMessageTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateMapMessageTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:211;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateMapMessageTest() throws Exception {
		String testName = "closedQueueSessionCreateMapMessageTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create MapMessage with closed session.");
			try {
				MapMessage m = tool.getDefaultQueueSession().createMapMessage();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateMapMessageTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateObjectMessageTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:215;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateObjectMessageTest() throws Exception {
		String testName = "closedQueueSessionCreateObjectMessageTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create ObjectMessage with closed session.");
			try {
				ObjectMessage m = tool.getDefaultQueueSession().createObjectMessage();
				if (m != null)
					logger.log(Logger.Level.TRACE, "m=" + m);
				logger.log(Logger.Level.TRACE, "FAIL: expected IllegalStateException");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateObjectMessageTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateObject2MessageTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:217;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateObject2MessageTest() throws Exception {
		String testName = "closedQueueSessionCreateObject2MessageTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create ObjectMessage(object) with closed session.");
			try {
				String s = "Simple object";
				ObjectMessage m = tool.getDefaultQueueSession().createObjectMessage(s);
				if (m != null)
					logger.log(Logger.Level.TRACE, "m=" + m);
				logger.log(Logger.Level.TRACE, "FAIL: expected IllegalStateException");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateObject2MessageTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateStreamMessageTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:219;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateStreamMessageTest() throws Exception {
		String testName = "closedQueueSessionCreateStreamMessageTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create StreamMessage with closed session.");
			try {
				StreamMessage m = tool.getDefaultQueueSession().createStreamMessage();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateStreamMessageTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateTextMessageTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:221;
	 * 
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateTextMessageTest() throws Exception {
		String testName = "closedQueueSessionCreateTextMessageTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create TextMessage with closed session.");
			try {
				TextMessage m = tool.getDefaultQueueSession().createTextMessage();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateTextMessageTest");
		}
	}

	/*
	 * @testName: closedQueueSessionCreateText2MessageTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:223;
	 * 
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCreateText2MessageTest() throws Exception {
		String testName = "closedQueueSessionCreateText2MessageTest";

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to create TextMessage with closed session.");
			try {
				TextMessage m = tool.getDefaultQueueSession().createTextMessage("test message");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionCreateText2MessageTest");
		}
	}

	/*
	 * @testName: closedQueueSessionReceiverCloseTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:338;
	 * 
	 * @test_Strategy: Close default receiver and call method on it.
	 */
	@Test
	public void closedQueueSessionReceiverCloseTest() throws Exception {
		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call close again");
			tool.getDefaultQueueReceiver().close();
		} catch (Exception e) {
			throw new Exception("closedQueueSessionReceiverCloseTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionGetMessageSelectorTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:326;
	 * 
	 * @test_Strategy: Close default receiver and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionGetMessageSelectorTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call getMessageSelector");
			try {
				String foo = tool.getDefaultQueueReceiver().getMessageSelector();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionGetMessageSelectorTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionReceiveTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:332;
	 * 
	 * @test_Strategy: Close default receiver and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionReceiveTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call receive");
			try {
				Message foo = tool.getDefaultQueueReceiver().receive();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionReceiveTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionReceiveTimeoutTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:334;
	 * 
	 * @test_Strategy: Close default receiver and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionReceiveTimeoutTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call receive(timeout)");
			try {
				Message foo = tool.getDefaultQueueReceiver().receive(timeout);

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionReceiveTimeoutTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionReceiveNoWaitTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:336;
	 * 
	 * @test_Strategy: Close default receiver and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionReceiveNoWaitTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call receiveNoWait");
			try {
				Message foo = tool.getDefaultQueueReceiver().receiveNoWait();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionReceiveNoWaitTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionReceiverGetQueueTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:268;
	 * 
	 * @test_Strategy: Close default receiver and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionReceiverGetQueueTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call getQueue");
			try {
				Queue foo = tool.getDefaultQueueReceiver().getQueue();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionReceiverGetQueueTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSenderCloseTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:315;
	 * 
	 * 
	 * @test_Strategy: Close default sender and call method on it.
	 */
	@Test
	public void closedQueueSessionSenderCloseTest() throws Exception {
		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call close again");
			tool.getDefaultQueueSender().close();
		} catch (Exception e) {
			throw new Exception("closedQueueSessionSenderCloseTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionGetDeliveryModeTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:303;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionGetDeliveryModeTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call getDeliveryMode");
			try {
				int foo = tool.getDefaultQueueSender().getDeliveryMode();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionGetDeliveryModeTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionGetDisableMessageIDTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:295;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionGetDisableMessageIDTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call getDisableMessageID");
			try {
				boolean foo = tool.getDefaultQueueSender().getDisableMessageID();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionGetDisableMessageIDTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionGetDisableMessageTimestampTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:299;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionGetDisableMessageTimestampTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call getDisableMessageTimestamp");
			try {
				boolean foo = tool.getDefaultQueueSender().getDisableMessageTimestamp();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionGetDisableMessageTimestampTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionGetPriorityTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:307;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionGetPriorityTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call getPriority");
			try {
				int foo = tool.getDefaultQueueSender().getPriority();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionGetPriorityTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionGetTimeToLiveTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:311;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionGetTimeToLiveTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call getTimeToLive");
			try {
				long foo = tool.getDefaultQueueSender().getTimeToLive();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionGetTimeToLiveTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSetDeliveryModeTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:301;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSetDeliveryModeTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call setDeliveryMode");
			try {
				tool.getDefaultQueueSender().setDeliveryMode(Message.DEFAULT_DELIVERY_MODE);
				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSetDeliveryModeTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSetDisableMessageIDTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:293;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSetDisableMessageIDTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call setDisableMessageID");
			try {
				tool.getDefaultQueueSender().setDisableMessageID(true);
				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSetDisableMessageIDTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSetDisableMessageTimestampTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:297;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSetDisableMessageTimestampTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call setDisableMessageTimestamp");
			try {
				tool.getDefaultQueueSender().setDisableMessageTimestamp(true);
				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSetDisableMessageTimestampTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSetPriorityTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:305;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSetPriorityTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call setPriority");
			try {
				tool.getDefaultQueueSender().setPriority(Message.DEFAULT_PRIORITY);
				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}
			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSetPriorityTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSetTimeToLiveTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:309;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSetTimeToLiveTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call setTimeToLive");
			try {
				tool.getDefaultQueueSender().setTimeToLive(Message.DEFAULT_TIME_TO_LIVE);
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSetTimeToLiveTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSenderGetQueueTest
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:196;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSenderGetQueueTest() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call getQueue");
			try {
				Queue foo = tool.getDefaultQueueSender().getQueue();

				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSenderGetQueueTest", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSend1Test
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:198;
	 * 
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSend1Test() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call send(Message)");
			try {
				tool.getDefaultQueueSender().send(new MessageTestImpl());
				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSend1Test", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSend2Test
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:200;
	 * 
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSend2Test() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call send(Message,int,int,long)");
			try {
				tool.getDefaultQueueSender().send(new MessageTestImpl(), Message.DEFAULT_DELIVERY_MODE,
						Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSend2Test", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSend3Test
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:202;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSend3Test() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call send(Queue,Message)");
			try {
				tool.getDefaultQueueSender().send(new MessageTestImpl());
				logger.log(Logger.Level.TRACE, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}

			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSend3Test", e);
		}
	}

	/*
	 * @testName: closedQueueSessionSend4Test
	 * 
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:204;
	 * 
	 * @test_Strategy: Close default sender and call method on it. Check for
	 * IllegalStateException.
	 */
	@Test
	public void closedQueueSessionSend4Test() throws Exception {

		try {
			createAndCloseSession(JmsTool.QUEUE, user, password);
			logger.log(Logger.Level.TRACE, "Try to call send(Queue,Message,int,int,long)");
			try {
				tool.getDefaultQueueSender().send(new MessageTestImpl(), Message.DEFAULT_DELIVERY_MODE,
						Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
				logger.log(Logger.Level.ERROR, "Fail: Exception was not thrown!");
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.TRACE, "Pass: threw expected error");
				return;
			} catch (Exception e) {
				TestUtil.printStackTrace(e);
				logger.log(Logger.Level.TRACE, "Fail: wrong exception: " + e.getClass().getName() + " was returned");
			}
			throw new Exception("Error: failures occurred during tests");

		} catch (Exception e) {
			throw new Exception("closedQueueSessionSend4Test", e);
		}
	}

	/*
	 * @testName: closedQueueSessionRecoverTest
	 *
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:235;
	 *
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionRecoverTest() throws Exception {
		try {
			createAndCloseSession(JmsTool.TX_QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to call recover() with closed session.");
			try {
				tool.getDefaultQueueSession().recover();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception("closedQueueSessionRecoverTest");
		} catch (Exception e) {
			logger.log(Logger.Level.ERROR, "closedQueueSessionRecoverTest failed: ", e);
			throw new Exception("closedQueueSessionRecoverTest", e);
		}
	}

	/*
	 * @testName: closedSessionRecoverTest
	 *
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:636;
	 *
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedSessionRecoverTest() throws Exception {
		String testName = "closedSessionRecoverTest";

		try {
			createAndCloseSession(JmsTool.COMMON_QTX, user, password);
			logger.log(Logger.Level.INFO, "Try to call recover() with closed session.");
			try {
				tool.getDefaultSession().recover();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.ERROR, testName + " failed: ", e);
			throw new Exception(testName);
		}
	}

	/*
	 * @testName: closedQueueSessionCommitTest
	 *
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:229;
	 *
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionCommitTest() throws Exception {
		String testName = "closedQueueSessionCommitTest";

		try {
			createAndCloseSession(JmsTool.TX_QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to call commit with closed session.");
			try {
				tool.getDefaultQueueSession().commit();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.ERROR, testName + " failed: ", e);
			throw new Exception(testName);
		}
	}

	/*
	 * @testName: closedQueueSessionGetTransactedTest
	 *
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:225;
	 *
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionGetTransactedTest() throws Exception {
		String testName = "closedQueueSessionGetTransactedTest";

		try {
			createAndCloseSession(JmsTool.TX_QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to call getTransacted() with closed session.");
			try {
				boolean b = tool.getDefaultQueueSession().getTransacted();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}

			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.ERROR, testName + " failed: ", e);
			throw new Exception(testName);
		}
	}

	/*
	 * @testName: closedQueueSessionRollbackTest
	 *
	 * @assertion_ids: JMS:SPEC:113; JMS:JAVADOC:231;
	 *
	 * @test_Strategy: Close default session and call method on it. Check for proper
	 * JMSException.
	 */
	@Test
	public void closedQueueSessionRollbackTest() throws Exception {
		String testName = "closedQueueSessionRollbackTest";

		try {
			createAndCloseSession(JmsTool.TX_QUEUE, user, password);
			logger.log(Logger.Level.INFO, "Try to call rollback() with closed session.");
			try {
				tool.getDefaultQueueSession().rollback();
			} catch (jakarta.jms.IllegalStateException ise) {
				logger.log(Logger.Level.INFO, "Caught expected exception");
				return;
			}
			throw new Exception(testName);
		} catch (Exception e) {
			logger.log(Logger.Level.TRACE, " " + e.getMessage());
			TestUtil.printStackTrace(e);
			throw new Exception("closedQueueSessionRollbackTest");
		}
	}
}
