Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove duplicated code / Delete unnecessary test code

  • Loading branch information...
commit c2d9d1f8d5c38293c778bf71a1f232296d592854 1 parent 8d1d894
Francisco Borges authored
View
5 hornetq-server/src/test/java/org/hornetq/tests/util/ServiceTestBase.java
@@ -75,10 +75,9 @@
public abstract class ServiceTestBase extends UnitTestCase
{
- // Constants -----------------------------------------------------
-
/**
- *
+ * Add a "sendCallNumber" property to messages sent using helper classes. Meant to help in
+ * debugging.
*/
private static final String SEND_CALL_NUMBER = "sendCallNumber";
protected static final long WAIT_TIMEOUT = 10000;
View
26 hornetq-server/src/test/java/org/hornetq/tests/util/UnitTestCase.java
@@ -176,9 +176,8 @@ protected Configuration createDefaultConfig(final boolean netty) throws Exceptio
}
}
- protected static final void basicClusterConnectionConfig(Configuration mainConfig,
- String connectorName,
- String... connectors)
+ protected static final void basicClusterConnectionConfig(Configuration mainConfig, String connectorName,
+ String... connectors)
{
ArrayList<String> connectors0 = new ArrayList<String>();
for (String c : connectors)
@@ -225,12 +224,13 @@ protected static ConfigurationImpl createBasicConfig() throws Exception
* @return
* @throws Exception
*/
- protected static ConfigurationImpl createBasicConfig(final int serverID) throws Exception
+ protected static final ConfigurationImpl createBasicConfig(final int serverID) throws Exception
{
ConfigurationImpl configuration = new ConfigurationImpl();
configuration.setSecurityEnabled(false);
configuration.setJournalMinFiles(2);
configuration.setJournalFileSize(100 * 1024);
+
configuration.setJournalType(getDefaultJournalType());
configuration.setJournalDirectory(getJournalDir(serverID, false));
@@ -246,21 +246,10 @@ protected static ConfigurationImpl createBasicConfig(final int serverID) throws
protected static Configuration createDefaultConfig(final Map<String, Object> params, final String... acceptors) throws Exception
{
- Configuration configuration = new ConfigurationImpl();
- configuration.setSecurityEnabled(false);
- configuration.setJMXManagementEnabled(false);
- configuration.setBindingsDirectory(getBindingsDir());
- configuration.setJournalMinFiles(2);
- configuration.setJournalDirectory(getJournalDir());
- configuration.setJournalFileSize(100 * 1024);
- configuration.setPagingDirectory(getPageDir());
- configuration.setLargeMessagesDirectory(getLargeMessagesDir());
- configuration.setJournalCompactMinFiles(0);
- configuration.setJournalCompactPercentage(0);
+ ConfigurationImpl configuration = createBasicConfig(-1);
configuration.setFileDeploymentEnabled(false);
-
- configuration.setJournalType(getDefaultJournalType());
+ configuration.setJMXManagementEnabled(false);
configuration.getAcceptorConfigurations().clear();
@@ -269,7 +258,6 @@ protected static Configuration createDefaultConfig(final Map<String, Object> par
TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
configuration.getAcceptorConfigurations().add(transportConfig);
}
- configuration.setClusterPassword(CLUSTER_PASSWORD);
return configuration;
}
@@ -766,6 +754,8 @@ protected static String getLargeMessagesDir(final int index, final boolean backu
private static String directoryNameSuffix(int index, boolean backup)
{
+ if (index == -1)
+ return "";
return index + "-" + (backup ? "B" : "L");
}
View
80 ...on-tests/src/test/java/org/hornetq/tests/integration/client/LargeMessageCompressTest.java
@@ -53,26 +53,22 @@ protected boolean isNetty()
@Override
protected ServerLocator createFactory(final boolean isNetty) throws Exception
{
- ServerLocator locator = super.createFactory(isNetty);
- locator.setCompressLargeMessage(true);
- return locator;
+ ServerLocator locator1 = super.createFactory(isNetty);
+ locator1.setCompressLargeMessage(true);
+ return locator1;
}
public void testLargeMessageCompression() throws Exception
{
final int messageSize = (int)(3.5 * HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE);
- ClientSession session = null;
-
- try
- {
- HornetQServer server = createServer(true, isNetty());
+ HornetQServer server = createServer(true, isNetty());
server.start();
ClientSessionFactory sf = createSessionFactory(locator);
- session = sf.createSession(false, false, false);
+ ClientSession session = addClientSession(sf.createSession(false, false, false));
session.createTemporaryQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS);
@@ -104,34 +100,19 @@ public void testLargeMessageCompression() throws Exception
session.close();
validateNoFilesOnLargeDir();
- }
- finally
- {
- try
- {
- session.close();
- }
- catch (Throwable ignored)
- {
- }
- }
}
public void testLargeMessageCompression2() throws Exception
{
final int messageSize = (int)(3.5 * HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE);
- ClientSession session = null;
-
- try
- {
HornetQServer server = createServer(true, isNetty());
server.start();
ClientSessionFactory sf = createSessionFactory(locator);
- session = sf.createSession(false, false, false);
+ ClientSession session = addClientSession(sf.createSession(false, false, false));
session.createTemporaryQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS);
@@ -177,34 +158,20 @@ public void testLargeMessageCompression2() throws Exception
input.close();
testFile.delete();
validateNoFilesOnLargeDir();
- }
- finally
- {
- try
- {
- session.close();
- }
- catch (Throwable ignored)
- {
- }
- }
+
}
public void testLargeMessageCompression3() throws Exception
{
final int messageSize = (int)(3.5 * HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE);
- ClientSession session = null;
-
- try
- {
- HornetQServer server = createServer(true, isNetty());
+ HornetQServer server = createServer(true, isNetty());
server.start();
ClientSessionFactory sf = createSessionFactory(locator);
- session = sf.createSession(false, false, false);
+ ClientSession session = addClientSession(sf.createSession(false, false, false));
session.createTemporaryQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS);
@@ -250,17 +217,6 @@ public void testLargeMessageCompression3() throws Exception
testFile.delete();
validateNoFilesOnLargeDir();
}
- finally
- {
- try
- {
- session.close();
- }
- catch (Throwable ignored)
- {
- }
- }
- }
@@ -268,17 +224,14 @@ public void testLargeMessageCompressionRestartAndCheckSize() throws Exception
{
final int messageSize = 1024 * 1024;
- ClientSession session = null;
- try
- {
- HornetQServer server = createServer(true, isNetty());
+ HornetQServer server = createServer(true, isNetty());
server.start();
ClientSessionFactory sf = createSessionFactory(locator);
- session = sf.createSession(false, false, false);
+ ClientSession session = addClientSession(sf.createSession(false, false, false));
session.createQueue(LargeMessageTest.ADDRESS, LargeMessageTest.ADDRESS, true);
@@ -347,17 +300,6 @@ public void testLargeMessageCompressionRestartAndCheckSize() throws Exception
testFile.delete();
validateNoFilesOnLargeDir();
- }
- finally
- {
- try
- {
- session.close();
- }
- catch (Throwable ignored)
- {
- }
- }
}
View
42 .../tests/integration/cluster/failover/ReplicatedMultipleServerFailoverExtraBackupsTest.java
@@ -44,40 +44,40 @@ public void testStartLiveFirst() throws Exception
{
backupServers.get(2).getServer().getConfiguration().setBackupGroupName(getNodeGroupName() + "-0");
backupServers.get(3).getServer().getConfiguration().setBackupGroupName(getNodeGroupName() + "-1");
- for (TestableServer liveServer : liveServers)
- {
- liveServer.start();
- }
- for (TestableServer backupServer : backupServers)
- {
- backupServer.start();
- waitForRemoteBackupSynchronization(backupServer.getServer());
- }
+
+ startServers(liveServers);
+ startServers(backupServers);
+ waitForBackupSyncs();
sendCrashReceive();
waitForTopology(backupServers.get(0).getServer(), liveServers.size(), 2);
sendCrashBackupReceive();
}
- @Override
- public void testStartBackupFirst() throws Exception
+ private void waitForBackupSyncs()
{
- backupServers.get(2).getServer().getConfiguration().setBackupGroupName(getNodeGroupName() + "-0");
- backupServers.get(3).getServer().getConfiguration().setBackupGroupName(getNodeGroupName() + "-1");
-
for (TestableServer backupServer : backupServers)
{
- backupServer.start();
- }
- for (TestableServer liveServer : liveServers)
- {
- liveServer.start();
+ waitForRemoteBackupSynchronization(backupServer.getServer());
}
+ }
- for (TestableServer backupServer : backupServers)
+ private void startServers(List<TestableServer> servers) throws Exception
+ {
+ for (TestableServer testableServer : servers)
{
- waitForRemoteBackupSynchronization(backupServer.getServer());
+ testableServer.start();
}
+ }
+ @Override
+ public void testStartBackupFirst() throws Exception
+ {
+ backupServers.get(2).getServer().getConfiguration().setBackupGroupName(getNodeGroupName() + "-0");
+ backupServers.get(3).getServer().getConfiguration().setBackupGroupName(getNodeGroupName() + "-1");
+
+ startServers(backupServers);
+ startServers(liveServers);
+ waitForBackupSyncs();
waitForTopology(liveServers.get(0).getServer(), liveServers.size(), 2);
sendCrashReceive();
Please sign in to comment.
Something went wrong with that request. Please try again.