Package net.buffalo.protocal.converters.map

Examples of net.buffalo.protocal.converters.map.ObjectConverter


    MapConverter mapConverter = new MapConverter();
    ArrayConverter arrayConverter = new ArrayConverter();
    SqlDateConverter sqlDateConverter = new SqlDateConverter();
    BigNumberConverter bigNumberConverter = new BigNumberConverter();
    ExceptionConverter exceptionConverter = new ExceptionConverter();
    ObjectConverter objectConverter = new ObjectConverter();

    converters.add(nullConverter);
    converters.add(booleanConverter);
    converters.add(doubleConverter);
    converters.add(integerConverter);
View Full Code Here


    assertEquals(string, stringWriter.getBuffer().toString());
   
  }
 
  public void testShouldSerializeParentClass() throws Exception {
    ObjectConverter os = new ObjectConverter();
    BirthdayPeople people = new BirthdayPeople();
    people.setBirthday(new Date());
    assertTrue(os.canConvert(BirthdayPeople.class));
    os.marshal(people, context, streamWriter);
    String output = stringWriter.getBuffer().toString();
    assertTrue(output.indexOf("date")>-1);
    assertTrue(output.indexOf("name") > -1);
    assertEquals(1, context.getObjects().size());
  }
View Full Code Here

import net.buffalo.protocal.io.StreamWriter;
import junit.framework.TestCase;

public class ComplexObjectTest extends TestCase {
  public void testAAA() throws Exception {
    ObjectConverter converter = new ObjectConverter();
    User user = new User("girl",null, "password", null, "Michael");
    List interests = new ArrayList();
    interests.add("Football");
    interests.add("Music");
    interests.add("Cook");
    user.setInterests(interests);
    user.setRoles(new String[]{"SA", "Architect"});
   
    StringWriter stringWriter = new StringWriter();
    StreamWriter streamWriter = new FastStreamWriter(stringWriter);
    MarshallingContext context = new DefaultMarshallingContext(new DefaultConverterLookup(), streamWriter);
    converter.marshal(user, context, streamWriter);
    assertEquals("<map><type>net.buffalo.protocal.User</type><string>username</string><string>Michael</string>" +
        "<string>password</string><string>password</string><string>gendor</string><string>girl</string>" +
        "<string>interests</string><list><type>java.util.ArrayList</type><length>3</length>" +
        "<string>Football</string><string>Music</string><string>Cook</string></list><string>roles</string>" +
        "<list><type>[string</type><length>2</length><string>SA</string><string>Architect</string></list></map>",
View Full Code Here

    streamWriter = new FastStreamWriter(stringWriter);
    context = new DefaultMarshallingContext(new DefaultConverterLookup(), streamWriter);
  }
 
  public void testShouldSerializeObject() throws Exception {
    ObjectConverter os = new ObjectConverter();
    assertFalse(os.canConvert(null));
    People people = new People();
    assertTrue(os.canConvert(People.class));
   
    os.marshal(people, context, streamWriter);
    String string = "<map>" +
            "<type>net.buffalo.protocal.People</type>" +
            "<string>name</string>" +
            "<null></null>" +
            "<string>age</string>" +
View Full Code Here

TOP

Related Classes of net.buffalo.protocal.converters.map.ObjectConverter

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.