From 72dfdfb1d9f77d0aa6bf10320d09cc67e7ac9d25 Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 10 Feb 2017 00:27:41 +0800 Subject: [PATCH] 2.0.0 release --- .../replicator/UnsupportOperationTest.java | 188 ++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 src/test/java/com/moilioncircle/redis/replicator/UnsupportOperationTest.java diff --git a/src/test/java/com/moilioncircle/redis/replicator/UnsupportOperationTest.java b/src/test/java/com/moilioncircle/redis/replicator/UnsupportOperationTest.java new file mode 100644 index 00000000..e1ae6bba --- /dev/null +++ b/src/test/java/com/moilioncircle/redis/replicator/UnsupportOperationTest.java @@ -0,0 +1,188 @@ +package com.moilioncircle.redis.replicator; + +import com.moilioncircle.redis.replicator.cmd.Command; +import com.moilioncircle.redis.replicator.cmd.CommandListener; +import com.moilioncircle.redis.replicator.cmd.CommandName; +import com.moilioncircle.redis.replicator.cmd.CommandParser; +import com.moilioncircle.redis.replicator.io.RedisInputStream; +import com.moilioncircle.redis.replicator.rdb.AuxFieldListener; +import com.moilioncircle.redis.replicator.rdb.RdbListener; +import com.moilioncircle.redis.replicator.rdb.datatype.AuxField; +import com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair; +import com.moilioncircle.redis.replicator.rdb.datatype.Module; +import com.moilioncircle.redis.replicator.rdb.module.ModuleParser; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.fail; + +/** + * Created by leon on 2/10/17. + */ +public class UnsupportOperationTest { + + @Test + public void testRdb() throws IOException { + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("dumpV7.rdb"), FileType.RDB, + Configuration.defaultSetting()); + replicator.addCommandListener(new CommandListener() { + @Override + public void handle(Replicator replicator, Command command) { + } + }); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("dumpV7.rdb"), FileType.RDB, + Configuration.defaultSetting()); + replicator.removeCommandListener(new CommandListener() { + @Override + public void handle(Replicator replicator, Command command) { + } + }); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("dumpV7.rdb"), FileType.RDB, + Configuration.defaultSetting()); + replicator.getCommandParser(CommandName.name("PING")); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("dumpV7.rdb"), FileType.RDB, + Configuration.defaultSetting()); + replicator.addCommandParser(CommandName.name("PING"), new CommandParser() { + @Override + public Command parse(Object[] command) { + return null; + } + }); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("dumpV7.rdb"), FileType.RDB, + Configuration.defaultSetting()); + replicator.removeCommandParser(CommandName.name("PING")); + replicator.open(); + fail(); + } catch (Exception e) { + } + } + + @Test + public void testAof() throws IOException { + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("dumpV7.rdb"), FileType.AOF, + Configuration.defaultSetting()); + replicator.addRdbListener(new RdbListener.Adaptor() { + @Override + public void handle(Replicator replicator, KeyValuePair kv) { + + } + }); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("appendonly1.aof"), FileType.AOF, + Configuration.defaultSetting()); + replicator.removeRdbListener(new RdbListener.Adaptor() { + @Override + public void handle(Replicator replicator, KeyValuePair kv) { + + } + }); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("appendonly1.aof"), FileType.AOF, + Configuration.defaultSetting()); + replicator.getModuleParser("hellotype", 0); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("appendonly1.aof"), FileType.AOF, + Configuration.defaultSetting()); + replicator.addModuleParser("hellotype", 0, new ModuleParser() { + @Override + public Module parse(RedisInputStream in) throws IOException { + return null; + } + }); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("appendonly1.aof"), FileType.AOF, + Configuration.defaultSetting()); + replicator.removeModuleParser("hellotype", 0); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("appendonly1.aof"), FileType.AOF, + Configuration.defaultSetting()); + replicator.addAuxFieldListener(new AuxFieldListener() { + @Override + public void handle(Replicator replicator, AuxField auxField) { + + } + }); + replicator.open(); + fail(); + } catch (Exception e) { + } + + try { + Replicator replicator = new RedisReplicator( + RedisSocketReplicatorTest.class.getClassLoader().getResourceAsStream("appendonly1.aof"), FileType.AOF, + Configuration.defaultSetting()); + replicator.removeAuxFieldListener(new AuxFieldListener() { + @Override + public void handle(Replicator replicator, AuxField auxField) { + + } + }); + replicator.open(); + fail(); + } catch (Exception e) { + } + } +}