Search in sources :

Example 16 with Component

use of org.exoplatform.container.xml.Component 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);
}
Also used : IUnmarshallingContext(org.jibx.runtime.IUnmarshallingContext) Configuration(org.exoplatform.container.xml.Configuration) IBindingFactory(org.jibx.runtime.IBindingFactory) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) Component(org.exoplatform.container.xml.Component) URL(java.net.URL)

Aggregations

Component (org.exoplatform.container.xml.Component)16 Configuration (org.exoplatform.container.xml.Configuration)9 ConfigurationManager (org.exoplatform.container.configuration.ConfigurationManager)6 InitParams (org.exoplatform.container.xml.InitParams)5 ObjectParameter (org.exoplatform.container.xml.ObjectParameter)4 ValueParam (org.exoplatform.container.xml.ValueParam)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 PrivilegedActionException (java.security.PrivilegedActionException)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 AbstractComponentAdapter (org.exoplatform.container.AbstractComponentAdapter)2 ComponentTask (org.exoplatform.container.ComponentTask)2 CyclicDependencyException (org.exoplatform.container.CyclicDependencyException)2 Dependency (org.exoplatform.container.Dependency)2 DefinitionException (org.exoplatform.container.context.DefinitionException)2 ComponentAdapter (org.exoplatform.container.spi.ComponentAdapter)2 ExternalComponentPlugins (org.exoplatform.container.xml.ExternalComponentPlugins)2 XMLField (org.exoplatform.xml.object.XMLField)2 XMLObject (org.exoplatform.xml.object.XMLObject)2 IBindingFactory (org.jibx.runtime.IBindingFactory)2