Examples of JsonConvert


Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

public class JsonConvertTest extends TestCase {

  public void testConvertToBoolean() throws Exception {
    String jsonStr = JsonHelper.toJsonExt(new Boolean(true));

    Boolean actual = new JsonConvert().convertToBoolean(jsonStr);
    Boolean expected = new Boolean(true);
    junit.framework.Assert.assertEquals(expected, actual);

  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  public void testConvertToByte() throws Exception {
    for (int i = 0; i < 256; i++) {
      String jsonStr = JsonHelper.toJsonExt(new Byte((byte) i));

      Byte actual = new JsonConvert().convertToByte(jsonStr);
      Byte expected = new Byte((byte) i);
      junit.framework.Assert.assertEquals(expected, actual);
    }

    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    Byte actual = new JsonConvert().convertToByte(jsonObj.get("fByte"));
    junit.framework.Assert.assertEquals(te.getFByte(), actual);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  }

  public void testConvertToCharacter() throws Exception {
    for (int i = 0; i < 1; i++) {
      String jsonStr = JsonHelper.toJsonExt(new Character((char) 'a'));
      Character actual = new JsonConvert().convertToCharacter(jsonStr);
      Character expected = new Character((char) 'a');
      junit.framework.Assert.assertEquals(expected, actual);
    }

    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    Character actual = new JsonConvert().convertToCharacter(jsonObj
        .get("fCharacter"));
    junit.framework.Assert.assertEquals(te.getFCharacter(), actual);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  }

  public void testConvertToDouble() throws Exception {
    String jsonStr = JsonHelper.toJsonExt(new Double(123.123D));

    Double actual = new JsonConvert().convertToDouble(jsonStr);
    Double expected = new Double(123.123D);
    junit.framework.Assert.assertEquals(expected, actual);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  }

  public void testConvertToFloat() throws Exception {
    String jsonStr = JsonHelper.toJsonExt(new Float(123.123F));

    Float actual = new JsonConvert().convertToFloat(jsonStr);
    Float expected = new Float(123.123F);
    junit.framework.Assert.assertEquals(expected, actual);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  }

  public void testConvertToInteger() throws Exception {
    String jsonStr = JsonHelper.toJsonExt(new Integer(123456));

    Integer actual = new JsonConvert().convertToInteger(jsonStr);
    Integer expected = new Integer(123456);
    junit.framework.Assert.assertEquals(expected, actual);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  }

  public void testConvertToLong() throws Exception {
    String jsonStr = JsonHelper.toJsonExt(new Long(123456789012345L));

    Long actual = new JsonConvert().convertToLong(jsonStr);
    Long expected = new Long(123456789012345L);
    junit.framework.Assert.assertEquals(expected, actual);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  }

  public void testConvertToShort() throws Exception {
    String jsonStr = JsonHelper.toJsonExt(new Short((short) 1234));

    Short actual = new JsonConvert().convertToShort(jsonStr);
    Short expected = new Short((short) 1234);
    junit.framework.Assert.assertEquals(expected, actual);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  public void testConvertToString() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    String actual = new JsonConvert().convertToString(jsonObj
        .get("fString"));
    junit.framework.Assert.assertEquals(te.getFString(), actual);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.core.convert.JsonConvert

  public void testConvertToboolean() throws Exception {
    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    boolean actual = new JsonConvert().convertToboolean(jsonObj
        .get("fboolean"));
    junit.framework.Assert.assertEquals(te.isFboolean(), actual);
  }
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.