Package org.exoplatform.ws.frameworks.json

Examples of org.exoplatform.ws.frameworks.json.BeanWithSimpleEnum


      assertNull(jsonValue.getElement("transientField"));
   }

   public void testBeanEnum() throws Exception
   {
      BeanWithSimpleEnum be = new BeanWithSimpleEnum();
      be.setName("name");
      be.setCount(StringEnum.TWO);
      be.setCounts(new StringEnum[]{StringEnum.ONE, StringEnum.TWO});
      be.setCountList(Arrays.asList(StringEnum.ONE, StringEnum.TWO, StringEnum.TREE));
      JsonValue jsonValue = new JsonGeneratorImpl().createJsonObject(be);
      //System.out.println(jsonValue);

      assertEquals("name", jsonValue.getElement("name").getStringValue());
View Full Code Here


      JsonDefaultHandler handler = new JsonDefaultHandler();
      jsonParser.parse(new ByteArrayInputStream(source.getBytes()), handler);
      JsonValue jsonValue = handler.getJsonObject();
      //System.out.println(jsonValue);

      BeanWithSimpleEnum o = ObjectBuilder.createObject(BeanWithSimpleEnum.class, jsonValue);

      assertEquals("andrew", o.getName());

      assertEquals(StringEnum.TREE, o.getCount());

      StringEnum[] counts = o.getCounts();
      assertEquals(2, counts.length);

      List<StringEnum> tmp = Arrays.asList(counts);
      assertTrue(tmp.contains(StringEnum.TWO));
      assertTrue(tmp.contains(StringEnum.TREE));

      tmp = o.getCountList();
      assertEquals(3, tmp.size());
      assertTrue(tmp.contains(StringEnum.ONE));
      assertTrue(tmp.contains(StringEnum.TWO));
      assertTrue(tmp.contains(StringEnum.TREE));
   }
View Full Code Here

      assertNull(jsonValue.getElement("transientField"));
   }

   public void testBeanEnum() throws Exception
   {
      BeanWithSimpleEnum be = new BeanWithSimpleEnum();
      be.setName("name");
      be.setCount(StringEnum.TWO);
      be.setCounts(new StringEnum[]{StringEnum.ONE, StringEnum.TWO});
      be.setCountList(Arrays.asList(StringEnum.ONE, StringEnum.TWO, StringEnum.TREE));
      JsonValue jsonValue = new JsonGeneratorImpl().createJsonObject(be);

      assertEquals("name", jsonValue.getElement("name").getStringValue());

      assertEquals(StringEnum.TWO.name(), jsonValue.getElement("count").getStringValue());
View Full Code Here

TOP

Related Classes of org.exoplatform.ws.frameworks.json.BeanWithSimpleEnum

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.