Examples of ObjectMapper


Examples of org.codehaus.jackson.map.ObjectMapper

    private ChainedResolver _resolver;

    protected MemoryConfigurationEntryStore(Map<String, String> configProperties)
    {
        _objectMapper = new ObjectMapper();
        _objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
        _objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
        _entries = new HashMap<UUID, ConfigurationEntry>();
        _brokerChildrenRelationshipMap = buildRelationshipClassMap();
        _resolver = new Strings.ChainedResolver(Strings.SYSTEM_RESOLVER,
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

    /**
     * Abstracted out for easier testing.
     */
    @SuppressWarnings("deprecation")
    protected ObjectMapper createObjectMapper() {
        ObjectMapper m = new ObjectMapper();
        m.configure(SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false);
        m.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
        m.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, true);
        m.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
        m.setSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY);
        // If Zencoder adds a new field before we have a chance to update, silently ignore these fields.
        // NOTE: disable this during testing
        m.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        return m;
    }
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

    public ConfiguredObjectRecord entryToObject(TupleInput tupleInput)
    {
        String type = tupleInput.readString();
        String json = tupleInput.readString();
        ObjectMapper mapper = new ObjectMapper();
        try
        {
            Map<String,Object> value = mapper.readValue(json, Map.class);
            ConfiguredObjectRecord configuredObject = new ConfiguredObjectRecord(_uuid, type, value);
            return configuredObject;
        }
        catch (IOException e)
        {
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

    public void objectToEntry(ConfiguredObjectRecord object, TupleOutput tupleOutput)
    {
        try
        {
            StringWriter writer = new StringWriter();
            new ObjectMapper().writeValue(writer, object.getAttributes());
            tupleOutput.writeString(object.getType());
            tupleOutput.writeString(writer.toString());
        }
        catch (JsonMappingException e)
        {
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

        ExternalResource fromto = resourceDataBinder.update(resource, resourceTO);
        assertNotNull(fromto);
        assertEquals(resource, fromto);

        ObjectMapper mapper = new ObjectMapper();

        StringWriter writer = new StringWriter();
        mapper.writeValue(writer, resourceTO);

        assertEquals(resourceTO, mapper.readValue(writer.toString(), ResourceTO.class));

        List<ResourceTO> resourceTOs = resourceDataBinder.getResourceTOs(resourceDAO.findAll());
        assertNotNull(resourceTOs);
        assertFalse(resourceTOs.isEmpty());

        writer = new StringWriter();
        mapper.writeValue(writer, resourceTOs);

        ResourceTO[] actual = mapper.readValue(writer.toString(), ResourceTO[].class);
        assertEquals(resourceTOs, Arrays.asList(actual));
    }
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

    //send back some response
    HttpResponse sourcesResp = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
                                                       HttpResponseStatus.OK);
    sourcesResp.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
    sourcesResp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
    ObjectMapper objMapper = new ObjectMapper();
    HttpChunk body =
        new DefaultHttpChunk(ChannelBuffers.wrappedBuffer(objMapper.writeValueAsBytes(String.valueOf(startScn))));
    NettyTestUtils.sendServerResponses(_dummyServer, clientAddr, sourcesResp, body);
  }
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

  "                }\n" +
  "        ]\n" +
  "}";

  public PhysicalSourceConfig convertToPhysicalSourceConfig(String str) {
    _mapper = new ObjectMapper();
    InputStreamReader isr = new InputStreamReader(IOUtils.toInputStream(str));
    PhysicalSourceConfig pConfig = null;
    try
    {
      pConfig = _mapper.readValue(isr, PhysicalSourceConfig.class);
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

        break; // nothing more to read
      String jsonString = new String(jsonBytes);
      String [] jsonStrings = jsonString.split("\n");
      assertEquals(jsonStrings.length, numEventsRead);

      ObjectMapper mapper = new ObjectMapper();

      for(int i=0; i<jsonStrings.length; i++) {
        // verify what was written
        String evtStr = jsonStrings[i];
        if (evtStr.equals(prevEvent)) {
          // It may so happen that we receive the same event twice, especially when the
          // offered buffer is small. This check gets around the issue.
          continue;
        }
        prevEvent = evtStr;
        Map<String, Object> jsonMap = mapper.readValue(evtStr,
                                                       new TypeReference<Map<String, Object>>(){});
        //assertEquals(jsonMap.size(), 10);
        Integer srcId = (Integer)jsonMap.get("srcId");
        if(!DbusEventUtils.isControlSrcId(srcId)) { // not a control message
          numNonControlEventsRead++;
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

    SimpleTestHttpClient httpClient = SimpleTestHttpClient.createLocal(TimeoutPolicy.ALL_TIMEOUTS);
    SimpleHttpResponseHandler respHandler = httpClient.sendRequest(_serverAddress, httpRequest);

    assertTrue("failed to get a response", respHandler.awaitResponseUninterruptedly(1, TimeUnit.SECONDS));
    ByteArrayInputStream in = new ByteArrayInputStream(respHandler.getReceivedBytes());
    ObjectMapper objMapper = new ObjectMapper();
    List<IdNamePair> res = objMapper.readValue(in, new TypeReference<List<IdNamePair>>(){});
    assertNotNull("no result", res);
    if (LOG.isDebugEnabled())
    {
      LOG.debug("/sources response:" + new String(respHandler.getReceivedBytes()));
    }
View Full Code Here

Examples of org.codehaus.jackson.map.ObjectMapper

    SimpleHttpResponseHandler respHandler = httpClient.sendRequest(_serverAddress, httpRequest);

    assertTrue("failed to get a response",
               respHandler.awaitResponseUninterruptedly(1, TimeUnit.SECONDS));
    ByteArrayInputStream in = new ByteArrayInputStream(respHandler.getReceivedBytes());
    ObjectMapper objMapper = new ObjectMapper();
    List<IdNamePair> res = objMapper.readValue(in, new TypeReference<List<IdNamePair>>(){});
    assertNotNull("no result", res);
    if (LOG.isDebugEnabled())
    {
      LOG.debug("/sources response:" + new String(respHandler.getReceivedBytes()));
    }
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.