[jboss-cvs] JBossAS SVN: r110452 - in projects/jboss-jca/trunk/common/src: test/java/org/jboss/jca/common/metadata/ds and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 26 10:32:43 EST 2011


Author: maeste
Date: 2011-01-26 10:32:43 -0500 (Wed, 26 Jan 2011)
New Revision: 110452

Added:
   projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForTemplateReplaceTestCase.java
   projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-ds.xml
   projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-partial-ds.xml
   projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-twoparts-ds.xml
   projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-twoparts-onewrong-ds.xml
   projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-wrong-property-ds.xml
   projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-max-pool-ds.xml
   projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-max-pool-wrong-ds.xml
Modified:
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/AbstractParser.java
   projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserExampleTestCase.java
   projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForValidatorExceptionTestCase.java
Log:
JBJCA-263 implementation and test cases

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/AbstractParser.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/AbstractParser.java	2011-01-26 12:45:55 UTC (rev 110451)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/AbstractParser.java	2011-01-26 15:32:43 UTC (rev 110452)
@@ -31,12 +31,20 @@
 import org.jboss.jca.common.metadata.common.CommonSecurityImpl;
 import org.jboss.jca.common.metadata.common.CommonXaPoolImpl;
 
+import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.jboss.logging.Logger;
+
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
 
+
+
 /**
  *
  * A AbstractParser.
@@ -46,6 +54,8 @@
  */
 public abstract class AbstractParser
 {
+   /** The logger */
+   private static Logger log = Logger.getLogger(AbstractParser.class);
 
    /**
     * convert an xml element in boolean value. Empty elements results with true (tag presence is sufficient condition)
@@ -53,11 +63,23 @@
     * @param reader the StAX reader
     * @return the boolean representing element
     * @throws XMLStreamException StAX exception
+    * @throws ParserException in case of non valid boolean for given element value
     */
-   protected boolean elementAsBoolean(XMLStreamReader reader) throws XMLStreamException
+   protected boolean elementAsBoolean(XMLStreamReader reader) throws XMLStreamException, ParserException
    {
-      String elementtext = reader.getElementText();
-      return elementtext == null || elementtext.length() == 0 ? true : Boolean.valueOf(elementtext.trim());
+      String elementtext = rawElementText(reader);
+      String stringValue = getSubstitutionValue(elementtext);
+      if (stringValue == null || stringValue.length() == 0 || stringValue.trim().equalsIgnoreCase("true") ||
+          stringValue.trim().equalsIgnoreCase("false"))
+      {
+
+         return stringValue == null || stringValue.length() == 0 ? true : Boolean.valueOf(stringValue.trim());
+      }
+      else
+      {
+         throw new ParserException(elementtext + " isn't a valid boolean for element " + reader.getLocalName() +
+                                   ". We accept only \"true\" or \"false\" as boolean value");
+      }
    }
 
    /**
@@ -68,14 +90,28 @@
     * @param defaultValue  defaultValue
     * @return the boolean representing element
     * @throws XMLStreamException StAX exception
+    * @throws ParserException in case of not valid boolena for given attribute
     */
    protected boolean attributeAsBoolean(XMLStreamReader reader, String attributeName, boolean defaultValue)
-      throws XMLStreamException
+      throws XMLStreamException, ParserException
    {
-      return reader.getAttributeValue("", attributeName) == null
-            || reader.getAttributeValue("", attributeName).length() == 0
+      String attributeString = rawAttributeText(reader, attributeName);
+      String stringValue = getSubstitutionValue(attributeString);
+      if (stringValue == null || stringValue.length() == 0 || stringValue.trim().equalsIgnoreCase("true") ||
+          stringValue.trim().equalsIgnoreCase("false"))
+      {
+
+         return attributeString == null
             ? defaultValue :
             Boolean.valueOf(reader.getAttributeValue("", attributeName).trim());
+      }
+      else
+      {
+         throw new ParserException(attributeString + " isn't a valid boolean for attribute " + attributeName +
+                                   " of element " + reader.getLocalName() +
+                                   ". We accept only \"true\" or \"false\" as boolean value");
+      }
+
    }
 
    /**
@@ -87,8 +123,23 @@
     */
    protected String elementAsString(XMLStreamReader reader) throws XMLStreamException
    {
+      String elementtext = rawElementText(reader);
+      //return elementtext;
+      return getSubstitutionValue(elementtext);
+   }
+
+   /**
+    * FIXME Comment this
+    *
+    * @param reader
+    * @return
+    * @throws XMLStreamException
+    */
+   private String rawElementText(XMLStreamReader reader) throws XMLStreamException
+   {
       String elementtext = reader.getElementText();
-      return elementtext == null ? null : elementtext.trim();
+      elementtext = elementtext == null ? null : elementtext.trim();
+      return elementtext;
    }
 
    /**
@@ -101,8 +152,23 @@
     */
    protected String attributeAsString(XMLStreamReader reader, String attributeName) throws XMLStreamException
    {
-      return reader.getAttributeValue("", attributeName) == null ? null : reader.getAttributeValue("", attributeName)
+      String attributeString = rawAttributeText(reader, attributeName);
+      return getSubstitutionValue(attributeString);
+   }
+
+   /**
+    * FIXME Comment this
+    *
+    * @param reader
+    * @param attributeName
+    * @return
+    */
+   private String rawAttributeText(XMLStreamReader reader, String attributeName)
+   {
+      String attributeString = reader.getAttributeValue("", attributeName) == null ? null : reader.getAttributeValue(
+         "", attributeName)
             .trim();
+      return attributeString;
    }
 
    /**
@@ -117,14 +183,14 @@
    {
       Integer integerValue;
       integerValue = null;
+      String elementtext = rawElementText(reader);
       try
       {
-
-         integerValue = Integer.valueOf(elementAsString(reader));
+         integerValue = Integer.valueOf(getSubstitutionValue(elementtext));
       }
       catch (NumberFormatException nfe)
       {
-         throw new ParserException(reader.getLocalName() + "isn't a valid number");
+         throw new ParserException(elementtext + " isn't a valid number for element " + reader.getLocalName());
       }
       return integerValue;
    }
@@ -141,14 +207,17 @@
    {
       Long longValue;
       longValue = null;
+      String elementtext = rawElementText(reader);
+
       try
       {
-         longValue = Long.valueOf(elementAsString(reader));
+         longValue = Long.valueOf(getSubstitutionValue(elementtext));
       }
       catch (NumberFormatException nfe)
       {
-         throw new ParserException(reader.getLocalName() + "isn't a valid number");
+         throw new ParserException(elementtext + " isn't a valid number for element " + reader.getLocalName());
       }
+
       return longValue;
    }
 
@@ -309,7 +378,7 @@
                {
 
                   return new CommonXaPoolImpl(minPoolSize, maxPoolSize, prefill, useStrictMin, isSameRmOverrideValue,
-                                        interleaving, padXid, wrapXaDataSource, noTxSeparatePool);
+                                              interleaving, padXid, wrapXaDataSource, noTxSeparatePool);
 
                }
                else
@@ -370,4 +439,111 @@
       throw new ParserException("Reached end of xml document unexpectedly");
    }
 
+   /**
+    * System property substitution
+    * @param input The input string
+    * @return The output
+    */
+   private String getSubstitutionValue(String input) throws XMLStreamException
+   {
+      if (input == null || input.trim().equals(""))
+         return input;
+      while ((input.indexOf("${")) != -1)
+      {
+         int from = input.indexOf("${");
+         int to = input.indexOf("}");
+         int dv = input.indexOf(":", from + 2);
+
+         if (dv != -1)
+         {
+            if (dv > to)
+               dv = -1;
+         }
+
+         String systemProperty = "";
+         String defaultValue = "";
+         String s = input.substring(from + 2, to);
+         if (dv == -1)
+         {
+            if ("/".equals(s))
+            {
+               systemProperty = File.separator;
+            }
+            else if (":".equals(s))
+            {
+               systemProperty = File.pathSeparator;
+            }
+            else
+            {
+               systemProperty = SecurityActions.getSystemProperty(s);
+            }
+         }
+         else
+         {
+            s = input.substring(from + 2, dv);
+            systemProperty = SecurityActions.getSystemProperty(s);
+            defaultValue = input.substring(dv + 1, to);
+         }
+         String prefix = "";
+         String postfix = "";
+
+         if (from != 0)
+         {
+            prefix = input.substring(0, from);
+         }
+
+         if (to + 1 < input.length() - 1)
+         {
+            postfix = input.substring(to + 1);
+         }
+
+         if (systemProperty != null && !systemProperty.trim().equals(""))
+         {
+            input = prefix + systemProperty + postfix;
+         }
+         else if (defaultValue != null && !defaultValue.trim().equals(""))
+         {
+            input = prefix + defaultValue + postfix;
+         }
+         else
+         {
+            input = prefix + postfix;
+            log.debugf("System property %s not set", s);
+         }
+      }
+      return input;
+   }
+
+   private static class SecurityActions
+   {
+      /**
+       * Constructor
+       */
+      private SecurityActions()
+      {
+      }
+
+      /**
+       * Get a system property
+       * @param name The property name
+       * @return The property value
+       */
+      static String getSystemProperty(final String name)
+      {
+         if (System.getSecurityManager() == null)
+         {
+            return System.getProperty(name);
+         }
+         else
+         {
+            return (String) AccessController.doPrivileged(new PrivilegedAction<Object>()
+            {
+               public Object run()
+               {
+                  return System.getProperty(name);
+               }
+            });
+         }
+      }
+   }
 }

Modified: projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserExampleTestCase.java
===================================================================
--- projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserExampleTestCase.java	2011-01-26 12:45:55 UTC (rev 110451)
+++ projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserExampleTestCase.java	2011-01-26 15:32:43 UTC (rev 110452)
@@ -67,6 +67,9 @@
       File directory = new File(DsParserExampleTestCase.class.getClassLoader().getResource("ds/example").toURI());
       xmlFiles = directory.listFiles(new FileSuffixFilter("-ds.xml"));
       parser = new DsParser();
+      //this property is set just to make possible property substitution defined in test resources.
+      //but property substitution is not the goal of this test case see DsParserForTemplateReplaceTestCase for that
+      System.setProperty("jboss.server.data.dir", "/tmp");
 
    }
 

Added: projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForTemplateReplaceTestCase.java
===================================================================
--- projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForTemplateReplaceTestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForTemplateReplaceTestCase.java	2011-01-26 15:32:43 UTC (rev 110452)
@@ -0,0 +1,236 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.common.metadata.ds;
+
+import org.jboss.jca.common.api.metadata.ds.DataSources;
+import org.jboss.jca.common.api.validator.ValidateException;
+import org.jboss.jca.common.metadata.ParserException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ *
+ * A DsParserForValidatorForTemplateReplaceTestCase. See also JBJCA-263 jira
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public class DsParserForTemplateReplaceTestCase
+{
+
+   private static DsParser parser;
+
+   /**
+   *
+   * beforeClass method
+   *
+   * @throws Exception in casae of file not found
+   */
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      parser = new DsParser();
+      System.setProperty("max.pool", "10");
+      System.setProperty("jndi.name", "java:/H2DS");
+      System.setProperty("jndi.name.prefix", "java:/");
+      System.setProperty("jndi.name.suffix", "H2DS");
+
+   }
+
+   /**
+    *
+    * shouldReplaceTemplateElementFromSystemProperty
+    *
+    * @throws Exception in case of parser error
+    * thrown
+    */
+   @Test
+   public void shouldReplaceTemplateElementFromSystemProperty() throws Exception
+   {
+
+      //given
+      File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+         .getResource("ds/unit/replace-max-pool-ds.xml")
+         .toURI());
+      //when
+      DataSources ds = doParse(xmlFile);
+      //then
+      Integer actualMaxPoolSize = ds.getDataSource().get(0).getPool().getMaxPoolSize();
+      assertThat(actualMaxPoolSize, is(10));
+   }
+
+   /**
+   *
+   * shouldReplaceTemplateAttributeFromSystemProperty
+   *
+   * @throws Exception in case of parser error
+   */
+   @Test
+   public void shouldReplaceTemplateAttributeFromSystemProperty() throws Exception
+   {
+
+      //given
+      File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+         .getResource("ds/unit/replace-jndi-name-ds.xml")
+         .toURI());
+      //when
+      DataSources ds = doParse(xmlFile);
+      //then
+      String actualJndiName = ds.getDataSource().get(0).getJndiName();
+      assertThat(actualJndiName, is("java:/H2DS"));
+   }
+
+   /**
+   *
+   * shouldReplaceTemplatePartialAttributeFromSystemProperty
+   *
+   * @throws Exception in case of parser error
+   */
+   @Test
+   public void shouldReplaceTemplatePartialAttributeFromSystemProperty() throws Exception
+   {
+
+      //given
+      File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+         .getResource("ds/unit/replace-jndi-name-partial-ds.xml")
+         .toURI());
+      //when
+      DataSources ds = doParse(xmlFile);
+      //then
+      String actualJndiName = ds.getDataSource().get(0).getJndiName();
+      assertThat(actualJndiName, is("java:/H2DS"));
+   }
+
+   /**
+   *
+   * shouldReplaceTemplateTwoPartsAttributeFromSystemProperty
+   *
+   * @throws Exception in case of parser error
+   */
+   @Test
+   public void shouldReplaceTemplateTwoPartsAttributeFromSystemProperty() throws Exception
+   {
+
+      //given
+      File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+         .getResource("ds/unit/replace-jndi-name-twoparts-ds.xml")
+         .toURI());
+      //when
+      DataSources ds = doParse(xmlFile);
+      //then
+      String actualJndiName = ds.getDataSource().get(0).getJndiName();
+      assertThat(actualJndiName, is("java:/H2DS"));
+   }
+
+   /**
+   *
+   * shouldReplaceTemplateAttributeWitNullIfSystemPropertyNotSet
+   *
+   * @throws Exception in case of parser error
+   */
+   @Test
+   public void shouldReplaceTemplateAttributeWitNullIfSystemPropertyNotSet() throws Exception
+   {
+
+      //given
+      File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+         .getResource("ds/unit/replace-jndi-name-wrong-property-ds.xml")
+         .toURI());
+      //when
+      DataSources ds = doParse(xmlFile);
+      //then
+      String actualJndiName = ds.getDataSource().get(0).getJndiName();
+      assertThat(actualJndiName, is(""));
+
+   }
+
+   /**
+   *
+   * shouldReplaceOnlyRightTemplateOnTwoPartsWithOneWrongAttributeIfSystemPropertyNotSet
+   *
+   * @throws Exception in case of parser error
+   */
+   @Test
+   public void shouldReplaceOnlyRightTemplateOnTwoPartsWithOneWrongAttributeIfSystemPropertyNotSet() throws Exception
+   {
+
+      //given
+      File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+         .getResource("ds/unit/replace-jndi-name-twoparts-onewrong-ds.xml")
+         .toURI());
+      //when
+      DataSources ds = doParse(xmlFile);
+      //then
+      String actualJndiName = ds.getDataSource().get(0).getJndiName();
+      assertThat(actualJndiName, is("H2DS"));
+
+   }
+
+   /**
+   *
+   * shouldThrowParserExceptionOnWrongSystemPropertyNotSetForNumberValue
+   *
+   * @throws Exception in case of parser error
+   */
+   @Test(expected = ParserException.class)
+   public void shouldThrowParserExceptionOnWrongSystemPropertyNotSetForNumberValue() throws Exception
+   {
+
+      //given
+      File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+         .getResource("ds/unit/replace-max-pool-wrong-ds.xml")
+         .toURI());
+      //when
+      DataSources ds = doParse(xmlFile);
+      //then throw ParserException
+
+   }
+
+   private DataSources doParse(File xmlFile) throws FileNotFoundException, Exception, IOException, ValidateException
+   {
+      FileInputStream is = null;
+
+      try
+      {
+         is = new FileInputStream(xmlFile);
+         //when
+         return parser.parse(is);
+
+      }
+      finally
+      {
+         if (is != null)
+            is.close();
+      }
+   }
+
+
+}

Modified: projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForValidatorExceptionTestCase.java
===================================================================
--- projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForValidatorExceptionTestCase.java	2011-01-26 12:45:55 UTC (rev 110451)
+++ projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForValidatorExceptionTestCase.java	2011-01-26 15:32:43 UTC (rev 110452)
@@ -54,6 +54,9 @@
    public static void beforeClass() throws Exception
    {
       parser = new DsParser();
+      //this property is set just to make possible property substitution defined in test resources.
+      //but property substitution is not the goal of this test case see DsParserForTemplateReplaceTestCase for that
+      System.setProperty("jboss.server.data.dir", "/tmp");
    }
 
    /**

Added: projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-ds.xml
===================================================================
--- projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-ds.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-ds.xml	2011-01-26 15:32:43 UTC (rev 110452)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+  <datasource jndi-name="${jndi.name}" pool-name="H2DS">
+    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+    <driver-class>org.h2.Driver</driver-class>
+    <pool>
+      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
+      <min-pool-size>5</min-pool-size>
+      <!-- The maximum connections in a pool/sub-pool -->
+      <max-pool-size>10</max-pool-size>
+    </pool>
+    <security>
+      <user-name>sa</user-name>
+      <password>sa</password>
+    </security>
+  </datasource>
+
+</datasources>

Added: projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-partial-ds.xml
===================================================================
--- projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-partial-ds.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-partial-ds.xml	2011-01-26 15:32:43 UTC (rev 110452)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+  <datasource jndi-name="java:/${jndi.name.suffix}" pool-name="H2DS">
+    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+    <driver-class>org.h2.Driver</driver-class>
+    <pool>
+      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
+      <min-pool-size>5</min-pool-size>
+      <!-- The maximum connections in a pool/sub-pool -->
+      <max-pool-size>10</max-pool-size>
+    </pool>
+    <security>
+      <user-name>sa</user-name>
+      <password>sa</password>
+    </security>
+  </datasource>
+
+</datasources>

Added: projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-twoparts-ds.xml
===================================================================
--- projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-twoparts-ds.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-twoparts-ds.xml	2011-01-26 15:32:43 UTC (rev 110452)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+  <datasource jndi-name="${jndi.name.prefix}${jndi.name.suffix}" pool-name="H2DS">
+    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+    <driver-class>org.h2.Driver</driver-class>
+    <pool>
+      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
+      <min-pool-size>5</min-pool-size>
+      <!-- The maximum connections in a pool/sub-pool -->
+      <max-pool-size>10</max-pool-size>
+    </pool>
+    <security>
+      <user-name>sa</user-name>
+      <password>sa</password>
+    </security>
+  </datasource>
+
+</datasources>

Added: projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-twoparts-onewrong-ds.xml
===================================================================
--- projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-twoparts-onewrong-ds.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-twoparts-onewrong-ds.xml	2011-01-26 15:32:43 UTC (rev 110452)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+  <datasource jndi-name="${jndi.name.prefix.wrong}${jndi.name.suffix}" pool-name="H2DS">
+    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+    <driver-class>org.h2.Driver</driver-class>
+    <pool>
+      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
+      <min-pool-size>5</min-pool-size>
+      <!-- The maximum connections in a pool/sub-pool -->
+      <max-pool-size>10</max-pool-size>
+    </pool>
+    <security>
+      <user-name>sa</user-name>
+      <password>sa</password>
+    </security>
+  </datasource>
+
+</datasources>

Added: projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-wrong-property-ds.xml
===================================================================
--- projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-wrong-property-ds.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-jndi-name-wrong-property-ds.xml	2011-01-26 15:32:43 UTC (rev 110452)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+  <datasource jndi-name="${jndi.name.wrong}" pool-name="H2DS">
+    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+    <driver-class>org.h2.Driver</driver-class>
+    <pool>
+      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
+      <min-pool-size>5</min-pool-size>
+      <!-- The maximum connections in a pool/sub-pool -->
+      <max-pool-size>10</max-pool-size>
+    </pool>
+    <security>
+      <user-name>sa</user-name>
+      <password>sa</password>
+    </security>
+  </datasource>
+
+</datasources>

Added: projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-max-pool-ds.xml
===================================================================
--- projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-max-pool-ds.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-max-pool-ds.xml	2011-01-26 15:32:43 UTC (rev 110452)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+  <datasource jndi-name="java:/H2DS" pool-name="H2DS">
+    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+    <driver-class>org.h2.Driver</driver-class>
+    <pool>
+      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
+      <min-pool-size>5</min-pool-size>
+      <!-- The maximum connections in a pool/sub-pool -->
+      <max-pool-size>${max.pool}</max-pool-size>
+    </pool>
+    <security>
+      <user-name>sa</user-name>
+      <password>sa</password>
+    </security>
+  </datasource>
+
+</datasources>

Added: projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-max-pool-wrong-ds.xml
===================================================================
--- projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-max-pool-wrong-ds.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/resources/ds/unit/replace-max-pool-wrong-ds.xml	2011-01-26 15:32:43 UTC (rev 110452)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+  <datasource jndi-name="java:/H2DS" pool-name="H2DS">
+    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+    <driver-class>org.h2.Driver</driver-class>
+    <pool>
+      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
+      <min-pool-size>5</min-pool-size>
+      <!-- The maximum connections in a pool/sub-pool -->
+      <max-pool-size>${max.pool.wrong}</max-pool-size>
+    </pool>
+    <security>
+      <user-name>sa</user-name>
+      <password>sa</password>
+    </security>
+  </datasource>
+
+</datasources>



More information about the jboss-cvs-commits mailing list