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:25 UTC
[18/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/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
index 4aa4c8c..00d75c8 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
@@ -35,6 +35,9 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
import org.mockito.invocation.InvocationOnMock;
@@ -59,9 +62,9 @@ import org.apache.qpid.server.model.VirtualHostNode;
import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
import org.apache.qpid.server.util.FileUtils;
import org.apache.qpid.server.virtualhost.QueueManagingVirtualHost;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTestCase
+public abstract class AbstractDurableConfigurationStoreTestCase extends UnitTestBase
{
private static final String EXCHANGE = org.apache.qpid.server.model.Exchange.class.getSimpleName();
private static final String QUEUE = Queue.class.getSimpleName();
@@ -84,15 +87,14 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
private ConfiguredObjectRecord _rootRecord;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
_queueId = UUIDGenerator.generateRandomUUID();
_exchangeId = UUIDGenerator.generateRandomUUID();
_factory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
- _storeName = getName();
+ _storeName = getTestName();
_storePath = TMP_FOLDER + File.separator + _storeName;
FileUtils.delete(new File(_storePath), true);
@@ -132,20 +134,23 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
protected abstract VirtualHostNode createVirtualHostNode(String storeLocation, ConfiguredObjectFactory factory);
- @Override
+ @After
public void tearDown() throws Exception
{
try
{
closeConfigStore();
- FileUtils.delete(new File(_storePath), true);
}
finally
{
- super.tearDown();
+ if (_storePath != null)
+ {
+ FileUtils.delete(new File(_storePath), true);
+ }
}
}
+ @Test
public void testCloseIsIdempotent() throws Exception
{
_configStore.closeConfigurationStore();
@@ -153,6 +158,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
_configStore.closeConfigurationStore();
}
+ @Test
public void testCreateExchange() throws Exception
{
Exchange<?> exchange = createTestExchange();
@@ -162,8 +168,8 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
_configStore.openConfigurationStore(_handler);
verify(_handler).handle(matchesRecord(_exchangeId, EXCHANGE,
- map( org.apache.qpid.server.model.Exchange.NAME, getName(),
- org.apache.qpid.server.model.Exchange.TYPE, getName()+"Type",
+ map( org.apache.qpid.server.model.Exchange.NAME, getTestName(),
+ org.apache.qpid.server.model.Exchange.TYPE, getTestName()+"Type",
org.apache.qpid.server.model.Exchange.LIFETIME_POLICY, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS.name())));
}
@@ -187,6 +193,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
return map;
}
+ @Test
public void testRemoveExchange() throws Exception
{
Exchange<?> exchange = createTestExchange();
@@ -256,32 +263,34 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
}
}
+ @Test
public void testCreateQueue() throws Exception
{
- Queue<?> queue = createTestQueue(getName(), getName() + "Owner", true, null);
+ Queue<?> queue = createTestQueue(getTestName(), getTestName() + "Owner", true, null);
_configStore.create(queue.asObjectRecord());
reopenStore();
_configStore.openConfigurationStore(_handler);
Map<String, Object> queueAttributes = new HashMap<>();
- queueAttributes.put(Queue.NAME, getName());
- queueAttributes.put(Queue.OWNER, getName()+"Owner");
+ queueAttributes.put(Queue.NAME, getTestName());
+ queueAttributes.put(Queue.OWNER, getTestName() + "Owner");
queueAttributes.put(Queue.EXCLUSIVE, ExclusivityPolicy.CONTAINER.name());
queueAttributes.put(Queue.TYPE, STANDARD);
verify(_handler).handle(matchesRecord(_queueId, QUEUE, queueAttributes));
}
+ @Test
public void testUpdateQueue() throws Exception
{
Map<String, Object> attributes = new HashMap<>();
attributes.put(Queue.TYPE, STANDARD);
- Queue<?> queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
+ Queue<?> queue = createTestQueue(getTestName(), getTestName() + "Owner", true, attributes);
_configStore.create(queue.asObjectRecord());
// update the queue to have exclusive=false
- queue = createTestQueue(getName(), getName() + "Owner", false, attributes);
+ queue = createTestQueue(getTestName(), getTestName() + "Owner", false, attributes);
_configStore.update(false, queue.asObjectRecord());
@@ -290,7 +299,7 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
Map<String,Object> queueAttributes = new HashMap<>();
- queueAttributes.put(Queue.NAME, getName());
+ queueAttributes.put(Queue.NAME, getTestName());
queueAttributes.putAll(attributes);
verify(_handler).handle(matchesRecord(_queueId, QUEUE, queueAttributes));
@@ -298,9 +307,10 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
}
+ @Test
public void testRemoveQueue() throws Exception
{
- Queue<?> queue = createTestQueue(getName(), getName() + "Owner", true, Collections.emptyMap());
+ Queue<?> queue = createTestQueue(getTestName(), getTestName() + "Owner", true, Collections.emptyMap());
_configStore.create(queue.asObjectRecord());
_configStore.remove(queue.asObjectRecord());
@@ -367,11 +377,11 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest
{
Exchange exchange = mock(Exchange.class);
Map<String,Object> actualAttributes = new HashMap<>();
- actualAttributes.put("name", getName());
- actualAttributes.put("type", getName() + "Type");
+ actualAttributes.put("name", getTestName());
+ actualAttributes.put("type", getTestName() + "Type");
actualAttributes.put("lifetimePolicy", LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
- when(exchange.getName()).thenReturn(getName());
- when(exchange.getType()).thenReturn(getName() + "Type");
+ when(exchange.getName()).thenReturn(getTestName());
+ when(exchange.getType()).thenReturn(getTestName() + "Type");
when(exchange.isAutoDelete()).thenReturn(true);
when(exchange.getId()).thenReturn(_exchangeId);
when(exchange.getCategoryClass()).thenReturn(Exchange.class);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
index 71c0d55..40d235e 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.store;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -29,6 +31,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.logging.EventLogger;
@@ -41,9 +47,9 @@ import org.apache.qpid.server.model.JsonSystemConfigImpl;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.SystemConfig;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class BrokerRecovererTest extends QpidTestCase
+public class BrokerRecovererTest extends UnitTestBase
{
private ConfiguredObjectRecord _brokerEntry = mock(ConfiguredObjectRecord.class);
@@ -53,10 +59,9 @@ public class BrokerRecovererTest extends QpidTestCase
private SystemConfig<?> _systemConfig;
private TaskExecutor _taskExecutor;
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
_taskExecutor = new CurrentThreadTaskExecutor();
_taskExecutor.start();
@@ -74,7 +79,7 @@ public class BrokerRecovererTest extends QpidTestCase
when(_brokerEntry.getType()).thenReturn(Broker.class.getSimpleName());
Map<String, Object> attributesMap = new HashMap<String, Object>();
attributesMap.put(Broker.MODEL_VERSION, BrokerModel.MODEL_VERSION);
- attributesMap.put(Broker.NAME, getName());
+ attributesMap.put(Broker.NAME, getTestName());
when(_brokerEntry.getAttributes()).thenReturn(attributesMap);
when(_brokerEntry.getParents()).thenReturn(Collections.singletonMap(SystemConfig.class.getSimpleName(), _systemConfig
@@ -86,12 +91,11 @@ public class BrokerRecovererTest extends QpidTestCase
when(_authenticationProvider1.getId()).thenReturn(_authenticationProvider1Id);
}
- @Override
- protected void tearDown() throws Exception
+ @After
+ public void tearDown() throws Exception
{
try
{
- super.tearDown();
}
finally
{
@@ -99,10 +103,11 @@ public class BrokerRecovererTest extends QpidTestCase
}
}
+ @Test
public void testCreateBrokerAttributes()
{
Map<String, Object> attributes = new HashMap<String, Object>();
- attributes.put(Broker.NAME, getName());
+ attributes.put(Broker.NAME, getTestName());
attributes.put(Broker.STATISTICS_REPORTING_PERIOD, 4000);
attributes.put(Broker.MODEL_VERSION, BrokerModel.MODEL_VERSION);
@@ -127,7 +132,10 @@ public class BrokerRecovererTest extends QpidTestCase
for (Map.Entry<String, Object> attribute : attributes.entrySet())
{
Object attributeValue = broker.getAttribute(attribute.getKey());
- assertEquals("Unexpected value of attribute '" + attribute.getKey() + "'", attribute.getValue(), attributeValue);
+ assertEquals("Unexpected value of attribute '" + attribute.getKey() + "'",
+ attribute.getValue(),
+ attributeValue);
+
}
}
@@ -166,6 +174,7 @@ public class BrokerRecovererTest extends QpidTestCase
}
+ @Test
public void testCreateBrokerWithPorts()
{
UUID authProviderId = UUID.randomUUID();
@@ -177,13 +186,13 @@ public class BrokerRecovererTest extends QpidTestCase
"authProvider"));
Broker<?> broker = _systemConfig.getContainer(Broker.class);
-
assertNotNull(broker);
broker.open();
assertEquals(_brokerId, broker.getId());
- assertEquals(1, broker.getPorts().size());
+ assertEquals((long) 1, (long) broker.getPorts().size());
}
+ @Test
public void testCreateBrokerWithOneAuthenticationProvider()
{
UUID authProviderId = UUID.randomUUID();
@@ -191,14 +200,13 @@ public class BrokerRecovererTest extends QpidTestCase
resolveObjects(_brokerEntry, createAuthProviderRecord(authProviderId, "authProvider"));
Broker<?> broker = _systemConfig.getContainer(Broker.class);
-
assertNotNull(broker);
broker.open();
assertEquals(_brokerId, broker.getId());
- assertEquals(1, broker.getAuthenticationProviders().size());
-
+ assertEquals((long) 1, (long) broker.getAuthenticationProviders().size());
}
+ @Test
public void testCreateBrokerWithMultipleAuthenticationProvidersAndPorts()
{
UUID authProviderId = UUID.randomUUID();
@@ -213,16 +221,18 @@ public class BrokerRecovererTest extends QpidTestCase
createPortRecord(port2Id, 5673, "authProvider2"));
Broker<?> broker = _systemConfig.getContainer(Broker.class);
-
assertNotNull(broker);
broker.open();
assertEquals(_brokerId, broker.getId());
- assertEquals(2, broker.getPorts().size());
+ assertEquals((long) 2, (long) broker.getPorts().size());
- assertEquals("Unexpected number of authentication providers", 2, broker.getAuthenticationProviders().size());
+ assertEquals("Unexpected number of authentication providers",
+ (long) 2,
+ (long) broker.getAuthenticationProviders().size());
}
+ @Test
public void testCreateBrokerWithGroupProvider()
{
@@ -231,14 +241,13 @@ public class BrokerRecovererTest extends QpidTestCase
resolveObjects(_brokerEntry, createGroupProviderRecord(authProviderId, "groupProvider"));
Broker<?> broker = _systemConfig.getContainer(Broker.class);
-
assertNotNull(broker);
broker.open();
assertEquals(_brokerId, broker.getId());
- assertEquals(1, broker.getGroupProviders().size());
-
+ assertEquals((long) 1, (long) broker.getGroupProviders().size());
}
+ @Test
public void testModelVersionValidationForIncompatibleMajorVersion() throws Exception
{
Map<String, Object> brokerAttributes = new HashMap<String, Object>();
@@ -248,7 +257,7 @@ public class BrokerRecovererTest extends QpidTestCase
// need to reset all the shared objects for every iteration of the test
setUp();
brokerAttributes.put(Broker.MODEL_VERSION, incompatibleVersion);
- brokerAttributes.put(Broker.NAME, getName());
+ brokerAttributes.put(Broker.NAME, getTestName());
when(_brokerEntry.getAttributes()).thenReturn(brokerAttributes);
resolveObjects(_brokerEntry);
@@ -259,12 +268,13 @@ public class BrokerRecovererTest extends QpidTestCase
}
+ @Test
public void testModelVersionValidationForIncompatibleMinorVersion() throws Exception
{
Map<String, Object> brokerAttributes = new HashMap<String, Object>();
String incompatibleVersion = BrokerModel.MODEL_MAJOR_VERSION + "." + Integer.MAX_VALUE;
brokerAttributes.put(Broker.MODEL_VERSION, incompatibleVersion);
- brokerAttributes.put(Broker.NAME, getName());
+ brokerAttributes.put(Broker.NAME, getTestName());
when(_brokerEntry.getAttributes()).thenReturn(brokerAttributes);
@@ -276,10 +286,11 @@ public class BrokerRecovererTest extends QpidTestCase
assertEquals("Unexpected broker state", State.ERRORED, broker.getState());
}
+ @Test
public void testIncorrectModelVersion() throws Exception
{
Map<String, Object> brokerAttributes = new HashMap<String, Object>();
- brokerAttributes.put(Broker.NAME, getName());
+ brokerAttributes.put(Broker.NAME, getTestName());
String[] versions = { Integer.MAX_VALUE + "_" + 0, "", null };
for (String modelVersion : versions)
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
index 357048e..8d8f991 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
@@ -20,6 +20,11 @@
*/
package org.apache.qpid.server.store;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -30,6 +35,9 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.junit.Before;
+import org.junit.Test;
+
import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.model.Broker;
@@ -38,10 +46,9 @@ import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.JsonSystemConfigImpl;
import org.apache.qpid.server.model.SystemConfig;
import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
-import org.apache.qpid.test.utils.QpidTestCase;
-
+import org.apache.qpid.test.utils.UnitTestBase;
-public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
+public class BrokerStoreUpgraderAndRecovererTest extends UnitTestBase
{
private static final long BROKER_CREATE_TIME = 1401385808828l;
private static final String BROKER_NAME = "Broker";
@@ -56,10 +63,9 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
private UUID _hostId;
private UUID _brokerId;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
_virtaulHosts = new ArrayList<>();
_hostId = UUID.randomUUID();
_brokerId = UUID.randomUUID();
@@ -82,6 +88,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
null, new HashMap<String,Object>());
}
+ @Test
public void testUpgradeVirtualHostWithJDBCStoreAndBoneCPPool()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -143,6 +150,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
return recoverer.upgrade(dcs, handler.getRecords());
}
+ @Test
public void testUpgradeVirtualHostWithJDBCStoreAndDefaultPool()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -191,6 +199,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertBrokerRecord(records);
}
+ @Test
public void testUpgradeVirtualHostWithDerbyStore()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -223,6 +232,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertBrokerRecord(records);
}
+ @Test
public void testUpgradeVirtualHostWithBDBStore()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -257,6 +267,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertBrokerRecord(records);
}
+ @Test
public void testUpgradeVirtualHostWithBDBHAStore()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -306,6 +317,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertBrokerRecord(records);
}
+ @Test
public void testUpgradeVirtualHostWithMemoryStore()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -336,6 +348,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertBrokerRecord(records);
}
+ @Test
public void testUpgradeBrokerRecordWithModelVersion1_0()
{
_brokerRecord.getAttributes().put("modelVersion", "1.0");
@@ -353,6 +366,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
upgradeBrokerRecordAndAssertUpgradeResults();
}
+ @Test
public void testUpgradeBrokerRecordWithModelVersion1_1()
{
_brokerRecord.getAttributes().put("modelVersion", "1.1");
@@ -370,6 +384,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
upgradeBrokerRecordAndAssertUpgradeResults();
}
+ @Test
public void testUpgradeBrokerRecordWithModelVersion1_2()
{
_brokerRecord.getAttributes().put("modelVersion", "1.2");
@@ -387,6 +402,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
upgradeBrokerRecordAndAssertUpgradeResults();
}
+ @Test
public void testUpgradeBrokerRecordWithModelVersion1_3()
{
_brokerRecord.getAttributes().put("modelVersion", "1.3");
@@ -404,6 +420,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
upgradeBrokerRecordAndAssertUpgradeResults();
}
+ @Test
public void testUpgradeNonAMQPPort()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -421,10 +438,11 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
List<ConfiguredObjectRecord> records = upgrade(dcs, recoverer);
assertTrue("No virtualhostalias rescords should be returned",
- findRecordByType("VirtualHostAlias", records).isEmpty());
+ findRecordByType("VirtualHostAlias", records).isEmpty());
}
+ @Test
public void testUpgradeImpliedAMQPPort()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -441,11 +459,12 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
List<ConfiguredObjectRecord> records = upgrade(dcs, recoverer);
assertFalse("VirtualHostAlias rescords should be returned",
- findRecordByType("VirtualHostAlias", records).isEmpty());
+ findRecordByType("VirtualHostAlias", records).isEmpty());
}
+ @Test
public void testUpgradeImpliedNonAMQPPort()
{
Map<String, Object> hostAttributes = new HashMap<>();
@@ -463,10 +482,10 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
List<ConfiguredObjectRecord> records = upgrade(dcs, recoverer);
assertTrue("No virtualhostalias rescords should be returned",
- findRecordByType("VirtualHostAlias", records).isEmpty());
-
+ findRecordByType("VirtualHostAlias", records).isEmpty());
}
+ @Test
public void testUpgradeBrokerType()
{
_brokerRecord.getAttributes().put("modelVersion", "3.0");
@@ -478,10 +497,11 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
List<ConfiguredObjectRecord> records = upgrade(dcs, recoverer);
List<ConfiguredObjectRecord> brokerRecords = findRecordByType("Broker", records);
- assertEquals("Unexpected number of broker records", 1, brokerRecords.size());
+ assertEquals("Unexpected number of broker records", (long) 1, (long) brokerRecords.size());
assertFalse("Unexpected type", brokerRecords.get(0).getAttributes().containsKey("type"));
}
+ @Test
public void testUpgradeAMQPPortWithNetworkBuffers()
{
Map<String, Object> portAttributes = new HashMap<>();
@@ -500,14 +520,17 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
List<ConfiguredObjectRecord> records = upgrade(dcs, recoverer);
List<ConfiguredObjectRecord> ports = findRecordByType("Port", records);
- assertEquals("Unexpected port size", 1, ports.size());
+ assertEquals("Unexpected port size", (long) 1, (long) ports.size());
ConfiguredObjectRecord upgradedRecord = ports.get(0);
Map<String, Object> attributes = upgradedRecord.getAttributes();
- assertFalse("receiveBufferSize is found " + attributes.get("receiveBufferSize"), attributes.containsKey("receiveBufferSize"));
- assertFalse("sendBufferSize is found " + attributes.get("sendBufferSize"), attributes.containsKey("sendBufferSize"));
+ assertFalse("receiveBufferSize is found " + attributes.get("receiveBufferSize"),
+ attributes.containsKey("receiveBufferSize"));
+ assertFalse("sendBufferSize is found " + attributes.get("sendBufferSize"),
+ attributes.containsKey("sendBufferSize"));
assertEquals("Unexpected name", getTestName(), attributes.get("name"));
}
+ @Test
public void testUpgradeRemoveJmxPlugin()
{
Map<String, Object> jmxPlugin = new HashMap<>();
@@ -530,6 +553,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertTrue("JMX Plugin was not removed", plugins.isEmpty());
}
+ @Test
public void testUpgradeRemoveJmxPortByType()
{
Map<String, Object> jmxPort = new HashMap<>();
@@ -552,6 +576,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertTrue("Port was not removed", ports.isEmpty());
}
+ @Test
public void testUpgradeRemoveRmiPortByType()
{
Map<String, Object> rmiPort = new HashMap<>();
@@ -573,6 +598,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertTrue("Port was not removed", ports.isEmpty());
}
+ @Test
public void testUpgradeRemoveJmxPortByProtocol()
{
Map<String, Object> jmxPort = new HashMap<>();
@@ -595,6 +621,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertTrue("Port was not removed", ports.isEmpty());
}
+ @Test
public void testUpgradeRemoveRmiPortByProtocol()
{
Map<String, Object> rmiPort2 = new HashMap<>();
@@ -617,6 +644,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertTrue("Port was not removed", ports.isEmpty());
}
+ @Test
public void testUpgradeRemovePreferencesProviderNonJsonLikeStore()
{
_brokerRecord.getAttributes().put("modelVersion", "6.0");
@@ -648,9 +676,10 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertTrue("PreferencesProvider was not removed", preferencesProviders.isEmpty());
List<ConfiguredObjectRecord> authenticationProviders = findRecordByType("AuthenticationProvider", records);
- assertEquals("AuthenticationProvider was removed", 1, authenticationProviders.size());
+ assertEquals("AuthenticationProvider was removed", (long) 1, (long) authenticationProviders.size());
}
+ @Test
public void testUpgradeRemovePreferencesProviderJsonLikeStore()
{
_brokerRecord.getAttributes().put("modelVersion", "6.0");
@@ -672,11 +701,12 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
List<ConfiguredObjectRecord> records = upgrade(dcs, recoverer);
List<ConfiguredObjectRecord> authenticationProviders = findRecordByType("AuthenticationProvider", records);
- assertEquals("AuthenticationProviders was removed", 1, authenticationProviders.size());
+ assertEquals("AuthenticationProviders was removed", (long) 1, (long) authenticationProviders.size());
assertFalse("PreferencesProvider was not removed",
- authenticationProviders.get(0).getAttributes().containsKey("preferencesproviders"));
+ authenticationProviders.get(0).getAttributes().containsKey("preferencesproviders"));
}
+ @Test
public void testUpgradeTrustStoreRecordsFrom_6_0() throws Exception
{
_brokerRecord.getAttributes().put("modelVersion", "6.0");
@@ -724,23 +754,24 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertNotNull("Trust store 3 is not found after upgrade", trustStore3Upgraded);
assertEquals("Unexpected attributes after upgrade for Trust store 1",
- trustStoreAttributes1,
- new HashMap<>(trustStore1Upgraded.getAttributes()));
+ trustStoreAttributes1,
+ new HashMap<>(trustStore1Upgraded.getAttributes()));
assertEquals("includedVirtualHostNodeMessageSources is not found",
- "true",
- trustStore2Upgraded.getAttributes().get("includedVirtualHostNodeMessageSources"));
+ "true",
+ trustStore2Upgraded.getAttributes().get("includedVirtualHostNodeMessageSources"));
assertNull("includedVirtualHostMessageSources is found",
- trustStore2Upgraded.getAttributes().get("includedVirtualHostMessageSources"));
+ trustStore2Upgraded.getAttributes().get("includedVirtualHostMessageSources"));
assertEquals("includedVirtualHostNodeMessageSources is not found",
- "true",
- trustStore3Upgraded.getAttributes().get("excludedVirtualHostNodeMessageSources"));
+ "true",
+ trustStore3Upgraded.getAttributes().get("excludedVirtualHostNodeMessageSources"));
assertNull("includedVirtualHostMessageSources is found",
- trustStore3Upgraded.getAttributes().get("excludedVirtualHostMessageSources"));
+ trustStore3Upgraded.getAttributes().get("excludedVirtualHostMessageSources"));
assertModelVersionUpgraded(records);
}
+ @Test
public void testUpgradeJmxRecordsFrom_3_0() throws Exception
{
_brokerRecord.getAttributes().put("modelVersion", "3.0");
@@ -782,6 +813,7 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
assertModelVersionUpgraded(records);
}
+ @Test
public void testUpgradeHttpPortFrom_6_0() throws Exception
{
_brokerRecord.getAttributes().put("modelVersion", "6.0");
@@ -812,13 +844,15 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
Map<String, String> upgradedContext = (Map<String, String>) upgradedAttributes.get("context");
assertFalse("Context variable \"port.http.additionalInternalThreads\" is not removed",
- upgradedContext.containsKey("port.http.additionalInternalThreads"));
+ upgradedContext.containsKey("port.http.additionalInternalThreads"));
assertFalse("Context variable \"port.http.maximumQueuedRequests\" is not removed",
- upgradedContext.containsKey("port.http.maximumQueuedRequests"));
+ upgradedContext.containsKey("port.http.maximumQueuedRequests"));
assertEquals("Context variable \"port.http.maximumQueuedRequests\" is not renamed",
- "1000", upgradedContext.get("qpid.port.http.acceptBacklog"));
+ "1000",
+ upgradedContext.get("qpid.port.http.acceptBacklog"));
}
+ @Test
public void testBrokerConnectionAttributesRemoval() throws Exception
{
_brokerRecord.getAttributes().put("modelVersion", "6.1");
@@ -840,20 +874,26 @@ public class BrokerStoreUpgraderAndRecovererTest extends QpidTestCase
expectedContext.put("qpid.port.closeWhenNoRoute", "false");
Object upgradedContext = upgradedAttributes.get("context");
- assertTrue("Unpexcted context", upgradedContext instanceof Map);
- assertEquals("Unexpected context", expectedContext, new HashMap<>(((Map<String, String>) upgradedContext)));
-
- assertFalse("Session count limit is not removed", upgradedAttributes.containsKey("connection.sessionCountLimit"));
- assertFalse("Heart beat delay is not removed", upgradedAttributes.containsKey("connection.heartBeatDelay"));
- assertFalse("Close when no route is not removed", upgradedAttributes.containsKey("conection.closeWhenNoRoute"));
+ final boolean condition = upgradedContext instanceof Map;
+ assertTrue("Unpexcted context", condition);
+ assertEquals("Unexpected context",
+ expectedContext,
+ new HashMap<>(((Map<String, String>) upgradedContext)));
+
+ assertFalse("Session count limit is not removed",
+ upgradedAttributes.containsKey("connection.sessionCountLimit"));
+ assertFalse("Heart beat delay is not removed",
+ upgradedAttributes.containsKey("connection.heartBeatDelay"));
+ assertFalse("Close when no route is not removed",
+ upgradedAttributes.containsKey("conection.closeWhenNoRoute"));
}
private void assertModelVersionUpgraded(final List<ConfiguredObjectRecord> records)
{
ConfiguredObjectRecord upgradedBrokerRecord = findRecordById(_brokerRecord.getId(), records);
assertEquals("Unexpected model version",
- BrokerModel.MODEL_VERSION,
- upgradedBrokerRecord.getAttributes().get(Broker.MODEL_VERSION));
+ BrokerModel.MODEL_VERSION,
+ upgradedBrokerRecord.getAttributes().get(Broker.MODEL_VERSION));
}
private void upgradeBrokerRecordAndAssertUpgradeResults()
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java
index a7383c8..37f601e 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/EventManagerTest.java
@@ -19,19 +19,22 @@
*/
package org.apache.qpid.server.store;
+import static org.apache.qpid.server.store.Event.PERSISTENT_MESSAGE_SIZE_OVERFULL;
+import static org.apache.qpid.server.store.Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.apache.qpid.server.store.Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL;
-import static org.apache.qpid.server.store.Event.PERSISTENT_MESSAGE_SIZE_OVERFULL;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.junit.Test;
+
+import org.apache.qpid.test.utils.UnitTestBase;
-public class EventManagerTest extends QpidTestCase
+public class EventManagerTest extends UnitTestBase
{
private EventManager _eventManager = new EventManager();
private EventListener _mockListener = mock(EventListener.class);
+ @Test
public void testEventListenerFires()
{
_eventManager.addEventListener(_mockListener, PERSISTENT_MESSAGE_SIZE_OVERFULL);
@@ -39,6 +42,7 @@ public class EventManagerTest extends QpidTestCase
verify(_mockListener).event(PERSISTENT_MESSAGE_SIZE_OVERFULL);
}
+ @Test
public void testEventListenerDoesntFire()
{
_eventManager.addEventListener(_mockListener, PERSISTENT_MESSAGE_SIZE_OVERFULL);
@@ -46,6 +50,7 @@ public class EventManagerTest extends QpidTestCase
verifyZeroInteractions(_mockListener);
}
+ @Test
public void testEventListenerFiresMultipleTimes()
{
_eventManager.addEventListener(_mockListener, PERSISTENT_MESSAGE_SIZE_OVERFULL);
@@ -58,6 +63,7 @@ public class EventManagerTest extends QpidTestCase
verify(_mockListener).event(PERSISTENT_MESSAGE_SIZE_UNDERFULL);
}
+ @Test
public void testMultipleListenersFireForSameEvent()
{
final EventListener mockListener1 = mock(EventListener.class);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreConfigurationTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreConfigurationTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreConfigurationTest.java
index 08f24d7..ee4d3c0 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreConfigurationTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreConfigurationTest.java
@@ -20,19 +20,33 @@
*/
package org.apache.qpid.server.store;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assume.assumeThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.Principal;
+import org.junit.Before;
+
import org.apache.qpid.server.model.BrokerTestHelper;
import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.model.VirtualHostNode;
import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNode;
+import org.apache.qpid.test.utils.VirtualHostNodeStoreType;
public class JsonFileConfigStoreConfigurationTest extends AbstractDurableConfigurationStoreTestCase
{
+ @Before
+ @Override
+ public void setUp() throws Exception
+ {
+ assumeThat(getVirtualHostNodeStoreType(), is(equalTo(VirtualHostNodeStoreType.JSON)));
+ super.setUp();
+ }
+
@Override
protected VirtualHostNode createVirtualHostNode(String storeLocation, ConfiguredObjectFactory factory)
{
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
index cf9d6b6..c1da8da 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
@@ -20,6 +20,9 @@
*/
package org.apache.qpid.server.store;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.inOrder;
@@ -34,6 +37,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.ArgumentMatcher;
import org.mockito.InOrder;
@@ -44,13 +50,13 @@ import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
+import org.apache.qpid.server.util.FileUtils;
import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.server.virtualhostnode.JsonVirtualHostNode;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
-import org.apache.qpid.server.util.FileUtils;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class JsonFileConfigStoreTest extends QpidTestCase
+public class JsonFileConfigStoreTest extends UnitTestBase
{
private JsonFileConfigStore _store;
private JsonVirtualHostNode<?> _parent;
@@ -63,15 +69,14 @@ public class JsonFileConfigStoreTest extends QpidTestCase
private static final String VIRTUAL_HOST_TYPE = "VirtualHost";
private ConfiguredObjectRecord _rootRecord;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
ConfiguredObjectFactory factory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
_parent = mock(JsonVirtualHostNode.class);
- when(_parent.getName()).thenReturn(getName());
+ when(_parent.getName()).thenReturn(getTestName());
when(_parent.getObjectFactory()).thenReturn(factory);
when(_parent.getModel()).thenReturn(factory.getModel());
_storeLocation = TestFileUtils.createTestDirectory("json", true);
@@ -82,19 +87,13 @@ public class JsonFileConfigStoreTest extends QpidTestCase
_handler = mock(ConfiguredObjectRecordHandler.class);
}
- @Override
+ @After
public void tearDown() throws Exception
{
- try
- {
- super.tearDown();
- }
- finally
- {
- FileUtils.delete(_storeLocation, true);
- }
+ FileUtils.delete(_storeLocation, true);
}
+ @Test
public void testNoStorePath() throws Exception
{
when(_parent.getStorePath()).thenReturn(null);
@@ -111,6 +110,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
+ @Test
public void testInvalidStorePath() throws Exception
{
when(_parent.getStorePath()).thenReturn(System.getProperty("file.separator"));
@@ -125,6 +125,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
}
+ @Test
public void testVisitEmptyStore()
{
_store.init(_parent);
@@ -136,6 +137,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
_store.closeConfigurationStore();
}
+ @Test
public void testInsertAndUpdateTopLevelObject() throws Exception
{
_store.init(_parent);
@@ -167,6 +169,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
_store.closeConfigurationStore();
}
+ @Test
public void testCreateObject() throws Exception
{
_store.init(_parent);
@@ -188,6 +191,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
_store.closeConfigurationStore();
}
+ @Test
public void testCreateAndUpdateObject() throws Exception
{
_store.init(_parent);
@@ -213,6 +217,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
+ @Test
public void testCreateAndRemoveObject() throws Exception
{
_store.init(_parent);
@@ -237,6 +242,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
_store.closeConfigurationStore();
}
+ @Test
public void testCreateUnknownObjectType() throws Exception
{
_store.init(_parent);
@@ -254,6 +260,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
}
+ @Test
public void testTwoObjectsWithSameId() throws Exception
{
_store.init(_parent);
@@ -278,6 +285,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
+ @Test
public void testObjectWithoutName() throws Exception
{
_store.init(_parent);
@@ -298,6 +306,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
}
+ @Test
public void testObjectWithNonStringName() throws Exception
{
_store.init(_parent);
@@ -318,6 +327,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
}
+ @Test
public void testChangeTypeOfObject() throws Exception
{
_store.init(_parent);
@@ -345,6 +355,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
}
}
+ @Test
public void testLockFileGuaranteesExclusiveAccess() throws Exception
{
_store.init(_parent);
@@ -364,6 +375,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
secondStore.init(_parent);
}
+ @Test
public void testStoreFileLifecycle()
{
File expectedJsonFile = new File(_storeLocation, _parent.getName() + ".json");
@@ -388,6 +400,7 @@ public class JsonFileConfigStoreTest extends QpidTestCase
assertFalse("JSON lock should not exist after delete", expectedJsonFileLck.exists());
}
+ @Test
public void testCreatedNestedObjects() throws Exception
{
_store.init(_parent);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java b/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
index 5ca6d10..9188dc2 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java
@@ -20,11 +20,17 @@
*/
package org.apache.qpid.server.store;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,10 +38,10 @@ import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
import org.apache.qpid.server.message.EnqueueableMessage;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.server.util.FileUtils;
+import org.apache.qpid.test.utils.UnitTestBase;
-public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase implements EventListener, TransactionLogResource
+public abstract class MessageStoreQuotaEventsTestBase extends UnitTestBase implements EventListener, TransactionLogResource
{
private static final Logger LOGGER = LoggerFactory.getLogger(MessageStoreQuotaEventsTestBase.class);
@@ -50,11 +56,9 @@ public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase imple
protected abstract MessageStore createStore() throws Exception;
protected abstract int getNumberOfMessagesToFillStore();
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
-
_storeLocation = new File(new File(TMP_FOLDER), getTestName());
FileUtils.delete(_storeLocation, true);
@@ -71,23 +75,20 @@ public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase imple
protected abstract VirtualHost createVirtualHost(String storeLocation);
- @Override
+ @After
public void tearDown() throws Exception
{
- try
+ if (_store != null)
{
- super.tearDown();
+ _store.closeMessageStore();
}
- finally
+ if (_storeLocation != null)
{
- if (_store != null)
- {
- _store.closeMessageStore();
- }
FileUtils.delete(_storeLocation, true);
}
}
+ @Test
public void testOverflow() throws Exception
{
Transaction transaction = _store.newTransaction();
@@ -183,4 +184,10 @@ public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase imple
{
return MessageDurability.DEFAULT;
}
+
+ @Override
+ public String getName()
+ {
+ return getTestName();
+ }
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java b/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
index 98093dd..441b153 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/MessageStoreTestCase.java
@@ -20,6 +20,11 @@
*/
package org.apache.qpid.server.store;
+import static junit.framework.TestCase.assertNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.eq;
@@ -35,20 +40,22 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import org.hamcrest.Description;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.ArgumentMatcher;
import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
import org.apache.qpid.server.message.EnqueueableMessage;
-import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.Transaction.EnqueueRecord;
import org.apache.qpid.server.store.handler.DistributedTransactionHandler;
import org.apache.qpid.server.store.handler.MessageHandler;
import org.apache.qpid.server.store.handler.MessageInstanceHandler;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public abstract class MessageStoreTestCase extends QpidTestCase
+public abstract class MessageStoreTestCase extends UnitTestBase
{
private MessageStore _store;
private VirtualHost<?> _parent;
@@ -58,11 +65,9 @@ public abstract class MessageStoreTestCase extends QpidTestCase
private static final double SPARSITY_FRACTION = 1.0;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
-
_parent = createVirtualHost();
_store = createMessageStore();
@@ -74,11 +79,10 @@ public abstract class MessageStoreTestCase extends QpidTestCase
QpidByteBuffer.initialisePool(BUFFER_SIZE, POOL_SIZE, SPARSITY_FRACTION);
}
- @Override
+ @After
public void tearDown() throws Exception
{
QpidByteBuffer.deinitialisePool();
- super.tearDown();
}
protected VirtualHost<?> getVirtualHost()
@@ -106,6 +110,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
}
+ @Test
public void testAddAndRemoveRecordXid() throws Exception
{
long format = 1l;
@@ -138,6 +143,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
verify(handler, never()).handle(eq(record), argThat(new RecordMatcher(enqueues)), argThat(new DequeueRecordMatcher(dequeues)));
}
+ @Test
public void testVisitMessages() throws Exception
{
long messageId = 1;
@@ -199,6 +205,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
txn.commitTran();
}
+ @Test
public void testVisitMessagesAborted() throws Exception
{
int contentSize = 0;
@@ -216,6 +223,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
verify(handler, times(2)).handle(any(StoredMessage.class));
}
+ @Test
public void testReopenedMessageStoreUsesLastMessageId() throws Exception
{
int contentSize = 0;
@@ -236,6 +244,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
assertTrue("Unexpected message id " + message.getMessageNumber(), message.getMessageNumber() >= 4);
}
+ @Test
public void testVisitMessageInstances() throws Exception
{
long messageId = 1;
@@ -256,6 +265,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
verify(handler, times(1)).handle(argThat(new EnqueueRecordMatcher(queueId, messageId)));
}
+ @Test
public void testVisitDistributedTransactions() throws Exception
{
long format = 1l;
@@ -280,6 +290,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
}
+ @Test
public void testCommitTransaction() throws Exception
{
final UUID mockQueueId = UUIDGenerator.generateRandomUUID();
@@ -305,6 +316,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
assertTrue("Message with id " + messageId2 + " is not found", enqueuedIds.contains(messageId2));
}
+ @Test
public void testRollbackTransactionBeforeCommit() throws Exception
{
final UUID mockQueueId = UUIDGenerator.generateRandomUUID();
@@ -336,6 +348,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
assertTrue("Message with id " + messageId3 + " is not found", enqueuedIds.contains(messageId3));
}
+ @Test
public void testRollbackTransactionAfterCommit() throws Exception
{
final UUID mockQueueId = UUIDGenerator.generateRandomUUID();
@@ -371,6 +384,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
assertTrue("Message with id " + messageId3 + " is not found", enqueuedIds.contains(messageId3));
}
+ @Test
public void testAddAndRemoveMessageWithoutContent() throws Exception
{
long messageId = 1;
@@ -410,6 +424,7 @@ public abstract class MessageStoreTestCase extends QpidTestCase
assertNull(retrievedMessageRef.get());
}
+ @Test
public void testMessageDeleted() throws Exception
{
MessageStore.MessageDeleteListener listener = mock(MessageStore.MessageDeleteListener.class);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java
index 40c11ee..c40ec53 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java
@@ -20,6 +20,10 @@
package org.apache.qpid.server.store;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -30,22 +34,23 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.junit.Before;
+import org.junit.Test;
+
import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.OverflowPolicy;
import org.apache.qpid.server.model.VirtualHostNode;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class VirtualHostStoreUpgraderAndRecovererTest extends QpidTestCase
+public class VirtualHostStoreUpgraderAndRecovererTest extends UnitTestBase
{
private VirtualHostNode<?> _virtualHostNode;
private VirtualHostStoreUpgraderAndRecoverer _upgraderAndRecoverer;
private DurableConfigurationStore _store;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
final Broker broker = mock(Broker.class);
_virtualHostNode = mock(VirtualHostNode.class);
@@ -54,6 +59,7 @@ public class VirtualHostStoreUpgraderAndRecovererTest extends QpidTestCase
_upgraderAndRecoverer = new VirtualHostStoreUpgraderAndRecoverer(_virtualHostNode);
}
+ @Test
public void testUpgradeFlowControlFrom_6_1() throws Exception
{
Map<String, Object> rootAttributes = new HashMap<>();
@@ -79,15 +85,17 @@ public class VirtualHostStoreUpgraderAndRecovererTest extends QpidTestCase
assertNotNull("Upgraded attributes not found", upgradedAttributes);
assertEquals("Unexpected maximumQueueDepthBytes", 1000, upgradedAttributes.get("maximumQueueDepthBytes"));
+
assertEquals("Unexpected queue.queueFlowResumeLimit",
- "70.00",
- ((Map<String, String>) upgradedAttributes.get("context")).get("queue.queueFlowResumeLimit"));
+ "70.00",
+ ((Map<String, String>) upgradedAttributes.get("context")).get("queue.queueFlowResumeLimit"));
assertEquals("Unexpected overflowPolicy",
- OverflowPolicy.PRODUCER_FLOW_CONTROL.name(),
- String.valueOf(upgradedAttributes.get("overflowPolicy")));
+ OverflowPolicy.PRODUCER_FLOW_CONTROL.name(),
+ String.valueOf(upgradedAttributes.get("overflowPolicy")));
}
+ @Test
public void testUpgradeQueueAlternateExchangeFrom_6_1() throws Exception
{
Map<String, Object> rootAttributes = new HashMap<>();
@@ -118,14 +126,17 @@ public class VirtualHostStoreUpgraderAndRecovererTest extends QpidTestCase
Map<String, Object> upgradedAttributes = upgradedQueueRecord.getAttributes();
assertNotNull("Upgraded attributes not found", upgradedAttributes);
- assertTrue("Attribute 'alternateBinding' was not added", upgradedAttributes.containsKey("alternateBinding"));
+ assertTrue("Attribute 'alternateBinding' was not added",
+ upgradedAttributes.containsKey("alternateBinding"));
assertEquals("Unexpected alternateBinding",
- new HashMap<>(Collections.singletonMap("destination", "testExchange")),
- new HashMap<>(((Map<String, String>) upgradedAttributes.get("alternateBinding"))));
- assertFalse("Attribute 'alternateExchange' was not removed", upgradedAttributes.containsKey("alternateExchange"));
+ new HashMap<>(Collections.singletonMap("destination", "testExchange")),
+ new HashMap<>(((Map<String, String>) upgradedAttributes.get("alternateBinding"))));
+ assertFalse("Attribute 'alternateExchange' was not removed",
+ upgradedAttributes.containsKey("alternateExchange"));
}
+ @Test
public void testUpgradeExchangeAlternateExchangeFrom_6_1() throws Exception
{
Map<String, Object> rootAttributes = new HashMap<>();
@@ -158,13 +169,15 @@ public class VirtualHostStoreUpgraderAndRecovererTest extends QpidTestCase
Map<String, Object> upgradedAttributes = upgradedQueueRecord.getAttributes();
assertNotNull("Upgraded attributes not found", upgradedAttributes);
- assertTrue("Attribute 'alternateBinding' was not added", upgradedAttributes.containsKey("alternateBinding"));
+ assertTrue("Attribute 'alternateBinding' was not added",
+ upgradedAttributes.containsKey("alternateBinding"));
assertEquals("Unexpected alternateBinding",
- new HashMap<>(Collections.singletonMap("destination", "testExchange")),
- new HashMap<>(((Map<String, String>) upgradedAttributes.get("alternateBinding"))));
- assertFalse("Attribute 'alternateExchange' was not removed", upgradedAttributes.containsKey("alternateExchange"));
-
+ new HashMap<>(Collections.singletonMap("destination", "testExchange")),
+ new HashMap<>(((Map<String, String>) upgradedAttributes.get("alternateBinding"))));
+ assertFalse("Attribute 'alternateExchange' was not removed",
+ upgradedAttributes.containsKey("alternateExchange"));
}
+ @Test
public void testUpgradeExchangeAlternateExchangeSpecifiedWithUUIDFrom_6_1() throws Exception
{
Map<String, Object> rootAttributes = new HashMap<>();
@@ -197,13 +210,16 @@ public class VirtualHostStoreUpgraderAndRecovererTest extends QpidTestCase
Map<String, Object> upgradedAttributes = upgradedQueueRecord.getAttributes();
assertNotNull("Upgraded attributes not found", upgradedAttributes);
- assertTrue("Attribute 'alternateBinding' was not added", upgradedAttributes.containsKey("alternateBinding"));
+ assertTrue("Attribute 'alternateBinding' was not added",
+ upgradedAttributes.containsKey("alternateBinding"));
assertEquals("Unexpected alternateBinding",
- new HashMap<>(Collections.singletonMap("destination", "testExchange")),
- new HashMap<>(((Map<String, String>) upgradedAttributes.get("alternateBinding"))));
- assertFalse("Attribute 'alternateExchange' was not removed", upgradedAttributes.containsKey("alternateExchange"));
+ new HashMap<>(Collections.singletonMap("destination", "testExchange")),
+ new HashMap<>(((Map<String, String>) upgradedAttributes.get("alternateBinding"))));
+ assertFalse("Attribute 'alternateExchange' was not removed",
+ upgradedAttributes.containsKey("alternateExchange"));
}
+ @Test
public void testUpgradeQueueSharedMessageGroupsFrom_6_1() throws Exception
{
Map<String, Object> rootAttributes = new HashMap<>();
@@ -234,15 +250,22 @@ public class VirtualHostStoreUpgraderAndRecovererTest extends QpidTestCase
Map<String, Object> upgradedAttributes = upgradedQueueRecord.getAttributes();
assertNotNull("Upgraded attributes not found", upgradedAttributes);
- assertFalse("Attribute 'messageGroupKey' was not removed", upgradedAttributes.containsKey("messageGroupKey"));
- assertFalse("Attribute 'messageGroupSharedGroups' was not removed", upgradedAttributes.containsKey("messageGroupSharedGroups"));
-
- assertTrue("Attribute 'messageGroupKeyOverride' was not added", upgradedAttributes.containsKey("messageGroupKeyOverride"));
- assertEquals("Unexpected messageGroupKeyOverride", "myheader", upgradedAttributes.get("messageGroupKeyOverride"));
- assertTrue("Attribute 'messageGroupType' was not added", upgradedAttributes.containsKey("messageGroupType"));
+ assertFalse("Attribute 'messageGroupKey' was not removed",
+ upgradedAttributes.containsKey("messageGroupKey"));
+ assertFalse("Attribute 'messageGroupSharedGroups' was not removed",
+ upgradedAttributes.containsKey("messageGroupSharedGroups"));
+
+ assertTrue("Attribute 'messageGroupKeyOverride' was not added",
+ upgradedAttributes.containsKey("messageGroupKeyOverride"));
+ assertEquals("Unexpected messageGroupKeyOverride",
+ "myheader",
+ upgradedAttributes.get("messageGroupKeyOverride"));
+ assertTrue("Attribute 'messageGroupType' was not added",
+ upgradedAttributes.containsKey("messageGroupType"));
assertEquals("Unexpected messageGroupType", "SHARED_GROUPS", upgradedAttributes.get("messageGroupType"));
}
+ @Test
public void testUpgradeQueueStandardMessageGroupsFrom_6_1() throws Exception
{
Map<String, Object> rootAttributes = new HashMap<>();
@@ -273,11 +296,15 @@ public class VirtualHostStoreUpgraderAndRecovererTest extends QpidTestCase
Map<String, Object> upgradedAttributes = upgradedQueueRecord.getAttributes();
assertNotNull("Upgraded attributes not found", upgradedAttributes);
- assertFalse("Attribute 'messageGroupKey' was not removed", upgradedAttributes.containsKey("messageGroupKey"));
- assertFalse("Attribute 'messageGroupSharedGroups' was not removed", upgradedAttributes.containsKey("messageGroupSharedGroups"));
- assertFalse("Attribute 'messageGroupKeyOverride' was added", upgradedAttributes.containsKey("messageGroupKeyOverride"));
+ assertFalse("Attribute 'messageGroupKey' was not removed",
+ upgradedAttributes.containsKey("messageGroupKey"));
+ assertFalse("Attribute 'messageGroupSharedGroups' was not removed",
+ upgradedAttributes.containsKey("messageGroupSharedGroups"));
+ assertFalse("Attribute 'messageGroupKeyOverride' was added",
+ upgradedAttributes.containsKey("messageGroupKeyOverride"));
- assertTrue("Attribute 'messageGroupType' was not added", upgradedAttributes.containsKey("messageGroupType"));
+ assertTrue("Attribute 'messageGroupType' was not added",
+ upgradedAttributes.containsKey("messageGroupType"));
assertEquals("Unexpected messageGroupType", "STANDARD", upgradedAttributes.get("messageGroupType"));
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/preferences/JsonFilePreferenceStoreTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/preferences/JsonFilePreferenceStoreTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/preferences/JsonFilePreferenceStoreTest.java
index df1aa76..d4586c8 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/preferences/JsonFilePreferenceStoreTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/preferences/JsonFilePreferenceStoreTest.java
@@ -19,6 +19,9 @@
package org.apache.qpid.server.store.preferences;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyCollection;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
@@ -37,23 +40,25 @@ import java.util.UUID;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.apache.qpid.server.model.BrokerModel;
import org.apache.qpid.server.model.SystemConfig;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.server.util.FileUtils;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class JsonFilePreferenceStoreTest extends QpidTestCase
+public class JsonFilePreferenceStoreTest extends UnitTestBase
{
private File _storeFile;
private ObjectMapper _objectMapper;
private PreferenceStoreUpdater _updater;
private JsonFilePreferenceStore _store;
- @Override
- protected void setUp() throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
_storeFile = new File(TMP_FOLDER, getTestName() + System.currentTimeMillis() + ".preferences.json");
_store = new JsonFilePreferenceStore(_storeFile.getPath(), SystemConfig.DEFAULT_POSIX_FILE_PERMISSIONS);
_objectMapper = new ObjectMapper();
@@ -61,8 +66,8 @@ public class JsonFilePreferenceStoreTest extends QpidTestCase
when(_updater.getLatestVersion()).thenReturn(BrokerModel.MODEL_VERSION);
}
- @Override
- protected void tearDown() throws Exception
+ @After
+ public void tearDown() throws Exception
{
try
{
@@ -71,10 +76,10 @@ public class JsonFilePreferenceStoreTest extends QpidTestCase
}
finally
{
- super.tearDown();
}
}
+ @Test
public void testOpenAndLoad() throws Exception
{
UUID prefId = UUID.randomUUID();
@@ -83,15 +88,18 @@ public class JsonFilePreferenceStoreTest extends QpidTestCase
Collection<PreferenceRecord> records = _store.openAndLoad(_updater);
- assertEquals("Unexpected size of stored preferences", 1, records.size());
+ assertEquals("Unexpected size of stored preferences", (long) 1, (long) records.size());
PreferenceRecord storeRecord = records.iterator().next();
assertEquals("Unexpected stored preference id", prefId, storeRecord.getId());
- assertEquals("Unexpected stored preference attributes", attributes, new HashMap<>(storeRecord.getAttributes()));
+ assertEquals("Unexpected stored preference attributes",
+ attributes,
+ new HashMap<>(storeRecord.getAttributes()));
verify(_updater, never()).updatePreferences(anyString(), anyCollection());
}
+ @Test
public void testUpdateOrCreate() throws Exception
{
final UUID id = UUID.randomUUID();
@@ -105,6 +113,7 @@ public class JsonFilePreferenceStoreTest extends QpidTestCase
assertSinglePreferenceRecordInStore(id, attributes);
}
+ @Test
public void testReplace() throws Exception
{
UUID prefId = UUID.randomUUID();
@@ -122,6 +131,7 @@ public class JsonFilePreferenceStoreTest extends QpidTestCase
assertSinglePreferenceRecordInStore(newPrefId, newAttributes);
}
+ @Test
public void testReplaceToDelete() throws Exception
{
UUID prefId = UUID.randomUUID();
@@ -134,6 +144,7 @@ public class JsonFilePreferenceStoreTest extends QpidTestCase
assertStoreVersionAndSizeAndGetData(0);
}
+ @Test
public void testUpdateFailIfNotOpened() throws Exception
{
try
@@ -147,6 +158,7 @@ public class JsonFilePreferenceStoreTest extends QpidTestCase
}
}
+ @Test
public void testReplaceFailIfNotOpened() throws Exception
{
try
@@ -194,7 +206,7 @@ public class JsonFilePreferenceStoreTest extends QpidTestCase
assertEquals("Unexpected stored version", BrokerModel.MODEL_VERSION, storedData.get("version"));
Collection preferences = (Collection) storedData.get("preferences");
- assertEquals("Unexpected size of preference records", expectedSize, preferences.size());
+ assertEquals("Unexpected size of preference records", (long) expectedSize, (long) preferences.size());
return preferences;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/store/preferences/PreferencesRecovererTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/store/preferences/PreferencesRecovererTest.java b/broker-core/src/test/java/org/apache/qpid/server/store/preferences/PreferencesRecovererTest.java
index b491b59..2496f95 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/store/preferences/PreferencesRecovererTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/store/preferences/PreferencesRecovererTest.java
@@ -20,6 +20,8 @@
package org.apache.qpid.server.store.preferences;
import static org.apache.qpid.server.model.preferences.PreferenceTestHelper.awaitPreferenceFuture;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import java.security.PrivilegedAction;
@@ -31,6 +33,10 @@ import java.util.UUID;
import javax.security.auth.Subject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.model.ConfiguredObject;
@@ -41,9 +47,9 @@ import org.apache.qpid.server.model.testmodels.hierarchy.TestCar;
import org.apache.qpid.server.model.testmodels.hierarchy.TestEngine;
import org.apache.qpid.server.model.testmodels.hierarchy.TestModel;
import org.apache.qpid.server.security.auth.TestPrincipalUtils;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class PreferencesRecovererTest extends QpidTestCase
+public class PreferencesRecovererTest extends UnitTestBase
{
public static final String TEST_USERNAME = "testUser";
private final Model _model = TestModel.getInstance();
@@ -54,10 +60,9 @@ public class PreferencesRecovererTest extends QpidTestCase
private TaskExecutor _preferenceTaskExecutor;
private PreferencesRecoverer _recoverer;
- @Override
+ @Before
public void setUp() throws Exception
{
- super.setUp();
_store = mock(PreferenceStore.class);
_testObject = _model.getObjectFactory()
.create(TestCar.class,
@@ -70,13 +75,13 @@ public class PreferencesRecovererTest extends QpidTestCase
_recoverer = new PreferencesRecoverer(_preferenceTaskExecutor);
}
- @Override
+ @After
public void tearDown() throws Exception
{
_preferenceTaskExecutor.stop();
- super.tearDown();
}
+ @Test
public void testRecoverEmptyPreferences() throws Exception
{
_recoverer.recoverPreferences(_testObject, Collections.<PreferenceRecord>emptyList(), _store);
@@ -84,6 +89,7 @@ public class PreferencesRecovererTest extends QpidTestCase
assertNotNull("Child object should have UserPreferences", _testChildObject.getUserPreferences());
}
+ @Test
public void testRecoverPreferences() throws Exception
{
final UUID p1Id = UUID.randomUUID();
@@ -116,10 +122,11 @@ public class PreferencesRecovererTest extends QpidTestCase
public Void run()
{
Set<Preference> preferences = awaitPreferenceFuture(_testObject.getUserPreferences().getPreferences());
- assertEquals("Unexpected number of preferences", 1, preferences.size());
+ assertEquals("Unexpected number of preferences", (long) 1, (long) preferences.size());
Set<Preference> childPreferences = awaitPreferenceFuture(_testChildObject.getUserPreferences().getPreferences());
- assertEquals("Unexpected number of preferences", 1, childPreferences.size());
+
+ assertEquals("Unexpected number of preferences", (long) 1, (long) childPreferences.size());
return null;
}
});
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/streams/CompositeInputStreamTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/streams/CompositeInputStreamTest.java b/broker-core/src/test/java/org/apache/qpid/server/streams/CompositeInputStreamTest.java
index 34ffd4d..d9b98dd 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/streams/CompositeInputStreamTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/streams/CompositeInputStreamTest.java
@@ -22,6 +22,8 @@
package org.apache.qpid.server.streams;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -31,11 +33,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class CompositeInputStreamTest extends TestCase
+import org.apache.qpid.test.utils.UnitTestBase;
+
+public class CompositeInputStreamTest extends UnitTestBase
{
+ @Test
public void testReadByteByByte_MultipleStreams() throws Exception
{
InputStream bis1 = new ByteArrayInputStream("ab".getBytes());
@@ -51,6 +56,7 @@ public class CompositeInputStreamTest extends TestCase
assertEquals("Expecting EOF", -1, cis.read());
}
+ @Test
public void testReadByteArray_MultipleStreams() throws Exception
{
InputStream bis1 = new ByteArrayInputStream("ab".getBytes());
@@ -72,6 +78,7 @@ public class CompositeInputStreamTest extends TestCase
assertEquals("Expecting EOF", -1, read3);
}
+ @Test
public void testReadsMixed_SingleStream() throws Exception
{
InputStream bis = new ByteArrayInputStream("abcd".getBytes());
@@ -89,6 +96,7 @@ public class CompositeInputStreamTest extends TestCase
assertEquals("Expecting EOF", -1, cis.read(buf));
}
+ @Test
public void testAvailable_MultipleStreams() throws Exception
{
InputStream bis1 = new ByteArrayInputStream("ab".getBytes());
@@ -106,6 +114,7 @@ public class CompositeInputStreamTest extends TestCase
assertEquals("Unexpected number of available bytes after last byte read", 0, cis.available());
}
+ @Test
public void testClose() throws Exception
{
InputStream bis1 = mock(InputStream.class);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java b/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java
index 49438d8..8039e5a 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/transport/SNITest.java
@@ -20,6 +20,8 @@
package org.apache.qpid.server.transport;
+import static org.junit.Assert.assertEquals;
+
import java.io.File;
import java.io.FileOutputStream;
import java.net.InetSocketAddress;
@@ -42,6 +44,9 @@ import javax.net.ssl.X509TrustManager;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.apache.qpid.server.SystemLauncher;
import org.apache.qpid.server.SystemLauncherListener.DefaultSystemLauncherListener;
@@ -58,10 +63,10 @@ import org.apache.qpid.server.security.FileKeyStore;
import org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager;
import org.apache.qpid.server.transport.network.security.ssl.SSLUtil;
import org.apache.qpid.server.transport.network.security.ssl.SSLUtil.KeyCertPair;
-import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.test.utils.TestFileUtils;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class SNITest extends QpidTestCase
+public class SNITest extends UnitTestBase
{
private static final int SOCKET_TIMEOUT = 10000;
private static final String KEYSTORE_PASSWORD = "password";
@@ -75,7 +80,7 @@ public class SNITest extends QpidTestCase
private int _boundPort;
private File _brokerWork;
- @Override
+ @Before
public void setUp() throws Exception
{
if(SSLUtil.canGenerateCerts())
@@ -132,11 +137,10 @@ public class SNITest extends QpidTestCase
inMemoryKeyStore.store(os, KEYSTORE_PASSWORD.toCharArray());
}
}
- super.setUp();
}
- @Override
- protected void tearDown() throws Exception
+ @After
+ public void tearDown() throws Exception
{
try
{
@@ -156,26 +160,29 @@ public class SNITest extends QpidTestCase
}
finally
{
- super.tearDown();
}
}
+ @Test
public void testValidCertChosen() throws Exception
{
performTest(true, "fooinvalid", "foo", _fooValid);
}
+ @Test
public void testMatchCertChosenEvenIfInvalid() throws Exception
{
performTest(true, "fooinvalid", "bar", _barInvalid);
}
+ @Test
public void testDefaultCertChose() throws Exception
{
performTest(true, "fooinvalid", null, _fooInvalid);
}
+ @Test
public void testMatchingCanBeDisabled() throws Exception
{
performTest(false, "fooinvalid", "foo", _fooInvalid);
@@ -228,7 +235,7 @@ public class SNITest extends QpidTestCase
socket.connect(address, SOCKET_TIMEOUT);
final Certificate[] certs = socket.getSession().getPeerCertificates();
- assertEquals(1, certs.length);
+ assertEquals((long) 1, (long) certs.length);
assertEquals(expectedCert.getCertificate(), certs[0]);
}
}
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java b/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java
index e83cdd1..d3fd34d 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/transport/TCPandSSLTransportTest.java
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.server.transport;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -41,6 +42,7 @@ import javax.xml.bind.DatatypeConverter;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,12 +51,13 @@ import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.Protocol;
import org.apache.qpid.server.model.Transport;
import org.apache.qpid.server.model.port.AmqpPort;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class TCPandSSLTransportTest extends QpidTestCase
+public class TCPandSSLTransportTest extends UnitTestBase
{
private static final Logger LOGGER = LoggerFactory.getLogger(TCPandSSLTransportTest.class);
+ @Test
public void testNoSSLv3SupportOnSSLOnlyPort() throws Exception
{
try
@@ -69,6 +72,7 @@ public class TCPandSSLTransportTest extends QpidTestCase
}
+ @Test
public void testNoTLSv1SupportOnSharedPort() throws Exception
{
try
@@ -83,6 +87,7 @@ public class TCPandSSLTransportTest extends QpidTestCase
}
+ @Test
public void testNoTLSv1SupportOnSSLOnlyPort() throws Exception
{
try
@@ -97,6 +102,7 @@ public class TCPandSSLTransportTest extends QpidTestCase
}
+ @Test
public void testNoSSLv3SupportOnSharedPort() throws Exception
{
try
@@ -111,6 +117,7 @@ public class TCPandSSLTransportTest extends QpidTestCase
}
+ @Test
public void testTLSSupportOnSharedPort() throws Exception
{
try
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/d0dcd3fc/broker-core/src/test/java/org/apache/qpid/server/transport/TransactionTimeoutTickerTest.java
----------------------------------------------------------------------
diff --git a/broker-core/src/test/java/org/apache/qpid/server/transport/TransactionTimeoutTickerTest.java b/broker-core/src/test/java/org/apache/qpid/server/transport/TransactionTimeoutTickerTest.java
index 9d49225..55de5c3 100644
--- a/broker-core/src/test/java/org/apache/qpid/server/transport/TransactionTimeoutTickerTest.java
+++ b/broker-core/src/test/java/org/apache/qpid/server/transport/TransactionTimeoutTickerTest.java
@@ -21,6 +21,8 @@
package org.apache.qpid.server.transport;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
@@ -30,12 +32,13 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.base.Supplier;
+import org.junit.Test;
import org.mockito.InOrder;
import org.apache.qpid.server.util.Action;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.UnitTestBase;
-public class TransactionTimeoutTickerTest extends QpidTestCase
+public class TransactionTimeoutTickerTest extends UnitTestBase
{
private TransactionTimeoutTicker _ticker;
@@ -44,6 +47,7 @@ public class TransactionTimeoutTickerTest extends QpidTestCase
private long _timeoutValue = 100;
private long _notificationRepeatPeriod = 5000;
+ @Test
public void testTickWhenNoTransaction() throws Exception
{
final long timeNow = System.currentTimeMillis();
@@ -61,6 +65,7 @@ public class TransactionTimeoutTickerTest extends QpidTestCase
verify(_notificationAction, never()).performAction(anyLong());
}
+ @Test
public void testTickDuringSingleTransaction() throws Exception
{
final long timeNow = System.currentTimeMillis();
@@ -80,6 +85,7 @@ public class TransactionTimeoutTickerTest extends QpidTestCase
verify(_notificationAction, never()).performAction(anyLong());
}
+ @Test
public void testTickDuringSingleTransactionWithSchedulingDelay() throws Exception
{
final long timeNow = System.currentTimeMillis();
@@ -101,6 +107,7 @@ public class TransactionTimeoutTickerTest extends QpidTestCase
verify(_notificationAction, never()).performAction(anyLong());
}
+ @Test
public void testTicksDuringManyTransactions() throws Exception
{
long timeNow = System.currentTimeMillis();
@@ -132,6 +139,7 @@ public class TransactionTimeoutTickerTest extends QpidTestCase
verify(_notificationAction, never()).performAction(anyLong());
}
+ @Test
public void testTicksDuringManyTransactionsWithSchedulingDelay() throws Exception
{
long timeNow = System.currentTimeMillis();
@@ -164,6 +172,7 @@ public class TransactionTimeoutTickerTest extends QpidTestCase
verify(_notificationAction, never()).performAction(anyLong());
}
+ @Test
public void testSingleTimeoutsDuringSingleTransaction() throws Exception
{
long timeNow = System.currentTimeMillis();
@@ -183,6 +192,7 @@ public class TransactionTimeoutTickerTest extends QpidTestCase
verify(_notificationAction, times(1)).performAction(expectedInitialIdle);
}
+ @Test
public void testMultipleTimeoutsDuringSingleTransaction_NotificationsRespectPeriod() throws Exception
{
InOrder inorder = inOrder(_notificationAction);
@@ -240,7 +250,7 @@ public class TransactionTimeoutTickerTest extends QpidTestCase
final long currentTime,
final TransactionTimeoutTicker ticker)
{
- assertEquals(message, expectedValue, ticker.getTimeToNextTick(currentTime));
- assertEquals(message, expectedValue, ticker.tick(currentTime));
+ assertEquals(message, expectedValue, (long) ticker.getTimeToNextTick(currentTime));
+ assertEquals(message, expectedValue, (long) ticker.tick(currentTime));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org