test_class.declarator: transcoder
test_class.modifier: private
test_class.original_string: private JsonTranscoder transcoder;
test_class.type: JsonTranscoder
test_class.var_name: transcoder
test_class.file: simple-spring-memcached/src/test/java/com/google/code/ssm/transcoders/JsonTranscoderTest.java
test_class.identifier: JsonTranscoderTest
test_case.body: @Test
      public void testEncodeAndDecodeWithCustomSerializer() {
          JsonObjectMapper mapper = new JsonObjectMapper();
  
          Map<Class<?>, JsonSerializer<?>> serializers = new HashMap<Class<?>, JsonSerializer<?>>();
          serializers.put(Point.class, new PointSerializer());
          mapper.setSerializers(serializers);
  
          transcoder = new JsonTranscoder(mapper);
  
          Point p = new Point(40, 50);
  
          // it won't be possible to deserialize it because no custom deserializer is registered and serialized data
          // doesn't contain info about class (type of serialized object), so the Jackson cannot figure out what
          // deserializer should be used
          CachedObject co = transcoder.encode(p);
          assertNotNull(co);
          assertNotNull(co.getData());
          assertEquals("{\"v\":\"40x50\"}", new String(co.getData()));
      }
test_case.class_method_signature: JsonTranscoderTest.testEncodeAndDecodeWithCustomSerializer()
test_case.full_signature: @Test public void testEncodeAndDecodeWithCustomSerializer()
test_case.identifier: testEncodeAndDecodeWithCustomSerializer
test_case.invocations: put setSerializers encode assertNotNull assertNotNull getData assertEquals getData
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEncodeAndDecodeWithCustomSerializer()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(JsonTranscoder.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(JsonTranscoder.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: JSON_SERIALIZED = 8
focal_class.modifier: private static final
focal_class.original_string: private static final int JSON_SERIALIZED = 8;
focal_class.type: int
focal_class.var_name: JSON_SERIALIZED
focal_class.declarator: mapper
focal_class.modifier: @Getter
      private final
focal_class.original_string: @Getter
      private final ObjectMapper mapper;
focal_class.type: ObjectMapper
focal_class.var_name: mapper
focal_class.file: simple-spring-memcached/src/main/java/com/google/code/ssm/transcoders/JsonTranscoder.java
focal_class.identifier: JsonTranscoder
focal_class.interfaces: implements CacheTranscoder
focal_class.class_method_signature: JsonTranscoder.JsonTranscoder(final ObjectMapper mapper)
focal_class.full_signature: public  JsonTranscoder(final ObjectMapper mapper)
focal_class.identifier: JsonTranscoder
focal_class.modifiers: public
focal_class.parameters: (final ObjectMapper mapper)
focal_class.signature:  JsonTranscoder(final ObjectMapper mapper)
focal_class.class_method_signature: JsonTranscoder.asyncDecode(final CachedObject data)
focal_class.full_signature: public boolean asyncDecode(final CachedObject data)
focal_class.identifier: asyncDecode
focal_class.modifiers: public
focal_class.parameters: (final CachedObject data)
focal_class.return: boolean
focal_class.signature: boolean asyncDecode(final CachedObject data)
focal_class.class_method_signature: JsonTranscoder.decode(final CachedObject data)
focal_class.full_signature: @Override public Object decode(final CachedObject data)
focal_class.identifier: decode
focal_class.modifiers: @Override public
focal_class.parameters: (final CachedObject data)
focal_class.return: Object
focal_class.signature: Object decode(final CachedObject data)
focal_class.class_method_signature: JsonTranscoder.encode(final Object o)
focal_class.full_signature: @Override public CachedObject encode(final Object o)
focal_class.identifier: encode
focal_class.modifiers: @Override public
focal_class.parameters: (final Object o)
focal_class.return: CachedObject
focal_class.signature: CachedObject encode(final Object o)
focal_class.class_method_signature: JsonTranscoder.getMaxSize()
focal_class.full_signature: public int getMaxSize()
focal_class.identifier: getMaxSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMaxSize()
focal_method.body: @Override
      public CachedObject encode(final Object o) {
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
  
          try {
              mapper.writeValue(baos, new Holder(o));
              return new CachedObjectImpl(JSON_SERIALIZED, baos.toByteArray());
          } catch (IOException e) {
              LOGGER.warn(String.format("Error serializing object %s", o), e);
              throw new RuntimeException(e);
          } finally {
              try {
                  baos.close();
              } catch (IOException e) {
                  LOGGER.warn("Error while closing stream", e);
              }
          }
      }
focal_method.class_method_signature: JsonTranscoder.encode(final Object o)
focal_method.full_signature: @Override public CachedObject encode(final Object o)
focal_method.identifier: encode
focal_method.invocations: writeValue toByteArray warn format close warn
focal_method.modifiers: @Override public
focal_method.parameters: (final Object o)
focal_method.return: CachedObject
focal_method.signature: CachedObject encode(final Object o)