Search in sources :

Example 36 with Configuration

use of org.exoplatform.container.xml.Configuration in project kernel by exoplatform.

the class TestInitParamProfile method testFooBarProfiles.

public void testFooBarProfiles() throws Exception {
    Configuration config = getConfiguration("init-param-configuration.xml", "foo", "bar");
    Component component = config.getComponent("Component");
    InitParams initParams = component.getInitParams();
    ValueParam valueParam = initParams.getValueParam("param");
    assertEquals("bar", valueParam.getValue());
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) Configuration(org.exoplatform.container.xml.Configuration) Component(org.exoplatform.container.xml.Component) ValueParam(org.exoplatform.container.xml.ValueParam)

Example 37 with Configuration

use of org.exoplatform.container.xml.Configuration 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

Configuration (org.exoplatform.container.xml.Configuration)37 Component (org.exoplatform.container.xml.Component)9 ExternalComponentPlugins (org.exoplatform.container.xml.ExternalComponentPlugins)5 ObjectParameter (org.exoplatform.container.xml.ObjectParameter)4 InitParams (org.exoplatform.container.xml.InitParams)3 ValueParam (org.exoplatform.container.xml.ValueParam)3 IBindingFactory (org.jibx.runtime.IBindingFactory)3 IUnmarshallingContext (org.jibx.runtime.IUnmarshallingContext)3 File (java.io.File)2 IOException (java.io.IOException)2 URL (java.net.URL)2 PrivilegedActionException (java.security.PrivilegedActionException)2 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Properties (java.util.Properties)1