ARTEMIS-3340 Removing not needed TemporaryFolder usages on tests

This commit is contained in:
Clebert Suconic 2021-08-04 15:03:51 -04:00
parent ca7a100de0
commit 56299433c3
10 changed files with 11 additions and 52 deletions

View File

@ -24,14 +24,9 @@ import org.apache.activemq.artemis.core.config.ha.ReplicationBackupPolicyConfigu
import org.apache.activemq.artemis.quorum.file.FileBasedPrimitiveManager; import org.apache.activemq.artemis.quorum.file.FileBasedPrimitiveManager;
import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils; import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public class PluggableQuorumInfiniteRedeliveryTest extends InfiniteRedeliveryTest { public class PluggableQuorumInfiniteRedeliveryTest extends InfiniteRedeliveryTest {
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
private DistributedPrimitiveManagerConfiguration managerConfiguration; private DistributedPrimitiveManagerConfiguration managerConfiguration;
public PluggableQuorumInfiniteRedeliveryTest(String protocol, boolean useCLI) { public PluggableQuorumInfiniteRedeliveryTest(String protocol, boolean useCLI) {
@ -43,7 +38,7 @@ public class PluggableQuorumInfiniteRedeliveryTest extends InfiniteRedeliveryTes
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
this.managerConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), this.managerConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(),
Collections.singletonMap("locks-folder", tmpFolder.newFolder("manager").toString())); Collections.singletonMap("locks-folder", temporaryFolder.newFolder("manager").toString()));
} }
@Override @Override

View File

@ -97,14 +97,9 @@ import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public abstract class ClusterTestBase extends ActiveMQTestBase { public abstract class ClusterTestBase extends ActiveMQTestBase {
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
private static final Logger log = Logger.getLogger(ClusterTestBase.class); private static final Logger log = Logger.getLogger(ClusterTestBase.class);
private static final int[] PORTS = {TransportConstants.DEFAULT_PORT, TransportConstants.DEFAULT_PORT + 1, TransportConstants.DEFAULT_PORT + 2, TransportConstants.DEFAULT_PORT + 3, TransportConstants.DEFAULT_PORT + 4, TransportConstants.DEFAULT_PORT + 5, TransportConstants.DEFAULT_PORT + 6, TransportConstants.DEFAULT_PORT + 7, TransportConstants.DEFAULT_PORT + 8, TransportConstants.DEFAULT_PORT + 9,}; private static final int[] PORTS = {TransportConstants.DEFAULT_PORT, TransportConstants.DEFAULT_PORT + 1, TransportConstants.DEFAULT_PORT + 2, TransportConstants.DEFAULT_PORT + 3, TransportConstants.DEFAULT_PORT + 4, TransportConstants.DEFAULT_PORT + 5, TransportConstants.DEFAULT_PORT + 6, TransportConstants.DEFAULT_PORT + 7, TransportConstants.DEFAULT_PORT + 8, TransportConstants.DEFAULT_PORT + 9,};
@ -151,7 +146,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase {
return pluggableQuorumConfiguration; return pluggableQuorumConfiguration;
} }
try { try {
pluggableQuorumConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", tmpFolder.newFolder("manager").toString())); pluggableQuorumConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", temporaryFolder.newFolder("manager").toString()));
} catch (IOException ioException) { } catch (IOException ioException) {
log.error(ioException); log.error(ioException);
return null; return null;

View File

@ -56,13 +56,9 @@ import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public abstract class FailoverTestBase extends ActiveMQTestBase { public abstract class FailoverTestBase extends ActiveMQTestBase {
// Constants ----------------------------------------------------- // Constants -----------------------------------------------------
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
protected static final SimpleString ADDRESS = new SimpleString("FailoverTestAddress"); protected static final SimpleString ADDRESS = new SimpleString("FailoverTestAddress");
@ -243,7 +239,7 @@ public abstract class FailoverTestBase extends ActiveMQTestBase {
managerConfiguration = managerConfiguration =
new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(),
Collections.singletonMap("locks-folder", tmpFolder.newFolder("manager").toString())); Collections.singletonMap("locks-folder", temporaryFolder.newFolder("manager").toString()));
ReplicatedBackupUtils.configurePluggableQuorumReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, null, managerConfiguration, managerConfiguration); ReplicatedBackupUtils.configurePluggableQuorumReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, null, managerConfiguration, managerConfiguration);

View File

@ -48,14 +48,9 @@ import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils; import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase { public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase {
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
private DistributedPrimitiveManagerConfiguration pluggableQuorumConfiguration = null; private DistributedPrimitiveManagerConfiguration pluggableQuorumConfiguration = null;
private DistributedPrimitiveManagerConfiguration getOrCreatePluggableQuorumConfiguration() { private DistributedPrimitiveManagerConfiguration getOrCreatePluggableQuorumConfiguration() {
@ -63,7 +58,7 @@ public abstract class MultipleServerFailoverTestBase extends ActiveMQTestBase {
return pluggableQuorumConfiguration; return pluggableQuorumConfiguration;
} }
try { try {
pluggableQuorumConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", tmpFolder.newFolder("manager").toString())); pluggableQuorumConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", temporaryFolder.newFolder("manager").toString()));
} catch (IOException ioException) { } catch (IOException ioException) {
return null; return null;
} }

View File

@ -27,21 +27,16 @@ import org.apache.activemq.artemis.core.config.ha.ReplicationPrimaryPolicyConfig
import org.apache.activemq.artemis.quorum.file.FileBasedPrimitiveManager; import org.apache.activemq.artemis.quorum.file.FileBasedPrimitiveManager;
import org.apache.activemq.artemis.tests.integration.cluster.failover.ReplicaTimeoutTest; import org.apache.activemq.artemis.tests.integration.cluster.failover.ReplicaTimeoutTest;
import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils; import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public class PluggableQuorumReplicaTimeoutTest extends ReplicaTimeoutTest { public class PluggableQuorumReplicaTimeoutTest extends ReplicaTimeoutTest {
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
@Override @Override
protected void configureReplicationPair(Configuration backupConfig, protected void configureReplicationPair(Configuration backupConfig,
Configuration liveConfig, Configuration liveConfig,
TransportConfiguration backupConnector, TransportConfiguration backupConnector,
TransportConfiguration backupAcceptor, TransportConfiguration backupAcceptor,
TransportConfiguration liveConnector) throws IOException { TransportConfiguration liveConnector) throws IOException {
DistributedPrimitiveManagerConfiguration managerConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", tmpFolder.newFolder("manager").toString())); DistributedPrimitiveManagerConfiguration managerConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", temporaryFolder.newFolder("manager").toString()));
ReplicatedBackupUtils.configurePluggableQuorumReplicationPair(backupConfig, backupConnector, backupAcceptor, ReplicatedBackupUtils.configurePluggableQuorumReplicationPair(backupConfig, backupConnector, backupAcceptor,
liveConfig, liveConnector, null, liveConfig, liveConnector, null,

View File

@ -26,18 +26,14 @@ import org.apache.activemq.artemis.core.config.ha.ReplicationBackupPolicyConfigu
import org.apache.activemq.artemis.core.config.ha.ReplicationPrimaryPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.ReplicationPrimaryPolicyConfiguration;
import org.apache.activemq.artemis.quorum.file.FileBasedPrimitiveManager; import org.apache.activemq.artemis.quorum.file.FileBasedPrimitiveManager;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public class PluggableQuorumReplicationFlowControlTest extends SharedNothingReplicationFlowControlTest { public class PluggableQuorumReplicationFlowControlTest extends SharedNothingReplicationFlowControlTest {
private DistributedPrimitiveManagerConfiguration managerConfiguration; private DistributedPrimitiveManagerConfiguration managerConfiguration;
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
@Before @Before
public void init() throws IOException { public void init() throws IOException {
managerConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", tmpFolder.newFolder("manager").toString())); managerConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", temporaryFolder.newFolder("manager").toString()));
} }
@Override @Override

View File

@ -47,19 +47,15 @@ import org.apache.activemq.artemis.quorum.file.FileBasedPrimitiveManager;
import org.apache.activemq.artemis.tests.util.Wait; import org.apache.activemq.artemis.tests.util.Wait;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class PluggableQuorumReplicationTest extends SharedNothingReplicationTest { public class PluggableQuorumReplicationTest extends SharedNothingReplicationTest {
private DistributedPrimitiveManagerConfiguration managerConfiguration; private DistributedPrimitiveManagerConfiguration managerConfiguration;
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
@Before @Before
public void init() throws IOException { public void init() throws IOException {
managerConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", tmpFolder.newFolder("manager").toString())); managerConfiguration = new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), Collections.singletonMap("locks-folder", temporaryFolder.newFolder("manager").toString()));
} }
@Override @Override

View File

@ -100,18 +100,13 @@ import org.apache.activemq.artemis.utils.critical.EmptyCriticalAnalyzer;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public final class ReplicationTest extends ActiveMQTestBase { public final class ReplicationTest extends ActiveMQTestBase {
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
@Parameterized.Parameter @Parameterized.Parameter
public boolean pluggableQuorum; public boolean pluggableQuorum;
@ -168,7 +163,7 @@ public final class ReplicationTest extends ActiveMQTestBase {
} else { } else {
DistributedPrimitiveManagerConfiguration managerConfiguration = DistributedPrimitiveManagerConfiguration managerConfiguration =
new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(),
Collections.singletonMap("locks-folder", tmpFolder.newFolder("manager").toString())); Collections.singletonMap("locks-folder", temporaryFolder.newFolder("manager").toString()));
ReplicatedBackupUtils.configurePluggableQuorumReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor, managerConfiguration, managerConfiguration); ReplicatedBackupUtils.configurePluggableQuorumReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor, managerConfiguration, managerConfiguration);
} }

View File

@ -51,7 +51,7 @@ public class PluggableQuorumBasicSecurityManagerFailoverTest extends FailoverTes
DistributedPrimitiveManagerConfiguration managerConfiguration = DistributedPrimitiveManagerConfiguration managerConfiguration =
new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(), new DistributedPrimitiveManagerConfiguration(FileBasedPrimitiveManager.class.getName(),
Collections.singletonMap("locks-folder", Collections.singletonMap("locks-folder",
tmpFolder.newFolder("manager").toString())); temporaryFolder.newFolder("manager").toString()));
ReplicatedBackupUtils.configurePluggableQuorumReplicationPair(backupConfig, backupConnector, backupAcceptor, ReplicatedBackupUtils.configurePluggableQuorumReplicationPair(backupConfig, backupConnector, backupAcceptor,
liveConfig, liveConnector, null, liveConfig, liveConnector, null,

View File

@ -28,8 +28,6 @@ import org.jboss.logging.Logger;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public class ZookeeperPluggableQuorumSinglePairTest extends PluggableQuorumSinglePairTest { public class ZookeeperPluggableQuorumSinglePairTest extends PluggableQuorumSinglePairTest {
@ -38,9 +36,7 @@ public class ZookeeperPluggableQuorumSinglePairTest extends PluggableQuorumSingl
// Beware: the server tick must be small enough that to let the session to be correctly expired // Beware: the server tick must be small enough that to let the session to be correctly expired
private static final int SERVER_TICK_MS = 100; private static final int SERVER_TICK_MS = 100;
@Rule private TestingCluster testingServer;
public TemporaryFolder tmpFolder = new TemporaryFolder();
protected TestingCluster testingServer;
private InstanceSpec[] clusterSpecs; private InstanceSpec[] clusterSpecs;
private int nodes; private int nodes;
@ -51,7 +47,7 @@ public class ZookeeperPluggableQuorumSinglePairTest extends PluggableQuorumSingl
nodes = 3; nodes = 3;
clusterSpecs = new InstanceSpec[nodes]; clusterSpecs = new InstanceSpec[nodes];
for (int i = 0; i < nodes; i++) { for (int i = 0; i < nodes; i++) {
clusterSpecs[i] = new InstanceSpec(tmpFolder.newFolder(), BASE_SERVER_PORT + i, -1, -1, true, -1, SERVER_TICK_MS, -1); clusterSpecs[i] = new InstanceSpec(temporaryFolder.newFolder(), BASE_SERVER_PORT + i, -1, -1, true, -1, SERVER_TICK_MS, -1);
} }
testingServer = new TestingCluster(clusterSpecs); testingServer = new TestingCluster(clusterSpecs);
testingServer.start(); testingServer.start();