You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2018/04/01 20:26:10 UTC
[03/30] qpid-broker-j git commit: QPID-8151: [Broker-J] [Unit tests]
Factor out QpidTestCase
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java
index 6681b79..1ced739 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigReaderTest.java
@@ -23,28 +23,46 @@ import java.io.Reader;
import java.util.List;
import java.util.Map;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.ConfigFileTestHelper;
import org.apache.qpid.disttest.client.property.PropertyValue;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
-public class ConfigReaderTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ConfigReaderTest extends UnitTestBase
{
private Config _config;
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
ConfigReader configReader = new ConfigReader();
Reader reader = ConfigFileTestHelper.getConfigFileReader(getClass(), "sampleConfig.json");
_config = configReader.readConfig(reader);
}
+ @Test
public void testReadTest()
{
List<TestConfig> tests = _config.getTestConfigs();
- assertEquals("Unexpected number of tests", 2, tests.size());
+ assertEquals("Unexpected number of tests", (long) 2, (long) tests.size());
TestConfig test1Config = tests.get(0);
assertNotNull("Test 1 configuration is expected", test1Config);
assertEquals("Unexpected test name", "Test 1", test1Config.getName());
@@ -53,11 +71,12 @@ public class ConfigReaderTest extends QpidTestCase
assertNotNull("Test 2 configuration is expected", test2Config);
}
+ @Test
public void testReadsTestWithQueues()
{
TestConfig test1Config = _config.getTestConfigs().get(0);
List<QueueConfig> queues = test1Config.getQueues();
- assertEquals("Unexpected number of queues", 2, queues.size());
+ assertEquals("Unexpected number of queues", (long) 2, (long) queues.size());
QueueConfig queue1Config = queues.get(0);
assertNotNull("Expected queue 1 config", queue1Config);
assertEquals("Unexpected queue name", "Json-Queue-Name", queue1Config.getName());
@@ -71,44 +90,48 @@ public class ConfigReaderTest extends QpidTestCase
Map<String, Object> attributes = queue2Config.getAttributes();
assertNotNull("Expected attributes", attributes);
assertFalse("Attributes are not loaded", attributes.isEmpty());
- assertEquals("Unexpected number of attributes", 1, attributes.size());
- assertEquals("Unexpected attribute 'x-qpid-priorities' value", 10,
- ((Number)attributes.get("x-qpid-priorities")).intValue());
+ assertEquals("Unexpected number of attributes", (long) 1, (long) attributes.size());
+ assertEquals("Unexpected attribute 'x-qpid-priorities' value",
+ (long) 10,
+ (long) ((Number) attributes.get("x-qpid-priorities")).intValue());
}
+ @Test
public void testReadsTestWithIterations()
{
TestConfig testConfig = _config.getTestConfigs().get(0);
List<IterationValue> iterationValues = testConfig.getIterationValues();
- assertEquals("Unexpected number of iterations", 2, iterationValues.size());
+ assertEquals("Unexpected number of iterations", (long) 2, (long) iterationValues.size());
IterationValue iteration1 = iterationValues.get(0);
String messageSizeProperty = "_messageSize";
assertEquals("Unexpected value for property " + messageSizeProperty,
- "100",
- iteration1.getIterationPropertyValuesWithUnderscores().get(messageSizeProperty));
+ "100",
+ iteration1.getIterationPropertyValuesWithUnderscores().get(messageSizeProperty));
}
+ @Test
public void testReadsMessageProviders()
{
TestConfig testConfig = _config.getTestConfigs().get(0);
ClientConfig cleintConfig = testConfig.getClients().get(0);
List<MessageProviderConfig> configs = cleintConfig.getMessageProviders();
assertNotNull("Message provider configs should not be null", configs);
- assertEquals("Unexpected number of message providers", 1, configs.size());
+ assertEquals("Unexpected number of message providers", (long) 1, (long) configs.size());
MessageProviderConfig messageProvider = configs.get(0);
assertNotNull("Message provider config should not be null", messageProvider);
assertEquals("Unexpected provider name", "testProvider1", messageProvider.getName());
Map<String, PropertyValue> properties = messageProvider.getMessageProperties();
assertNotNull("Message properties should not be null", properties);
- assertEquals("Unexpected number of message properties", 3, properties.size());
+ assertEquals("Unexpected number of message properties", (long) 3, (long) properties.size());
assertNotNull("test property is not found", properties.get("test"));
assertNotNull("priority property is not found", properties.get("priority"));
assertNotNull("id property is not found", properties.get("id"));
- }
+ }
+ @Test
public void testReadsJS() throws Exception
{
ConfigReader configReader = new ConfigReader();
@@ -116,32 +139,32 @@ public class ConfigReaderTest extends QpidTestCase
_config = configReader.getConfigFromFile(path);
List<TestConfig> testConfigs = _config.getTestConfigs();
- assertEquals("Unexpected number of tests", 2, testConfigs.size());
+ assertEquals("Unexpected number of tests", (long) 2, (long) testConfigs.size());
TestConfig testConfig1 = _config.getTestConfigs().get(0);
List<ClientConfig> cleintConfigs = testConfig1.getClients();
- assertEquals("Unexpected number of test 1 clients", 2, cleintConfigs.size());
+ assertEquals("Unexpected number of test 1 clients", (long) 2, (long) cleintConfigs.size());
List<QueueConfig> queueConfigs = testConfig1.getQueues();
- assertEquals("Unexpected number of test 1 queue", 1, queueConfigs.size());
+ assertEquals("Unexpected number of test 1 queue", (long) 1, (long) queueConfigs.size());
assertEquals("Unexpected queue name", "Json-Queue-Name", queueConfigs.get(0).getName());
ClientConfig cleintConfig = cleintConfigs.get(0);
List<ConnectionConfig> connectionConfigs = cleintConfig.getConnections();
- assertEquals("Unexpected number of connections", 1, connectionConfigs.size());
+ assertEquals("Unexpected number of connections", (long) 1, (long) connectionConfigs.size());
List<SessionConfig> sessionConfigs = connectionConfigs.get(0).getSessions();
- assertEquals("Unexpected number of sessions", 1, sessionConfigs.size());
- assertEquals("Unexpected ack mode", 0, sessionConfigs.get(0).getAcknowledgeMode());
+ assertEquals("Unexpected number of sessions", (long) 1, (long) sessionConfigs.size());
+ assertEquals("Unexpected ack mode", (long) 0, (long) sessionConfigs.get(0).getAcknowledgeMode());
TestConfig testConfig2 = _config.getTestConfigs().get(1);
List<ClientConfig> cleintConfigs2 = testConfig2.getClients();
- assertEquals("Unexpected number of test 1 clients", 2, cleintConfigs2.size());
+ assertEquals("Unexpected number of test 1 clients", (long) 2, (long) cleintConfigs2.size());
List<QueueConfig> queueConfigs2 = testConfig2.getQueues();
- assertEquals("Unexpected number of test 1 queue", 1, queueConfigs2.size());
+ assertEquals("Unexpected number of test 1 queue", (long) 1, (long) queueConfigs2.size());
assertEquals("Unexpected queue name", "Json-Queue-Name", queueConfigs2.get(0).getName());
ClientConfig cleintConfig2 = cleintConfigs2.get(0);
List<ConnectionConfig> connectionConfigs2 = cleintConfig2.getConnections();
- assertEquals("Unexpected number of connections", 1, connectionConfigs2.size());
+ assertEquals("Unexpected number of connections", (long) 1, (long) connectionConfigs2.size());
List<SessionConfig> sessionConfigs2 = connectionConfigs2.get(0).getSessions();
- assertEquals("Unexpected number of sessions", 1, sessionConfigs2.size());
- assertEquals("Unexpected ack mode", 1, sessionConfigs2.get(0).getAcknowledgeMode());
+ assertEquals("Unexpected number of sessions", (long) 1, (long) sessionConfigs2.size());
+ assertEquals("Unexpected ack mode", (long) 1, (long) sessionConfigs2.get(0).getAcknowledgeMode());
}
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java
index 291ce2a..e96fa35 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConfigTest.java
@@ -24,22 +24,40 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.junit.Assert;
-public class ConfigTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ConfigTest extends UnitTestBase
{
+ @Test
public void testGetTestsForTestWithIteratingMessageSizes()
{
Config config = createConfigWithIteratingMessageSizes();
List<TestInstance> testConfigs = config.getTests();
- assertEquals("should have a test config for each message size", 2, testConfigs.size());
+ assertEquals("should have a test config for each message size", (long) 2, (long) testConfigs.size());
TestInstance instance0 = testConfigs.get(0);
- assertEquals(0, instance0.getIterationNumber());
+ assertEquals((long) 0, (long) instance0.getIterationNumber());
TestInstance instance1 = testConfigs.get(1);
- assertEquals(1, instance1.getIterationNumber());
+ assertEquals((long) 1, (long) instance1.getIterationNumber());
}
private Config createConfigWithIteratingMessageSizes()
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java
index 0eee80e..14dd1db 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConnectionConfigTest.java
@@ -27,28 +27,48 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.message.Command;
import org.apache.qpid.disttest.message.CreateConnectionCommand;
import org.apache.qpid.disttest.message.NoOpCommand;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class ConnectionConfigTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ConnectionConfigTest extends UnitTestBase
{
private static final String CONNECTION_FACTORY_NAME = "ConnectionFactoryName";
private static final String CONNECTION_NAME = "ConnectionName";
+ @Test
public void testConnectionConfigHasZeroArgConstructorForGson()
{
ConnectionConfig c = new ConnectionConfig();
assertNotNull(c);
}
+ @Test
public void testCreateCommandsForConnectionAndChildren()
{
ConnectionConfig connectionConfig = createConnectionConfigWithChildCommands();
List<Command> commands = connectionConfig.createCommands();
- assertEquals(3, commands.size());
+ assertEquals((long) 3, (long) commands.size());
assertCommandEquals(commands, 0, CreateConnectionCommand.class);
assertCommandEquals(commands, 1, NoOpCommand.class);
@@ -59,10 +79,11 @@ public class ConnectionConfigTest extends QpidTestCase
assertEquals(CONNECTION_FACTORY_NAME, createConnectionCommand.getConnectionFactoryName());
}
+ @Test
public void testGetTotalNumberOfParticipants()
{
ConnectionConfig connectionConfig = createConnectionConfigWithTwoParticipants();
- assertEquals(2, connectionConfig.getTotalNumberOfParticipants());
+ assertEquals((long) 2, (long) connectionConfig.getTotalNumberOfParticipants());
}
private ConnectionConfig createConnectionConfigWithTwoParticipants()
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java
index 0aa05a1..1b26ffb 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ConsumerConfigTest.java
@@ -19,17 +19,37 @@
*/
package org.apache.qpid.disttest.controller.config;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.message.CreateConsumerCommand;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class ConsumerConfigTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ConsumerConfigTest extends UnitTestBase
{
+ @Test
public void testConsumerHasZeroArgConstructorForGson()
{
ConsumerConfig c = new ConsumerConfig();
assertNotNull(c);
}
+ @Test
public void testCreateConsumerCommand()
{
boolean isTopic = true;
@@ -64,7 +84,7 @@ public class ConsumerConfigTest extends QpidTestCase
assertEquals(consumerName, createConsumerCommand.getParticipantName());
assertEquals(destinationName, createConsumerCommand.getDestinationName());
assertEquals(numberOfMessages, createConsumerCommand.getNumberOfMessages());
- assertEquals(batchSize, createConsumerCommand.getBatchSize());
+ assertEquals((long) batchSize, (long) createConsumerCommand.getBatchSize());
assertEquals(maximumDuration, createConsumerCommand.getMaximumDuration());
assertEquals(isTopic, createConsumerCommand.isTopic());
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java
index 860f6af..5d239d4 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/IterationValueTest.java
@@ -27,9 +27,25 @@ import java.util.Map;
import org.apache.qpid.disttest.message.CreateConnectionCommand;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class IterationValueTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class IterationValueTest extends UnitTestBase
{
private static final int MAXIMUM_DURATION = 10;
@@ -38,10 +54,9 @@ public class IterationValueTest extends QpidTestCase
private CreateConsumerCommand _createConsumerCommand;
private Map<String, String> _iterationValueMap;
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
_createConsumerCommand = mock(CreateConsumerCommand.class);
_iterationValueMap = new HashMap<String, String>();
@@ -49,6 +64,7 @@ public class IterationValueTest extends QpidTestCase
_iterationValueMap.put("_durableSubscription", String.valueOf(IS_DURABLE_SUBSCRIPTION));
}
+ @Test
public void testApplyPopulatedIterationValueToCommandWithMatchingProperties() throws Exception
{
IterationValue iterationValue = new IterationValue(_iterationValueMap);
@@ -59,6 +75,7 @@ public class IterationValueTest extends QpidTestCase
verify(_createConsumerCommand).setDurableSubscription(IS_DURABLE_SUBSCRIPTION);
}
+ @Test
public void testApplyPopulatedIterationValueToCommandWithoutMatchingProperties() throws Exception
{
IterationValue iterationValue = new IterationValue(_iterationValueMap);
@@ -69,6 +86,7 @@ public class IterationValueTest extends QpidTestCase
verifyZeroInteractions(createConnectionCommand);
}
+ @Test
public void testApplyUnpopulatedIterationValueToCommand() throws Exception
{
IterationValue iterationValue = new IterationValue();
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java
index 984c11e..5632518 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/JavaScriptConfigEvaluatorTest.java
@@ -28,39 +28,65 @@ import java.util.TreeMap;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+import org.junit.Assert;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
-public class JavaScriptConfigEvaluatorTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class JavaScriptConfigEvaluatorTest extends UnitTestBase
{
private void performTest(Map configAsObject) throws Exception
{
// Tests are produced by the QPID.iterations js function
List<?> countries = getPropertyAsList(configAsObject, "_countries");
- assertEquals("Unexpected number of countries", 2, countries.size());
+ assertEquals("Unexpected number of countries", (long) 2, (long) countries.size());
Map country0 = (Map) countries.get(0);
assertEquals("Unexpected country name", "Country", country0.get("_name"));
- assertEquals("Unexpected country iteration number", 0, ((Number)country0.get("_iterationNumber")).intValue());
+ assertEquals("Unexpected country iteration number",
+ (long) 0,
+ (long) ((Number) country0.get("_iterationNumber")).intValue());
List<?> regions = getPropertyAsList(country0, "_regions");
- assertEquals("Unexpected number of regions", 2, regions.size());
+ assertEquals("Unexpected number of regions", (long) 2, (long) regions.size());
// Region names are produced by the QPID.times js function
Map region0 = (Map) regions.get(0);
assertEquals("Unexpected region name", "repeatingRegion0", region0.get("_name"));
assertEquals("Unexpected region name", "repeatingRegion1", ((Map)regions.get(1)).get("_name"));
// Iterating attribute are produced by the QPID.iterations js function
- assertEquals("Unexpected iterating attribute", "0", ((Map)((List)region0.get("_towns")).get(0)).get("_iteratingAttribute"));
+ assertEquals("Unexpected iterating attribute",
+ "0",
+ ((Map)((List)region0.get("_towns")).get(0)).get("_iteratingAttribute"));
Map country1 = (Map) countries.get(1);
regions = getPropertyAsList(country1, "_regions");
region0 = (Map) regions.get(0);
- assertEquals("Unexpected country iteration number", 1, ((Number)country1.get("_iterationNumber")).intValue());
- assertEquals("Unexpected iterating attribute", "1", ((Map)((List)region0.get("_towns")).get(0)).get("_iteratingAttribute"));
+ assertEquals("Unexpected country iteration number",
+ (long) 1,
+ (long) ((Number) country1.get("_iterationNumber")).intValue());
+ assertEquals("Unexpected iterating attribute",
+ "1",
+ ((Map)((List)region0.get("_towns")).get(0)).get("_iteratingAttribute"));
}
+ @Test
public void testEvaluateJavaScript() throws Exception
{
String jsFilePath = TestFileUtils.createTempFileFromResource(this, "JavaScriptConfigEvaluatorTest-test-config.js").getAbsolutePath();
@@ -71,6 +97,7 @@ public class JavaScriptConfigEvaluatorTest extends QpidTestCase
performTest(configAsObject);
}
+ @Test
public void testEvaluateJavaScriptWithReader() throws Exception
{
String jsFilePath = TestFileUtils.createTempFileFromResource(this, "JavaScriptConfigEvaluatorTest-test-config.js").getAbsolutePath();
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java
index 148c07b..15d1c2f 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/MessageProviderConfigTest.java
@@ -21,13 +21,32 @@ package org.apache.qpid.disttest.controller.config;
import java.util.HashMap;
import java.util.Map;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.client.property.PropertyValue;
import org.apache.qpid.disttest.client.property.SimplePropertyValue;
import org.apache.qpid.disttest.message.CreateMessageProviderCommand;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class MessageProviderConfigTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class MessageProviderConfigTest extends UnitTestBase
{
+ @Test
public void testCreateCommandsForMessageProvider()
{
Map<String, PropertyValue> messageProperties = new HashMap<String, PropertyValue>();
@@ -39,6 +58,7 @@ public class MessageProviderConfigTest extends QpidTestCase
assertEquals("Unexpected properties", messageProperties, command.getMessageProperties());
}
+ @Test
public void testMessageProviderConfig()
{
Map<String, PropertyValue> messageProperties = new HashMap<String, PropertyValue>();
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java
index b16ead6..9f58014 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/ProducerConfigTest.java
@@ -22,25 +22,46 @@ package org.apache.qpid.disttest.controller.config;
import javax.jms.DeliveryMode;
import javax.jms.Message;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.message.CreateProducerCommand;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class ProducerConfigTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ProducerConfigTest extends UnitTestBase
{
+ @Test
public void testProducerHasZeroArgConstructorForGson()
{
ProducerConfig p = new ProducerConfig();
assertNotNull(p);
}
+ @Test
public void testConfigProvidesJmsDefaults()
{
CreateProducerCommand p = new ProducerConfig().createCommand("session1");
- assertEquals(Message.DEFAULT_DELIVERY_MODE, p.getDeliveryMode());
- assertEquals(Message.DEFAULT_PRIORITY, p.getPriority());
+ assertEquals((long) Message.DEFAULT_DELIVERY_MODE, (long) p.getDeliveryMode());
+ assertEquals((long) Message.DEFAULT_PRIORITY, (long) p.getPriority());
assertEquals(Message.DEFAULT_TIME_TO_LIVE, p.getTimeToLive());
}
+ @Test
public void testCreateProducerCommandAppliesDurationOverride()
{
long overriddenDuration = 123;
@@ -49,24 +70,27 @@ public class ProducerConfigTest extends QpidTestCase
CreateProducerCommand command = producerConfig.createCommand("name");
- assertEquals(123, command.getMaximumDuration());
+ assertEquals((long) 123, command.getMaximumDuration());
}
+ @Test
public void testMessageSizeDefault()
{
CreateProducerCommand producer = new ProducerConfig().createCommand("session1");
- assertEquals("Unexpected default message size", 1024, producer.getMessageSize());
+ assertEquals("Unexpected default message size", (long) 1024, (long) producer.getMessageSize());
}
+ @Test
public void testMessageSizeDefaultOverride()
{
final long overriddenMessageSize = 4096;
setTestSystemProperty(ProducerConfig.MESSAGE_SIZE_OVERRIDE_SYSTEM_PROPERTY, String.valueOf(overriddenMessageSize));
CreateProducerCommand producer2 = new ProducerConfig().createCommand("session1");
- assertEquals("Unexpected message size", overriddenMessageSize, producer2.getMessageSize());
+ assertEquals("Unexpected message size", overriddenMessageSize, (long) producer2.getMessageSize());
}
+ @Test
public void testCreateProducerCommand()
{
String destination = "url:/destination";
@@ -98,13 +122,13 @@ public class ProducerConfigTest extends QpidTestCase
assertEquals("session1", command.getSessionName());
assertEquals("producer1", command.getParticipantName());
assertEquals(destination, command.getDestinationName());
- assertEquals(numberOfMessages, command.getNumberOfMessages());
- assertEquals(batchSize, command.getBatchSize());
+ assertEquals((long) numberOfMessages, command.getNumberOfMessages());
+ assertEquals((long) batchSize, (long) command.getBatchSize());
assertEquals(maximumDuration, command.getMaximumDuration());
- assertEquals(DeliveryMode.NON_PERSISTENT, command.getDeliveryMode());
- assertEquals(messageSize, command.getMessageSize());
- assertEquals(priority, command.getPriority());
+ assertEquals((long) DeliveryMode.NON_PERSISTENT, (long) command.getDeliveryMode());
+ assertEquals((long) messageSize, (long) command.getMessageSize());
+ assertEquals((long) priority, (long) command.getPriority());
assertEquals(timeToLive, command.getTimeToLive());
assertEquals(interval, command.getInterval());
assertEquals(providerName, command.getMessageProviderName());
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java
index 02cdbb8..3c507ca 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/SessionConfigTest.java
@@ -29,44 +29,65 @@ import java.util.List;
import javax.jms.Session;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.message.Command;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
import org.apache.qpid.disttest.message.CreateProducerCommand;
import org.apache.qpid.disttest.message.CreateSessionCommand;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class SessionConfigTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class SessionConfigTest extends UnitTestBase
{
private static final String CONNECTION_NAME = "conn1";
private static final String SESSION = "session1";
+ @Test
public void testSessionHasZeroArgConstructorForGson()
{
SessionConfig s = new SessionConfig();
assertNotNull(s);
}
+ @Test
public void testCreateCommandsForSessionAndChildren()
{
SessionConfig sessionConfig = createSessionConfigWithChildCommands();
List<Command> commands = sessionConfig.createCommands(CONNECTION_NAME);
- assertEquals(3, commands.size());
+ assertEquals((long) 3, (long) commands.size());
assertCommandEquals(commands, 0, CreateSessionCommand.class);
assertCommandEquals(commands, 1, CreateProducerCommand.class);
assertCommandEquals(commands, 2, CreateConsumerCommand.class);
CreateSessionCommand createSessionCommand = getCommand(commands, 0);
- assertEquals(Session.AUTO_ACKNOWLEDGE, createSessionCommand.getAcknowledgeMode());
+ assertEquals((long) Session.AUTO_ACKNOWLEDGE, (long) createSessionCommand.getAcknowledgeMode());
assertEquals(SESSION, createSessionCommand.getSessionName());
assertEquals(CONNECTION_NAME, createSessionCommand.getConnectionName());
}
+ @Test
public void testGetTotalNumberOfParticipants()
{
SessionConfig sessionConfig = createSessionConfigWithOneConsumerAndOneProducer();
- assertEquals(2, sessionConfig.getTotalNumberOfParticipants());
+ assertEquals((long) 2, (long) sessionConfig.getTotalNumberOfParticipants());
}
private SessionConfig createSessionConfigWithOneConsumerAndOneProducer()
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java
index be7c7a7..6c15fd1 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestConfigTest.java
@@ -26,52 +26,75 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.controller.CommandForClient;
import org.apache.qpid.disttest.message.NoOpCommand;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class TestConfigTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class TestConfigTest extends UnitTestBase
{
private static final QueueConfig[] EMPTY_QUEUES_ARRAY = new QueueConfig[0];
private static final String CLIENT1 = "client1";
private static final String CLIENT2 = "client2";
private static final String TEST1 = "test1";
+ @Test
public void testConfigHasZeroArgConstructorForGson()
{
TestConfig c = new TestConfig();
assertNotNull(c);
}
+ @Test
public void testCreateCommandsForClient()
{
TestConfig config = createTestConfigWithClientConfigReturningChildCommands();
List<CommandForClient> commandsForClients = config.createCommands();
- assertEquals("Unexpected number of commands for client", 3, commandsForClients.size());
+ assertEquals("Unexpected number of commands for client", (long) 3, (long) commandsForClients.size());
assertCommandForClient(commandsForClients, 0, CLIENT1, NoOpCommand.class);
assertCommandForClient(commandsForClients, 1, CLIENT1, NoOpCommand.class);
assertCommandForClient(commandsForClients, 2, CLIENT2, NoOpCommand.class);
}
+ @Test
public void testGetClientNames()
{
TestConfig config = createTestConfigWithTwoClients();
- assertEquals(2, config.getClientNames().size());
+ assertEquals((long) 2, (long) config.getClientNames().size());
}
+ @Test
public void testGetTotalNumberOfClients()
{
TestConfig config = createTestConfigWithTwoClients();
- assertEquals(2, config.getTotalNumberOfClients());
+ assertEquals((long) 2, (long) config.getTotalNumberOfClients());
}
+ @Test
public void testGetTotalNumberOfParticipants()
{
TestConfig config = createTestConfigWithTwoClients();
- assertEquals(2, config.getTotalNumberOfParticipants());
+ assertEquals((long) 2, (long) config.getTotalNumberOfParticipants());
}
private TestConfig createTestConfigWithClientConfigReturningChildCommands()
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java
index b1c96da..0fd709f 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/controller/config/TestInstanceTest.java
@@ -26,13 +26,31 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.controller.CommandForClient;
import org.apache.qpid.disttest.message.CreateConsumerCommand;
import org.apache.qpid.disttest.message.CreateProducerCommand;
import org.apache.qpid.disttest.message.NoOpCommand;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class TestInstanceTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class TestInstanceTest extends UnitTestBase
{
private static final String CLIENT_NAME = "CLIENT_NAME";
private static final int ITERATION_NUMBER = 0;
@@ -41,10 +59,9 @@ public class TestInstanceTest extends QpidTestCase
private CreateProducerCommand _createProducerCommand;
private CreateConsumerCommand _createConsumerCommand;
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
_noOpCommand = mock(NoOpCommand.class);
_createProducerCommand = mock(CreateProducerCommand.class);
when(_createProducerCommand.getMaximumDuration()).thenReturn(1l);
@@ -53,6 +70,7 @@ public class TestInstanceTest extends QpidTestCase
when(_createConsumerCommand.getMaximumDuration()).thenReturn(1l);
}
+ @Test
public void testCreateCommandsWithIterationValues()
{
IterationValue iterationValue = mock(IterationValue.class);
@@ -62,22 +80,24 @@ public class TestInstanceTest extends QpidTestCase
TestInstance testInstance = new TestInstance(config, ITERATION_NUMBER, iterationValue);
List<CommandForClient> commandsForClients = testInstance.createCommands();
- assertEquals("Unexpected number of commands for client", 3, commandsForClients.size());
+ assertEquals("Unexpected number of commands for client", (long) 3, (long) commandsForClients.size());
verify(iterationValue).applyToCommand(_noOpCommand);
verify(iterationValue).applyToCommand(_createProducerCommand);
verify(iterationValue).applyToCommand(_createConsumerCommand);
}
+ @Test
public void testCreateCommandsWithoutIterationValues()
{
TestConfig config = createTestConfig();
TestInstance testInstance = new TestInstance(config);
List<CommandForClient> commandsForClients = testInstance.createCommands();
- assertEquals("Unexpected number of commands for client", 3, commandsForClients.size());
+ assertEquals("Unexpected number of commands for client", (long) 3, (long) commandsForClients.size());
}
+ @Test
public void testGetConfiguredClientNames()
{
TestConfig testConfig = mock(TestConfig.class);
@@ -85,7 +105,7 @@ public class TestInstanceTest extends QpidTestCase
TestInstance testInstance = new TestInstance(testConfig);
List<String> clientNames = testInstance.getClientNames();
- assertEquals(1, clientNames.size());
+ assertEquals((long) 1, (long) clientNames.size());
assertEquals(CLIENT_NAME, clientNames.get(0));
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java b/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java
index d8897da..0ef3dd6 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/db/ResultsDbWriterTest.java
@@ -40,14 +40,32 @@ import java.util.TimeZone;
import javax.naming.Context;
import javax.naming.NamingException;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.controller.ResultsForAllTests;
import org.apache.qpid.disttest.db.ResultsDbWriter.Clock;
import org.apache.qpid.disttest.message.ParticipantResult;
import org.apache.qpid.disttest.results.ResultsTestFixture;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
-public class ResultsDbWriterTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ResultsDbWriterTest extends UnitTestBase
{
private static final long _dummyTimestamp = 1234;
@@ -55,17 +73,16 @@ public class ResultsDbWriterTest extends QpidTestCase
private Clock _clock = mock(Clock.class);
private ResultsTestFixture _resultsTestFixture = new ResultsTestFixture();
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
_tempDbDirectory = createTestDirectory();
when(_clock.currentTimeMillis()).thenReturn(_dummyTimestamp);
}
- @Override
- protected void tearDown() throws Exception
+ @After
+ public void tearDown() throws Exception
{
try
{
@@ -73,11 +90,11 @@ public class ResultsDbWriterTest extends QpidTestCase
}
finally
{
- super.tearDown();
}
}
+ @Test
public void testWriteResults() throws Exception
{
Context context = getContext();
@@ -93,6 +110,7 @@ public class ResultsDbWriterTest extends QpidTestCase
assertResultsAreInDb(context, expectedResult, runId);
}
+ @Test
public void testDefaultRunId() throws Exception
{
TimeZone defaultTimeZone = TimeZone.getDefault();
@@ -102,10 +120,11 @@ public class ResultsDbWriterTest extends QpidTestCase
TimeZone.setDefault(TimeZone.getTimeZone("GMT-05:00"));
ResultsDbWriter resultsDbWriter = new ResultsDbWriter(getContext(), null, _clock);
String runId = resultsDbWriter.getRunId();
- assertEquals(
- "Default run id '" + runId + "' should correspond to dummy timestamp " + _clock.currentTimeMillis(),
- "run 1970-01-01 00:00:01.234",
- runId);
+ assertEquals("Default run id '" + runId + "' should correspond to dummy timestamp " + _clock.currentTimeMillis(),
+
+ "run 1970-01-01 00:00:01.234",
+ runId);
+
}
finally
{
@@ -144,9 +163,11 @@ public class ResultsDbWriterTest extends QpidTestCase
{
rs.next();
assertEquals(participantResult.getTestName(), rs.getString(TEST_NAME.getDisplayName()));
- assertEquals(participantResult.getIterationNumber(), rs.getInt(ITERATION_NUMBER.getDisplayName()));
+ assertEquals((long) participantResult.getIterationNumber(),
+ (long) rs.getInt(ITERATION_NUMBER.getDisplayName()));
+
assertEquals(participantResult.getParticipantName(), rs.getString(PARTICIPANT_NAME.getDisplayName()));
- assertEquals(participantResult.getThroughput(), rs.getDouble(THROUGHPUT.getDisplayName()));
+ assertEquals(participantResult.getThroughput(), (Object) rs.getDouble(THROUGHPUT.getDisplayName()));
assertEquals(expectedRunId, rs.getString(ResultsDbWriter.RUN_ID));
assertEquals(new Timestamp(_dummyTimestamp), rs.getTimestamp(ResultsDbWriter.INSERTED_TIMESTAMP));
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java b/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java
index d4f0cb1..12abaf1 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/jms/JmsMessageAdaptorTest.java
@@ -18,20 +18,38 @@
*/
package org.apache.qpid.disttest.jms;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.message.Command;
import org.apache.qpid.disttest.message.CommandType;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class JmsMessageAdaptorTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class JmsMessageAdaptorTest extends UnitTestBase
{
+ @Test
public void testCheckAllCommandTypes()
{
for (CommandType commandType : CommandType.values())
{
Class<? extends Command> clazz = JmsMessageAdaptor.getCommandClassFromType(commandType);
assertNotNull(clazz);
-
}
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java b/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java
index 54efc65..766793a 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/message/JsonHandlerTest.java
@@ -24,20 +24,37 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.client.property.ListPropertyValue;
import org.apache.qpid.disttest.client.property.PropertyValue;
import org.apache.qpid.disttest.json.JsonHandler;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class JsonHandlerTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class JsonHandlerTest extends UnitTestBase
{
private JsonHandler _jsonHandler = null;
private SendChristmasCards _testCommand = null;
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
_jsonHandler = new JsonHandler();
@@ -45,15 +62,20 @@ public class JsonHandlerTest extends QpidTestCase
_testCommand._persons = Arrays.asList(new Person("Phil"), new Person("Andrew"));
}
+ @Test
public void testMarshallUnmarshall() throws Exception
{
final String jsonString = _jsonHandler.marshall(_testCommand);
final SendChristmasCards unmarshalledCommand = _jsonHandler.unmarshall(jsonString, SendChristmasCards.class);
- assertEquals("Unmarshalled command should be equal to the original object", _testCommand, unmarshalledCommand);
+ assertEquals("Unmarshalled command should be equal to the original object",
+ _testCommand,
+ unmarshalledCommand);
+
}
+ @Test
public void testSimplePropertyValueMarshallUnmarshall() throws Exception
{
String json = "{'_messageProperties': {'test': 1}}";
@@ -62,17 +84,21 @@ public class JsonHandlerTest extends QpidTestCase
Map<String, PropertyValue> properties = unmarshalledCommand.getMessageProperties();
assertNotNull("Properties should not be null", properties);
assertFalse("Properties should not be empty", properties.isEmpty());
- assertEquals("Unexpected properties size", 1, properties.size());
+ assertEquals("Unexpected properties size", (long) 1, (long) properties.size());
PropertyValue testProperty = properties.get("test");
assertNotNull("Unexpected property test", testProperty);
- assertTrue("Unexpected property test", testProperty.getValue() instanceof Number);
- assertEquals("Unexpected property value", 1, ((Number)testProperty.getValue()).intValue());
+ final boolean condition = testProperty.getValue() instanceof Number;
+ assertTrue("Unexpected property test", condition);
+ assertEquals("Unexpected property value", (long) 1, (long) ((Number) testProperty.getValue()).intValue());
String newJson =_jsonHandler.marshall(unmarshalledCommand);
final TestCommand newUnmarshalledCommand = _jsonHandler.unmarshall(newJson, TestCommand.class);
- assertEquals("Unmarshalled command should be equal to the original object", unmarshalledCommand, newUnmarshalledCommand);
+ assertEquals("Unmarshalled command should be equal to the original object",
+ unmarshalledCommand,
+ newUnmarshalledCommand);
}
+ @Test
public void testGeneratorDesrialization() throws Exception
{
String json = "{'_messageProperties': {'test': 1, 'generator': {'@def': 'list', '_cyclic': false, '_items': ['first', " +
@@ -82,14 +108,16 @@ public class JsonHandlerTest extends QpidTestCase
Map<String, PropertyValue> properties = unmarshalledCommand.getMessageProperties();
assertNotNull("Properties should not be null", properties);
assertFalse("Properties should not be empty", properties.isEmpty());
- assertEquals("Unexpected properties size", 2, properties.size());
+ assertEquals("Unexpected properties size", (long) 2, (long) properties.size());
PropertyValue testProperty = properties.get("test");
assertNotNull("Unexpected property test", testProperty);
- assertTrue("Unexpected property test", testProperty.getValue() instanceof Number);
- assertEquals("Unexpected property value", 1, ((Number)testProperty.getValue()).intValue());
+ final boolean condition1 = testProperty.getValue() instanceof Number;
+ assertTrue("Unexpected property test", condition1);
+ assertEquals("Unexpected property value", (long) 1, (long) ((Number) testProperty.getValue()).intValue());
Object generatorObject = properties.get("generator");
- assertTrue("Unexpected generator object : " + generatorObject, generatorObject instanceof ListPropertyValue);
+ final boolean condition = generatorObject instanceof ListPropertyValue;
+ assertTrue("Unexpected generator object : " + generatorObject, condition);
PropertyValue generator = (PropertyValue)generatorObject;
assertEquals("Unexpected generator value", "first", generator.getValue());
@@ -100,7 +128,9 @@ public class JsonHandlerTest extends QpidTestCase
String newJson =_jsonHandler.marshall(unmarshalledCommand);
final TestCommand newUnmarshalledCommand = _jsonHandler.unmarshall(newJson, TestCommand.class);
- assertEquals("Unmarshalled command should be equal to the original object", unmarshalledCommand, newUnmarshalledCommand);
+ assertEquals("Unmarshalled command should be equal to the original object",
+ unmarshalledCommand,
+ newUnmarshalledCommand);
}
/**
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java b/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java
index 42a0ce3..4fcf620 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/message/ParticipantResultTest.java
@@ -46,11 +46,29 @@ import java.util.Date;
import javax.jms.DeliveryMode;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.junit.Assert;
-public class ParticipantResultTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ParticipantResultTest extends UnitTestBase
{
+ @Test
public void testSharedParticipantResultAttributes() throws Exception
{
final String participantName = "PARTICIPANT_NAME1";
@@ -93,22 +111,23 @@ public class ParticipantResultTest extends QpidTestCase
result.setErrorMessage(errorMessage);
- assertEquals(participantName, result.getAttributes().get(PARTICIPANT_NAME));
- assertEquals(testName, result.getAttributes().get(TEST_NAME));
- assertEquals(iterationNumber, result.getAttributes().get(ITERATION_NUMBER));
- assertEquals(clientConfiguredName, result.getAttributes().get(CONFIGURED_CLIENT_NAME));
- assertEquals(numberOfMessages, result.getAttributes().get(NUMBER_OF_MESSAGES_PROCESSED));
- assertEquals(timeTaken, result.getAttributes().get(TIME_TAKEN));
- assertEquals(timeTaken, result.getAttributes().get(TIME_TAKEN));
- assertEquals(timeTaken, result.getAttributes().get(TIME_TAKEN));
- assertEquals(batchSize, result.getAttributes().get(BATCH_SIZE));
- assertEquals(maximumDuration, result.getAttributes().get(MAXIMUM_DURATION));
+ assertEquals(participantName, result.getAttributes().get(PARTICIPANT_NAME));
+ assertEquals(testName, result.getAttributes().get(TEST_NAME));
+ assertEquals(iterationNumber, result.getAttributes().get(ITERATION_NUMBER));
+ assertEquals(clientConfiguredName, result.getAttributes().get(CONFIGURED_CLIENT_NAME));
+ assertEquals(numberOfMessages, result.getAttributes().get(NUMBER_OF_MESSAGES_PROCESSED));
+ assertEquals(timeTaken, result.getAttributes().get(TIME_TAKEN));
+ assertEquals(timeTaken, result.getAttributes().get(TIME_TAKEN));
+ assertEquals(timeTaken, result.getAttributes().get(TIME_TAKEN));
+ assertEquals(batchSize, result.getAttributes().get(BATCH_SIZE));
+ assertEquals(maximumDuration, result.getAttributes().get(MAXIMUM_DURATION));
assertEquals(totalNumberOfConsumers, result.getAttributes().get(TOTAL_NUMBER_OF_CONSUMERS));
assertEquals(totalNumberOfProducers, result.getAttributes().get(TOTAL_NUMBER_OF_PRODUCERS));
- assertEquals(acknowledgeMode, result.getAttributes().get(ACKNOWLEDGE_MODE));
- assertEquals(errorMessage, result.getAttributes().get(ERROR_MESSAGE));
+ assertEquals(acknowledgeMode, result.getAttributes().get(ACKNOWLEDGE_MODE));
+ assertEquals(errorMessage, result.getAttributes().get(ERROR_MESSAGE));
}
+ @Test
public void testConsumerParticipantResultAttributes() throws Exception
{
ConsumerParticipantResult result = new ConsumerParticipantResult();
@@ -127,14 +146,15 @@ public class ParticipantResultTest extends QpidTestCase
result.setNoLocal(noLocal);
result.setSynchronousConsumer(synchronousConsumer);
- assertEquals(topic, result.getAttributes().get(IS_TOPIC));
- assertEquals(durable, result.getAttributes().get(IS_DURABLE_SUBSCRIPTION));
- assertEquals(browsingSubscription, result.getAttributes().get(IS_BROWSING_SUBSCRIPTION));
- assertEquals(selector, result.getAttributes().get(IS_SELECTOR));
- assertEquals(noLocal, result.getAttributes().get(IS_NO_LOCAL));
- assertEquals(synchronousConsumer, result.getAttributes().get(IS_SYNCHRONOUS_CONSUMER));
+ assertEquals(topic, result.getAttributes().get(IS_TOPIC));
+ assertEquals(durable, result.getAttributes().get(IS_DURABLE_SUBSCRIPTION));
+ assertEquals(browsingSubscription, result.getAttributes().get(IS_BROWSING_SUBSCRIPTION));
+ assertEquals(selector, result.getAttributes().get(IS_SELECTOR));
+ assertEquals(noLocal, result.getAttributes().get(IS_NO_LOCAL));
+ assertEquals(synchronousConsumer, result.getAttributes().get(IS_SYNCHRONOUS_CONSUMER));
}
+ @Test
public void testProducerParticipantResultAttributes() throws Exception
{
ProducerParticipantResult result = new ProducerParticipantResult();
@@ -151,11 +171,10 @@ public class ParticipantResultTest extends QpidTestCase
result.setPayloadSize(messageSize);
result.setDeliveryMode(deliveryMode);
-
- assertEquals(priority, result.getAttributes().get(PRIORITY));
- assertEquals(timeToLive, result.getAttributes().get(TIME_TO_LIVE));
- assertEquals(producerInterval, result.getAttributes().get(PRODUCER_INTERVAL));
- assertEquals(messageSize, result.getAttributes().get(PAYLOAD_SIZE));
- assertEquals(deliveryMode, result.getAttributes().get(DELIVERY_MODE));
+ assertEquals(priority, result.getAttributes().get(PRIORITY));
+ assertEquals(timeToLive, result.getAttributes().get(TIME_TO_LIVE));
+ assertEquals(producerInterval, result.getAttributes().get(PRODUCER_INTERVAL));
+ assertEquals(messageSize, result.getAttributes().get(PAYLOAD_SIZE));
+ assertEquals(deliveryMode, result.getAttributes().get(DELIVERY_MODE));
}
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsCsvWriterTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsCsvWriterTest.java b/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsCsvWriterTest.java
index be84ac3..bc14da0 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsCsvWriterTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsCsvWriterTest.java
@@ -27,14 +27,31 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import com.google.common.io.Resources;
+import org.junit.Assert;
import org.apache.qpid.disttest.controller.ResultsForAllTests;
import org.apache.qpid.disttest.results.aggregation.ITestResult;
import org.apache.qpid.disttest.results.formatting.CSVFormatter;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
-public class ResultsCsvWriterTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ResultsCsvWriterTest extends UnitTestBase
{
private CSVFormatter _csvFormater = mock(CSVFormatter.class);
@@ -42,13 +59,13 @@ public class ResultsCsvWriterTest extends QpidTestCase
private ResultsCsvWriter _resultsFileWriter = new ResultsCsvWriter(_outputDir);
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
_resultsFileWriter.setCsvFormater(_csvFormater);
}
+ @Test
public void testWriteResultsToFile() throws Exception
{
List<ITestResult> testResult1 = mock(List.class);
@@ -71,19 +88,22 @@ public class ResultsCsvWriterTest extends QpidTestCase
File resultsFile1 = new File(_outputDir, "config1.csv");
- assertEquals(expectedCsvContents1, Resources.toString(resultsFile1.toURI().toURL(), StandardCharsets.UTF_8));
+ assertEquals(expectedCsvContents1,
+ Resources.toString(resultsFile1.toURI().toURL(), StandardCharsets.UTF_8));
_resultsFileWriter.writeResults(results2, "config2.json");
File resultsFile2 = new File(_outputDir, "config2.csv");
- assertEquals(expectedCsvContents2, Resources.toString(resultsFile2.toURI().toURL(), StandardCharsets.UTF_8));
+ assertEquals(expectedCsvContents2,
+ Resources.toString(resultsFile2.toURI().toURL(), StandardCharsets.UTF_8));
when(_csvFormater.format(any(List.class))).thenReturn(expectedSummaryFileContents);
_resultsFileWriter.end();
File summaryFile = new File(_outputDir, ResultsCsvWriter.TEST_SUMMARY_FILE_NAME);
- assertEquals(expectedSummaryFileContents, Resources.toString(summaryFile.toURI().toURL(), StandardCharsets.UTF_8));
+ assertEquals(expectedSummaryFileContents,
+ Resources.toString(summaryFile.toURI().toURL(), StandardCharsets.UTF_8));
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java b/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
index 208565a..3b380a0 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/results/ResultsXmlWriterTest.java
@@ -20,6 +20,12 @@
*/
package org.apache.qpid.disttest.results;
+import static org.apache.qpid.test.utils.JvmVendor.IBM;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assume.assumeThat;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -28,19 +34,40 @@ import java.nio.charset.StandardCharsets;
import java.util.Collections;
import com.google.common.io.Resources;
+import org.junit.Before;
import org.apache.qpid.disttest.controller.ResultsForAllTests;
import org.apache.qpid.disttest.message.ParticipantResult;
import org.apache.qpid.disttest.results.aggregation.ITestResult;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
-public class ResultsXmlWriterTest extends QpidTestCase
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ResultsXmlWriterTest extends UnitTestBase
{
private File _outputDir = TestFileUtils.createTestDirectory();
private ResultsWriter _resultsFileWriter = new ResultsXmlWriter(_outputDir);
+ @Before
+ public void setUp() throws Exception
+ {
+ assumeThat("Transformer on IBM JDK has different whitespace behaviour", getJvmVendor(), is(not(equalTo(IBM))));
+ }
+
+ @Test
public void testResultForNoTests() throws Exception
{
ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
@@ -55,6 +82,7 @@ public class ResultsXmlWriterTest extends QpidTestCase
assertEquals(expectedXmlContent, Resources.toString(resultsFile.toURI().toURL(), StandardCharsets.UTF_8));
}
+ @Test
public void testResultForOneTest() throws Exception
{
ITestResult test = mock(ITestResult.class);
@@ -72,9 +100,10 @@ public class ResultsXmlWriterTest extends QpidTestCase
File resultsFile = new File(_outputDir, "config.xml");
- assertEquals(expectedXmlContent, Resources.toString(resultsFile.toURI().toURL(), StandardCharsets.UTF_8));
+ assertEquals(expectedXmlContent, Resources.toString(resultsFile.toURI().toURL(), StandardCharsets.UTF_8));
}
+ @Test
public void testResultForOneTestWithError() throws Exception
{
ParticipantResult resultWithError = mock(ParticipantResult.class);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java b/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java
index 011eb4e..401e3e4 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/AggregatorTest.java
@@ -24,21 +24,39 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.controller.ResultsForAllTests;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class AggregatorTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class AggregatorTest extends UnitTestBase
{
private Aggregator _aggregator = new Aggregator();
private TestResultAggregator _testResultAggregator = mock(TestResultAggregator.class);
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
_aggregator.setTestResultAggregator(_testResultAggregator);
}
+ @Test
public void testAggregrateManyTestResults() throws Exception
{
ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
@@ -50,7 +68,7 @@ public class AggregatorTest extends QpidTestCase
when(_testResultAggregator.aggregateTestResult(testResult2)).thenReturn(mock(AggregatedTestResult.class));
ResultsForAllTests aggregatedResultsForAllTests = _aggregator.aggregateResults(resultsForAllTests);
- assertEquals(2, aggregatedResultsForAllTests.getTestResults().size());
+ assertEquals((long) 2, (long) aggregatedResultsForAllTests.getTestResults().size());
verify(_testResultAggregator).aggregateTestResult(testResult1);
verify(_testResultAggregator).aggregateTestResult(testResult2);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java b/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java
index 5bc98af..f98c326 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/ParticipantResultAggregatorTest.java
@@ -23,10 +23,28 @@ import java.util.Date;
import javax.jms.Session;
+import org.junit.Assert;
+
import org.apache.qpid.disttest.message.ParticipantResult;
-import org.apache.qpid.test.utils.QpidTestCase;
-public class ParticipantResultAggregatorTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ParticipantResultAggregatorTest extends UnitTestBase
{
private ParticipantResultAggregator _aggregator = new ParticipantResultAggregator(ParticipantResult.class, AGGREGATED_RESULT_NAME);
@@ -52,6 +70,7 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
private static final double EXPECTED_AGGREGATED_ALL_THROUGHPUT = ((OVERALL_PROCESSED)/1024)/((OVERALL_TIMETAKEN)/1000);
private static final int EXPECTED_AGGREGATED_MESSAGE_THROUGHPUT = (int)(OVERALL_NUMBER_OF_MESSAGES_PROCESSED * 1000.0d/OVERALL_TIMETAKEN);
+ @Test
public void testStartAndEndDateForOneParticipantResult()
{
ParticipantResult result = new ParticipantResult();
@@ -64,6 +83,7 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
assertEquals(PARTICIPANT1_ENDDATE, aggregatedResult.getEndInMillis());
}
+ @Test
public void testStartAndEndDateForTwoParticipantResults()
{
ParticipantResult result1 = new ParticipantResult();
@@ -82,6 +102,7 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
assertEquals(PARTICIPANT2_ENDDATE, aggregatedResult.getEndInMillis());
}
+ @Test
public void testComputeNumberOfMessagesProcessed()
{
ParticipantResult result1 = new ParticipantResult();
@@ -94,9 +115,10 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(25, aggregatedResult.getNumberOfMessagesProcessed());
+ assertEquals((long) 25, aggregatedResult.getNumberOfMessagesProcessed());
}
+ @Test
public void testComputeTotalPayloadProcessed()
{
ParticipantResult result1 = new ParticipantResult();
@@ -112,6 +134,7 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
assertEquals(OVERALL_PROCESSED, aggregatedResult.getTotalPayloadProcessed());
}
+ @Test
public void testComputeThroughput()
{
ParticipantResult result1 = new ParticipantResult();
@@ -131,6 +154,7 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
assertEquals(EXPECTED_AGGREGATED_ALL_THROUGHPUT, aggregatedResult.getThroughput(), 0.1);
}
+ @Test
public void testComputeMessageThroughput()
{
ParticipantResult result1 = new ParticipantResult();
@@ -147,10 +171,11 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(EXPECTED_AGGREGATED_MESSAGE_THROUGHPUT, aggregatedResult.getMessageThroughput());
-
+ assertEquals((long) EXPECTED_AGGREGATED_MESSAGE_THROUGHPUT,
+ (long) aggregatedResult.getMessageThroughput());
}
+ @Test
public void testConstantTestNameAndIterationNumberRolledUp() throws Exception
{
ParticipantResult result1 = new ParticipantResult();
@@ -165,10 +190,11 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(TEST_ITERATION_NUMBER, aggregatedResult.getIterationNumber());
+ assertEquals((long) TEST_ITERATION_NUMBER, (long) aggregatedResult.getIterationNumber());
assertEquals(TEST_NAME, aggregatedResult.getTestName());
}
+ @Test
public void testConstantPayloadSizesRolledUp() throws Exception
{
final int payloadSize = 1024;
@@ -183,9 +209,10 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(payloadSize, aggregatedResult.getPayloadSize());
+ assertEquals((long) payloadSize, (long) aggregatedResult.getPayloadSize());
}
+ @Test
public void testDifferingPayloadSizesNotRolledUp() throws Exception
{
final int payload1Size = 1024;
@@ -201,9 +228,10 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(0, aggregatedResult.getPayloadSize());
+ assertEquals((long) 0, (long) aggregatedResult.getPayloadSize());
}
+ @Test
public void testConstantBatchSizesRolledUp() throws Exception
{
final int batchSize = 10;
@@ -218,9 +246,10 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(batchSize, aggregatedResult.getBatchSize());
+ assertEquals((long) batchSize, (long) aggregatedResult.getBatchSize());
}
+ @Test
public void testDifferingBatchSizesNotRolledUp() throws Exception
{
final int batch1Size = 10;
@@ -236,9 +265,10 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(0, aggregatedResult.getBatchSize());
+ assertEquals((long) 0, (long) aggregatedResult.getBatchSize());
}
+ @Test
public void testConstantAcknowledgeModesRolledUp() throws Exception
{
ParticipantResult result1 = new ParticipantResult();
@@ -251,9 +281,10 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(Session.DUPS_OK_ACKNOWLEDGE, aggregatedResult.getAcknowledgeMode());
+ assertEquals((long) Session.DUPS_OK_ACKNOWLEDGE, (long) aggregatedResult.getAcknowledgeMode());
}
+ @Test
public void testDifferingAcknowledgeModesNotRolledUp() throws Exception
{
ParticipantResult result1 = new ParticipantResult();
@@ -266,9 +297,10 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result2);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(-1, aggregatedResult.getAcknowledgeMode());
+ assertEquals((long) -1, (long) aggregatedResult.getAcknowledgeMode());
}
+ @Test
public void testSumNumberOfConsumerAndProducers() throws Exception
{
final int expectedNumberOfProducers = 1;
@@ -288,10 +320,11 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
_aggregator.aggregate(result3);
ParticipantResult aggregatedResult = _aggregator.getAggregatedResult();
- assertEquals(expectedNumberOfConsumers, aggregatedResult.getTotalNumberOfConsumers());
- assertEquals(expectedNumberOfProducers, aggregatedResult.getTotalNumberOfProducers());
+ assertEquals((long) expectedNumberOfConsumers, (long) aggregatedResult.getTotalNumberOfConsumers());
+ assertEquals((long) expectedNumberOfProducers, (long) aggregatedResult.getTotalNumberOfProducers());
}
+ @Test
public void testConstantProtocolRolledUp() throws Exception
{
String protocolVersion = "PROTOCOL_VERSION";
@@ -309,6 +342,7 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
assertEquals(protocolVersion, aggregatedResult.getProtocolVersion());
}
+ @Test
public void testDifferingProtocolNotRolledUp() throws Exception
{
ParticipantResult result1 = new ParticipantResult();
@@ -324,6 +358,7 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
assertNull(aggregatedResult.getProtocolVersion());
}
+ @Test
public void testConstantProviderVersionRolledUp() throws Exception
{
String providerVersion = "PROVIDER_VERSION";
@@ -341,6 +376,7 @@ public class ParticipantResultAggregatorTest extends QpidTestCase
assertEquals(providerVersion, aggregatedResult.getProtocolVersion());
}
+ @Test
public void testDifferingProviderVersionNotRolledUp() throws Exception
{
ParticipantResult result1 = new ParticipantResult();
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java
----------------------------------------------------------------------
diff --git a/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java b/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java
index 7417ddd..4378fe8 100644
--- a/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java
+++ b/perftests/src/test/java/org/apache/qpid/disttest/results/aggregation/SeriesStatisticsTest.java
@@ -23,20 +23,38 @@ package org.apache.qpid.disttest.results.aggregation;
import java.util.Arrays;
import java.util.Collection;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.junit.Assert;
-public class SeriesStatisticsTest extends QpidTestCase
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.After;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class SeriesStatisticsTest extends UnitTestBase
{
public static Collection<Long> SERIES = Arrays.asList(new Long[] { 2l, 4l, 4l, 4l, 5l, 5l, 7l, 9l, 5l });
+ @Test
public void testAggregate()
{
SeriesStatistics results = new SeriesStatistics();
results.addMessageLatencies(SERIES);
results.aggregate();
assertEquals("Unexpected average", 5.0, results.getAverage(), 0.01);
- assertEquals("Unexpected min", 2, results.getMinimum());
- assertEquals("Unexpected max", 9, results.getMaximum());
+ assertEquals("Unexpected min", (long) 2, results.getMinimum());
+ assertEquals("Unexpected max", (long) 9, results.getMaximum());
assertEquals("Unexpected standard deviation", 2.0, results.getStandardDeviation(), 0.01);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org