-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bunch of missing commands and a test to check if Jedis is updated
- Loading branch information
Jonathan Leibiusky
committed
Sep 14, 2010
1 parent
9b202c3
commit a8ffacd
Showing
7 changed files
with
179 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/test/java/redis/clients/jedis/tests/JedisNewCommandsCheckTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package redis.clients.jedis.tests; | ||
|
||
import java.io.BufferedInputStream; | ||
import java.io.DataInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.lang.reflect.Method; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import redis.clients.jedis.Jedis; | ||
import redis.clients.jedis.JedisPubSub; | ||
import redis.clients.jedis.Transaction; | ||
|
||
public class JedisNewCommandsCheckTest extends Assert { | ||
@Test | ||
@Ignore(value = "Ignored because still missing information for DEBUG and LINSERT commands") | ||
public void checkJedisIsUpdated() throws IOException { | ||
String[] commands = getAvailableCommands(); | ||
Set<String> implementedCommands = getImplementedCommands(); | ||
|
||
Set<String> missingCommands = new HashSet<String>(); | ||
for (String command : commands) { | ||
if (!implementedCommands.contains(command.trim())) { | ||
missingCommands.add(command); | ||
} | ||
} | ||
|
||
if (!missingCommands.isEmpty()) { | ||
fail("There are missing commands: " + missingCommands.toString()); | ||
} | ||
} | ||
|
||
private Set<String> getImplementedCommands() { | ||
Method[] methods = Jedis.class.getDeclaredMethods(); | ||
Set<String> implementedCommands = new HashSet<String>(); | ||
for (Method method : methods) { | ||
implementedCommands.add(method.getName().trim().toLowerCase()); | ||
} | ||
|
||
methods = JedisPubSub.class.getDeclaredMethods(); | ||
for (Method method : methods) { | ||
implementedCommands.add(method.getName().trim().toLowerCase()); | ||
} | ||
|
||
methods = Transaction.class.getDeclaredMethods(); | ||
for (Method method : methods) { | ||
implementedCommands.add(method.getName().trim().toLowerCase()); | ||
} | ||
implementedCommands.add("config"); | ||
return implementedCommands; | ||
} | ||
|
||
private String[] getAvailableCommands() throws MalformedURLException, | ||
IOException { | ||
URL url = new URL("http://dimaion.com/redis/master"); | ||
InputStream openStream = url.openStream(); | ||
DataInputStream dis = new DataInputStream(new BufferedInputStream( | ||
openStream)); | ||
byte[] all = new byte[dis.available()]; | ||
dis.readFully(all); | ||
String commandList = new String(all); | ||
String[] commands = commandList.split("\n"); | ||
return commands; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters