summaryrefslogtreecommitdiff
path: root/qpid/java/systests/src
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/systests/src')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java7
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java11
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java22
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java20
-rwxr-xr-xqpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java406
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java207
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java24
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/client/HeartbeatTest.java5
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/client/failover/MultipleBrokersFailoverTest.java28
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/client/ssl/SSLTest.java24
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/server/BrokerStartupTest.java4
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/server/logging/BrokerLoggingTest.java119
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java2
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/LoggingManagementTest.java20
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/ManagementLoggingTest.java8
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/prefetch/ZeroPrefetchTest.java83
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java78
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java3
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java174
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/LogViewerTest.java49
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java149
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java55
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java1
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java4
-rw-r--r--qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java38
25 files changed, 680 insertions, 861 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
index 2c3ad1f8e5..e609d73268 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
@@ -76,7 +76,6 @@ public class Asserts
ConfiguredObject.DESCRIPTION,
ConfiguredObject.CONTEXT,
ConfiguredObject.DESIRED_STATE,
- VirtualHost.SUPPORTED_QUEUE_TYPES,
VirtualHost.TYPE);
assertEquals("Unexpected value of attribute " + VirtualHost.NAME,
@@ -93,12 +92,6 @@ public class Asserts
virtualHost.get(VirtualHost.QUEUE_DEAD_LETTER_QUEUE_ENABLED));
@SuppressWarnings("unchecked")
- Collection<String> exchangeTypes = (Collection<String>) virtualHost.get(VirtualHost.SUPPORTED_EXCHANGE_TYPES);
- assertEquals("Unexpected value of attribute " + VirtualHost.SUPPORTED_EXCHANGE_TYPES,
- new HashSet<String>(Arrays.asList("headers", "topic", "direct", "fanout")),
- new HashSet<String>(exchangeTypes));
-
- @SuppressWarnings("unchecked")
Map<String, Object> statistics = (Map<String, Object>) virtualHost.get(STATISTICS_ATTRIBUTE);
Asserts.assertAttributesPresent(statistics,
"queueCount","exchangeCount","bytesIn","bytesOut","messagesIn", "messagesOut");
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java
index 3af57327d2..4537d1a678 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java
@@ -20,10 +20,19 @@
*/
package org.apache.qpid.test.utils;
+import org.apache.qpid.server.BrokerOptions;
+
public interface BrokerHolder
{
- String getWorkingDirectory();
+ public void start(BrokerOptions options) throws Exception;
void shutdown();
void kill();
String dumpThreads();
+
+ enum BrokerType
+ {
+ EXTERNAL /** Test case relies on a Broker started independently of the test-suite */,
+ INTERNAL /** Test case starts an embedded broker within this JVM */,
+ SPAWNED /** Test case spawns a new broker as a separate process */
+ }
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java
index f980453d49..a76f79f8b0 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java
@@ -21,12 +21,13 @@
package org.apache.qpid.test.utils;
import java.security.PrivilegedAction;
+import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import org.apache.qpid.server.Broker;
-import org.apache.qpid.server.security.auth.TaskPrincipal;
+import org.apache.qpid.server.BrokerOptions;
import org.apache.qpid.server.security.SecurityManager;
import javax.security.auth.Subject;
@@ -35,27 +36,22 @@ public class InternalBrokerHolder implements BrokerHolder
{
private static final Logger LOGGER = Logger.getLogger(InternalBrokerHolder.class);
- private final Broker _broker;
- private final String _workingDirectory;
+ private Broker _broker;
private Set<Integer> _portsUsedByBroker;
- public InternalBrokerHolder(final Broker broker, String workingDirectory, Set<Integer> portsUsedByBroker)
+ public InternalBrokerHolder(Set<Integer> portsUsedByBroker)
{
- if(broker == null)
- {
- throw new IllegalArgumentException("Broker must not be null");
- }
-
- _broker = broker;
- _workingDirectory = workingDirectory;
_portsUsedByBroker = portsUsedByBroker;
}
@Override
- public String getWorkingDirectory()
+ public void start(BrokerOptions options) throws Exception
{
- return _workingDirectory;
+ LOGGER.info("Starting internal broker (same JVM)");
+
+ _broker = new Broker();
+ _broker.startup(options);
}
public void shutdown()
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java
index 9413e38606..12be233c35 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java
@@ -35,27 +35,21 @@ public final class Piper extends Thread
private static final Logger LOGGER = Logger.getLogger(Piper.class);
private final BufferedReader _in;
- private final PrintStream _out;
+ private final Logger _out;
private final String _ready;
private final CountDownLatch _latch;
private final String _stopped;
- private final String _prefix;
private volatile boolean _seenReady;
private volatile String _stopLine;
- public Piper(InputStream in, PrintStream out, String ready, String stopped)
- {
- this(in, out, ready, stopped, null);
- }
-
- public Piper(InputStream in, PrintStream out, String ready, String stopped, String prefix)
+ public Piper(InputStream in, String ready, String stopped, String threadName, String loggerName)
{
+ super(threadName);
_in = new BufferedReader(new InputStreamReader(in));
- _out = out;
+ _out = Logger.getLogger(loggerName);
_ready = ready;
_stopped = stopped;
_seenReady = false;
- _prefix = prefix;
if (this._ready != null && !this._ready.equals(""))
{
@@ -87,11 +81,7 @@ public final class Piper extends Thread
String line;
while ((line = _in.readLine()) != null)
{
- if (_prefix != null)
- {
- line = _prefix + line;
- }
- _out.println(line);
+ _out.info(line);
if (_latch != null && line.contains(_ready))
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
index 369a76a6c6..9a3308603b 100755
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
@@ -18,9 +18,7 @@
package org.apache.qpid.test.utils;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -28,7 +26,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.TimeUnit;
import javax.jms.BytesMessage;
import javax.jms.Connection;
@@ -48,8 +45,10 @@ import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnectionFactory;
@@ -60,7 +59,6 @@ import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.jms.BrokerDetails;
import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.server.Broker;
import org.apache.qpid.server.BrokerOptions;
import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
@@ -83,19 +81,11 @@ public class QpidBrokerTestCase extends QpidTestCase
{
private TaskExecutor _taskExecutor;
- public enum BrokerType
- {
- EXTERNAL /** Test case relies on a Broker started independently of the test-suite */,
- INTERNAL /** Test case starts an embedded broker within this JVM */,
- SPAWNED /** Test case spawns a new broker as a separate process */
- }
-
public static final String GUEST_USERNAME = "guest";
public static final String GUEST_PASSWORD = "guest";
- protected final static String QpidHome = System.getProperty("QPID_HOME");
private final File _configFile = new File(System.getProperty("broker.config"));
- private File _logConfigFile;
+ private File _spawnedBrokerLogConfigFile;
protected final String _brokerStoreType = System.getProperty("broker.config-store-type", "JSON");
protected static final Logger _logger = Logger.getLogger(QpidBrokerTestCase.class);
protected static final int LOGMONITOR_TIMEOUT = 5000;
@@ -128,11 +118,7 @@ public class QpidBrokerTestCase extends QpidTestCase
private static final String BROKER_COMMAND_PLATFORM = "broker.command." + SystemUtils.getOSConfigSuffix();
private static final String BROKER_CLEAN_BETWEEN_TESTS = "broker.clean.between.tests";
private static final String BROKER_VERSION = "broker.version";
- protected static final String BROKER_READY = "broker.ready";
- private static final String BROKER_STOPPED = "broker.stopped";
private static final String TEST_OUTPUT = "test.output";
- private static final String BROKER_LOG_INTERLEAVE = "broker.log.interleave";
- private static final String BROKER_LOG_PREFIX = "broker.log.prefix";
private static final String BROKER_PERSITENT = "broker.persistent";
public static final String PROFILE_USE_SSL = "profile.use_ssl";
@@ -141,41 +127,30 @@ public class QpidBrokerTestCase extends QpidTestCase
public static final int DEFAULT_JMXPORT_REGISTRYSERVER = 8999;
public static final int JMXPORT_CONNECTORSERVER_OFFSET = 100;
public static final int DEFAULT_HTTP_MANAGEMENT_PORT_VALUE = 8080;
- public static final int DEFAULT_HTTPS_MANAGEMENT_PORT_VALUE = 8443;
public static final String TEST_AMQP_PORT_PROTOCOLS_PROPERTY="test.amqp_port_protocols";
// values
protected static final String JAVA = "java";
- protected static final String CPP = "cpp";
-
- protected static final String QPID_HOME = "QPID_HOME";
public static final int DEFAULT_PORT = Integer.getInteger("test.port", DEFAULT_PORT_VALUE);
public static final int FAILING_PORT = Integer.parseInt(System.getProperty("test.port.alt"));
public static final int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", DEFAULT_JMXPORT_REGISTRYSERVER);
public static final int DEFAULT_HTTP_MANAGEMENT_PORT = Integer.getInteger("test.hport", DEFAULT_HTTP_MANAGEMENT_PORT_VALUE);
- public static final int DEFAULT_HTTPS_MANAGEMENT_PORT = Integer.getInteger("test.hsport", DEFAULT_HTTPS_MANAGEMENT_PORT_VALUE);
public static final int DEFAULT_SSL_PORT = Integer.getInteger("test.port.ssl", DEFAULT_SSL_PORT_VALUE);
protected String _brokerLanguage = System.getProperty(BROKER_LANGUAGE, JAVA);
- protected BrokerType _brokerType = BrokerType.valueOf(System.getProperty(BROKER_TYPE, "").toUpperCase());
+ protected BrokerHolder.BrokerType _brokerType = BrokerHolder.BrokerType.valueOf(System.getProperty(BROKER_TYPE, "").toUpperCase());
private static final String BROKER_COMMAND_TEMPLATE = System.getProperty(BROKER_COMMAND_PLATFORM, System.getProperty(BROKER_COMMAND));
- protected BrokerCommandHelper _brokerCommandHelper = new BrokerCommandHelper(BROKER_COMMAND_TEMPLATE);
private Boolean _brokerCleanBetweenTests = Boolean.getBoolean(BROKER_CLEAN_BETWEEN_TESTS);
private final Protocol _brokerProtocol = Protocol.valueOf("AMQP_" + System.getProperty(BROKER_VERSION, " ").substring(1));
protected String _output = System.getProperty(TEST_OUTPUT, System.getProperty("java.io.tmpdir"));
protected Boolean _brokerPersistent = Boolean.getBoolean(BROKER_PERSITENT);
- protected static String _brokerLogPrefix = System.getProperty(BROKER_LOG_PREFIX,"BROKER: ");
- protected static boolean _interleaveBrokerLog = Boolean.valueOf(System.getProperty(BROKER_LOG_INTERLEAVE,"true"));
-
protected File _outputFile;
- protected PrintStream _testcaseOutputStream;
-
protected Map<Integer, BrokerHolder> _brokers = new HashMap<Integer, BrokerHolder>();
protected InitialContext _initialContext;
@@ -195,6 +170,8 @@ public class QpidBrokerTestCase extends QpidTestCase
/** Size to create our message*/
private int _messageSize = DEFAULT_MESSAGE_SIZE;
+ private String _brokerCommandTemplate;
+
/** Type of message*/
protected enum MessageType
{
@@ -210,7 +187,8 @@ public class QpidBrokerTestCase extends QpidTestCase
{
super();
_brokerConfigurations = new HashMap<Integer, TestBrokerConfiguration>();
- initialiseLogConfigFile();
+ initialiseSpawnedBrokerLogConfigFile();
+ _brokerCommandTemplate = BROKER_COMMAND_TEMPLATE;
}
public TestBrokerConfiguration getBrokerConfiguration(int port)
@@ -259,12 +237,12 @@ public class QpidBrokerTestCase extends QpidTestCase
return configuration;
}
- private void initialiseLogConfigFile()
+ private void initialiseSpawnedBrokerLogConfigFile()
{
- _logConfigFile = new File(LOG4J_CONFIG_FILE_PATH);
- if(!_logConfigFile.exists())
+ _spawnedBrokerLogConfigFile = new File(SPAWNED_BROKER_LOG4J_CONFIG_FILE_PATH);
+ if(!_spawnedBrokerLogConfigFile.exists())
{
- throw new RuntimeException("Log config file " + _logConfigFile.getAbsolutePath() + " does not exist");
+ throw new RuntimeException("Log config file " + _spawnedBrokerLogConfigFile.getAbsolutePath() + " does not exist");
}
}
@@ -276,36 +254,18 @@ public class QpidBrokerTestCase extends QpidTestCase
@Override
public void runBare() throws Throwable
{
- String qname = getClass().getName() + "." + getName();
-
// Initialize this for each test run
_env = new HashMap<String, String>();
- PrintStream oldOut = System.out;
- PrintStream oldErr = System.err;
- PrintStream out = null;
- PrintStream err = null;
+ // Log4j properties expects this to be set
+ System.setProperty("qpid.testMethod", "-" + getName());
+ System.setProperty("qpid.testClass", getClass().getName());
- boolean redirected = _output != null && _output.length() > 0;
- if (redirected)
- {
- _outputFile = new File(String.format("%s/TEST-%s.out", _output, qname));
- out = new PrintStream(new FileOutputStream(_outputFile), true);
- err = new PrintStream(String.format("%s/TEST-%s.err", _output, qname));
+ String log4jConfigFile = System.getProperty("log4j.configuration.file");
+ DOMConfigurator.configure(log4jConfigFile);
- System.setOut(out);
- System.setErr(err);
-
- if (_interleaveBrokerLog)
- {
- _testcaseOutputStream = out;
- }
- else
- {
- _testcaseOutputStream = new PrintStream(new FileOutputStream(String
- .format("%s/TEST-%s.broker.out", _output, qname)), true);
- }
- }
+ // get log file from file appender
+ _outputFile = new File(((FileAppender)LogManager.getRootLogger().getAllAppenders().nextElement()).getFile());
try
{
@@ -324,7 +284,7 @@ public class QpidBrokerTestCase extends QpidTestCase
revertSystemProperties();
revertLoggingLevels();
- if(_brokerCleanBetweenTests)
+ if (_brokerCleanBetweenTests)
{
final String qpidWork = System.getProperty("QPID_WORK");
cleanBrokerWork(qpidWork);
@@ -333,17 +293,7 @@ public class QpidBrokerTestCase extends QpidTestCase
_logger.info("========== stop " + getTestName() + " ==========");
- if (redirected)
- {
- System.setErr(oldErr);
- System.setOut(oldOut);
- err.close();
- out.close();
- if (!_interleaveBrokerLog)
- {
- _testcaseOutputStream.close();
- }
- }
+ LogManager.resetConfiguration();
}
}
@@ -403,7 +353,7 @@ public class QpidBrokerTestCase extends QpidTestCase
protected int getPort(int port)
{
- if (!_brokerType.equals(BrokerType.EXTERNAL))
+ if (!_brokerType.equals(BrokerHolder.BrokerType.EXTERNAL))
{
return port == 0 ? DEFAULT_PORT : port;
}
@@ -425,28 +375,33 @@ public class QpidBrokerTestCase extends QpidTestCase
public void startBroker(int port, boolean managementMode) throws Exception
{
+ startBroker(port, managementMode, null);
+ }
+
+ public void startBroker(int port, boolean managementMode, String log4jFile) throws Exception
+ {
int actualPort = getPort(port);
TestBrokerConfiguration configuration = getBrokerConfiguration(actualPort);
- startBroker(actualPort, configuration, managementMode);
+ startBroker(actualPort, configuration, managementMode, log4jFile);
}
protected File getBrokerCommandLog4JFile()
{
- return _logConfigFile;
+ return _spawnedBrokerLogConfigFile;
}
protected void setBrokerCommandLog4JFile(File file)
{
- _logConfigFile = file;
+ _spawnedBrokerLogConfigFile = file;
_logger.info("Modified log config file to: " + file);
}
- public void startBroker(int port, TestBrokerConfiguration testConfiguration) throws Exception
+ public void startBroker(int port, TestBrokerConfiguration testConfiguration, String log4jFile) throws Exception
{
- startBroker(port, testConfiguration, false);
+ startBroker(port, testConfiguration, false, log4jFile);
}
- public void startBroker(int port, TestBrokerConfiguration testConfiguration, boolean managementMode) throws Exception
+ protected void startBroker(int port, TestBrokerConfiguration testConfiguration, boolean managementMode, String log4jFile) throws Exception
{
port = getPort(port);
@@ -455,181 +410,12 @@ public class QpidBrokerTestCase extends QpidTestCase
throw new IllegalStateException("There is already an existing broker running on port " + port);
}
- Set<Integer> portsUsedByBroker = guessAllPortsUsedByBroker(port);
String testConfig = saveTestConfiguration(port, testConfiguration);
-
- if (_brokerType.equals(BrokerType.INTERNAL) && !existingInternalBroker())
- {
- setSystemProperty(BrokerProperties.PROPERTY_USE_CUSTOM_RMI_SOCKET_FACTORY, "false");
- BrokerOptions options = new BrokerOptions();
-
- options.setConfigurationStoreType(_brokerStoreType);
- options.setConfigurationStoreLocation(testConfig);
- options.setManagementMode(managementMode);
- if (managementMode)
- {
- options.setManagementModePassword(MANAGEMENT_MODE_PASSWORD);
- }
-
- //Set the log config file, relying on the log4j.configuration system property
- //set on the JVM by the JUnit runner task in module.xml.
- options.setLogConfigFileLocation(_logConfigFile.getAbsolutePath());
-
- Broker broker = new Broker();
- _logger.info("Starting internal broker (same JVM)");
- broker.startup(options);
-
- _brokers.put(port, new InternalBrokerHolder(broker, System.getProperty("QPID_WORK"), portsUsedByBroker));
- }
- else if (!_brokerType.equals(BrokerType.EXTERNAL))
- {
- // Add the port to QPID_WORK to ensure unique working dirs for multi broker tests
- final String qpidWork = getQpidWork(_brokerType, port);
-
- String[] cmd = _brokerCommandHelper.getBrokerCommand(port, testConfig, _brokerStoreType, _logConfigFile);
- if (managementMode)
- {
- String[] newCmd = new String[cmd.length + 3];
- System.arraycopy(cmd, 0, newCmd, 0, cmd.length);
- newCmd[cmd.length] = "-mm";
- newCmd[cmd.length + 1] = "-mmpass";
- newCmd[cmd.length + 2] = MANAGEMENT_MODE_PASSWORD;
- cmd = newCmd;
- }
- _logger.info("Starting spawn broker using command: " + StringUtils.join(cmd, ' '));
- ProcessBuilder pb = new ProcessBuilder(cmd);
- pb.redirectErrorStream(true);
- Map<String, String> processEnv = pb.environment();
- String qpidHome = System.getProperty(QPID_HOME);
- processEnv.put(QPID_HOME, qpidHome);
- //Augment Path with bin directory in QPID_HOME.
- boolean foundPath = false;
- final String pathEntry = qpidHome + File.separator + "bin";
- for(Map.Entry<String,String> entry : processEnv.entrySet())
- {
- if(entry.getKey().equalsIgnoreCase("path"))
- {
- entry.setValue(entry.getValue().concat(File.pathSeparator + pathEntry));
- foundPath = true;
- }
- }
- if(!foundPath)
- {
- processEnv.put("PATH", pathEntry);
-
- }
- //Add the test name to the broker run.
- // DON'T change PNAME, qpid.stop needs this value.
- processEnv.put("QPID_PNAME", "-DPNAME=QPBRKR -DTNAME=\"" + getTestName() + "\"");
- processEnv.put("QPID_WORK", qpidWork);
-
- // Use the environment variable to set amqj.logging.level for the broker
- // The value used is a 'server' value in the test configuration to
- // allow a differentiation between the client and broker logging levels.
- if (System.getProperty("amqj.server.logging.level") != null)
- {
- setBrokerEnvironment("AMQJ_LOGGING_LEVEL", System.getProperty("amqj.server.logging.level"));
- }
-
- // Add all the environment settings the test requested
- if (!_env.isEmpty())
- {
- for (Map.Entry<String, String> entry : _env.entrySet())
- {
- processEnv.put(entry.getKey(), entry.getValue());
- }
- }
-
- String qpidOpts = "";
-
- // a synchronized hack to avoid adding into QPID_OPTS the values
- // of JVM properties "test.virtualhosts" and "test.config" set by a concurrent startup process
- synchronized (_propertiesSetForBroker)
- {
- // Add default test logging levels that are used by the log4j-test
- // Use the convenience methods to push the current logging setting
- // in to the external broker's QPID_OPTS string.
- setSystemProperty("amqj.protocol.logging.level");
- setSystemProperty("root.logging.level");
-
- setSystemProperty("test.port");
- setSystemProperty("test.mport");
- setSystemProperty("test.cport");
- setSystemProperty("test.hport");
- setSystemProperty("test.hsport");
- setSystemProperty("test.port.ssl");
- setSystemProperty("test.port.alt");
- setSystemProperty("test.port.alt.ssl");
- setSystemProperty("test.amqp_port_protocols");
-
- setSystemProperty("virtualhostnode.type");
- setSystemProperty("virtualhostnode.context.blueprint");
-
- // Add all the specified system properties to QPID_OPTS
- if (!_propertiesSetForBroker.isEmpty())
- {
- for (String key : _propertiesSetForBroker.keySet())
- {
- qpidOpts += " -D" + key + "=" + _propertiesSetForBroker.get(key);
- }
- }
- }
- if (processEnv.containsKey("QPID_OPTS"))
- {
- qpidOpts = processEnv.get("QPID_OPTS") + qpidOpts;
- }
- processEnv.put("QPID_OPTS", qpidOpts);
-
- // cpp broker requires that the work directory is created
- createBrokerWork(qpidWork);
-
- Process process = pb.start();
-
- Piper p = new Piper(process.getInputStream(),
- _testcaseOutputStream,
- System.getProperty(BROKER_READY),
- System.getProperty(BROKER_STOPPED),
- _interleaveBrokerLog ? _brokerLogPrefix : null);
-
- p.start();
- StringBuilder cmdLine = new StringBuilder(cmd[0]);
- for(int i = 1; i< cmd.length; i++)
- {
- cmdLine.append(' ');
- cmdLine.append(cmd[i]);
- }
-
- SpawnedBrokerHolder holder = new SpawnedBrokerHolder(process, qpidWork, portsUsedByBroker, cmdLine.toString());
- if (!p.await(30, TimeUnit.SECONDS))
- {
- _logger.info("broker failed to become ready (" + p.getReady() + "):" + p.getStopLine());
- String threadDump = holder.dumpThreads();
- if (!threadDump.isEmpty())
- {
- _logger.info("the result of a try to capture thread dump:" + threadDump);
- }
- //Ensure broker has stopped
- process.destroy();
- cleanBrokerWork(qpidWork);
- throw new RuntimeException("broker failed to become ready:"
- + p.getStopLine());
- }
-
- try
- {
- //test that the broker is still running and hasn't exited unexpectedly
- int exit = process.exitValue();
- _logger.info("broker aborted: " + exit);
- cleanBrokerWork(qpidWork);
- throw new RuntimeException("broker aborted: " + exit);
- }
- catch (IllegalThreadStateException e)
- {
- // this is expect if the broker started successfully
- }
-
- _brokers.put(port, holder);
- }
+ String log4jConfig = log4jFile == null ? getBrokerCommandLog4JFile().getAbsolutePath() : log4jFile;
+ BrokerOptions options = getBrokerOptions(managementMode, testConfig, log4jConfig, log4jFile == null);
+ BrokerHolder holder = new BrokerHolderFactory().create(_brokerType, port, this);
+ _brokers.put(port, holder);
+ holder.start(options);
}
private boolean existingInternalBroker()
@@ -645,21 +431,6 @@ public class QpidBrokerTestCase extends QpidTestCase
return false;
}
- private String getQpidWork(BrokerType broker, int port)
- {
- if (!broker.equals(BrokerType.EXTERNAL))
- {
- return System.getProperty("QPID_WORK")+ "/" + port;
- }
-
- return System.getProperty("QPID_WORK");
- }
-
- public String getTestConfigFile()
- {
- return getTestConfigFile(getPort());
- }
-
public String getTestConfigFile(int port)
{
return _output + File.separator + getTestQueueName() + "-" + port + "-config";
@@ -1035,7 +806,7 @@ public class QpidBrokerTestCase extends QpidTestCase
protected boolean isInternalBroker()
{
- return _brokerType.equals(BrokerType.INTERNAL);
+ return _brokerType.equals(BrokerHolder.BrokerType.INTERNAL);
}
protected boolean isBrokerStorePersistent()
@@ -1397,16 +1168,6 @@ public class QpidBrokerTestCase extends QpidTestCase
return message;
}
- protected int getMessageSize()
- {
- return _messageSize;
- }
-
- protected void setMessageSize(int byteSize)
- {
- _messageSize = byteSize;
- }
-
public BrokerDetails getBroker()
{
try
@@ -1453,4 +1214,91 @@ public class QpidBrokerTestCase extends QpidTestCase
session.commit();
session.close();
}
+
+ protected BrokerOptions getBrokerOptions( boolean managementMode, String testConfig, String log4jConfig, boolean skipLoggingConfiguration)
+ {
+ BrokerOptions options = new BrokerOptions();
+
+ options.setConfigurationStoreType(_brokerStoreType);
+ options.setConfigurationStoreLocation(testConfig);
+ options.setManagementMode(managementMode);
+ if (managementMode)
+ {
+ options.setManagementModePassword(MANAGEMENT_MODE_PASSWORD);
+ }
+ options.setSkipLoggingConfiguration(skipLoggingConfiguration);
+ options.setLogConfigFileLocation(log4jConfig);
+ options.setStartupLoggedToSystemOut(false);
+ return options;
+ }
+
+ private Map<String, String> getJvmProperties()
+ {
+ Map<String,String> jvmOptions = new HashMap();
+ synchronized (_propertiesSetForBroker)
+ {
+ jvmOptions.putAll(_propertiesSetForBroker);
+
+ copySystemProperty("amqj.protocol.logging.level", jvmOptions);
+ copySystemProperty("root.logging.level", jvmOptions);
+
+ copySystemProperty("test.port", jvmOptions);
+ copySystemProperty("test.mport", jvmOptions);
+ copySystemProperty("test.cport", jvmOptions);
+ copySystemProperty("test.hport", jvmOptions);
+ copySystemProperty("test.hsport", jvmOptions);
+ copySystemProperty("test.port.ssl", jvmOptions);
+ copySystemProperty("test.port.alt", jvmOptions);
+ copySystemProperty("test.port.alt.ssl", jvmOptions);
+ copySystemProperty("test.amqp_port_protocols", jvmOptions);
+
+ copySystemProperty("virtualhostnode.type", jvmOptions);
+ copySystemProperty("virtualhostnode.context.blueprint", jvmOptions);
+ }
+ return jvmOptions;
+ }
+
+ private void copySystemProperty(String name, Map<String, String> jvmOptions)
+ {
+ String value = System.getProperty(name);
+ if (value != null)
+ {
+ jvmOptions.put(name, value);
+ }
+ }
+
+ private Map<String, String> getEnvironmentProperties()
+ {
+ return new HashMap<>(_env);
+ }
+
+ private String getBrokerCommandTemplate()
+ {
+ return _brokerCommandTemplate;
+ }
+
+ public static class BrokerHolderFactory
+ {
+
+ public BrokerHolder create(BrokerHolder.BrokerType brokerType, int port, QpidBrokerTestCase testCase)
+ {
+ Set<Integer> portsUsedByBroker = testCase.guessAllPortsUsedByBroker(port);
+ BrokerHolder holder = null;
+ if (brokerType.equals(BrokerHolder.BrokerType.INTERNAL) && !testCase.existingInternalBroker())
+ {
+ testCase.setSystemProperty(BrokerProperties.PROPERTY_USE_CUSTOM_RMI_SOCKET_FACTORY, "false");
+ holder = new InternalBrokerHolder(portsUsedByBroker);
+ }
+ else if (!brokerType.equals(BrokerHolder.BrokerType.EXTERNAL))
+ {
+
+ Map<String,String> jvmOptions = testCase.getJvmProperties();
+ Map<String,String> environmentProperties = testCase.getEnvironmentProperties();
+
+ holder = new SpawnedBrokerHolder(testCase.getBrokerCommandTemplate(), port, testCase.getTestName(), jvmOptions, environmentProperties, brokerType, portsUsedByBroker);
+ }
+ return holder;
+ }
+ }
+
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
index 4b747e869c..2581093f97 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/SpawnedBrokerHolder.java
@@ -22,6 +22,7 @@ package org.apache.qpid.test.utils;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -30,39 +31,215 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
+import org.apache.qpid.server.BrokerOptions;
+import org.apache.qpid.server.configuration.BrokerProperties;
+import org.apache.qpid.server.logging.messages.BrokerMessages;
+import org.apache.qpid.util.FileUtils;
import org.apache.qpid.util.SystemUtils;
public class SpawnedBrokerHolder implements BrokerHolder
{
private static final Logger LOGGER = Logger.getLogger(SpawnedBrokerHolder.class);
+ protected static final String BROKER_READY = System.getProperty("broker.ready", BrokerMessages.READY().toString());
+ private static final String BROKER_STOPPED = System.getProperty("broker.stopped", BrokerMessages.STOPPED().toString());
- private final Process _process;
- private final Integer _pid;
- private final String _workingDirectory;
+ private final BrokerType _type;
+ private final int _port;
+ private final String _name;
+ private final Map<String, String> _jvmOptions;
+ private final Map<String, String> _environmentSettings;
+ protected BrokerCommandHelper _brokerCommandHelper;
+
+ private Process _process;
+ private Integer _pid;
private Set<Integer> _portsUsedByBroker;
- private final String _brokerCommand;
+ private String _brokerCommand;
+
+ public SpawnedBrokerHolder(String brokerCommandTemplate, int port, String name, Map<String, String> jvmOptions, Map<String, String> environmentSettings, BrokerType type, Set<Integer> portsUsedByBroker)
+ {
+ _type = type;
+ _portsUsedByBroker = portsUsedByBroker;
+ _port = port;
+ _name = name;
+ _jvmOptions = jvmOptions;
+ _environmentSettings = environmentSettings;
+ _brokerCommandHelper = new BrokerCommandHelper(brokerCommandTemplate);
+ }
- public SpawnedBrokerHolder(final Process process, final String workingDirectory, Set<Integer> portsUsedByBroker,
- String brokerCmd)
+
+ @Override
+ public void start(BrokerOptions brokerOptions) throws Exception
{
- if(process == null)
+ // Add the port to QPID_WORK to ensure unique working dirs for multi broker tests
+ final String qpidWork = getQpidWork(_type, _port);
+
+ String[] cmd = _brokerCommandHelper.getBrokerCommand(_port, brokerOptions.getConfigurationStoreLocation(), brokerOptions.getConfigurationStoreType(),
+ new File(brokerOptions.getLogConfigFileLocation()));
+ if (brokerOptions.isManagementMode())
+ {
+ String[] newCmd = new String[cmd.length + 3];
+ System.arraycopy(cmd, 0, newCmd, 0, cmd.length);
+ newCmd[cmd.length] = "-mm";
+ newCmd[cmd.length + 1] = "-mmpass";
+ newCmd[cmd.length + 2] = brokerOptions.getManagementModePassword();
+ cmd = newCmd;
+ }
+ ProcessBuilder pb = new ProcessBuilder(cmd);
+ pb.redirectErrorStream(true);
+ Map<String, String> processEnv = pb.environment();
+ String qpidHome = System.getProperty(BrokerProperties.PROPERTY_QPID_HOME);
+ processEnv.put(BrokerProperties.PROPERTY_QPID_HOME, qpidHome);
+
+ //Augment Path with bin directory in QPID_HOME.
+ boolean foundPath = false;
+ final String pathEntry = qpidHome + File.separator + "bin";
+ for(Map.Entry<String,String> entry : processEnv.entrySet())
+ {
+ if(entry.getKey().equalsIgnoreCase("path"))
+ {
+ entry.setValue(entry.getValue().concat(File.pathSeparator + pathEntry));
+ foundPath = true;
+ }
+ }
+ if(!foundPath)
+ {
+ processEnv.put("PATH", pathEntry);
+ }
+ //Add the test name to the broker run.
+ // DON'T change PNAME, qpid.stop needs this value.
+ processEnv.put("QPID_PNAME", "-DPNAME=QPBRKR -DTNAME=\"" + _name + "\"");
+ processEnv.put("QPID_WORK", qpidWork);
+
+ // Use the environment variable to set amqj.logging.level for the broker
+ // The value used is a 'server' value in the test configuration to
+ // allow a differentiation between the client and broker logging levels.
+ if (System.getProperty("amqj.server.logging.level") != null)
+ {
+ processEnv.put("AMQJ_LOGGING_LEVEL", System.getProperty("amqj.server.logging.level"));
+ }
+
+ // Add all the environment settings the test requested
+ if (!_environmentSettings.isEmpty())
+ {
+ for (Map.Entry<String, String> entry : _environmentSettings.entrySet())
+ {
+ processEnv.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ String qpidOpts = "";
+
+ // Add all the specified system properties to QPID_OPTS
+ if (!_jvmOptions.isEmpty())
{
- throw new IllegalArgumentException("Process must not be null");
+ for (String key : _jvmOptions.keySet())
+ {
+ qpidOpts += " -D" + key + "=" + _jvmOptions.get(key);
+ }
}
- _process = process;
+ if (processEnv.containsKey("QPID_OPTS"))
+ {
+ qpidOpts = processEnv.get("QPID_OPTS") + qpidOpts;
+ }
+ processEnv.put("QPID_OPTS", qpidOpts);
+
+ // cpp broker requires that the work directory is created
+ createBrokerWork(qpidWork);
+
+ _process = pb.start();
+
+ Piper standardOutputPiper = new Piper(_process.getInputStream(),
+ BROKER_READY,
+ BROKER_STOPPED,
+ "STD", "BROKER-" + _port);
+
+ standardOutputPiper.start();
+
+ new Piper(_process.getErrorStream(), null, null, "ERROR", "BROKER-" + _port).start();
+
+ StringBuilder cmdLine = new StringBuilder(cmd[0]);
+ for(int i = 1; i< cmd.length; i++)
+ {
+ cmdLine.append(' ');
+ cmdLine.append(cmd[i]);
+ }
+
+ _brokerCommand = cmdLine.toString();
_pid = retrieveUnixPidIfPossible();
- _workingDirectory = workingDirectory;
- _portsUsedByBroker = portsUsedByBroker;
- _brokerCommand = brokerCmd;
+
+ if (!standardOutputPiper.await(30, TimeUnit.SECONDS))
+ {
+ LOGGER.info("broker failed to become ready (" + standardOutputPiper.getReady() + "):" + standardOutputPiper.getStopLine());
+ String threadDump = dumpThreads();
+ if (!threadDump.isEmpty())
+ {
+ LOGGER.info("the result of a try to capture thread dump:" + threadDump);
+ }
+ //Ensure broker has stopped
+ _process.destroy();
+ cleanBrokerWork(qpidWork);
+ throw new RuntimeException("broker failed to become ready:"
+ + standardOutputPiper.getStopLine());
+ }
+
+ try
+ {
+ //test that the broker is still running and hasn't exited unexpectedly
+ int exit = _process.exitValue();
+ LOGGER.info("broker aborted: " + exit);
+ cleanBrokerWork(qpidWork);
+ throw new RuntimeException("broker aborted: " + exit);
+ }
+ catch (IllegalThreadStateException e)
+ {
+ // this is expect if the broker started successfully
+ }
+
}
- @Override
- public String getWorkingDirectory()
+ protected void createBrokerWork(final String qpidWork)
{
- return _workingDirectory;
+ if (qpidWork != null)
+ {
+ final File dir = new File(qpidWork);
+ dir.mkdirs();
+ if (!dir.isDirectory())
+ {
+ throw new RuntimeException("Failed to created Qpid work directory : " + qpidWork);
+ }
+ }
+ }
+
+ private String getQpidWork(BrokerType broker, int port)
+ {
+ if (!broker.equals(BrokerType.EXTERNAL))
+ {
+ return System.getProperty(BrokerProperties.PROPERTY_QPID_WORK) + File.separator + port;
+ }
+
+ return System.getProperty(BrokerProperties.PROPERTY_QPID_WORK);
+ }
+
+ private void cleanBrokerWork(final String qpidWork)
+ {
+ if (qpidWork != null)
+ {
+ LOGGER.info("Cleaning broker work dir: " + qpidWork);
+
+ File file = new File(qpidWork);
+ if (file.exists())
+ {
+ final boolean success = FileUtils.delete(file, true);
+ if(!success)
+ {
+ throw new RuntimeException("Failed to recursively delete beneath : " + file);
+ }
+ }
+ }
}
public void shutdown()
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java
index fb254f59ae..549edcd650 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java
@@ -44,21 +44,7 @@ import org.apache.qpid.server.BrokerOptions;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.logging.LogRecorder;
-import org.apache.qpid.server.model.AbstractSystemConfig;
-import org.apache.qpid.server.model.AccessControlProvider;
-import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.BrokerModel;
-import org.apache.qpid.server.model.BrokerShutdownProvider;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.GroupProvider;
-import org.apache.qpid.server.model.JsonSystemConfigImpl;
-import org.apache.qpid.server.model.Plugin;
-import org.apache.qpid.server.model.PreferencesProvider;
-import org.apache.qpid.server.model.SystemConfig;
-import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.model.VirtualHostAlias;
-import org.apache.qpid.server.model.VirtualHostNode;
+import org.apache.qpid.server.model.*;
import org.apache.qpid.server.model.adapter.FileBasedGroupProvider;
import org.apache.qpid.server.model.adapter.FileBasedGroupProviderImpl;
import org.apache.qpid.server.plugin.PluggableFactoryLoader;
@@ -108,7 +94,7 @@ public class TestBrokerConfiguration
final AbstractSystemConfig parentObject = new JsonSystemConfigImpl(taskExecutor,
mock(EventLogger.class),
mock(LogRecorder.class),
- brokerOptions,
+ brokerOptions.convertToSystemConfigAttributes(),
mock(BrokerShutdownProvider.class));
ConfiguredObjectRecordConverter converter = new ConfiguredObjectRecordConverter(BrokerModel.getInstance());
@@ -216,10 +202,13 @@ public class TestBrokerConfiguration
SystemConfigFactory configFactory =
(new PluggableFactoryLoader<>(SystemConfigFactory.class)).get(_storeType);
+ Map<String, Object> attributes = new HashMap<>(brokerOptions.convertToSystemConfigAttributes());
+ attributes.put(SystemConfig.STARTUP_LOGGED_TO_SYSTEM_OUT, false);
+ attributes.put(ConfiguredObject.DESIRED_STATE, State.QUIESCED);
final SystemConfig parentObject = configFactory.newInstance(_taskExecutor,
mock(EventLogger.class),
mock(LogRecorder.class),
- brokerOptions,
+ attributes,
mock(BrokerShutdownProvider.class));
parentObject.open();
@@ -252,6 +241,7 @@ public class TestBrokerConfiguration
configurationStore.openConfigurationStore(parentObject,true,initialRecords.toArray(new ConfiguredObjectRecord[initialRecords.size()]));
configurationStore.closeConfigurationStore();
+ parentObject.close();
return true;
}
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/client/HeartbeatTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/client/HeartbeatTest.java
index 881a37a970..6612fedd35 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/client/HeartbeatTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/client/HeartbeatTest.java
@@ -120,12 +120,15 @@ public class HeartbeatTest extends QpidBrokerTestCase
sendConn.setHeartbeatListener(sendListener);
receiveConn.start();
+ // Start the flow of messages to the consumer
+ consumer.receiveNoWait();
+
for(int i = 0; i < 5; i++)
{
producer.send(senderSession.createTextMessage("Msg " + i));
Thread.sleep(500);
assertNotNull("Expected to received message", consumer.receive(500));
- // Consumer does not ack the message in order to generate no bytes from consumer back to Broker
+ // Consumer does not ack the message in order that no bytes flow from consumer connection back to Broker
}
assertTrue("Too few heartbeats sent "+ receiveListener.getHeartbeatsSent() +" (expected at least 2)", receiveListener.getHeartbeatsSent()>=2);
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/client/failover/MultipleBrokersFailoverTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/client/failover/MultipleBrokersFailoverTest.java
index 15ec0f9a4d..c59b0ecf34 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/client/failover/MultipleBrokersFailoverTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/client/failover/MultipleBrokersFailoverTest.java
@@ -38,7 +38,6 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionURL;
import org.apache.qpid.jms.ConnectionListener;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.test.utils.TestUtils;
import org.apache.qpid.util.FileUtils;
public class MultipleBrokersFailoverTest extends QpidBrokerTestCase implements ConnectionListener
@@ -48,9 +47,10 @@ public class MultipleBrokersFailoverTest extends QpidBrokerTestCase implements C
private static final String FAILOVER_VIRTUAL_HOST = "failover";
private static final String NON_FAILOVER_VIRTUAL_HOST = "nonfailover";
private static final String BROKER_PORTION_FORMAT = "tcp://localhost:%d?connectdelay='%d',retries='%d'";
- private static final int FAILOVER_RETRIES = 1;
- private static final int FAILOVER_CONNECTDELAY = 1000;
- private static final int FAILOVER_FACTOR = 4;
+ private static final int FAILOVER_RETRIES = 0;
+ private static final int FAILOVER_CONNECTDELAY = 0;
+ private static final int FAILOVER_AWAIT_TIME = 10000;
+
private int[] _brokerPorts;
private AMQConnectionURL _connectionURL;
@@ -169,7 +169,7 @@ public class MultipleBrokersFailoverTest extends QpidBrokerTestCase implements C
killBroker(_brokerPorts[1]);
- awaitForFailoverCompletion(FAILOVER_CONNECTDELAY * _brokerPorts.length * FAILOVER_FACTOR);
+ awaitForFailoverCompletion(FAILOVER_AWAIT_TIME);
assertEquals("Failover is not started as expected", 0, _failoverStarted.getCount());
assertSendReceive(2);
@@ -185,7 +185,7 @@ public class MultipleBrokersFailoverTest extends QpidBrokerTestCase implements C
stopBroker(_brokerPorts[1]);
- awaitForFailoverCompletion(FAILOVER_CONNECTDELAY * _brokerPorts.length * FAILOVER_FACTOR);
+ awaitForFailoverCompletion(FAILOVER_AWAIT_TIME);
assertEquals("Failover is not started as expected", 0, _failoverStarted.getCount());
assertSendReceive(1);
@@ -214,20 +214,12 @@ public class MultipleBrokersFailoverTest extends QpidBrokerTestCase implements C
}
}
- private void awaitForFailoverCompletion(long delay)
+ private void awaitForFailoverCompletion(long delay) throws Exception
{
_logger.info("Awaiting Failover completion..");
- try
- {
- if (!_failoverComplete.await(delay, TimeUnit.MILLISECONDS))
- {
- _logger.warn("Test thread stack:\n\n" + TestUtils.dumpThreads());
- fail("Failover did not complete");
- }
- }
- catch (InterruptedException e)
+ if (!_failoverComplete.await(delay, TimeUnit.MILLISECONDS))
{
- fail("Test was interrupted:" + e.getMessage());
+ fail("Failover did not complete within " + delay + "ms.");
}
}
@@ -239,7 +231,7 @@ public class MultipleBrokersFailoverTest extends QpidBrokerTestCase implements C
receivedMessage instanceof TextMessage);
}
- private void init(int acknowledgeMode, boolean startConnection) throws JMSException
+ private void init(int acknowledgeMode, boolean startConnection) throws Exception
{
boolean isTransacted = acknowledgeMode == Session.SESSION_TRANSACTED ? true : false;
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/client/ssl/SSLTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/client/ssl/SSLTest.java
index 1dba5ced9d..7c82ea8e55 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/client/ssl/SSLTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/client/ssl/SSLTest.java
@@ -94,6 +94,29 @@ public class SSLTest extends QpidBrokerTestCase
}
}
+ public void testSSLConnectionToPlainPortRejected() throws Exception
+ {
+ if (shouldPerformTest())
+ {
+ super.setUp();
+
+ String url = "amqp://guest:guest@test/?brokerlist='tcp://localhost:%s" +
+ "?ssl='true''";
+
+ url = String.format(url,QpidBrokerTestCase.DEFAULT_PORT);
+
+ try
+ {
+ getConnection(new AMQConnectionURL(url));
+ fail("Exception not thrown");
+ }
+ catch (JMSException e)
+ {
+ assertTrue("Unexpected exception message", e.getMessage().contains("Unrecognized SSL message, plaintext connection?"));
+ }
+ }
+ }
+
public void testHostVerificationIsOnByDefault() throws Exception
{
if (shouldPerformTest())
@@ -116,6 +139,7 @@ public class SSLTest extends QpidBrokerTestCase
try
{
getConnection(new AMQConnectionURL(url));
+ fail("Exception not thrown");
}
catch(JMSException e)
{
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/server/BrokerStartupTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/server/BrokerStartupTest.java
index e267bf439b..c475432113 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/server/BrokerStartupTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/server/BrokerStartupTest.java
@@ -77,7 +77,7 @@ public class BrokerStartupTest extends AbstractTestLogging
brokerConfigFile.delete();
}
- startBroker(port, null);
+ startBroker(port, null, null);
AMQConnectionURL url = new AMQConnectionURL(String.format("amqp://"
+ GUEST_USERNAME
@@ -209,7 +209,7 @@ public class BrokerStartupTest extends AbstractTestLogging
brokerConfigFile.delete();
}
- startBroker(port, null);
+ startBroker(port, null, null);
AMQConnectionURL url = new AMQConnectionURL(String.format("amqp://"
+ GUEST_USERNAME
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/BrokerLoggingTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
index 4952c4e10e..f7953e56d1 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/server/logging/BrokerLoggingTest.java
@@ -22,13 +22,15 @@ package org.apache.qpid.server.logging;
import junit.framework.AssertionFailedError;
-import org.apache.qpid.server.BrokerOptions;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.LogManager;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.Transport;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
import org.apache.qpid.transport.ConnectionException;
import org.apache.qpid.util.LogMonitor;
+import java.io.File;
import java.io.IOException;
import java.net.Socket;
import java.util.Collections;
@@ -59,6 +61,7 @@ public class BrokerLoggingTest extends AbstractTestLogging
private static final Pattern BROKER_MESSAGE_LOG_PATTERN = Pattern.compile(BROKER_MESSAGE_LOG_REG_EXP);
private static final String BRK_LOG_PREFIX = "BRK-";
+ @Override
public void setUp() throws Exception
{
setLogMessagePrefix();
@@ -146,94 +149,6 @@ public class BrokerLoggingTest extends AbstractTestLogging
/**
* Description:
- * On startup the broker must report correctly report the log4j file in use. This is important as it can help diagnose why logging messages are not being reported.
- * Input:
- * No custom -l value should be provided on the command line so that the default value is correctly reported.
- * Output:
- *
- * <date> MESSAGE BRK-1007 : Using logging configuration : <$QPID_HOME>/etc/log4j.xml
- *
- * Validation Steps:
- *
- * 1. The BRK ID is correct
- * 2. This occurs before the BRK-1001 startup message.
- * 3. The log4j file is the full path to the file specified on the commandline.
- *
- * @throws Exception caused by broker startup
- */
- public void testBrokerStartupDefaultLog4j() throws Exception
- {
- if (isJavaBroker() && isExternalBroker() && !isInternalBroker())
- {
- String TESTID = "BRK-1007";
-
- _brokerCommandHelper.removeBrokerCommandLog4JFile();
-
- startBroker();
-
- // Now we can create the monitor as _outputFile will now be defined
- _monitor = new LogMonitor(_outputFile);
-
- // Ensure broker has fully started up.
- getConnection();
-
- // Ensure we wait for TESTID to be logged
- waitAndFindMatches(TESTID);
-
- List<String> results = waitAndFindMatches(BRK_LOG_PREFIX);
- try
- {
- // Validation
-
- assertTrue("BRKer message not logged", results.size() > 0);
-
- boolean validation = false;
- for (String rawLog : results)
- {
- // We don't care about messages after we have our log config
- if (validation)
- {
- break;
- }
-
- String log = getLog(rawLog);
-
- // Ensure we do not have a BRK-1001 message before
- if (!getMessageID(log).equals(TESTID))
- {
- assertFalse(getMessageID(log).equals("BRK-1001"));
- continue;
- }
-
- //1
- validateMessageID(TESTID, log);
-
- //2
- //There will be 1 copy of this startup message (via SystemOut)
- assertEquals("Unexpected log4j configuration message count.",
- 1, findMatches(TESTID).size());
-
- //3
- String defaultLog4j = System.getProperty(QPID_HOME) + "/" + BrokerOptions.DEFAULT_LOG_CONFIG_FILE;
- assertTrue("Log4j file(" + defaultLog4j + ") details not correctly logged:" + getMessageString(log),
- getMessageString(log).endsWith(defaultLog4j));
-
- validation = true;
- }
-
- assertTrue("Validation not performed: " + TESTID + " not logged", validation);
- }
- catch (AssertionFailedError afe)
- {
- dumpLogs(results, _monitor);
-
- throw afe;
- }
- }
- }
-
- /**
- * Description:
* On startup the broker must report correctly report the log4j file in use. This is important as it can help diagnose why logging messages are not being reported. The broker must also be capable of correctly recognising the command line property to specify the custom logging configuration.
* Input:
* The value of -l specified on the command line.
@@ -254,11 +169,17 @@ public class BrokerLoggingTest extends AbstractTestLogging
// This logging startup code only occurs when you run a Java broker
if (isJavaBroker())
{
- String customLog4j = getBrokerCommandLog4JFile().getAbsolutePath();
+ // Log4j properties expects this to be set
+ System.setProperty("qpid.testMethod", "-" + getName() + ".customLog4j");
+ System.setProperty("qpid.testClass", getClass().getName() );
+
+ String customLog4j = System.getProperty("log4j.configuration.file");
String TESTID = "BRK-1007";
- startBroker();
+ startBroker(0, false, customLog4j);
+ _outputFile = new File(((FileAppender) LogManager.getRootLogger().getAllAppenders().nextElement()).getFile());
+
// Now we can create the monitor as _outputFile will now be defined
_monitor = new LogMonitor(_outputFile);
@@ -385,7 +306,7 @@ public class BrokerLoggingTest extends AbstractTestLogging
//2
//There will be 2 copies of the startup message (one via SystemOut, and one via Log4J)
assertEquals("Unexpected startup message count",
- 2, findMatches(TESTID).size());
+ 1, findMatches(TESTID).size());
validation = true;
}
@@ -471,9 +392,8 @@ public class BrokerLoggingTest extends AbstractTestLogging
assertEquals("Incorrect message", TESTID, id);
//2
- //There will be 2 copies of the startup message (one via SystemOut, and one via Log4J)
assertEquals("Unexpected listen message count",
- 2, findMatches(TESTID).size());
+ 1, findMatches(TESTID).size());
//3
String message = getMessageString(log);
@@ -587,7 +507,7 @@ public class BrokerLoggingTest extends AbstractTestLogging
//There will be 4 copies of the startup message (two via SystemOut, and two via Log4J)
List<String> listenMessages = findMatches(TESTID);
assertEquals("Four listen messages should be found.",
- 4, listenMessages .size());
+ 2, listenMessages .size());
int tcpStarted = 0;
int sslStarted = 0;
@@ -604,8 +524,8 @@ public class BrokerLoggingTest extends AbstractTestLogging
}
}
- assertEquals("Unexpected number of logs 'Listening on TCP port'", 2, tcpStarted);
- assertEquals("Unexpected number of logs 'Listening on SSL port'", 2, sslStarted);
+ assertEquals("Unexpected number of logs 'Listening on TCP port'", 1, tcpStarted);
+ assertEquals("Unexpected number of logs 'Listening on SSL port'", 1, sslStarted);
//4 Test ports open
testSocketOpen(getPort());
@@ -690,10 +610,9 @@ public class BrokerLoggingTest extends AbstractTestLogging
//2
assertEquals("Ready message not present", "Qpid Broker Ready", getMessageString(log));
- //There will be 2 copies of the startup message (one via SystemOut, and one via Log4J)
assertEquals("Unexpected ready message count",
- 2, findMatches(TESTID).size());
- assertEquals("The ready messages should have been the last 2 messages", results.size() - 2, i);
+ 1, findMatches(TESTID).size());
+ assertEquals("The ready messages should have been the last 2 messages", results.size() - 1, i);
validationComplete = true;
break;
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java b/qpid/java/systests/src/test/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
index 789ad420d8..f7722a8384 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/server/security/acl/AbstractACLTestCase.java
@@ -59,7 +59,7 @@ public abstract class AbstractACLTestCase extends QpidBrokerTestCase implements
@Override
public void setUp() throws Exception
{
- getBrokerConfiguration().addGroupFileConfiguration(System.getProperty(QPID_HOME) + "/etc/groups-systests");
+ getBrokerConfiguration().addGroupFileConfiguration(QPID_HOME + "/etc/groups-systests");
// run test specific setup
String testSetup = StringUtils.replace(getName(), "test", "setUp");
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/LoggingManagementTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/LoggingManagementTest.java
index 3717c1594d..a06ed7be52 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/LoggingManagementTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/LoggingManagementTest.java
@@ -25,6 +25,7 @@ import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
import org.apache.qpid.management.common.mbeans.LoggingManagement;
+import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.logging.log4j.LoggingManagementFacadeTest;
import org.apache.qpid.test.utils.JMXTestUtils;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
@@ -35,7 +36,6 @@ import org.apache.qpid.util.LogMonitor;
* System test for Logging Management. <b>These tests rely on value set within
* test-profiles/log4j-test.xml</b>.
*
- * @see LoggingManagementMBeanTest
* @see LoggingManagementFacadeTest
*
*/
@@ -44,7 +44,9 @@ public class LoggingManagementTest extends QpidBrokerTestCase
private JMXTestUtils _jmxUtils;
private LoggingManagement _loggingManagement;
private LogMonitor _monitor;
+ private File _logConfig;
+ @Override
public void setUp() throws Exception
{
getBrokerConfiguration().addJmxManagementConfiguration();
@@ -56,8 +58,9 @@ public class LoggingManagementTest extends QpidBrokerTestCase
File tmpLogFile = File.createTempFile("log4j" + "." + getName(), ".xml");
tmpLogFile.deleteOnExit();
- FileUtils.copy(getBrokerCommandLog4JFile(), tmpLogFile);
+ FileUtils.copy(new File(System.getProperty("log4j.configuration.file")), tmpLogFile);
setBrokerCommandLog4JFile(tmpLogFile);
+ _logConfig = tmpLogFile;
super.setUp();
_jmxUtils.open();
@@ -66,6 +69,12 @@ public class LoggingManagementTest extends QpidBrokerTestCase
_monitor = new LogMonitor(_outputFile);
}
+ public void startBroker() throws Exception
+ {
+ super.startBroker(0, false, _logConfig.getAbsolutePath());
+ }
+
+ @Override
public void tearDown() throws Exception
{
try
@@ -74,6 +83,11 @@ public class LoggingManagementTest extends QpidBrokerTestCase
{
_jmxUtils.close();
}
+
+ if (_logConfig != null)
+ {
+ _logConfig.delete();
+ }
}
finally
{
@@ -122,7 +136,7 @@ public class LoggingManagementTest extends QpidBrokerTestCase
_loggingManagement.setConfigFileLoggerLevel(operationalLoggingLogger, "OFF");
List<String> matches = _monitor.waitAndFindMatches("Setting level to OFF for logger 'qpid.message'", 5000);
- assertEquals(1, matches.size());
+ assertTrue(matches.size()>=1);
assertEffectiveLoggingLevel(operationalLoggingLogger, "INFO");
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/ManagementLoggingTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/ManagementLoggingTest.java
index cb6eae013e..4df81845d8 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/ManagementLoggingTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/management/jmx/ManagementLoggingTest.java
@@ -104,7 +104,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
//There will be 2 copies of the startup message (one via SystemOut, and one via Log4J)
results = findMatches("MNG-1001");
assertEquals("Unexpected startup message count.",
- 2, results.size());
+ 1, results.size());
//3
assertEquals("Startup log message is not 'Startup'.", "JMX Management Startup",
@@ -185,7 +185,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
// Validation
//There will be 4 startup messages (two via SystemOut, and two via Log4J)
- assertEquals("Unexpected MNG-1002 message count", 4, results.size());
+ assertEquals("Unexpected MNG-1002 message count", 2, results.size());
String log = getLogMessage(results, 0);
@@ -197,7 +197,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
assertTrue("RMI Registry port not as expected(" + mPort + ").:" + getMessageString(log),
getMessageString(log).endsWith(String.valueOf(mPort)));
- log = getLogMessage(results, 2);
+ log = getLogMessage(results, 1);
//1
validateMessageID("MNG-1002", log);
@@ -243,7 +243,7 @@ public class ManagementLoggingTest extends AbstractTestLogging
// Validate we only have two MNG-1002 (one via stdout, one via log4j)
results = findMatches("MNG-1006");
assertEquals("Upexpected SSL Keystore message count",
- 2, results.size());
+ 1, results.size());
// Validate the keystore path is as expected
assertTrue("SSL Keystore entry expected.:" + getMessageString(log),
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/prefetch/ZeroPrefetchTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/prefetch/ZeroPrefetchTest.java
new file mode 100644
index 0000000000..6a9fa0175a
--- /dev/null
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/prefetch/ZeroPrefetchTest.java
@@ -0,0 +1,83 @@
+/*
+ *
+ * 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.apache.qpid.systest.prefetch;
+
+import java.util.UUID;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import org.apache.qpid.configuration.ClientProperties;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
+public class ZeroPrefetchTest extends QpidBrokerTestCase
+{
+
+ private static final String TEST_PROPERTY_NAME = "testProp";
+
+ // send two messages to the queue, consume and acknowledge one message on connection 1
+ // create a second connection and attempt to consume the second message - this will only be possible
+ // if the first connection has no prefetch
+ public void testZeroPrefetch() throws Exception
+ {
+ setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, "0");
+ Connection prefetch1Connection = getConnection();
+
+ prefetch1Connection.start();
+
+ final Session prefetch1session = prefetch1Connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Queue queue = prefetch1session.createQueue(getTestQueueName());
+ MessageConsumer prefetch1consumer = prefetch1session.createConsumer(queue);
+
+
+ Session producerSession = prefetch1Connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = producerSession.createProducer(queue);
+ Message firstMessage = producerSession.createMessage();
+ String firstPropertyValue = UUID.randomUUID().toString();
+ firstMessage.setStringProperty(TEST_PROPERTY_NAME, firstPropertyValue);
+ producer.send(firstMessage);
+
+ Message secondMessage = producerSession.createMessage();
+ String secondPropertyValue = UUID.randomUUID().toString();
+ secondMessage.setStringProperty(TEST_PROPERTY_NAME, secondPropertyValue);
+ producer.send(secondMessage);
+
+
+ Message receivedMessage = prefetch1consumer.receive(2000l);
+ assertNotNull("First message was not received", receivedMessage);
+ assertEquals("Message property was not as expected", firstPropertyValue, receivedMessage.getStringProperty(TEST_PROPERTY_NAME));
+
+ Connection prefetch2Connection = getConnection();
+
+ prefetch2Connection.start();
+ final Session prefetch2session = prefetch2Connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer prefetch2consumer = prefetch2session.createConsumer(queue);
+
+ receivedMessage = prefetch2consumer.receive(2000l);
+ assertNotNull("Second message was not received", receivedMessage);
+ assertEquals("Message property was not as expected", secondPropertyValue, receivedMessage.getStringProperty(TEST_PROPERTY_NAME));
+
+ }
+}
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
index 4140c9c12c..0dda8e077b 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/AccessControlProviderRestTest.java
@@ -125,34 +125,28 @@ public class AccessControlProviderRestTest extends QpidRestTestCase
public void testReplaceAccessControlProvider() throws Exception
{
- String accessControlProviderName1 = getTestName() + "1";
- //verify that the access control provider doesn't exist, and
- //in doing so implicitly verify that the 'denied' user can
- //actually currently connect because no ACL is in effect yet
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertAccessControlProviderExistence(accessControlProviderName1, false);
//create the access control provider using the 'allowed' user
getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- int responseCode = createAccessControlProvider(accessControlProviderName1, _aclFileContent1);
+ int responseCode = createAccessControlProvider(getTestName(), _aclFileContent1);
assertEquals("Access control provider creation should be allowed", 201, responseCode);
//verify it exists with the 'allowed' user
- assertAccessControlProviderExistence(accessControlProviderName1, true);
+ assertAccessControlProviderExistence(getTestName(), true);
//verify the 'denied' and 'other' user can no longer access the management
//interface due to the just-created ACL file now preventing them
getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertCanAccessManagementInterface(accessControlProviderName1, false);
+ assertCanAccessManagementInterface(getTestName(), false);
getRestTestHelper().setUsernameAndPassword(OTHER_USER, OTHER_USER);
- assertCanAccessManagementInterface(accessControlProviderName1, false);
+ assertCanAccessManagementInterface(getTestName(), false);
//create the replacement access control provider using the 'allowed' user.
String accessControlProviderName2 = getTestName() + "2";
getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- responseCode = createAccessControlProvider(accessControlProviderName2, _aclFileContent2);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
+ responseCode = createAccessControlProvider(getTestName(), _aclFileContent2);
+ assertEquals("Access control provider creation should be allowed", 200, responseCode);
//Verify that it took effect immediately, replacing the first access control provider
@@ -162,11 +156,6 @@ public class AccessControlProviderRestTest extends QpidRestTestCase
getRestTestHelper().setUsernameAndPassword(OTHER_USER, OTHER_USER);
assertCanAccessManagementInterface(accessControlProviderName2, true);
- //remove the original access control provider using the 'allowed' user
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName1, "DELETE");
- assertEquals("Access control provider deletion should be allowed", 200, responseCode);
- assertAccessControlProviderExistence(accessControlProviderName1, false);
//verify the 'denied' user still can't access the management interface, the 'other' user still can, thus
//confirming that the second access control provider is still in effect
@@ -177,61 +166,6 @@ public class AccessControlProviderRestTest extends QpidRestTestCase
}
- public void testAddAndRemoveSecondAccessControlProviderReinstatesOriginal() throws Exception
- {
- String accessControlProviderName1 = getTestName() + "1";
-
- //verify that the access control provider doesn't exist, and
- //in doing so implicitly verify that the 'denied' user can
- //actually currently connect because no ACL is in effect yet
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertAccessControlProviderExistence(accessControlProviderName1, false);
-
- //create the access control provider using the 'allowed' user
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- int responseCode = createAccessControlProvider(accessControlProviderName1, _aclFileContent1);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
-
- //verify it exists with the 'allowed' user
- assertAccessControlProviderExistence(accessControlProviderName1, true);
-
- //verify the 'denied' and 'other' user can no longer access the management
- //interface due to the just-created ACL file now preventing them
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertCanAccessManagementInterface(accessControlProviderName1, false);
- getRestTestHelper().setUsernameAndPassword(OTHER_USER, OTHER_USER);
- assertCanAccessManagementInterface(accessControlProviderName1, false);
-
- //create the replacement access control provider using the 'allowed' user.
- String accessControlProviderName2 = getTestName() + "2";
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- responseCode = createAccessControlProvider(accessControlProviderName2, _aclFileContent2);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
-
- //Verify that it took effect immediately, replacing the first access control provider
-
- //verify the 'denied' user still can't access the management interface, but the 'other' user now CAN.
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertCanAccessManagementInterface(accessControlProviderName2, false);
- getRestTestHelper().setUsernameAndPassword(OTHER_USER, OTHER_USER);
- assertCanAccessManagementInterface(accessControlProviderName2, true);
-
- //remove the second access control provider using the 'allowed' user
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName2, "DELETE");
- assertEquals("Access control provider deletion should be allowed", 200, responseCode);
- assertAccessControlProviderExistence(accessControlProviderName2, false);
-
- //verify the 'denied' user still can't access the management interface, the
- //'other' now CANT again, the 'allowed' still can, thus confirming that the
- //first access control provider is now in effect once again
- getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- assertCanAccessManagementInterface(accessControlProviderName2, false);
- getRestTestHelper().setUsernameAndPassword(OTHER_USER, OTHER_USER);
- assertCanAccessManagementInterface(accessControlProviderName2, false);
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- assertCanAccessManagementInterface(accessControlProviderName2, true);
- }
public void testRemovalOfAccessControlProviderInErrorStateUsingManagementMode() throws Exception
{
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java
index ba95eecc6d..4023830a8d 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/BrokerRestTest.java
@@ -235,9 +235,6 @@ public class BrokerRestTest extends QpidRestTestCase
assertNotNull("Unexpected value of attribute ports", brokerDetails.get(BROKER_PORTS_ATTRIBUTE));
assertNotNull("Unexpected value of attribute authenticationproviders", brokerDetails.get(BROKER_AUTHENTICATIONPROVIDERS_ATTRIBUTE));
- assertNotNull("Unexpected value of attribute supportedVirtualHostTypes", brokerDetails.get(Broker.SUPPORTED_VIRTUALHOST_TYPES));
- assertNotNull("Unexpected value of attribute supportedVirtualHostNodeTypes", brokerDetails.get(Broker.SUPPORTED_VIRTUALHOSTNODE_TYPES));
-
}
}
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java
index 4b881d1e9f..03b0a7a304 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/KeyStoreRestTest.java
@@ -20,23 +20,20 @@
*/
package org.apache.qpid.systest.rest;
-import java.io.IOException;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.qpid.server.model.AbstractConfiguredObject;
import org.apache.qpid.server.model.KeyStore;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Transport;
import org.apache.qpid.server.security.FileKeyStore;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
import org.apache.qpid.test.utils.TestSSLConstants;
+import org.apache.qpid.util.DataUrlUtils;
+import org.apache.qpid.util.FileUtils;
public class KeyStoreRestTest extends QpidRestTestCase
{
@@ -56,7 +53,7 @@ public class KeyStoreRestTest extends QpidRestTestCase
Map<String, Object> keystore = keyStores.get(0);
assertKeyStoreAttributes(keystore, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE,
- System.getProperty(QPID_HOME) + "/../" + TestSSLConstants.BROKER_KEYSTORE, null);
+ QPID_HOME + "/../" + TestSSLConstants.BROKER_KEYSTORE, null);
}
public void testCreate() throws Exception
@@ -67,7 +64,7 @@ public class KeyStoreRestTest extends QpidRestTestCase
String certAlias = "app2";
assertNumberOfKeyStores(1);
- createKeyStore(name, certAlias);
+ createKeyStore(name, certAlias, TestSSLConstants.KEYSTORE, TestSSLConstants.KEYSTORE_PASSWORD);
assertNumberOfKeyStores(2);
List<Map<String, Object>> keyStores = getRestTestHelper().getJsonAsList("keystore/" + name);
@@ -76,161 +73,72 @@ public class KeyStoreRestTest extends QpidRestTestCase
assertKeyStoreAttributes(keyStores.get(0), name, TestSSLConstants.KEYSTORE, certAlias);
}
- public void testDelete() throws Exception
+ public void testCreateWithDataUrl() throws Exception
{
super.setUp();
String name = getTestName();
- String certAlias = "app2";
+ byte[] keystoreAsBytes = FileUtils.readFileAsBytes(TestSSLConstants.KEYSTORE);
+ String dataUrlForKeyStore = DataUrlUtils.getDataUrlForBytes(keystoreAsBytes);
assertNumberOfKeyStores(1);
- createKeyStore(name, certAlias);
+ createKeyStore(name, null, dataUrlForKeyStore, TestSSLConstants.KEYSTORE_PASSWORD);
assertNumberOfKeyStores(2);
- int responseCode = getRestTestHelper().submitRequest("keystore/" + name , "DELETE");
- assertEquals("Unexpected response code for provider deletion", 200, responseCode);
-
- List<Map<String, Object>> keyStore = getRestTestHelper().getJsonAsList("keystore/" + name);
- assertNotNull("details should not be null", keyStore);
- assertTrue("details should be empty as the keystore no longer exists", keyStore.isEmpty());
-
- //check only the default systests key store remains
- List<Map<String, Object>> keyStores = assertNumberOfKeyStores(1);
- Map<String, Object> keystore = keyStores.get(0);
- assertKeyStoreAttributes(keystore, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE,
- System.getProperty(QPID_HOME) + "/../" + TestSSLConstants.BROKER_KEYSTORE, null);
- }
-
- public void testDeleteFailsWhenKeyStoreInUse() throws Exception
- {
- String name = "testDeleteFailsWhenKeyStoreInUse";
-
- //add a new key store config to use
- Map<String, Object> sslKeyStoreAttributes = new HashMap<String, Object>();
- sslKeyStoreAttributes.put(KeyStore.NAME, name);
- sslKeyStoreAttributes.put(FileKeyStore.PATH, TestSSLConstants.BROKER_KEYSTORE);
- sslKeyStoreAttributes.put(FileKeyStore.PASSWORD, TestSSLConstants.BROKER_KEYSTORE_PASSWORD);
- getBrokerConfiguration().addObjectConfiguration(KeyStore.class,sslKeyStoreAttributes);
-
- //add the SSL port using it
- Map<String, Object> sslPortAttributes = new HashMap<String, Object>();
- sslPortAttributes.put(Port.TRANSPORTS, Collections.singleton(Transport.SSL));
- sslPortAttributes.put(Port.PORT, DEFAULT_SSL_PORT);
- sslPortAttributes.put(Port.NAME, TestBrokerConfiguration.ENTRY_NAME_SSL_PORT);
- sslPortAttributes.put(Port.AUTHENTICATION_PROVIDER, TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER);
- sslPortAttributes.put(Port.KEY_STORE, name);
- getBrokerConfiguration().addObjectConfiguration(Port.class,sslPortAttributes);
-
- super.setUp();
-
- //verify the keystore is there
- assertNumberOfKeyStores(2);
-
- List<Map<String, Object>> keyStore = getRestTestHelper().getJsonAsList("keystore/" + name);
- assertNotNull("details should not be null", keyStore);
- assertKeyStoreAttributes(keyStore.get(0), name, TestSSLConstants.BROKER_KEYSTORE, null);
-
- //try to delete it, which should fail as it is in use
- int responseCode = getRestTestHelper().submitRequest("keystore/" + name , "DELETE");
- assertEquals("Unexpected response code for provider deletion", 409, responseCode);
+ List<Map<String, Object>> keyStores = getRestTestHelper().getJsonAsList("keystore/" + name);
+ assertNotNull("details cannot be null", keyStores);
- //check its still there
- assertNumberOfKeyStores(2);
- keyStore = getRestTestHelper().getJsonAsList("keystore/" + name);
- assertNotNull("details should not be null", keyStore);
- assertKeyStoreAttributes(keyStore.get(0), name, TestSSLConstants.BROKER_KEYSTORE, null);
+ assertKeyStoreAttributes(keyStores.get(0), name, dataUrlForKeyStore, null);
}
- public void testUpdateWithGoodPathSucceeds() throws Exception
+ public void testDelete() throws Exception
{
super.setUp();
String name = getTestName();
+ String certAlias = "app2";
assertNumberOfKeyStores(1);
- createKeyStore(name, null);
+ createKeyStore(name, certAlias, TestSSLConstants.KEYSTORE, TestSSLConstants.KEYSTORE_PASSWORD);
assertNumberOfKeyStores(2);
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(KeyStore.NAME, name);
- attributes.put(FileKeyStore.PATH, TestSSLConstants.UNTRUSTED_KEYSTORE);
-
- int responseCode = getRestTestHelper().submitRequest("keystore/" + name , "PUT", attributes);
- assertEquals("Unexpected response code for keystore update", 200, responseCode);
+ getRestTestHelper().submitRequest("keystore/" + name, "DELETE", HttpServletResponse.SC_OK);
List<Map<String, Object>> keyStore = getRestTestHelper().getJsonAsList("keystore/" + name);
assertNotNull("details should not be null", keyStore);
+ assertTrue("details should be empty as the keystore no longer exists", keyStore.isEmpty());
- assertKeyStoreAttributes(keyStore.get(0), name, TestSSLConstants.UNTRUSTED_KEYSTORE, null);
+ //check only the default systests key store remains
+ List<Map<String, Object>> keyStores = assertNumberOfKeyStores(1);
+ Map<String, Object> keystore = keyStores.get(0);
+ assertKeyStoreAttributes(keystore, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE,
+ QPID_HOME + "/../" + TestSSLConstants.BROKER_KEYSTORE, null);
}
- public void testUpdateWithNonExistentPathFails() throws Exception
+ public void testUpdate() throws Exception
{
super.setUp();
String name = getTestName();
assertNumberOfKeyStores(1);
- createKeyStore(name, null);
+ createKeyStore(name, null, TestSSLConstants.KEYSTORE, TestSSLConstants.KEYSTORE_PASSWORD);
assertNumberOfKeyStores(2);
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(KeyStore.NAME, name);
- attributes.put(FileKeyStore.PATH, "does.not.exist");
+ attributes.put(FileKeyStore.PATH, TestSSLConstants.UNTRUSTED_KEYSTORE);
- int responseCode = getRestTestHelper().submitRequest("keystore/" + name , "PUT", attributes);
- assertEquals("Unexpected response code for keystore update", 409, responseCode);
+ getRestTestHelper().submitRequest("keystore/" + name, "PUT", attributes, HttpServletResponse.SC_OK);
List<Map<String, Object>> keyStore = getRestTestHelper().getJsonAsList("keystore/" + name);
assertNotNull("details should not be null", keyStore);
- //verify the details remain unchanged
- assertKeyStoreAttributes(keyStore.get(0), name, TestSSLConstants.KEYSTORE, null);
+ assertKeyStoreAttributes(keyStore.get(0), name, TestSSLConstants.UNTRUSTED_KEYSTORE, null);
}
- public void testUpdateCertificateAlias() throws Exception
- {
- super.setUp();
-
- String name = getTestName();
- assertNumberOfKeyStores(1);
- createKeyStore(name, "app1");
- assertNumberOfKeyStores(2);
-
- List<Map<String, Object>> keyStore = getRestTestHelper().getJsonAsList("keystore/" + name);
- assertNotNull("details should not be null", keyStore);
- assertKeyStoreAttributes(keyStore.get(0), name, TestSSLConstants.KEYSTORE, "app1");
-
- //Update the certAlias from app1 to app2
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(KeyStore.NAME, name);
- attributes.put(FileKeyStore.CERTIFICATE_ALIAS, "app2");
-
- int responseCode = getRestTestHelper().submitRequest("keystore/" + name , "PUT", attributes);
- assertEquals("Unexpected response code for keystore update", 200, responseCode);
-
- keyStore = getRestTestHelper().getJsonAsList("keystore/" + name);
- assertNotNull("details should not be null", keyStore);
-
- assertKeyStoreAttributes(keyStore.get(0), name, TestSSLConstants.KEYSTORE, "app2");
-
- //Update the certAlias to clear it (i.e go from from app1 to null)
- attributes = new HashMap<String, Object>();
- attributes.put(KeyStore.NAME, name);
- attributes.put(FileKeyStore.CERTIFICATE_ALIAS, null);
-
- responseCode = getRestTestHelper().submitRequest("keystore/" + name , "PUT", attributes);
- assertEquals("Unexpected response code for keystore update", 200, responseCode);
-
- keyStore = getRestTestHelper().getJsonAsList("keystore/" + name);
- assertNotNull("details should not be null", keyStore);
-
- assertKeyStoreAttributes(keyStore.get(0), name, TestSSLConstants.KEYSTORE, null);
- }
-
- private List<Map<String, Object>> assertNumberOfKeyStores(int numberOfKeystores) throws IOException,
- JsonParseException, JsonMappingException
+ private List<Map<String, Object>> assertNumberOfKeyStores(int numberOfKeystores) throws Exception
{
List<Map<String, Object>> keyStores = getRestTestHelper().getJsonAsList("keystore");
assertNotNull("keystores should not be null", keyStores);
@@ -239,16 +147,18 @@ public class KeyStoreRestTest extends QpidRestTestCase
return keyStores;
}
- private void createKeyStore(String name, String certAlias) throws IOException, JsonGenerationException, JsonMappingException
+ private void createKeyStore(String name, String certAlias, final String keyStorePath, final String keystorePassword) throws Exception
{
- Map<String, Object> keyStoreAttributes = new HashMap<String, Object>();
+ Map<String, Object> keyStoreAttributes = new HashMap<>();
keyStoreAttributes.put(KeyStore.NAME, name);
- keyStoreAttributes.put(FileKeyStore.PATH, TestSSLConstants.KEYSTORE);
- keyStoreAttributes.put(FileKeyStore.PASSWORD, TestSSLConstants.KEYSTORE_PASSWORD);
- keyStoreAttributes.put(FileKeyStore.CERTIFICATE_ALIAS, certAlias);
+ keyStoreAttributes.put(FileKeyStore.PATH, keyStorePath);
+ keyStoreAttributes.put(FileKeyStore.PASSWORD, keystorePassword);
+ if (certAlias != null)
+ {
+ keyStoreAttributes.put(FileKeyStore.CERTIFICATE_ALIAS, certAlias);
+ }
- int responseCode = getRestTestHelper().submitRequest("keystore/" + name, "PUT", keyStoreAttributes);
- assertEquals("Unexpected response code", 201, responseCode);
+ getRestTestHelper().submitRequest("keystore/" + name, "PUT", keyStoreAttributes, HttpServletResponse.SC_CREATED);
}
private void assertKeyStoreAttributes(Map<String, Object> keystore, String name, String path, String certAlias)
@@ -261,12 +171,16 @@ public class KeyStoreRestTest extends QpidRestTestCase
AbstractConfiguredObject.SECURED_STRING_VALUE, keystore.get(FileKeyStore.PASSWORD));
assertEquals("unexpected type of default systests key store",
java.security.KeyStore.getDefaultType(), keystore.get(FileKeyStore.KEY_STORE_TYPE));
- assertEquals("unexpected certificateAlias value",
- certAlias, keystore.get(FileKeyStore.CERTIFICATE_ALIAS));
if(certAlias == null)
{
assertFalse("should not be a certificateAlias attribute",
keystore.containsKey(FileKeyStore.CERTIFICATE_ALIAS));
}
+ else
+ {
+ assertEquals("unexpected certificateAlias value",
+ certAlias, keystore.get(FileKeyStore.CERTIFICATE_ALIAS));
+
+ }
}
}
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/LogViewerTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/LogViewerTest.java
index f2fb2581f7..a7bf743e72 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/LogViewerTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/LogViewerTest.java
@@ -28,25 +28,40 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.apache.qpid.server.BrokerOptions;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.apache.qpid.server.configuration.BrokerProperties;
public class LogViewerTest extends QpidRestTestCase
{
- public static final String DEFAULT_FILE_APPENDER_NAME = "FileAppender";
private String _expectedLogFileName;
+ private FileAppender _fileAppender;
+ private String _appenderName;
+ @Override
public void setUp() throws Exception
{
- setSystemProperty("logsuffix", "-" + getTestQueueName());
- _expectedLogFileName = System.getProperty("logprefix", "") + "qpid" + System.getProperty("logsuffix", "") + ".log";
-
- // use real broker log file
- File brokerLogFile = new File(System.getProperty(QPID_HOME), BrokerOptions.DEFAULT_LOG_CONFIG_FILE);
- setBrokerCommandLog4JFile(brokerLogFile);
+ _appenderName = getTestQueueName();
+ _expectedLogFileName = "qpid-" + _appenderName + ".log";
+ _fileAppender = new FileAppender(new SimpleLayout(),
+ System.getProperty(BrokerProperties.PROPERTY_QPID_WORK) + File.separator + _expectedLogFileName, false);
+ _fileAppender.setName(_appenderName);
+ Logger.getRootLogger().addAppender(_fileAppender);
super.setUp();
}
+ @Override
+ public void tearDown() throws Exception
+ {
+ if (_fileAppender != null)
+ {
+ Logger.getRootLogger().removeAppender(_fileAppender);
+ }
+ super.tearDown();
+ }
+
public void testGetLogFiles() throws Exception
{
List<Map<String, Object>> logFiles = getRestTestHelper().getJsonAsList("/service/logfilenames");
@@ -54,24 +69,32 @@ public class LogViewerTest extends QpidRestTestCase
// 1 file appender is configured in QPID default log4j xml:
assertTrue("Unexpected number of log files", logFiles.size() > 0);
+ Map<String, Object> logFileDetails = null;
+ for (Map<String, Object> appenderDetails: logFiles)
+ {
+ if (_appenderName.equals(appenderDetails.get("appenderName")))
+ {
+ logFileDetails = appenderDetails;
+ break;
+ }
+ }
- Map<String, Object> logFileDetails = logFiles.get(0);
assertEquals("Unexpected log file name", _expectedLogFileName, logFileDetails.get("name"));
assertEquals("Unexpected log file mime type", "text/plain", logFileDetails.get("mimeType"));
- assertEquals("Unexpected log file appender",DEFAULT_FILE_APPENDER_NAME, logFileDetails.get("appenderName"));
+ assertEquals("Unexpected log file appender",_appenderName, logFileDetails.get("appenderName"));
assertTrue("Unexpected log file size", ((Number)logFileDetails.get("size")).longValue()>0);
assertTrue("Unexpected log file modification time", ((Number)logFileDetails.get("lastModified")).longValue()>0);
}
public void testDownloadExistingLogFiles() throws Exception
{
- byte[] bytes = getRestTestHelper().getBytes("/service/logfile?l=" + DEFAULT_FILE_APPENDER_NAME + "%2F" + _expectedLogFileName);
+ byte[] bytes = getRestTestHelper().getBytes("/service/logfile?l=" + _appenderName + "%2F" + _expectedLogFileName);
ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bytes));
try
{
ZipEntry entry = zis.getNextEntry();
- assertEquals("Unexpected broker log file name", DEFAULT_FILE_APPENDER_NAME + "/" + _expectedLogFileName, entry.getName());
+ assertEquals("Unexpected broker log file name", _appenderName + "/" + _expectedLogFileName, entry.getName());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
@@ -91,7 +114,7 @@ public class LogViewerTest extends QpidRestTestCase
public void testDownloadNonExistingLogFiles() throws Exception
{
- int responseCode = getRestTestHelper().submitRequest("/service/logfile?l=" + DEFAULT_FILE_APPENDER_NAME + "%2F"
+ int responseCode = getRestTestHelper().submitRequest("/service/logfile?l=" + _appenderName + "%2F"
+ _expectedLogFileName + "_" + System.currentTimeMillis(), "GET");
assertEquals("Unexpected response code", 404, responseCode);
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java
index 5d2e9de3fa..6cca3fc12c 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/TrustStoreRestTest.java
@@ -20,23 +20,19 @@
*/
package org.apache.qpid.systest.rest;
-import java.io.IOException;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
+import javax.servlet.http.HttpServletResponse;
import org.apache.qpid.server.model.AbstractConfiguredObject;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Transport;
import org.apache.qpid.server.model.TrustStore;
import org.apache.qpid.server.security.FileTrustStore;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
import org.apache.qpid.test.utils.TestSSLConstants;
+import org.apache.qpid.util.DataUrlUtils;
+import org.apache.qpid.util.FileUtils;
public class TrustStoreRestTest extends QpidRestTestCase
{
@@ -56,7 +52,7 @@ public class TrustStoreRestTest extends QpidRestTestCase
Map<String, Object> truststore = trustStores.get(0);
assertTrustStoreAttributes(truststore, TestBrokerConfiguration.ENTRY_NAME_SSL_TRUSTSTORE,
- System.getProperty(QPID_HOME) + "/../" + TestSSLConstants.BROKER_TRUSTSTORE, false);
+ QPID_HOME + "/../" + TestSSLConstants.BROKER_TRUSTSTORE, false);
}
public void testCreate() throws Exception
@@ -66,7 +62,7 @@ public class TrustStoreRestTest extends QpidRestTestCase
String name = getTestName();
assertNumberOfTrustStores(1);
- createTrustStore(name, true);
+ createTrustStore(name, true, TestSSLConstants.TRUSTSTORE, TestSSLConstants.TRUSTSTORE_PASSWORD);
assertNumberOfTrustStores(2);
List<Map<String, Object>> trustStores = getRestTestHelper().getJsonAsList("truststore/" + name);
@@ -75,157 +71,73 @@ public class TrustStoreRestTest extends QpidRestTestCase
assertTrustStoreAttributes(trustStores.get(0), name, TestSSLConstants.TRUSTSTORE, true);
}
- public void testDelete() throws Exception
+ public void testCreateUsingDataUrl() throws Exception
{
super.setUp();
String name = getTestName();
+ byte[] trustStoreAsBytes = FileUtils.readFileAsBytes(TestSSLConstants.TRUSTSTORE);
+ String dataUrlForTruststore = DataUrlUtils.getDataUrlForBytes(trustStoreAsBytes);
assertNumberOfTrustStores(1);
- createTrustStore(name, false);
- assertNumberOfTrustStores(2);
-
- int responseCode = getRestTestHelper().submitRequest("truststore/" + name , "DELETE");
- assertEquals("Unexpected response code for provider deletion", 200, responseCode);
-
- List<Map<String, Object>> trustStore = getRestTestHelper().getJsonAsList("truststore/" + name);
- assertNotNull("details should not be null", trustStore);
- assertTrue("details should be empty as the truststore no longer exists", trustStore.isEmpty());
-
- //check only the default systests trust store remains
- List<Map<String, Object>> trustStores = assertNumberOfTrustStores(1);
- Map<String, Object> truststore = trustStores.get(0);
- assertTrustStoreAttributes(truststore, TestBrokerConfiguration.ENTRY_NAME_SSL_TRUSTSTORE,
- System.getProperty(QPID_HOME) + "/../" + TestSSLConstants.BROKER_TRUSTSTORE, false);
- }
-
- public void testDeleteFailsWhenTrustStoreInUse() throws Exception
- {
- String name = "testDeleteFailsWhenTrustStoreInUse";
-
- //add a new trust store config to use
- Map<String, Object> sslTrustStoreAttributes = new HashMap<String, Object>();
- sslTrustStoreAttributes.put(TrustStore.NAME, name);
- sslTrustStoreAttributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE);
- sslTrustStoreAttributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD);
- getBrokerConfiguration().addObjectConfiguration(TrustStore.class,sslTrustStoreAttributes);
-
- //add the SSL port using it
- Map<String, Object> sslPortAttributes = new HashMap<String, Object>();
- sslPortAttributes.put(Port.TRANSPORTS, Collections.singleton(Transport.SSL));
- sslPortAttributes.put(Port.PORT, DEFAULT_SSL_PORT);
- sslPortAttributes.put(Port.NAME, TestBrokerConfiguration.ENTRY_NAME_SSL_PORT);
- sslPortAttributes.put(Port.AUTHENTICATION_PROVIDER, TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER);
- sslPortAttributes.put(Port.KEY_STORE, TestBrokerConfiguration.ENTRY_NAME_SSL_KEYSTORE);
- sslPortAttributes.put(Port.TRUST_STORES, Collections.singleton(name));
- getBrokerConfiguration().addObjectConfiguration(Port.class, sslPortAttributes);
- super.setUp();
+ createTrustStore(name, false, dataUrlForTruststore, TestSSLConstants.TRUSTSTORE_PASSWORD);
- //verify the truststore is there
assertNumberOfTrustStores(2);
- List<Map<String, Object>> trustStore = getRestTestHelper().getJsonAsList("truststore/" + name);
- assertNotNull("details should not be null", trustStore);
- assertTrustStoreAttributes(trustStore.get(0), name, TestSSLConstants.TRUSTSTORE, false);
-
- //try to delete it, which should fail as it is in use
- int responseCode = getRestTestHelper().submitRequest("truststore/" + name , "DELETE");
- assertEquals("Unexpected response code for provider deletion", 409, responseCode);
+ List<Map<String, Object>> trustStores = getRestTestHelper().getJsonAsList("truststore/" + name);
+ assertNotNull("details cannot be null", trustStores);
- //check its still there
- assertNumberOfTrustStores(2);
- trustStore = getRestTestHelper().getJsonAsList("truststore/" + name);
- assertNotNull("details should not be null", trustStore);
- assertTrustStoreAttributes(trustStore.get(0), name, TestSSLConstants.TRUSTSTORE, false);
+ assertTrustStoreAttributes(trustStores.get(0), name, dataUrlForTruststore, false);
}
- public void testUpdateWithGoodPathSucceeds() throws Exception
+ public void testDelete() throws Exception
{
super.setUp();
String name = getTestName();
assertNumberOfTrustStores(1);
- createTrustStore(name, false);
+ createTrustStore(name, false, TestSSLConstants.TRUSTSTORE, TestSSLConstants.TRUSTSTORE_PASSWORD);
assertNumberOfTrustStores(2);
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(TrustStore.NAME, name);
- attributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE);
-
- int responseCode = getRestTestHelper().submitRequest("truststore/" + name , "PUT", attributes);
- assertEquals("Unexpected response code for truststore update", 200, responseCode);
+ getRestTestHelper().submitRequest("truststore/" + name , "DELETE", HttpServletResponse.SC_OK);
List<Map<String, Object>> trustStore = getRestTestHelper().getJsonAsList("truststore/" + name);
assertNotNull("details should not be null", trustStore);
+ assertTrue("details should be empty as the truststore no longer exists", trustStore.isEmpty());
- assertTrustStoreAttributes(trustStore.get(0), name, TestSSLConstants.TRUSTSTORE, false);
+ //check only the default systests trust store remains
+ List<Map<String, Object>> trustStores = assertNumberOfTrustStores(1);
+ Map<String, Object> truststore = trustStores.get(0);
+ assertTrustStoreAttributes(truststore, TestBrokerConfiguration.ENTRY_NAME_SSL_TRUSTSTORE,
+ QPID_HOME + "/../" + TestSSLConstants.BROKER_TRUSTSTORE, false);
}
- public void testUpdateWithNonExistentPathFails() throws Exception
- {
- super.setUp();
-
- String name = getTestName();
-
- assertNumberOfTrustStores(1);
- createTrustStore(name, false);
- assertNumberOfTrustStores(2);
-
- Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(TrustStore.NAME, name);
- attributes.put(FileTrustStore.PATH, "does.not.exist");
-
- int responseCode = getRestTestHelper().submitRequest("truststore/" + name , "PUT", attributes);
- assertEquals("Unexpected response code for trust store update", 409, responseCode);
-
- List<Map<String, Object>> trustStore = getRestTestHelper().getJsonAsList("truststore/" + name);
- assertNotNull("details should not be null", trustStore);
-
- //verify the details remain unchanged
- assertTrustStoreAttributes(trustStore.get(0), name, TestSSLConstants.TRUSTSTORE, false);
- }
- public void testUpdatePeersOnly() throws Exception
+ public void testUpdate() throws Exception
{
super.setUp();
String name = getTestName();
assertNumberOfTrustStores(1);
- createTrustStore(name, false);
+ createTrustStore(name, false, TestSSLConstants.TRUSTSTORE, TestSSLConstants.TRUSTSTORE_PASSWORD);
assertNumberOfTrustStores(2);
- //update the peersOnly attribute from false to true
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(TrustStore.NAME, name);
- attributes.put(FileTrustStore.PEERS_ONLY, true);
+ attributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE);
- int responseCode = getRestTestHelper().submitRequest("truststore/" + name , "PUT", attributes);
- assertEquals("Unexpected response code for trust store update", 200, responseCode);
+ getRestTestHelper().submitRequest("truststore/" + name , "PUT", attributes, HttpServletResponse.SC_OK);
List<Map<String, Object>> trustStore = getRestTestHelper().getJsonAsList("truststore/" + name);
assertNotNull("details should not be null", trustStore);
- assertTrustStoreAttributes(trustStore.get(0), name, TestSSLConstants.TRUSTSTORE, true);
-
- //Update peersOnly to clear it (i.e go from from true to null, which will default to false)
- attributes = new HashMap<String, Object>();
- attributes.put(TrustStore.NAME, name);
- attributes.put(FileTrustStore.PEERS_ONLY, null);
-
- responseCode = getRestTestHelper().submitRequest("truststore/" + name , "PUT", attributes);
- assertEquals("Unexpected response code for trust store update", 200, responseCode);
-
- trustStore = getRestTestHelper().getJsonAsList("truststore/" + name);
- assertNotNull("details should not be null", trustStore);
-
assertTrustStoreAttributes(trustStore.get(0), name, TestSSLConstants.TRUSTSTORE, false);
}
- private List<Map<String, Object>> assertNumberOfTrustStores(int numberOfTrustStores) throws IOException,
- JsonParseException, JsonMappingException
+ private List<Map<String, Object>> assertNumberOfTrustStores(int numberOfTrustStores) throws Exception
{
List<Map<String, Object>> trustStores = getRestTestHelper().getJsonAsList("truststore");
assertNotNull("trust stores should not be null", trustStores);
@@ -234,17 +146,16 @@ public class TrustStoreRestTest extends QpidRestTestCase
return trustStores;
}
- private void createTrustStore(String name, boolean peersOnly) throws IOException, JsonGenerationException, JsonMappingException
+ private void createTrustStore(String name, boolean peersOnly, final String truststorePath, final String truststorePassword) throws Exception
{
Map<String, Object> trustStoreAttributes = new HashMap<String, Object>();
trustStoreAttributes.put(TrustStore.NAME, name);
//deliberately using the client trust store to differentiate from the one we are already for broker
- trustStoreAttributes.put(FileTrustStore.PATH, TestSSLConstants.TRUSTSTORE);
- trustStoreAttributes.put(FileTrustStore.PASSWORD, TestSSLConstants.TRUSTSTORE_PASSWORD);
+ trustStoreAttributes.put(FileTrustStore.PATH, truststorePath);
+ trustStoreAttributes.put(FileTrustStore.PASSWORD, truststorePassword);
trustStoreAttributes.put(FileTrustStore.PEERS_ONLY, peersOnly);
- int responseCode = getRestTestHelper().submitRequest("truststore/" + name, "PUT", trustStoreAttributes);
- assertEquals("Unexpected response code", 201, responseCode);
+ getRestTestHelper().submitRequest("truststore/" + name, "PUT", trustStoreAttributes, HttpServletResponse.SC_CREATED);
}
private void assertTrustStoreAttributes(Map<String, Object> truststore, String name, String path, boolean peersOnly)
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
index 8c4effd685..86ebf11575 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/systest/rest/acl/BrokerACLTest.java
@@ -714,19 +714,6 @@ public class BrokerACLTest extends QpidRestTestCase
/* === AccessControlProvider === */
- public void testCreateAccessControlProviderAllowed() throws Exception
- {
- getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
-
- String accessControlProviderName = getTestName();
-
- assertAccessControlProviderExistence(accessControlProviderName, false);
-
- int responseCode = createAccessControlProvider(accessControlProviderName);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
-
- assertAccessControlProviderExistence(accessControlProviderName, true);
- }
public void testCreateAccessControlProviderDenied() throws Exception
{
@@ -746,18 +733,13 @@ public class BrokerACLTest extends QpidRestTestCase
{
getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- String accessControlProviderName = getTestName();
-
- assertAccessControlProviderExistence(accessControlProviderName, false);
-
- int responseCode = createAccessControlProvider(accessControlProviderName);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
+ String accessControlProviderName = TestBrokerConfiguration.ENTRY_NAME_ACL_FILE;
assertAccessControlProviderExistence(accessControlProviderName, true);
getRestTestHelper().setUsernameAndPassword(DENIED_USER, DENIED_USER);
- responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "DELETE");
+ int responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "DELETE");
assertEquals("Access control provider deletion should be denied", 403, responseCode);
assertAccessControlProviderExistence(accessControlProviderName, true);
@@ -767,16 +749,12 @@ public class BrokerACLTest extends QpidRestTestCase
{
getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- String accessControlProviderName = getTestName();
+ String accessControlProviderName = TestBrokerConfiguration.ENTRY_NAME_ACL_FILE;
- assertAccessControlProviderExistence(accessControlProviderName, false);
-
- int responseCode = createAccessControlProvider(accessControlProviderName);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
assertAccessControlProviderExistence(accessControlProviderName, true);
- responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "DELETE");
+ int responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "DELETE");
assertEquals("Access control provider deletion should be allowed", 200, responseCode);
assertAccessControlProviderExistence(accessControlProviderName, false);
@@ -786,20 +764,16 @@ public class BrokerACLTest extends QpidRestTestCase
{
getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- String accessControlProviderName = getTestName();
-
- assertAccessControlProviderExistence(accessControlProviderName, false);
-
- int responseCode = createAccessControlProvider(accessControlProviderName);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
+ String accessControlProviderName = TestBrokerConfiguration.ENTRY_NAME_ACL_FILE;
assertAccessControlProviderExistence(accessControlProviderName, true);
+ File aclFile = TestFileUtils.createTempFile(this, ".acl", "ACL ALLOW all all");
+
Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(GroupProvider.NAME, accessControlProviderName);
- attributes.put(GroupProvider.TYPE, FileBasedGroupProviderImpl.GROUP_FILE_PROVIDER_TYPE);
- attributes.put(FileBasedGroupProvider.PATH, "/path/to/file");
- responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "PUT", attributes);
+ attributes.put(AccessControlProvider.NAME, accessControlProviderName);
+ attributes.put(FileBasedGroupProvider.PATH, aclFile.getAbsolutePath());
+ int responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "PUT", attributes);
assertEquals("Setting of access control provider attributes should be allowed", 200, responseCode);
}
@@ -807,12 +781,7 @@ public class BrokerACLTest extends QpidRestTestCase
{
getRestTestHelper().setUsernameAndPassword(ALLOWED_USER, ALLOWED_USER);
- String accessControlProviderName = getTestName();
-
- assertAccessControlProviderExistence(accessControlProviderName, false);
-
- int responseCode = createAccessControlProvider(accessControlProviderName);
- assertEquals("Access control provider creation should be allowed", 201, responseCode);
+ String accessControlProviderName = TestBrokerConfiguration.ENTRY_NAME_ACL_FILE;
assertAccessControlProviderExistence(accessControlProviderName, true);
@@ -822,7 +791,7 @@ public class BrokerACLTest extends QpidRestTestCase
attributes.put(GroupProvider.NAME, accessControlProviderName);
attributes.put(GroupProvider.TYPE, FileBasedGroupProviderImpl.GROUP_FILE_PROVIDER_TYPE);
attributes.put(FileBasedGroupProvider.PATH, "/path/to/file");
- responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "PUT", attributes);
+ int responseCode = getRestTestHelper().submitRequest("accesscontrolprovider/" + accessControlProviderName, "PUT", attributes);
assertEquals("Setting of access control provider attributes should be denied", 403, responseCode);
}
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
index ed03e83292..191f9d72cf 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
@@ -81,7 +81,6 @@ public class ConnectionTest extends QpidBrokerTestCase
+ "&temporaryQueueExchange='tmp.direct'"
+ "&temporaryTopicExchange='tmp.topic'");
- System.err.println(url.toString());
conn = new AMQConnection(url);
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java
index 3fe45143d5..dfec1a8517 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/JavaServerCloseRaceConditionTest.java
@@ -106,7 +106,7 @@ public class JavaServerCloseRaceConditionTest extends QpidBrokerTestCase
}
catch (Exception e)
{
- assertTrue("Exception should say the exchange is not known.", e.getMessage().contains("Unknown exchange: " + EXCHANGE_NAME));
+ assertTrue("Exception should say the exchange is not known.", e.getMessage().contains("Unknown exchange: '" + EXCHANGE_NAME + "'"));
}
try
@@ -119,7 +119,7 @@ public class JavaServerCloseRaceConditionTest extends QpidBrokerTestCase
}
catch (Exception e)
{
- assertTrue("Exception should say the exchange is not known.", e.getMessage().contains("Unknown exchange: " + EXCHANGE_NAME));
+ assertTrue("Exception should say the exchange is not known.", e.getMessage().contains("Unknown exchange: '" + EXCHANGE_NAME + "'"));
}
}
diff --git a/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java b/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
index df32bd7858..de30a98a7d 100644
--- a/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
+++ b/qpid/java/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
@@ -35,7 +35,7 @@ import org.apache.qpid.test.utils.QpidBrokerTestCase;
public class MessageConsumerCloseTest extends QpidBrokerTestCase
{
- Exception _exception;
+ private volatile Exception _exception;
public void testConsumerCloseAndSessionRollback() throws Exception
{
@@ -65,7 +65,7 @@ public class MessageConsumerCloseTest extends QpidBrokerTestCase
boolean messageReceived = receiveLatch.await(1l, TimeUnit.SECONDS);
consumer.close();
- assertNull("Exception occured on rollback:" + _exception, _exception);
+ assertNull("Exception occurred on rollback:" + _exception, _exception);
assertTrue("Message is not received", messageReceived);
consumer = session.createConsumer(destination);
@@ -74,4 +74,38 @@ public class MessageConsumerCloseTest extends QpidBrokerTestCase
Message message2 = consumer.receive(1000l);
assertNotNull("message2 is not received", message2);
}
+
+ public void testPrefetchedMessagesReleasedOnConsumerClose() throws Exception
+ {
+ Connection connection = getConnection();
+ final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+
+ Destination destination = getTestQueue();
+ MessageConsumer consumer = session.createConsumer(destination);
+
+ sendMessage(session, destination, 3);
+
+ connection.start();
+
+ Message msg1 = consumer.receive(1000);
+ assertNotNull("Message one was null", msg1);
+ assertEquals("Message one has unexpected content", 0, msg1.getIntProperty(INDEX));
+ session.commit();
+
+ // Messages two and three will have been prefetched by the consumer.
+ // Closing the consumer must make the available for delivery elsewhere
+
+ consumer.close();
+
+ MessageConsumer consumer2 = session.createConsumer(destination);
+
+ Message msg2 = consumer2.receive(1000);
+ Message msg3 = consumer2.receive(1000);
+ assertNotNull("Message two was null", msg2);
+ assertEquals("Message two has unexpected content", 1, msg2.getIntProperty(INDEX));
+
+ assertNotNull("Message three was null", msg3);
+ assertEquals("Message three has unexpected content", 2, msg3.getIntProperty(INDEX));
+ session.commit();
+ }
}