Package org.bifrost.xmlio.config

Examples of org.bifrost.xmlio.config.XmlIOConfig


   * Test serializing an object with date and timestamp properties.
   */
  public void testDateComplex()
  {
    // Configure date/timestamp formats
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Override the default date and timestamp converters to use a different
    // format.
    DateConverter dconv = new DateConverter("yyyy-MM-dd");
    config.addConverter(dconv);
    TimestampConverter tconv = new TimestampConverter("yyyy-MM-dd HH:mm");
    config.addConverter(tconv);
   
    List plist = new LinkedList();
    PropertyMap pmap = new PropertyMap("created");
    plist.add(pmap);
    pmap = new PropertyMap("startDate");
    plist.add(pmap);
    pmap = new PropertyMap("startTime");
    dconv = new DateConverter("HH:mm:ss");
    pmap.setConverter(dconv);
    plist.add(pmap);
    pmap = new PropertyMap("endTime");
    pmap.setConverter(dconv);
    plist.add(pmap);
    pmap = new PropertyMap("calendar");
    pmap.setConverter(new GregorianCalendarConverter());
    plist.add(pmap);
    ObjectMap omap = new ObjectMap("TestHelperDate", "TestHelperDate", plist);
    config.addObjectMap(omap);
   
    CharArrayWriter output = new CharArrayWriter();
    assertNotNull(output);
    TestHelperDate helper = new TestHelperDate();
    assertNotNull(helper);
View Full Code Here


   * Test serializing a simple object made of of primative properties, where the
   * properties are serialized to XML attributes, not elements.
   */
  public void testSimpleAttributes()
  {
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    ObjectMap oMap =
      ObjectMap.createFromClassAsAttributes(TestHelperSimple.class);
    config.addObjectMap(oMap);

    CharArrayWriter output = new CharArrayWriter();
    assertNotNull(output);
    TestHelperSimple simple = new TestHelperSimple();
    assertNotNull(simple);
View Full Code Here

   * Test serializing a simple object made of of primative properties, where the
   * properties are serialized to XML attributes, not elements.
   */
  public void testMixedAttributes()
  {
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    ObjectMap oMap = ObjectMap.createFromClass(TestHelperSimple.class);
    PropertyMap pMap = oMap.getPropertyMapFromName("number");
    pMap.setWriteAsAttribute(true);
    config.addObjectMap(oMap);

    CharArrayWriter output = new CharArrayWriter();
    assertNotNull(output);
    TestHelperSimple simple = new TestHelperSimple();
    assertNotNull(simple);
View Full Code Here

   * object attributes are mapped from their java names to different xml names.
   */
  public void testObjectPropertyMapping()
  {
//    String configString = createXml(TEST_OBJECT_PROPERTY_MAPPING);
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    List list = new LinkedList();
    list.add(new PropertyMap("a", "string"));
    list.add(new PropertyMap("b", "number"));
    ObjectMap oMap = new ObjectMap("obj", "TestHelperSimple", list);
    config.addObjectMap(oMap);
    list = new LinkedList();
    list.add(new PropertyMap("obj", "testHelperSimple"));
    oMap = new ObjectMap("TestHelperComplex", "TestHelperComplex", list);
    config.addObjectMap(oMap);
    // Create the object graph
    TestHelperComplex helper = new TestHelperComplex();
    assertNotNull(helper);
    TestHelperSimple simple = new TestHelperSimple(222l, "aaa");
    helper.setTestHelperSimple(simple);
View Full Code Here

   * in it.  The wrapper object outputs in the inner objects as elements, but
   * the properties of the inner objects are output as XML attributes.
   */
  public void testComplexAttributes()
  {
    XmlIOConfig config = XmlIOConfig.getInstance();
    ObjectMap oMap =
      ObjectMap.createFromClassAsAttributes(TestHelperSimple.class);
    config.addObjectMap(oMap);

    CharArrayWriter output = new CharArrayWriter();
    assertNotNull(output);
    TestHelperComplex complex = new TestHelperComplex();
    assertNotNull(complex);
View Full Code Here

    String configString = createXml(TEST_DATE_SIMPLE);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;

    // Configure date/timestamp formats
    XmlIOConfig config = XmlIOConfig.getInstance();
    DateConverter dconv = new DateConverter("yyyy-MM-dd");
    config.addConverter(dconv);
    TimestampConverter tconv = new TimestampConverter("yyyy-MM-dd HH:mm");
    config.addConverter(tconv);

    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
    }
View Full Code Here

    String configString = createXml(TEST_DATE_COMPLEX);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;

    // Configure date/timestamp formats
    XmlIOConfig config = XmlIOConfig.getInstance();
    DateConverter dconv = new DateConverter("yyyy-MM-dd");
    config.addConverter(dconv);
    TimestampConverter tconv = new TimestampConverter("yyyy-MM-dd HH:mm");
    config.addConverter(tconv);

    List plist = new LinkedList();
    PropertyMap pmap = new PropertyMap("created");
    plist.add(pmap);
    pmap = new PropertyMap("startDate");
    plist.add(pmap);
    pmap = new PropertyMap("startTime");
    dconv = new DateConverter("HH:mm:ss");
    pmap.setConverter(dconv);
    plist.add(pmap);
    pmap = new PropertyMap("endTime");
    pmap.setConverter(dconv);
    plist.add(pmap);
    ObjectMap omap = new ObjectMap("TestHelperDate", "TestHelperDate", plist);
    config.addObjectMap(omap);

    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
    }
View Full Code Here

  public void testSimpleNamespaces()
  {
    String configString = createXml(TEST_SIMPLE_NAMESPACES);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    XmlIOConfig config = XmlIOConfig.getInstance();
    try
    {
      NamespaceMap map = new NamespaceMap();
      map.setUri("http://www.bifrost.org/xmlio");
      map.setPrefix("helpers");
      map.setPackageName("org.bifrost.xmlio.test.helpers");
      config.addNamespaceMap(map);
      xmlReader = new XmlReader(reader, "");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
View Full Code Here

   * object attributes are mapped from xml names to their actual java names.
   */
  public void testObjectPropertyMapping()
  {
    String configString = createXml(TEST_OBJECT_PROPERTY_MAPPING);
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    List list = new LinkedList();
    list.add(new PropertyMap("a", "string"));
    list.add(new PropertyMap("b", "number"));
    ObjectMap oMap = new ObjectMap("obj", "TestHelperSimple", list);
    config.addObjectMap(oMap);
    list = new LinkedList();
    list.add(new PropertyMap("obj", "TestHelperSimple"));
    oMap = new ObjectMap("TestHelperComplex", "TestHelperComplex", list);
    config.addObjectMap(oMap);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
View Full Code Here

   * object attributes are mapped from xml names to their actual java names.
   */
  public void testObjectMapping()
  {
    String configString = createXml(TEST_OBJECT_MAPPING);
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    List list = new LinkedList();
    list.add(new PropertyMap("obj", "TestHelperSimple"));
    ObjectMap oMap = new ObjectMap("TestHelperComplex", "TestHelperComplex", list);
    config.addObjectMap(oMap);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
View Full Code Here

TOP

Related Classes of org.bifrost.xmlio.config.XmlIOConfig

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.