Package net.rubyeye.xmemcached.transcoders

Examples of net.rubyeye.xmemcached.transcoders.CachedData


  public void testDecodeManayTimes() {
    Person p = new Person();
    p.name = "xmc";
    p.age = 1;
    CachedData cachedData = tokyoTyrantTranscoder.encode(p);
    Person decodePerson = (Person) tokyoTyrantTranscoder.decode(cachedData);
    assertNotSame(p, decodePerson);
    assertEquals(p, decodePerson);
   
    Person decodePerson2 = (Person) tokyoTyrantTranscoder.decode(cachedData);
View Full Code Here


  }

  public void testEncodeDecode() {
    // simple type
    CachedData cachedData = tokyoTyrantTranscoder.encode(1);
    assertEquals(8, cachedData.getData().length);
    assertEquals(1, tokyoTyrantTranscoder.decode(cachedData));

    long currentTimeMillis = System.currentTimeMillis();
    cachedData = tokyoTyrantTranscoder.encode(currentTimeMillis);
    assertEquals(12, cachedData.getData().length);
    assertEquals(currentTimeMillis, tokyoTyrantTranscoder
        .decode(cachedData));

    cachedData = tokyoTyrantTranscoder.encode("hello");
    assertEquals(9, cachedData.getData().length);
    assertEquals("hello", tokyoTyrantTranscoder.decode(cachedData));

    cachedData = tokyoTyrantTranscoder.encode(2.3d);
    assertEquals(12, cachedData.getData().length);
    assertEquals(2.3d, tokyoTyrantTranscoder.decode(cachedData));

    // collection
    List<String> list = new ArrayList<String>();
    list.add("1");
    cachedData = tokyoTyrantTranscoder.encode(list);
    int oldLength = cachedData.getData().length;
    List<String> decodedList = (List) tokyoTyrantTranscoder
        .decode(cachedData);
    assertEquals(1, decodedList.size());
    assertTrue(decodedList.contains("1"));
View Full Code Here

public class NullTranscoder extends PrimitiveTypeTranscoder<byte[]> {
  private static final int flags = 0;

  public CachedData encode(byte[] bs) {
    return new CachedData(flags, bs);
  }
View Full Code Here

TOP

Related Classes of net.rubyeye.xmemcached.transcoders.CachedData

Copyright © 2018 www.massapicom. 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.