use of org.jibx.runtime.IBindingFactory in project kernel by exoplatform.
the class TestConfigurationService method testMarshallAndUnmarshall.
public void testMarshallAndUnmarshall() throws Exception {
String basedir = System.getProperty("basedir");
ConfigurationUnmarshaller unmarshaller = new ConfigurationUnmarshaller();
URL url = TestConfigurationService.class.getResource("../../../../configuration.xml");
Object obj = unmarshaller.unmarshall(url);
IBindingFactory bfact = BindingDirectory.getFactory(Configuration.class);
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream(basedir + "/target/configuration.xml"));
}
use of org.jibx.runtime.IBindingFactory in project kernel by exoplatform.
the class TestConfigurationXML method testSystemPropertyResolving.
public void testSystemPropertyResolving() throws Exception {
System.setProperty("c_value", "c_external_value");
System.setProperty("d_value", "d_external_value");
System.setProperty("false_value", "false");
System.setProperty("true_value", "true");
System.setProperty("FALSE_value", "FALSE");
System.setProperty("TRUE_value", "TRUE");
System.setProperty("integer_value", "5");
System.setProperty("long_value", "41");
System.setProperty("double_value", "172.5");
//
IBindingFactory bfact = BindingDirectory.getFactory(XMLObject.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
URL url = TestConfigurationXML.class.getResource("../../../../test-resolved-property.xml");
Configuration conf = (Configuration) uctx.unmarshalDocument(url.openStream(), null);
assertNotNull(conf);
//
Component component = conf.getComponent("component");
assertNotNull(component);
//
assertValueParam("a_value", component, "a");
assertValueParam("${b_value}", component, "b");
assertValueParam("c_external_value", component, "c");
assertValueParam("_d_external_value_", component, "d");
//
assertPropertyParam("a_value", component, "e", "e_a");
assertPropertyParam("${b_value}", component, "e", "e_b");
assertPropertyParam("c_external_value", component, "e", "e_c");
assertPropertyParam("_d_external_value_", component, "e", "e_d");
//
ObjectParameter o = component.getInitParams().getObjectParam("f");
assertNotNull(o);
Person p = (Person) o.getObject();
assertNotNull(p);
assertEquals("a_value", p.address_a);
assertEquals("${b_value}", p.address_b);
assertEquals("c_external_value", p.address_c);
assertEquals("_d_external_value_", p.address_d);
assertEquals(true, p.male_a);
assertEquals(false, p.male_b);
assertEquals(true, p.male_c);
assertEquals(false, p.male_d);
assertEquals(true, p.male_e);
assertEquals(false, p.male_f);
assertEquals(4, p.age_a);
assertEquals(5, p.age_b);
assertEquals(40, p.weight_a);
assertEquals(41, p.weight_b);
assertEquals(172.4D, p.size_a);
assertEquals(172.5D, p.size_b);
}
use of org.jibx.runtime.IBindingFactory in project kernel by exoplatform.
the class TestDataXML method testMarshallAndUnmarshall.
public void testMarshallAndUnmarshall() throws Exception {
String projectdir = System.getProperty("basedir");
IBindingFactory bfact = BindingDirectory.getFactory(XMLObject.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
URL url = TestDataXML.class.getResource("../../../../object.xml");
Object obj = uctx.unmarshalDocument(url.openStream(), null);
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream(projectdir + "/target/object.xml"));
}
Aggregations