Package org.bifrost.xmlio

Examples of org.bifrost.xmlio.XmlReader


    list.add(new PropertyMap("a", "string"));
    list.add(new PropertyMap("b", "number"));
    ObjectMap oMap = new ObjectMap("TestHelperSimple", "TestHelperSimple", list);
    config.addObjectMap(oMap);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperComplex helper = (TestHelperComplex)xmlReader.getRootObject();
    assertNotNull(helper);
    assertNotNull(helper.getTestHelperSimple());
    Iterator i = helper.getTestHelperSimple().iterator();
    assertTrue(i.hasNext());
    TestHelperSimple simple = (TestHelperSimple)i.next();
View Full Code Here


    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    config.addPropertyMap(new PropertyMap("a", "string"));
    config.addPropertyMap(new PropertyMap("b", "number"));
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperComplex helper = (TestHelperComplex)xmlReader.getRootObject();
    assertNotNull(helper);
    assertNotNull(helper.getTestHelperSimple());
    Iterator i = helper.getTestHelperSimple().iterator();
    assertTrue(i.hasNext());
    TestHelperSimple simple = (TestHelperSimple)i.next();
View Full Code Here

   */
  public void testIneritedObjects()
  {
    String configString = createXml(TEST_INHERITANCE);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers:org.bifrost.xmlio.test.helpers.inheritance");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperSalesLot helper = (TestHelperSalesLot)xmlReader.getRootObject();
    assertNotNull(helper);
    assertNotNull(helper.getTestHelperVehicle());
    Iterator i = helper.getTestHelperVehicle().iterator();
   
    // Boat
View Full Code Here

   */
  public void testSimpleArray()
  {
    String configString = createXml(TEST_SIMPLE_ARRAY);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperArray helper = (TestHelperArray)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue("Got " + helper.getNumber(), helper.getNumber() == 123);
    assertTrue(helper.getString().getClass().isArray());
    String[] array = (String[])helper.getString();
    assertNotNull(array);
View Full Code Here

   */
  public void testComplexArray()
  {
    String configString = createXml(TEST_COMPLEX_ARRAY);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperComplexArray helper = (TestHelperComplexArray)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue(helper.getNumber() == 123);
    assertTrue(helper.getTestHelperSimple().getClass().isArray());
    TestHelperSimple[] array = (TestHelperSimple[])helper.getTestHelperSimple();
    assertNotNull(array);
View Full Code Here

   */
  public void testMultiplePackagesSimple()
  {
    String configString = createXml(TEST_MULTI_PACKAGE);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader,
        "org.bifrost.xmlio.test.helpers:org.bifrost.xmlio.test.helpers.subpackage");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperTwoPackages helper = (TestHelperTwoPackages)xmlReader.getRootObject();
    assertNotNull(helper);
    assertNotNull(helper.getTestHelperSimple());
    Iterator i = helper.getTestHelperSimple().iterator();
    assertTrue(i.hasNext());
    TestHelperSimple simpleHelper = (TestHelperSimple)i.next();
View Full Code Here

   */
  public void testDateSimple()
  {
    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");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperDate helper = (TestHelperDate)xmlReader.getRootObject();
    assertNotNull(helper);
    Calendar cal = new GregorianCalendar();
    // Validate that the date property was set correctly
    // Note: month numbers start from 0!
    cal.setTime(helper.getCreated());
View Full Code Here

   */
  public void testDateComplex()
  {
    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");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperDate helper = (TestHelperDate)xmlReader.getRootObject();
    assertNotNull(helper);
    Calendar cal = new GregorianCalendar();
    // Validate that the timestamp property was set correctly
    cal.setTime(helper.getCreated());
    assertTrue(cal.get(Calendar.YEAR) == 2003);
View Full Code Here

   */
  public void testSimpleInvalidAttributeName()
  {
    String configString = createXml(TEST_SIMPLE_NO_ATTRIBUTE);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
      assertNotNull(xmlReader) ;
    }
    catch (XmlException e)
    {
      String test = e.toString().toLowerCase();
View Full Code Here

   */
  public void testObjectNotFound()
  {
    String configString = createXml(TEST_NO_OBJECT);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
      assertNotNull(xmlReader) ;
    }
    catch (XmlException e)
    {
      String test = e.toString().toLowerCase();
View Full Code Here

TOP

Related Classes of org.bifrost.xmlio.XmlReader

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.