sabbey37 commented on a change in pull request #6493:
URL: https://github.com/apache/geode/pull/6493#discussion_r635275338



##########
File path: 
geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/pubsub/AbstractSubCommandsIntegrationTest.java
##########
@@ -0,0 +1,156 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ *
+ */
+
+package org.apache.geode.redis.internal.executor.pubsub;
+
+import static 
org.apache.geode.redis.RedisCommandArgumentsTestHelper.assertAtLeastNArgs;
+import static 
org.apache.geode.redis.internal.executor.pubsub.SubCommandExecutor.UNKNOWN_SUBCOMMAND_ERROR_BASE;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Protocol;
+
+import org.apache.geode.redis.RedisIntegrationTest;
+import org.apache.geode.redis.mocks.MockSubscriber;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+
+public abstract class AbstractSubCommandsIntegrationTest implements 
RedisIntegrationTest {
+  private Jedis subscriber;
+  private Jedis introspector;
+  private MockSubscriber mockSubscriber;
+
+  @Before
+  public void setup() {
+    mockSubscriber = new MockSubscriber();
+    subscriber = new Jedis("localhost", getPort());
+    introspector = new Jedis("localhost", getPort());
+  }
+
+  @After
+  public void teardown() {
+    if (mockSubscriber.getSubscribedChannels() > 0) {
+      mockSubscriber.unsubscribe();
+    }
+    waitFor(() -> mockSubscriber.getSubscribedChannels() == 0);

Review comment:
       Since this is generic, we should also check for pattern subscriptions 
and `punsubscribe` if needed.  I wonder if we should also wait for the 
subscriberThread to no longer be alive....
   
   ```
   waitFor(() -> !subscriberThread.isAlive());
   ```

##########
File path: 
geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/pubsub/AbstractSubCommandsIntegrationTest.java
##########
@@ -0,0 +1,156 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ *
+ */
+
+package org.apache.geode.redis.internal.executor.pubsub;
+
+import static 
org.apache.geode.redis.RedisCommandArgumentsTestHelper.assertAtLeastNArgs;
+import static 
org.apache.geode.redis.internal.executor.pubsub.SubCommandExecutor.UNKNOWN_SUBCOMMAND_ERROR_BASE;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Protocol;
+
+import org.apache.geode.redis.RedisIntegrationTest;
+import org.apache.geode.redis.mocks.MockSubscriber;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+
+public abstract class AbstractSubCommandsIntegrationTest implements 
RedisIntegrationTest {
+  private Jedis subscriber;
+  private Jedis introspector;
+  private MockSubscriber mockSubscriber;
+
+  @Before
+  public void setup() {
+    mockSubscriber = new MockSubscriber();
+    subscriber = new Jedis("localhost", getPort());
+    introspector = new Jedis("localhost", getPort());
+  }
+
+  @After
+  public void teardown() {
+    if (mockSubscriber.getSubscribedChannels() > 0) {
+      mockSubscriber.unsubscribe();
+    }
+    waitFor(() -> mockSubscriber.getSubscribedChannels() == 0);
+  }
+
+  @Test
+  public void Pubsub_shouldError_givenTooFewArguments() {
+    assertAtLeastNArgs(introspector, Protocol.Command.PUBSUB, 1);
+  }

Review comment:
       We should also add a test for too many arguments for `PUBSUB CHANNELS`.  
It looks like `CHANNELS` only accepts one argument.

##########
File path: 
geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/pubsub/AbstractSubCommandsIntegrationTest.java
##########
@@ -0,0 +1,156 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ *
+ */
+
+package org.apache.geode.redis.internal.executor.pubsub;
+
+import static 
org.apache.geode.redis.RedisCommandArgumentsTestHelper.assertAtLeastNArgs;
+import static 
org.apache.geode.redis.internal.executor.pubsub.SubCommandExecutor.UNKNOWN_SUBCOMMAND_ERROR_BASE;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Protocol;
+
+import org.apache.geode.redis.RedisIntegrationTest;
+import org.apache.geode.redis.mocks.MockSubscriber;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
+
+public abstract class AbstractSubCommandsIntegrationTest implements 
RedisIntegrationTest {
+  private Jedis subscriber;
+  private Jedis introspector;
+  private MockSubscriber mockSubscriber;
+
+  @Before
+  public void setup() {
+    mockSubscriber = new MockSubscriber();
+    subscriber = new Jedis("localhost", getPort());
+    introspector = new Jedis("localhost", getPort());
+  }
+
+  @After
+  public void teardown() {
+    if (mockSubscriber.getSubscribedChannels() > 0) {
+      mockSubscriber.unsubscribe();
+    }
+    waitFor(() -> mockSubscriber.getSubscribedChannels() == 0);
+  }
+
+  @Test
+  public void Pubsub_shouldError_givenTooFewArguments() {
+    assertAtLeastNArgs(introspector, Protocol.Command.PUBSUB, 1);
+  }
+
+  @Test
+  @SuppressWarnings("unchecked")

Review comment:
       We don't need this `SuppressWarnings`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to