You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by on...@apache.org on 2020/04/11 18:03:37 UTC

[geode] branch revert-4937-feature_parity_redis_srem_command created (now ab59fbd)

This is an automated email from the ASF dual-hosted git repository.

onichols pushed a change to branch revert-4937-feature_parity_redis_srem_command
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at ab59fbd  Revert "GEODE-7978: Improve tests for Redis Module SREM Command (#4937)"

This branch includes the following new commits:

     new ab59fbd  Revert "GEODE-7978: Improve tests for Redis Module SREM Command (#4937)"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[geode] 01/01: Revert "GEODE-7978: Improve tests for Redis Module SREM Command (#4937)"

Posted by on...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

onichols pushed a commit to branch revert-4937-feature_parity_redis_srem_command
in repository https://gitbox.apache.org/repos/asf/geode.git

commit ab59fbdb9fe5ca8044764ab6750f4c2733327f7c
Author: Owen Nichols <34...@users.noreply.github.com>
AuthorDate: Sat Apr 11 11:03:11 2020 -0700

    Revert "GEODE-7978: Improve tests for Redis Module SREM Command (#4937)"
    
    This reverts commit b664be6654f70e7832f01c1fddf05ac2da102f95.
---
 .../org/apache/geode/redis/GeoIntegrationTest.java |  3 +-
 .../apache/geode/redis/SetsIntegrationTest.java    | 93 +++-------------------
 .../executor/set/SetExecutorJUnitTest.java         | 18 ++---
 3 files changed, 21 insertions(+), 93 deletions(-)

diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java
index 844b9e5..b38e17f 100755
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/GeoIntegrationTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -51,7 +52,7 @@ public class GeoIntegrationTest {
   private static int port = 6379;
 
   @BeforeClass
-  public static void setUp() {
+  public static void setUp() throws IOException {
     CacheFactory cf = new CacheFactory();
     // cf.set("log-file", "redis.log");
     cf.set(LOG_LEVEL, "error");
diff --git a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetsIntegrationTest.java b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetsIntegrationTest.java
index 7d8da16..53422bc 100755
--- a/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetsIntegrationTest.java
+++ b/geode-redis/src/integrationTest/java/org/apache/geode/redis/SetsIntegrationTest.java
@@ -18,7 +18,6 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.catchThrowable;
 
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -734,91 +733,19 @@ public class SetsIntegrationTest {
   }
 
   @Test
-  public void testSRem_should_ReturnTheNumberOfElementsRemoved() {
-    String key = "key";
-    String field1 = "field1";
-    String field2 = "field2";
-    jedis.sadd(key, field1, field2);
-
-    Long removedElementsCount = jedis.srem(key, field1, field2);
-
-    assertThat(removedElementsCount).isEqualTo(2);
-  }
-
-  @Test
-  public void testSRem_should_RemoveSpecifiedElementsFromSet() {
-    String key = "key";
-    String field1 = "field1";
-    String field2 = "field2";
-    jedis.sadd(key, field1, field2);
-
-    jedis.srem(key, field2);
-
-    Set<String> membersInSet = jedis.smembers(key);
-    assertThat(membersInSet).doesNotContain(field2);
-  }
-
-  @Test
-  public void testSRem_should_ThrowError_givenOnlyKey() {
-    String key = "key";
-    String field1 = "field1";
-    String field2 = "field2";
-    jedis.sadd(key, field1, field2);
-
-    Throwable caughtException = catchThrowable(
-        () -> jedis.srem(key));
-
-    assertThat(caughtException).hasMessageContaining("wrong number of arguments");
-  }
-
-  @Test
-  public void testSRem_should_notRemoveMembersOfSetNotSpecified() {
-    String key = "key";
-    String field1 = "field1";
-    String field2 = "field2";
-    jedis.sadd(key, field1, field2);
-
-    jedis.srem(key, field1);
-
-    Set<String> membersInSet = jedis.smembers(key);
-    assertThat(membersInSet).containsExactly(field2);
-  }
-
-  @Test
-  public void testSRem_should_ignoreMembersNotInSpecifiedSet() {
-    String key = "key";
-    String field1 = "field1";
-    String field2 = "field2";
-    String unkownField = "random-guy";
-    jedis.sadd(key, field1, field2);
-
-    long result = jedis.srem(key, unkownField);
-
-    assertThat(result).isEqualTo(0);
-  }
-
-  @Test
-  public void testSRem_should_throwError_givenKeyThatIsNotASet() {
-    String key = "key";
-    String value = "value";
-    jedis.set(key, value);
-
-    Throwable caughtException = catchThrowable(
-        () -> jedis.srem(key, value));
+  public void testSRem() {
+    jedis.sadd("master", "field1", "field2");
 
-    assertThat(caughtException)
-        .hasMessageContaining(
-            "WRONGTYPE Operation against a key holding the wrong kind of value");
-  }
-
-  @Test
-  public void testSRem_shouldReturnZero_givenNonExistingKey() {
-    String key = "key";
-    String field = "field";
+    Long sremCount = jedis.srem("master", "field1", "field2", "unknown");
+    Set<String> sremSet = jedis.smembers("master");
+    assertThat(sremCount).isEqualTo(2);
+    assertThat(sremSet).isEmpty();
 
-    long result = jedis.srem(key, field);
+    sremCount = jedis.srem("master", "field1", "field2", "unknown");
+    assertThat(sremCount).isEqualTo(0);
 
-    assertThat(result).isEqualTo(0);
+    sremCount = jedis.srem("unknownkey", "field1");
+    assertThat(sremCount).isEqualTo(0);
   }
 
   @Test
diff --git a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/set/SetExecutorJUnitTest.java b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/set/SetExecutorJUnitTest.java
index 897aba5..d185afb 100644
--- a/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/set/SetExecutorJUnitTest.java
+++ b/geode-redis/src/test/java/org/apache/geode/redis/internal/executor/set/SetExecutorJUnitTest.java
@@ -349,26 +349,26 @@ public class SetExecutorJUnitTest {
   }
 
   @Test
-  public void verifyErrorMessage_WhenTooFewArgsPassedToSRem() {
-    Executor subject = new SRemExecutor();
+  public void verifyErrorMessageWhenWrongArgsPassedToSRem() {
+    Executor sRemExecutor = new SRemExecutor();
     List<byte[]> commandsAsBytes = new ArrayList<>();
     commandsAsBytes.add("SREM".getBytes());
-
-    ArgumentCaptor<ByteBuf> argsErrorCaptor =
-        ArgumentCaptor.forClass(ByteBuf.class);
+    ArgumentCaptor<ByteBuf> argsErrorCaptor = ArgumentCaptor.forClass(ByteBuf.class);
 
     when(context.getByteBufAllocator()).thenReturn(byteBuf);
-
     when(command.getProcessedCommand()).thenReturn(commandsAsBytes);
 
+    sRemExecutor.executeCommand(command, context);
+
     commandsAsBytes.add("key1".getBytes());
-    subject.executeCommand(command, context);
+    sRemExecutor.executeCommand(command, context);
 
-    verify(command).setResponse(argsErrorCaptor.capture());
+    verify(command, times(2)).setResponse(argsErrorCaptor.capture());
 
     List<ByteBuf> capturedErrors = argsErrorCaptor.getAllValues();
-
     assertThat(capturedErrors.get(0).toString(Charset.defaultCharset()))
         .startsWith("-ERR The wrong number of arguments or syntax was provided");
+    assertThat(capturedErrors.get(1).toString(Charset.defaultCharset()))
+        .startsWith("-ERR The wrong number of arguments or syntax was provided");
   }
 }