Package test.utils.json

Examples of test.utils.json.SimpleObj2


    Assert.assertThat(temp.getHeight(), is(33.24));
  }
 
  @Test
  public void test4() {
    SimpleObj2 so2 = new SimpleObj2();
    so2.setId(334);
   
    User user = new User();
    user.setId(2434L);
    user.setName("Pengtao");
    so2.setUser(user);
   
    Book book = new Book();
    book.setId(23424);
    book.setPrice(3.4);
    book.setSell(true);
    book.setText("cccccccc");
    book.setTitle("ddddd");
    so2.setBook(book);
   
    String jsonStr = Json.toJson(so2);
   
    SimpleObj2 temp = Json.toObject(jsonStr, SimpleObj2.class);
    Assert.assertThat(temp.getBook().getPrice(), is(3.4));
    Assert.assertThat(temp.getBook().getTitle(), nullValue());
    Assert.assertThat(temp.getId(), is(334));
  }
View Full Code Here


    Assert.assertThat(new String(obj2.getByteArr(), "utf-8"), is("0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+"));
  }
 
  @Test
  public void test11() {
    SimpleObj2 obj = new SimpleObj2();
    obj.setSex('c');
    obj.setSymbol("测试一下".toCharArray());
   
    String json = Json.toJson(obj);
    SimpleObj2 obj2 = Json.toObject(json, SimpleObj2.class);
    Assert.assertThat(obj2.getSex(), is('c'));
    Assert.assertThat(new String(obj2.getSymbol()), is("测试一下"));
  }
View Full Code Here

    Assert.assertThat(p.getReadbooktype().get("测试一下"), is(23));
  }
 
  @Test
  public void testBigNumber() {
    SimpleObj2 s = new SimpleObj2();
    s.setBigDecimal(new BigDecimal("-3.34"));
    s.setBigInteger(new BigInteger("-4"));
    String json = Json.toJson(s);
    System.out.println(json);
   
    SimpleObj2 s2 = Json.toObject(json, SimpleObj2.class);
    Assert.assertThat(s2.getBigDecimal(), is(new BigDecimal("-3.34")));
    Assert.assertThat(s2.getBigInteger(), is(new BigInteger("-4")));
  }
View Full Code Here

TOP

Related Classes of test.utils.json.SimpleObj2

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.