Package com.bansheeproject.xmlbuilder

Examples of com.bansheeproject.xmlbuilder.Parser


   
  }
 
  @Test
  public void testMapped() throws DatatypeConfigurationException {
    Parser parser = new Parser();
    DefaultMappedSimple defaultMappedSimple = new DefaultMappedSimple();
   
    Date date = new Date();
    defaultMappedSimple.dateValue = date;
    defaultMappedSimple.longValue = 1L;
    defaultMappedSimple.string = "stringValue";
   
    String xml = parser.encode(defaultMappedSimple);
   
    StringBuilder expected = new StringBuilder();
    expected.append("<simple><dateValue>");
   
    Calendar calendar = GregorianCalendar.getInstance();
View Full Code Here


   
    defaultMappedComplex.simple.stringValue = "simpleValue";
   
   
   
    Parser parser = new Parser();
   
    String xml = parser.encode(defaultMappedComplex);
   
    Assert.assertEquals("<outerComplex><stringValue>simpleValue</stringValue></outerComplex>", xml);
  }
View Full Code Here

  public void testMapped3() {
    DefaultMappedComplex defaultMappedComplex = new DefaultMappedComplex();
   
    defaultMappedComplex.stringValue = "simpleValue";
   
    Parser parser = new Parser();
   
    String xml = parser.encode(defaultMappedComplex);
   
    Assert.assertEquals("<outerComplex><stringValue>simpleValue</stringValue></outerComplex>", xml);
  }
View Full Code Here

 
  @Test
  public void testSimpleUnmarshall() {
    String xml = "<stringValue>test</stringValue>";
   
    Parser parser = new Parser();
    Simple simple = (Simple)parser.decode(xml, Simple.class);
   
   
    Assert.assertNotNull(simple);
    Assert.assertEquals("test", simple.stringValue);
   
View Full Code Here

 
 
  @Test
  public void testUnmarshallWithPath() {
    String xml = "<complex><test>testValue</test></complex>";
    Parser parser = new Parser();
    ComplexWithPath complexWithPath = (ComplexWithPath)parser.decode(xml, ComplexWithPath.class);
   
    Assert.assertNotNull(complexWithPath);
    Assert.assertEquals("testValue", complexWithPath.test);
   
   
View Full Code Here

   
  }
  @Test
  public void testUnmarshallWithSpacedXML() {
    String xml = "<complex>\n\t<test>testValue</test>\n</complex>";
    Parser parser = new Parser();
    ComplexWithPath complexWithPath = (ComplexWithPath)parser.decode(xml, ComplexWithPath.class);
   
    Assert.assertNotNull(complexWithPath);
    Assert.assertEquals("testValue", complexWithPath.test);
   
  }
View Full Code Here

  }
 
  @Test
  public void testRespectXMLSpaces() {
    String xml = "<complex>\n\t<test>testValue  \n</test>\n</complex>";
    Parser parser = new Parser();
    ComplexWithPath complexWithPath = (ComplexWithPath)parser.decode(xml, ComplexWithPath.class);
   
    Assert.assertNotNull(complexWithPath);
    Assert.assertEquals("testValue  \n", complexWithPath.test);
  }
View Full Code Here

 
 
  @Test
  public void testUnmarshallAttribute() {
    String xml = "<element attribute=\"attr\" />";
    Parser parser = new Parser();
   
    SimpleWithAttribute simple = (SimpleWithAttribute)parser.decode(xml, SimpleWithAttribute.class);
   
    Assert.assertNotNull(simple);
    Assert.assertEquals("attr", simple.attribute);
  }
View Full Code Here

 
 
  @Test
  public void testUnmarshallNested() {
    String xml = "<stringValue>string</stringValue>";
    Parser parser = new Parser();
   
    Complex complex = (Complex) parser.decode(xml, Complex.class);
   
    Assert.assertNotNull(complex);
    Assert.assertNotNull(complex.simple);
    Assert.assertEquals("string", complex.simple.stringValue);
   
View Full Code Here

  @Test(expectedExceptions={ParseException.class})
  public void testNonsenseXML() {
   
    String nonsense = "fdskjssadsa";
   
    Parser parser = new Parser();
    parser.decode(nonsense, Simple.class);
   
  }
View Full Code Here

TOP

Related Classes of com.bansheeproject.xmlbuilder.Parser

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.