You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jj...@apache.org on 2018/11/15 10:12:20 UTC
[geode] branch develop updated: GEODE-3835: Use TemporayFolder
instead of /tmp (#2811)
This is an automated email from the ASF dual-hosted git repository.
jjramos pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 7f70a28 GEODE-3835: Use TemporayFolder instead of /tmp (#2811)
7f70a28 is described below
commit 7f70a282d24ecc56604d62dcb4552f5a98e69853
Author: Juan José Ramos <ju...@users.noreply.github.com>
AuthorDate: Thu Nov 15 10:12:09 2018 +0000
GEODE-3835: Use TemporayFolder instead of /tmp (#2811)
- Fixed minor warnings.
- Replaced the usage of `junit.Assert` by `assertj`.
---
.../DistributedSystemBridgeIntegrationTest.java} | 32 ++++++++++------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeIntegrationTest.java
similarity index 92%
rename from geode-core/src/test/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeJUnitTest.java
rename to geode-core/src/integrationTest/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeIntegrationTest.java
index a0e12e4..9c184c8 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeJUnitTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/management/internal/beans/DistributedSystemBridgeIntegrationTest.java
@@ -16,7 +16,7 @@ package org.apache.geode.management.internal.beans;
import static org.apache.geode.management.internal.ManagementConstants.OBJECTNAME__GATEWAYSENDER_MXBEAN;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.isA;
@@ -34,7 +34,9 @@ import javax.management.ObjectName;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import org.mockito.InOrder;
import org.apache.geode.distributed.internal.DistributionManager;
@@ -50,14 +52,13 @@ import org.apache.geode.management.GatewaySenderMXBean;
import org.apache.geode.management.internal.FederationComponent;
import org.apache.geode.test.fake.Fakes;
-public class DistributedSystemBridgeJUnitTest {
+public class DistributedSystemBridgeIntegrationTest {
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
private GemFireCacheImpl cache;
private BackupService backupService;
-
private DistributedSystemBridge bridge;
-
- private ObjectName name1, name2, name3, name4;
private GatewaySenderMXBean bean1, bean2, bean3, bean4;
@Before
@@ -74,13 +75,13 @@ public class DistributedSystemBridgeJUnitTest {
DLockService.addLockServiceForTests(BackupLockService.LOCK_SERVICE_NAME, dlock);
- name1 = ObjectName
+ ObjectName name1 = ObjectName
.getInstance(MessageFormat.format(OBJECTNAME__GATEWAYSENDER_MXBEAN, "sender1", "server1"));
- name2 = ObjectName
+ ObjectName name2 = ObjectName
.getInstance(MessageFormat.format(OBJECTNAME__GATEWAYSENDER_MXBEAN, "sender2", "server2"));
- name3 = ObjectName
+ ObjectName name3 = ObjectName
.getInstance(MessageFormat.format(OBJECTNAME__GATEWAYSENDER_MXBEAN, "sender3", "server3"));
- name4 = ObjectName
+ ObjectName name4 = ObjectName
.getInstance(MessageFormat.format(OBJECTNAME__GATEWAYSENDER_MXBEAN, "sender4", "server4"));
bean1 = mock(GatewaySenderMXBean.class);
@@ -109,7 +110,7 @@ public class DistributedSystemBridgeJUnitTest {
public void testSuccessfulBackup() throws Exception {
DistributionManager dm = cache.getDistributionManager();
- bridge.backupAllMembers("/tmp", null);
+ bridge.backupAllMembers(temporaryFolder.getRoot().getAbsolutePath(), null);
InOrder inOrder = inOrder(dm, backupService);
inOrder.verify(dm).putOutgoing(isA(PrepareBackupRequest.class));
@@ -119,7 +120,7 @@ public class DistributedSystemBridgeJUnitTest {
}
@Test
- public void testPrepareErrorAbortsBackup() throws Exception {
+ public void testPrepareErrorAbortsBackup() {
DistributionManager dm = cache.getDistributionManager();
PersistentMemberManager memberManager = mock(PersistentMemberManager.class);
BackupService backupService = mock(BackupService.class);
@@ -128,12 +129,9 @@ public class DistributedSystemBridgeJUnitTest {
when(cache.getBackupService()).thenReturn(backupService);
when(dm.putOutgoing(isA(PrepareBackupRequest.class)))
.thenThrow(new RuntimeException("Fail the prepare"));
-
- try {
- bridge.backupAllMembers("/tmp", null);
- fail("Should have failed with an exception");
- } catch (RuntimeException expected) {
- }
+ assertThatThrownBy(
+ () -> bridge.backupAllMembers(temporaryFolder.getRoot().getAbsolutePath(), null))
+ .isInstanceOf(RuntimeException.class).hasMessage("Fail the prepare");
verify(dm).putOutgoing(isA(AbortBackupRequest.class));
verify(backupService).abortBackup();