Examples of CachedData


Examples of net.rubyeye.xmemcached.transcoders.CachedData

  }

  public void testCompressedObject() throws Exception {
    tc.setCompressionThreshold(8);
    Calendar c = Calendar.getInstance();
    CachedData cd = tc.encode(c);
    assertEquals(SerializingTranscoder.SERIALIZED
        | SerializingTranscoder.COMPRESSED, cd.getFlag());
    assertEquals(c, tc.decode(cd));
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

  public void testCompressedObjectDecompressZipMode() throws Exception {
    tc.setCompressionThreshold(8);
    tc.setCompressionMode(CompressionMode.ZIP);
    Calendar c = Calendar.getInstance();
    CachedData cd = tc.encode(c);
    assertEquals(SerializingTranscoder.SERIALIZED
        | SerializingTranscoder.COMPRESSED, cd.getFlag());
    assertEquals(c, tc.decode(cd));
    tc.setCompressionMode(CompressionMode.GZIP);
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

    tc.setCompressionMode(CompressionMode.GZIP);
  }

  public void testUnencodeable() throws Exception {
    try {
      CachedData cd = tc.encode(new Object());
      fail("Should fail to serialize, got" + cd);
    } catch (IllegalArgumentException e) {
      // pass
    }
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

      // pass
    }
  }

  public void testUndecodeable() throws Exception {
    CachedData cd = new CachedData(
        Integer.MAX_VALUE
            & ~(SerializingTranscoder.COMPRESSED | SerializingTranscoder.SERIALIZED),
        tu.encodeInt(Integer.MAX_VALUE), tc.getMaxSize(), -1);
    assertNull(tc.decode(cd));
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

        tu.encodeInt(Integer.MAX_VALUE), tc.getMaxSize(), -1);
    assertNull(tc.decode(cd));
  }

  public void testUndecodeableSerialized() throws Exception {
    CachedData cd = new CachedData(SerializingTranscoder.SERIALIZED,
        tu.encodeInt(Integer.MAX_VALUE), tc.getMaxSize(), -1);
    assertNull(tc.decode(cd));
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

        tu.encodeInt(Integer.MAX_VALUE), tc.getMaxSize(), -1);
    assertNull(tc.decode(cd));
  }

  public void testUndecodeableCompressed() throws Exception {
    CachedData cd = new CachedData(SerializingTranscoder.COMPRESSED,
        tu.encodeInt(Integer.MAX_VALUE), tc.getMaxSize(), -1);
    System.out.println("got " + tc.decode(cd));
    assertNull(tc.decode(cd));
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

    Assert.assertEquals(this.map, decodeAndGet(this.map,
        this.whalinTranscoder));
  }

  private Object decodeAndGet(Object obj, Transcoder transcoder) {
    CachedData data = transcoder.encode(obj);
    Object decodeString = transcoder.decode(data);
    return decodeString;
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

    Object decodeString = transcoder.decode(data);
    return decodeString;
  }

  private String encodeAndGet(Object obj, Transcoder transcoder) {
    CachedData data = encode(obj, transcoder);
    String encodeString = new String(data.getData());
    return encodeString;
  }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

        decodeError();
      } else {
        this.countDownLatch();
      }
    } else {
      CachedData value = this.returnValues.values().iterator().next();
      // If disable save primitive type as string,the response data have
      // 4-bytes flag aheader.
      if (!this.transcoder.isPrimitiveAsString()) {
        byte[] data = value.getData();
        if (data.length >= 4) {
          byte[] flagBytes = new byte[4];
          System.arraycopy(data, 0, flagBytes, 0, 4);
          byte[] realData = new byte[data.length - 4];
          System.arraycopy(data, 4, realData, 0, data.length - 4);
          int flag = transcoderUtils.decodeInt(flagBytes);
          value.setFlag(flag);
          value.setData(realData);
          value.setCapacity(realData.length);
        }
      }
      setResult(value);
      this.countDownLatch();
    }
View Full Code Here

Examples of net.rubyeye.xmemcached.transcoders.CachedData

    String encodeString = new String(data.getData());
    return encodeString;
  }

  private CachedData encode(Object str, Transcoder transcoder) {
    CachedData data = transcoder.encode(str);
    return data;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.