Package net.rubyeye.xmemcached.transcoders

Examples of net.rubyeye.xmemcached.transcoders.CachedData


  public void testCompressedStringNotSmaller() throws Exception {
    String s1="This is a test simple string that will not be compressed.";
    // Reduce the compression threshold so it'll attempt to compress it.
    tc.setCompressionThreshold(8);
    CachedData cd=tc.encode(s1);
    // This should *not* be compressed because it is too small
    assertEquals(WhalinTranscoder.SPECIAL_STRING, cd.getFlag());
    assertTrue(Arrays.equals(s1.getBytes(), cd.getData()));
    assertEquals(s1, tc.decode(cd));
  }
View Full Code Here


  public void testCompressedString() throws Exception {
    // This one will actually compress
    String s1="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    tc.setCompressionThreshold(8);
    CachedData cd=tc.encode(s1);
    assertEquals(
      WhalinTranscoder.COMPRESSED | WhalinTranscoder.SPECIAL_STRING,
      cd.getFlag());
    assertFalse(Arrays.equals(s1.getBytes(), cd.getData()));
    assertEquals(s1, tc.decode(cd));
  }
View Full Code Here

    assertEquals(s1, tc.decode(cd));
  }

  public void testObject() throws Exception {
    Calendar c=Calendar.getInstance();
    CachedData cd=tc.encode(c);
    assertEquals(WhalinTranscoder.SERIALIZED, cd.getFlag());
    assertEquals(c, tc.decode(cd));
  }
View Full Code Here

  }

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

    assertEquals(c, tc.decode(cd));
  }

  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

      // pass
    }
  }

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

        tc.getMaxSize(),-1);
    assertNull(tc.decode(cd));
  }

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

        tc.getMaxSize(),-1);
    assertNull(tc.decode(cd));
  }

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

  public void testLong() throws Exception {
    assertEquals(923, tc.decode(tc.encode(923L)).longValue());
  }

  public void testBadFlags() throws Exception {
    CachedData cd=tc.encode(9284L);
    assertNull(tc.decode(new CachedData(cd.getFlag()+1, cd.getData(),
        CachedData.MAX_SIZE,-1)));
  }
View Full Code Here

  public void testEncodeDecodeLargeValue(){
    List<Long> list=new ArrayList<Long>(1000000);
    for(long i=0;i<1000000;i++){
      list.add(i);
    }
    CachedData cachedData = tokyoTyrantTranscoder.encode(list);
    List<Long> decodeList = (List<Long>) tokyoTyrantTranscoder.decode(cachedData);
    assertNotSame(list, decodeList);
    assertEquals(list, decodeList);
   
    List<Long> decodeList2 = (List<Long>) tokyoTyrantTranscoder.decode(cachedData);
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.