public MapCompositeValueSupport compositeValueMap(Map<String, String> map) {
    // TODO: update MetaValueFactory for MapCompositeMetaType
    // MetaValue metaValue = getMetaValueFactory().create(xaPropValues, getMapType());
    MapCompositeValueSupport metaValue = new MapCompositeValueSupport(SimpleMetaType.STRING);
    for (String key : map.keySet()) {
      MetaValue value = SimpleValueSupport.wrap(map.get(key));
      metaValue.put(key, value);
    }

    return metaValue;
  }
  /**
   * Test adding a new tx-connection-factory deployment with xa enabled
   *
   * @throws Exception
   */
  public void testAddTxXAConnectionFactory() throws Exception {
    String jndiName = "TestTxCf";
    Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();

    addCommonCfProperties(
        propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");

    Map<String, String> xaProps = new HashMap<String, String>();
    xaProps.put("SessionDefaultType", "javax.jms.Topic");
    xaProps.put("SessionDefaultType.type", "java.lang.String");
    xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
    xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
    MetaValue metaValue = this.compositeValueMap(xaProps);

    propValues.put("config-property", metaValue);

    propValues.put("xa-transaction", SimpleValueSupport.wrap(Boolean.TRUE));
    propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
    propValues.put("interleaving", SimpleValueSupport.wrap(Boolean.TRUE));

    // todo: how to set the specific domain?
    // ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
    // props.get("security-domain").setValue(secDomain);

    createComponentTest(
        "TxConnectionFactoryTemplate",
        propValues,
        "testTxXACf",
        new ComponentType("ConnectionFactory", "Tx"),
        jndiName);
    // Query the interleaving
    ManagementView mgtView = getManagementView();
    ComponentType type = new ComponentType("ConnectionFactory", "Tx");
    ManagedComponent txcf = mgtView.getComponent(jndiName, type);
    assertNotNull(txcf);
    ManagedProperty interleaving = txcf.getProperty("interleaving");
    assertNotNull("interleaving", interleaving);
    MetaValue interleavingMV = interleaving.getValue();
    assertNotNull("interleaving.value", interleavingMV);
    assertEquals(SimpleValueSupport.wrap(Boolean.TRUE), interleavingMV);
  }
  /**
   * Test adding a new hsql DataSource deployment
   *
   * @throws Exception
   */
  public void testAddXADataSource() throws Exception {
    String jndiName = "TestXaDs";
    Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();

    addCommonDsProperties(propValues, jndiName, "jboss-xa-jdbc.rar", "javax.sql.DataSource");

    propValues.put("xa-datasource-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
    propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
    propValues.put("interleaving", SimpleValueSupport.wrap(true));

    HashMap<String, String> xaPropValues = new HashMap<String, String>();
    xaPropValues.put("URL", "jdbc:hsqldb");
    xaPropValues.put("User", "sa");
    xaPropValues.put("Password", "");

    // MetaValue metaValue = getMetaValueFactory().create(xaPropValues, getMapType());
    MetaValue metaValue = this.compositeValueMap(xaPropValues);
    propValues.put("xa-datasource-properties", metaValue);

    createComponentTest(
        "XADataSourceTemplate",
        propValues,
        "testXaDs",
        KnownComponentTypes.DataSourceTypes.XA.getType(),
        jndiName);

    // Query the interleaving
    ManagementView mgtView = getManagementView();
    ComponentType type = KnownComponentTypes.DataSourceTypes.XA.getType();
    ManagedComponent txcf = mgtView.getComponent(jndiName, type);
    assertNotNull(txcf);
    ManagedProperty interleaving = txcf.getProperty("interleaving");
    assertNotNull("interleaving", interleaving);
    MetaValue interleavingMV = interleaving.getValue();
    assertNotNull("interleaving.value", interleavingMV);
    assertEquals(
        "interleaving.value is true", SimpleValueSupport.wrap(Boolean.TRUE), interleavingMV);
  }
  private void addNonXaDsProperties(
      Map<String, MetaValue> propValues, String jndiName, String rarName, String conDef) {
    addCommonDsProperties(propValues, jndiName, rarName, conDef);

    propValues.put("transaction-isolation", SimpleValueSupport.wrap("TRANSACTION_SERIALIZABLE"));
    propValues.put("user-name", SimpleValueSupport.wrap("sa"));
    propValues.put("password", SimpleValueSupport.wrap(""));

    // non xa ds
    propValues.put("driver-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
    propValues.put("connection-url", SimpleValueSupport.wrap("jdbc:hsqldb:."));
    // A metadata type with a null type-mapping, JBAS-6215
    MutableCompositeMetaType metadataType =
        new MutableCompositeMetaType(
            "org.jboss.resource.metadata.mcf.DBMSMetaData", "metadata type");
    metadataType.addItem("typeMapping", "The jdbc type mapping", SimpleMetaType.STRING);
    HashMap<String, MetaValue> items = new HashMap<String, MetaValue>();
    items.put("typeMapping", null);
    CompositeValueSupport metadata = new CompositeValueSupport(metadataType, items);
    propValues.put("metadata", metadata);

    // todo: connection-properties
  }
 private void addCommonCfProperties(
     Map<String, MetaValue> propValues, String jndiName, String rarName, String conDef) {
   propValues.put("jndi-name", SimpleValueSupport.wrap(jndiName));
   propValues.put("rar-name", SimpleValueSupport.wrap(rarName));
   propValues.put("use-java-context", SimpleValueSupport.wrap(Boolean.TRUE));
   propValues.put("connection-definition", SimpleValueSupport.wrap(conDef));
   // propValues.put("jmx-invoker-name",
   // SimpleValueSupport.wrap("jboss:service=invoker,type=jrmp"));
   propValues.put("min-pool-size", SimpleValueSupport.wrap(new Integer(0)));
   propValues.put("max-pool-size", SimpleValueSupport.wrap(new Integer(11)));
   propValues.put("blocking-timeout-millis", SimpleValueSupport.wrap(new Long(15000)));
   propValues.put("idle-timeout-minutes", SimpleValueSupport.wrap(new Integer(111)));
   propValues.put("prefill", SimpleValueSupport.wrap(Boolean.TRUE));
   propValues.put("background-validation", SimpleValueSupport.wrap(Boolean.TRUE));
   propValues.put("background-validation-millis", SimpleValueSupport.wrap(new Long(5000)));
   propValues.put("validate-on-match", SimpleValueSupport.wrap(Boolean.FALSE));
   propValues.put("use-strict-min", SimpleValueSupport.wrap(Boolean.TRUE));
   propValues.put("no-tx-separate-pools", SimpleValueSupport.wrap(Boolean.TRUE));
   propValues.put(
       "statistics-formatter",
       SimpleValueSupport.wrap(
           "org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter"));
   propValues.put("isSameRM-override-value", SimpleValueSupport.wrap(Boolean.FALSE));
   propValues.put("type-mapping", SimpleValueSupport.wrap("Hypersonic SQL"));
   // todo: config-property
   // todo: security-domain
   // todo: depends
   // todo: metadata
   // todo: local-transaction
 }
 private void addCommonDsProperties(
     Map<String, MetaValue> propValues, String jndiName, String rarName, String conDef) {
   addCommonCfProperties(propValues, jndiName, rarName, conDef);
   propValues.put("new-connection-sql", SimpleValueSupport.wrap("CALL ABS(2.0)"));
   propValues.put("check-valid-connection-sql", SimpleValueSupport.wrap("CALL ABS(1.0)"));
   propValues.put(
       "valid-connection-checker-class-name",
       SimpleValueSupport.wrap(
           "org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker"));
   propValues.put(
       "exception-sorter-class-name",
       SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyExceptionSorter"));
   propValues.put(
       "stale-connection-checker-class-name",
       SimpleValueSupport.wrap(
           "org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker"));
   propValues.put("track-statements", SimpleValueSupport.wrap(""));
   propValues.put("prepared-statement-cache-size", SimpleValueSupport.wrap(12));
   propValues.put("share-prepared-statements", SimpleValueSupport.wrap(Boolean.TRUE));
   propValues.put("set-tx-query-timeout", SimpleValueSupport.wrap(Boolean.TRUE));
   propValues.put("query-timeout", SimpleValueSupport.wrap(new Integer(100)));
   propValues.put("url-delimiter", SimpleValueSupport.wrap("+"));
   propValues.put(
       "url-selector-strategy-class-name",
       SimpleValueSupport.wrap("org.jboss.test.jca.support.MyURLSelector"));
   propValues.put("use-try-lock", SimpleValueSupport.wrap(new Integer(5000)));
 }