sabbey37 commented on a change in pull request #6447:
URL: https://github.com/apache/geode/pull/6447#discussion_r629403702
##########
File path:
geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractKeysIntegrationTest.java
##########
@@ -54,68 +55,71 @@ public void errors_givenWrongNumberOfArguments() {
@Test
public void givenSplat_withASCIIdata_returnsExpectedMatches() {
- jedis.set("string1", "v1");
- jedis.sadd("set1", "member1");
- jedis.hset("hash1", "key1", "field1");
- assertThat(jedis.keys("*")).containsExactlyInAnyOrder("string1", "set1",
"hash1");
- assertThat(jedis.keys("s*")).containsExactlyInAnyOrder("string1", "set1");
- assertThat(jedis.keys("h*")).containsExactlyInAnyOrder("hash1");
- assertThat(jedis.keys("foo*")).isEmpty();
+ jedis.set("{K}string1", "v1");
+ jedis.sadd("{K}set1", "member1");
+ jedis.hset("{K}hash1", "key1", "field1");
+ assertThat(jedis.keys("{K}*")).containsExactlyInAnyOrder("{K}string1",
"{K}set1", "{K}hash1");
+ assertThat(jedis.keys("{K}s*")).containsExactlyInAnyOrder("{K}string1",
"{K}set1");
+ assertThat(jedis.keys("{K}h*")).containsExactlyInAnyOrder("{K}hash1");
+ assertThat(jedis.keys("{K}foo*")).isEmpty();
}
@Test
public void givenSplat_withBinaryData_returnsExpectedMatches() {
byte[] stringKey =
- new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', 't', 'r', 'i',
'n', 'g', '1'};
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's',
't', 'r', 'i', 'n', 'g',
+ '1'};
byte[] value = new byte[] {'v', '1'};
jedis.set(stringKey, value);
- byte[] setKey = new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's',
'e', 't', '1'};
+ byte[] setKey =
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's',
'e', 't', '1'};
byte[] member = new byte[] {'m', '1'};
jedis.sadd(setKey, member);
- byte[] hashKey = new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 'h',
'a', 's', 'h', '1'};
- byte[] key = new byte[] {'k', 'e', 'y', '1'};
+ byte[] hashKey =
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 'h',
'a', 's', 'h', '1'};
+ byte[] key = new byte[] {'{', 1, '}', 'k', 'e', 'y', '1'};
jedis.hset(hashKey, key, value);
assertThat(jedis.exists(stringKey));
assertThat(jedis.exists(setKey));
assertThat(jedis.exists(hashKey));
Review comment:
Unrelated to your PR, but it looks like these `assertThat` lines (lines
82-84) don't verify anything at the moment. We need to add an `isTrue()` to
all of them. You don't have to fix this as part of this PR though.
##########
File path:
geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/key/AbstractKeysIntegrationTest.java
##########
@@ -54,68 +55,71 @@ public void errors_givenWrongNumberOfArguments() {
@Test
public void givenSplat_withASCIIdata_returnsExpectedMatches() {
- jedis.set("string1", "v1");
- jedis.sadd("set1", "member1");
- jedis.hset("hash1", "key1", "field1");
- assertThat(jedis.keys("*")).containsExactlyInAnyOrder("string1", "set1",
"hash1");
- assertThat(jedis.keys("s*")).containsExactlyInAnyOrder("string1", "set1");
- assertThat(jedis.keys("h*")).containsExactlyInAnyOrder("hash1");
- assertThat(jedis.keys("foo*")).isEmpty();
+ jedis.set("{K}string1", "v1");
+ jedis.sadd("{K}set1", "member1");
+ jedis.hset("{K}hash1", "key1", "field1");
+ assertThat(jedis.keys("{K}*")).containsExactlyInAnyOrder("{K}string1",
"{K}set1", "{K}hash1");
+ assertThat(jedis.keys("{K}s*")).containsExactlyInAnyOrder("{K}string1",
"{K}set1");
+ assertThat(jedis.keys("{K}h*")).containsExactlyInAnyOrder("{K}hash1");
+ assertThat(jedis.keys("{K}foo*")).isEmpty();
}
@Test
public void givenSplat_withBinaryData_returnsExpectedMatches() {
byte[] stringKey =
- new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's', 't', 'r', 'i',
'n', 'g', '1'};
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's',
't', 'r', 'i', 'n', 'g',
+ '1'};
byte[] value = new byte[] {'v', '1'};
jedis.set(stringKey, value);
- byte[] setKey = new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's',
'e', 't', '1'};
+ byte[] setKey =
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 's',
'e', 't', '1'};
byte[] member = new byte[] {'m', '1'};
jedis.sadd(setKey, member);
- byte[] hashKey = new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 'h',
'a', 's', 'h', '1'};
- byte[] key = new byte[] {'k', 'e', 'y', '1'};
+ byte[] hashKey =
+ new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed, 0, 4, 0, 5, 'h',
'a', 's', 'h', '1'};
+ byte[] key = new byte[] {'{', 1, '}', 'k', 'e', 'y', '1'};
jedis.hset(hashKey, key, value);
assertThat(jedis.exists(stringKey));
assertThat(jedis.exists(setKey));
assertThat(jedis.exists(hashKey));
- assertThat(jedis.keys(new byte[]
{'*'})).containsExactlyInAnyOrder(stringKey, setKey, hashKey);
- assertThat(jedis.keys(new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5,
's', '*'}))
+ assertThat(jedis.keys(new byte[] {'{', 1, '}',
'*'})).containsExactlyInAnyOrder(stringKey,
+ setKey, hashKey);
+ assertThat(jedis.keys(new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed,
0, 4, 0, 5, 's', '*'}))
.containsExactlyInAnyOrder(stringKey, setKey);
- assertThat(jedis.keys(new byte[] {(byte) 0xac, (byte) 0xed, 0, 4, 0, 5,
'h', '*'}))
+ assertThat(jedis.keys(new byte[] {'{', 1, '}', (byte) 0xac, (byte) 0xed,
0, 4, 0, 5, 'h', '*'}))
.containsExactlyInAnyOrder(hashKey);
- assertThat(jedis.keys(new byte[] {'f', '*'})).isEmpty();
+ assertThat(jedis.keys(new byte[] {'{', 1, '}', 'f', '*'})).isEmpty();
}
@Test
- public void givenBinaryValue_withExactMatch_preservesBinaryData()
- throws UnsupportedEncodingException {
- String chinese_utf16 = "子";
- byte[] utf16encodedBytes = chinese_utf16.getBytes("UTF-16");
+ public void givenBinaryValue_withExactMatch_preservesBinaryData() {
+ String chineseHashTag = "{子}";
+ byte[] utf8encodedBytes = chineseHashTag.getBytes(StandardCharsets.UTF_8);
Review comment:
I noticed this was switched to `UTF-8` from `UTF-16`. Do we need to add
an additional test for UTF_16?
--
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:
[email protected]