public static void test22() {
    byte[] b = new byte[10];
    for (int i = 0; i < 10; i++) b[i] = (byte) i;

    mc.set("foo", b);
    assert Arrays.equals((byte[]) mc.get("foo"), b);
  }
 public static void test11() {
   mc.set("foo", new Integer(100), new Date(System.currentTimeMillis()));
   try {
     Thread.sleep(1000);
   } catch (Exception ex) {
   }
   assert mc.get("foo") == null;
 }
  public static void test15() {

    Map stats = mc.statsItems();
    assert stats != null;

    stats = mc.statsSlabs();
    assert stats != null;
  }
 public static void test12() {
   long i = 0;
   mc.storeCounter("foo", i);
   mc.incr("foo"); // foo now == 1
   mc.incr("foo", (long) 5); // foo now == 6
   long j = mc.decr("foo", (long) 2); // foo now == 4
   assert j == 4;
   assert j == mc.getCounter("foo");
 }
  public static void test19() {
    int max = 100;
    String[] keys = new String[max];
    for (int i = 0; i < max; i++) {
      keys[i] = Integer.toString(i);
      mc.set(keys[i], "value" + i);
    }

    Map<String, Object> results = mc.getMulti(keys);
    for (int i = 0; i < max; i++) {
      assert results.get(keys[i]).equals("value" + i);
    }
  }
  public static void test24() {

    String[] allKeys = {"key1", "key2", "key3", "key4", "key5", "key6", "key7"};
    String[] setKeys = {"key1", "key3", "key5", "key7"};

    for (String key : setKeys) {
      mc.set(key, key);
    }

    Map<String, Object> results = mc.getMulti(allKeys);

    assert allKeys.length == results.size();
    for (String key : setKeys) {
      String val = (String) results.get(key);
      assert key.equals(val);
    }
  }
  public static void test20(int max, int skip, int start) {
    int numEntries = max / skip + 1;
    String[] keys = new String[numEntries];
    byte[][] vals = new byte[numEntries][];

    int size = start;
    for (int i = 0; i < numEntries; i++) {
      keys[i] = Integer.toString(size);
      vals[i] = new byte[size + 1];
      for (int j = 0; j < size + 1; j++) vals[i][j] = (byte) j;

      mc.set(keys[i], vals[i]);
      size += skip;
    }

    Map<String, Object> results = mc.getMulti(keys);
    for (int i = 0; i < numEntries; i++)
      assert Arrays.equals((byte[]) results.get(keys[i]), vals[i]);
  }
  public static void test14() {
    assert !mc.keyExists("foobar123");
    mc.set("foobar123", new Integer(100000));
    assert mc.keyExists("foobar123");

    assert !mc.keyExists("counterTest123");
    mc.storeCounter("counterTest123", 0);
    assert mc.keyExists("counterTest123");
  }
  public static void runAlTests(MemcachedClient mc) {
    test14();
    for (int t = 0; t < 2; t++) {
      mc.setCompressEnable((t & 1) == 1);

      test1();
      test2();
      test3();
      test4();
      test5();
      test6();
      test7();
      test8();
      test9();
      test10();
      test11();
      test12();
      test13();
      test15();
      test16();
      test17();
      test21();
      test22();
      test23();
      test24();

      for (int i = 0; i < 3; i++) test19();

      test20(8191, 1, 0);
      test20(8192, 1, 0);
      test20(8193, 1, 0);

      test20(16384, 100, 0);
      test20(17000, 128, 0);

      test20(128 * 1024, 1023, 0);
      test20(128 * 1024, 1023, 1);
      test20(128 * 1024, 1024, 0);
      test20(128 * 1024, 1024, 1);

      test20(128 * 1024, 1023, 0);
      test20(128 * 1024, 1023, 1);
      test20(128 * 1024, 1024, 0);
      test20(128 * 1024, 1024, 1);

      test20(900 * 1024, 32 * 1024, 0);
      test20(900 * 1024, 32 * 1024, 1);
    }
  }
  public static void test18() {
    long i = 0;
    mc.addOrIncr("foo"); // foo now == 0
    mc.incr("foo"); // foo now == 1
    mc.incr("foo", (long) 5); // foo now == 6

    mc.addOrIncr("foo"); // foo now 7

    long j = mc.decr("foo", (long) 3); // foo now == 4
    assert j == 4;
    assert j == mc.getCounter("foo");
  }
 public static void test10() {
   mc.set("foo", new Float(1.1f));
   Float o = (Float) mc.get("foo");
   assert o.floatValue() == 1.1f;
 }
 public static void test9() {
   mc.set("foo", new Double(1.1));
   Double o = (Double) mc.get("foo");
   assert o.doubleValue() == 1.1;
 }
 public static void test8() {
   mc.set("foo", new Long(Long.MAX_VALUE));
   Long o = (Long) mc.get("foo");
   assert o.longValue() == Long.MAX_VALUE;
 }
 public static void test7() {
   mc.set("foo", new Short((short) 100));
   Short o = (Short) mc.get("foo");
   assert o.shortValue() == 100;
 }
 public static void test6() {
   mc.set("foo", new StringBuffer("hello"));
   StringBuffer o = (StringBuffer) mc.get("foo");
   assert o.toString().equals("hello");
 }
 public static void test5() {
   mc.set("foo", new Byte((byte) 127));
   Byte b = (Byte) mc.get("foo");
   assert b.byteValue() == 127;
 }
 public static void test4() {
   mc.set("foo", new Character('z'));
   Character c = (Character) mc.get("foo");
   assert c.charValue() == 'z';
 }
 public static void test3() {
   String input = "test of string encoding";
   mc.set("foo", input);
   String s = (String) mc.get("foo");
   assert s.equals(input);
 }
 public static void test2() {
   mc.set("foo", new Integer(Integer.MAX_VALUE));
   Integer i = (Integer) mc.get("foo");
   assert i.intValue() == Integer.MAX_VALUE;
 }
 public static void test16() {
   assert !mc.set("foo", null);
 }
 public static void test23() {
   TestClass tc = new TestClass("foo", "bar", new Integer(32));
   mc.set("foo", tc);
   assert tc.equals((TestClass) mc.get("foo"));
 }
 public static void test1() {
   mc.set("foo", Boolean.TRUE);
   Boolean b = (Boolean) mc.get("foo");
   assert b.booleanValue();
 }
 public static void test13() {
   Date d1 = new Date();
   mc.set("foo", d1);
   Date d2 = (Date) mc.get("foo");
   assert d1.equals(d2);
 }