Package org.bifrost.xmlio

Examples of org.bifrost.xmlio.XmlReader


   * Test reading from a file that does not exist.  Make sure the file
   * <code>/foobardpath/foobarfile.xml</code> does not exist.
   */
  public void testInvalidFile()
  {
    XmlReader config = null;
    try
    {
      String packageName = nameOfPackage(this.getClass().getName());
      config = new XmlReader("/foobardpath/foobarfile.xml", packageName);
      assertNotNull(config);
    }
    catch (XmlException e)
    {
      String test = e.toString().toLowerCase();
View Full Code Here


   * Test reading from a url that cannot be connected to.  Make sure the url
   * <code>http://foobardhost/foobarfile.xml</code> is invalid.
   */
  public void testInvalidUrl()
  {
    XmlReader config = null;
    try
    {
      String packageName = nameOfPackage(this.getClass().getName());
      URL url = new URL("http://foobardhost/foobarfile.xml");
      config = new XmlReader(url, packageName);
      assertNotNull(config);
    }
    catch (XmlException e)
    {
      String test = e.toString().toLowerCase();
View Full Code Here

   */
  public void testSimpleObject()
  {
    String configString = createXml(TEST_SIMPLE);
    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);
    TestHelperSimple helper = (TestHelperSimple)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue(helper.getNumber() == 123);
    assertTrue("abc".equals(helper.getString()));
  } // end testSimpleObject()
View Full Code Here

   */
  public void testSimpleChild()
  {
    String configString = createXml(TEST_SIMPLE_CHILD);
    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);
    TestHelperParent helper = (TestHelperParent)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue("Got " + helper.getVariable(), "hello world".equals(helper.getVariable()));
    assertNotNull(helper.getTestHelperParent());
    assertTrue(helper.getTestHelperParent().size() == 1);
    Iterator iter = helper.getTestHelperParent().iterator();
View Full Code Here

   */
  public void testDeepChild()
  {
    String configString = createXml(TEST_DEEP_CHILD);
    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);
    TestHelperParent helper = (TestHelperParent)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue("Got " + helper.getVariable(), "a1".equals(helper.getVariable()));
    assertNotNull(helper.getTestHelperParent());
    assertTrue(helper.getTestHelperParent().size() == 1);
    Iterator iter = helper.getTestHelperParent().iterator();
View Full Code Here

   */
  public void testSimpleWithAmpersand()
  {
    String configString = createXml(TEST_AMP);
    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);
    TestHelperSimple helper = (TestHelperSimple)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue(helper.getNumber() == 123);
    assertTrue("a&b".equals(helper.getString()));
  } // end testSimpleWithAmpersand()
View Full Code Here

   */
  public void testSimpleWithXmlBrackets()
  {
    String configString = createXml(TEST_BRACKETS);
    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);
    TestHelperSimple helper = (TestHelperSimple)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue(helper.getNumber() == 123);
    assertTrue("a<b>c".equals(helper.getString()));
  } // end testSimpleWithAmpersand()
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());
    }
    assertNotNull(xmlReader);
    TestHelperSimple helper = (TestHelperSimple)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue(helper.getNumber() == 123);
    assertTrue("abc".equals(helper.getString()));
  } // end testSimpleObject()
View Full Code Here

   */
  public void testFullPackageName()
  {
    String configString = createXml(TEST_FULL_PACKAGE_NAME);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "");
    }
    catch (XmlException e)
    {
      fail("Unexpected error: " + e.toString());
    }
    assertNotNull(xmlReader);
    TestHelperSimple helper = (TestHelperSimple)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue("Got " + helper.getNumber(), helper.getNumber() == 123);
    assertTrue("Got '" + helper.getString() + "'", "abc".equals(helper.getString()));
  } // end testFullPackageName()
View Full Code Here

   */
  public void testObjectWithNullAttribute()
  {
    String configString = createXml(TEST_NULL);
    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);
    TestHelperSimple helper = (TestHelperSimple)xmlReader.getRootObject();
    assertNotNull(helper);
    assertTrue(helper.getNumber() == 123);
    assertTrue(helper.getString() == null);
  } // end testObjectWithNullAttribute()
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.