You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2019/05/07 16:22:15 UTC

[geode] 03/03: GEODE-6742: Rename and move ExceptionsDUnitTest to integrationTest

This is an automated email from the ASF dual-hosted git repository.

klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git

commit d315756f958e91875bbe79179de1ed37141502b6
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Mon May 6 11:04:10 2019 -0700

    GEODE-6742: Rename and move ExceptionsDUnitTest to integrationTest
    
    * Rename to TransactionTimeoutExceptionIntegrationTest.
    * Fix up the tests with catchThrowable and assertions.
    * Move cachejta.xml and newDB to TemporaryFolder.
    * Use apache commons utils instead of inlined code.
    * Use just the XAPooledDataSource.
---
 .../internal/jta/dunit/ExceptionsDUnitTest.java    | 296 ---------------------
 ...TransactionTimeoutExceptionIntegrationTest.java | 199 ++++++++++++++
 ...ionTimeoutExceptionIntegrationTest_cachejta.xml | 250 +++++++++++++++++
 3 files changed, 449 insertions(+), 296 deletions(-)

diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/ExceptionsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/ExceptionsDUnitTest.java
deleted file mode 100755
index 60cf828..0000000
--- a/geode-core/src/distributedTest/java/org/apache/geode/internal/jta/dunit/ExceptionsDUnitTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal.jta.dunit;
-
-import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
-import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource;
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.sql.DataSource;
-import javax.transaction.UserTransaction;
-
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.internal.OSProcess;
-import org.apache.geode.internal.jta.CacheUtils;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
-
-// TODO: this is a broken test that does not run
-public class ExceptionsDUnitTest extends JUnit4DistributedTestCase {
-
-  static DistributedSystem ds;
-  static Cache cache;
-  // private static String tblName;
-
-  private static String readFile(String filename) throws IOException {
-    // String lineSep = System.getProperty("\n");
-    BufferedReader br = new BufferedReader(new FileReader(filename));
-    String nextLine = "";
-    StringBuffer sb = new StringBuffer();
-    while ((nextLine = br.readLine()) != null) {
-      sb.append(nextLine);
-      //
-      // note:
-      // BufferedReader strips the EOL character.
-      //
-      // sb.append(lineSep);
-    }
-    LogWriterUtils.getLogWriter().fine("***********\n " + sb);
-    return sb.toString();
-  }
-
-  public ExceptionsDUnitTest() {
-    super();
-  }
-
-  private static String modifyFile(String str) throws IOException {
-    String search = "<jndi-binding type=\"XAPooledDataSource\"";
-    String last_search = "</jndi-binding>";
-    String newDB = "newDB_" + OSProcess.getId();
-    String jndi_str =
-        "<jndi-binding type=\"XAPooledDataSource\" jndi-name=\"XAPooledDataSource\"          jdbc-driver-class=\"org.apache.derby.jdbc.EmbeddedDriver\" init-pool-size=\"5\" max-pool-size=\"5\" idle-timeout-seconds=\"600\" blocking-timeout-seconds=\"6\" login-timeout-seconds=\"2\" conn-pooled-datasource-class=\"org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource\" xa-datasource-class=\"org.apache.derby.jdbc.EmbeddedXADataSource\" user-name=\"mitul\" password=\"83f0069202c571faf1ae6c42b [...]
-            + newDB + ";create=true\" >";
-    String config_prop = "<config-property>"
-        + "<config-property-name>description</config-property-name>"
-        + "<config-property-type>java.lang.String</config-property-type>"
-        + "<config-property-value>hi</config-property-value>" + "</config-property>"
-        + "<config-property>" + "<config-property-name>user</config-property-name>"
-        + "<config-property-type>java.lang.String</config-property-type>"
-        + "<config-property-value>jeeves</config-property-value>" + "</config-property>"
-        + "<config-property>" + "<config-property-name>password</config-property-name>"
-        + "<config-property-type>java.lang.String</config-property-type>"
-        + "<config-property-value>83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a</config-property-value>        "
-        + "</config-property>" + "<config-property>"
-        + "<config-property-name>databaseName</config-property-name>"
-        + "<config-property-type>java.lang.String</config-property-type>"
-        + "<config-property-value>" + newDB + "</config-property-value>" + "</config-property>\n";
-    String new_str = jndi_str + config_prop;
-    /*
-     * String new_str = " <jndi-binding type=\"XAPooledDataSource\" jndi-name=\"XAPooledDataSource\"
-     * jdbc-driver-class=\"org.apache.derby.jdbc.EmbeddedDriver\"
-     * init-pool-size=\"5\" max-pool-size=\"5\" idle-timeout-seconds=\"600\"
-     * blocking-timeout-seconds=\"6\" login-timeout-seconds=\"2\"
-     * conn-pooled-datasource-class=\"org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource\"
-     * xa-datasource-class=\"org.apache.derby.jdbc.EmbeddedXADataSource\" user-name=\"mitul\"
-     * password=\"83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a\"
-     * connection-url=\"jdbc:derby:"+newDB+";create=true\" > <property
-     * key=\"description\" value=\"hi\"/> <property key=\"databaseName\"
-     * value=\""+newDB+"\"/> <property key=\"user\" value=\"mitul\"/> <property key=\"password\"
-     * value=\"83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a\"/>";
-     */
-    int n1 = str.indexOf(search);
-    LogWriterUtils.getLogWriter().fine("Start Index = " + n1);
-    int n2 = str.indexOf(last_search, n1);
-    StringBuffer sbuff = new StringBuffer(str);
-    LogWriterUtils.getLogWriter().fine("END Index = " + n2);
-    String modified_str = sbuff.replace(n1, n2, new_str).toString();
-    return modified_str;
-  }
-
-  public static void init() throws Exception {
-    Properties props = new Properties();
-    int pid = OSProcess.getId();
-    String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath();
-    /** * Return file as string and then modify the string accordingly ** */
-    String file_as_str = readFile(
-        createTempFileFromResource(CacheUtils.class, "cachejta.xml")
-            .getAbsolutePath());
-    file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid);
-    String modified_file_str = modifyFile(file_as_str);
-    FileOutputStream fos = new FileOutputStream(path);
-    BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fos));
-    wr.write(modified_file_str);
-    wr.flush();
-    wr.close();
-    props.setProperty(CACHE_XML_FILE, path);
-    // String tableName = "";
-    // props.setProperty(DistributionConfig.ConfigurationProperties.MCAST_PORT, "10339");
-    try {
-      // ds = DistributedSystem.connect(props);
-      ds = (new ExceptionsDUnitTest()).getSystem(props);
-      cache = CacheFactory.create(ds);
-    } catch (Exception e) {
-      e.printStackTrace(System.err);
-      throw new Exception("" + e);
-    }
-  }
-
-  public static Cache getCache() {
-    return cache;
-  }
-
-  public static void startCache() {
-    try {
-      if (cache == null || cache.isClosed()) {
-        cache = CacheFactory.create(ds);
-      }
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-  }
-
-  public static void closeCache() {
-    try {
-      if (cache != null && !cache.isClosed()) {
-        cache.close();
-      }
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    try {
-      if (ds != null)
-        ds.disconnect();
-    } catch (Exception e) {
-      LogWriterUtils.getLogWriter().fine("Error in disconnecting from Distributed System");
-    }
-  }
-
-  @Override
-  public final void postSetUp() throws Exception {
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    vm0.invoke(() -> ExceptionsDUnitTest.init());
-  }
-
-  @Override
-  public final void preTearDown() throws Exception {
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    vm0.invoke(() -> ExceptionsDUnitTest.closeCache());
-  }
-
-  public static void testBlockingTimeOut() {
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    vm0.invoke(() -> ExceptionsDUnitTest.runTest1());
-  }
-
-  public static void testLoginTimeOut() {
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    vm0.invoke(() -> ExceptionsDUnitTest.runTest2());
-  }
-
-  public static void testTransactionTimeOut() {
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    vm0.invoke(() -> ExceptionsDUnitTest.runTest3());
-  }
-
-  public static void runTest1() throws Exception {
-    boolean exceptionOccurred = false;
-    try {
-      Context ctx = cache.getJNDIContext();
-      DataSource ds1 = null;
-      DataSource ds2 = null;
-      ds1 = (DataSource) ctx.lookup("java:/XAPooledDataSource");
-      ds2 = (DataSource) ctx.lookup("java:/SimpleDataSource");
-      ds2.getConnection();
-      ds1 = (DataSource) ctx.lookup("java:/XAPooledDataSource");
-      UserTransaction utx = (UserTransaction) ctx.lookup("java:/UserTransaction");
-      utx.begin();
-      ds1.getConnection();
-      Thread.sleep(8000);
-      try {
-        utx.commit();
-      } catch (Exception e) {
-        exceptionOccurred = true;
-      }
-      if (!exceptionOccurred)
-        fail("Exception did not occur on commit although was supposed" + "occur");
-    } catch (Exception e) {
-      LogWriterUtils.getLogWriter().fine("Exception caught in runTest1 due to : " + e);
-      fail("failed in runTest1 due to " + e);
-    }
-  }
-
-  public static void runTest2() throws Exception {
-    boolean exceptionOccurred1 = false;
-    boolean exceptionOccurred2 = false;
-    try {
-      Context ctx = cache.getJNDIContext();
-      DataSource ds1 = null;
-      DataSource ds2 = null;
-      ds1 = (DataSource) ctx.lookup("java:/XAPooledDataSource");
-      ds2 = (DataSource) ctx.lookup("java:/SimpleDataSource");
-      ds2.getConnection();
-      ds1.getConnection();
-      ds1.getConnection();
-      ds1.getConnection();
-      ds1.getConnection();
-      ds1.getConnection();
-      UserTransaction utx = (UserTransaction) ctx.lookup("java:/UserTransaction");
-      utx.begin();
-      try {
-        ds1.getConnection();
-        Thread.sleep(8000);
-      } catch (SQLException e) {
-        exceptionOccurred1 = true;
-      }
-      try {
-        utx.commit();
-      } catch (Exception e) {
-        exceptionOccurred2 = true;
-      }
-      if (!exceptionOccurred1)
-        fail("Exception (Login-Time-Out)did not occur although was supposed" + "to occur");
-      if (exceptionOccurred2)
-        fail("Exception did occur on commit, although was not supposed" + "to occur");
-    } catch (Exception e) {
-      fail("failed in runTest2 due to " + e);
-    }
-  }
-
-  public static void runTest3() throws Exception {
-    boolean exceptionOccurred = false;
-    try {
-      Context ctx = cache.getJNDIContext();
-      DataSource ds1 = null;
-      DataSource ds2 = null;
-      ds1 = (DataSource) ctx.lookup("java:/XAPooledDataSource");
-      ds2 = (DataSource) ctx.lookup("java:/SimpleDataSource");
-      ds2.getConnection();
-      UserTransaction utx = (UserTransaction) ctx.lookup("java:/UserTransaction");
-      utx.begin();
-      utx.setTransactionTimeout(2);
-      ds1.getConnection();
-      Thread.sleep(4000);
-      try {
-        utx.commit();
-      } catch (Exception e) {
-        exceptionOccurred = true;
-      }
-      if (!exceptionOccurred)
-        fail("Exception (Transaction-Time-Out)did not occur although was supposed" + "to occur");
-    } catch (Exception e) {
-      fail("failed in runTest3 due to " + e);
-    }
-  }
-}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/TransactionTimeoutExceptionIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/TransactionTimeoutExceptionIntegrationTest.java
new file mode 100755
index 0000000..b13f9f5
--- /dev/null
+++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/jta/TransactionTimeoutExceptionIntegrationTest.java
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.jta;
+
+import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
+import static org.apache.geode.test.util.ResourceUtils.getResource;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowable;
+
+import java.io.File;
+import java.nio.charset.Charset;
+import java.sql.SQLException;
+import java.time.Duration;
+import java.util.Properties;
+import java.util.regex.Pattern;
+
+import javax.naming.Context;
+import javax.sql.DataSource;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+import javax.transaction.xa.XAException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.internal.process.ProcessUtils;
+
+/**
+ * Fixed up (best as possible) and re-enabled JTA tests from ExceptionsDUnitTest. Treat these as
+ * characterization tests because I think some of this behavior is not strictly correct.
+ */
+public class TransactionTimeoutExceptionIntegrationTest {
+
+  private static final Pattern NEW_DB_PATTERN = Pattern.compile("newDB");
+  private static final int DATA_SOURCE_POOL_SIZE = 2;
+  private static final int BLOCKING_TIMEOUT_SECONDS = 6;
+  private static final int IDLE_TIMEOUT_SECONDS = 600;
+  private static final int LOGIN_TIMEOUT_SECONDS = 2;
+  private static final int TRANSACTION_TIMEOUT_SECONDS = 2;
+
+  private Cache cache;
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Before
+  public void setUp() throws Exception {
+    String derbySystemHome = temporaryFolder.newFolder("derby").getAbsolutePath();
+    System.setProperty("derby.system.home", derbySystemHome);
+
+    String newDB = "newDB_" + ProcessUtils.identifyPid();
+
+    String input =
+        IOUtils.toString(getResource("TransactionTimeoutExceptionIntegrationTest_cachejta.xml"),
+            Charset.defaultCharset());
+    input = NEW_DB_PATTERN.matcher(input).replaceAll(newDB);
+    String output = modifyCacheJtaXml(input, newDB);
+    File cacheJtaXmlFile = temporaryFolder.newFile("cachejta.xml");
+
+    FileUtils.writeStringToFile(cacheJtaXmlFile, output, Charset.defaultCharset());
+
+    Properties props = new Properties();
+    props.setProperty(CACHE_XML_FILE, cacheJtaXmlFile.getAbsolutePath());
+
+    cache = new CacheFactory(props).create();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    cache.close();
+  }
+
+  @Test
+  public void testBlockingTimeOut() throws Exception {
+    Context jndiContext = cache.getJNDIContext();
+    DataSource dataSource = (DataSource) jndiContext.lookup("java:/XAPooledDataSource");
+    UserTransaction utx = (UserTransaction) jndiContext.lookup("java:/UserTransaction");
+    utx.begin();
+    dataSource.getConnection();
+
+    // sleep longer than the blocking timeout (nothing exposed to await on)
+    Thread.sleep(Duration.ofSeconds(BLOCKING_TIMEOUT_SECONDS * 2).toMillis());
+
+    Throwable thrown = catchThrowable(() -> utx.commit());
+
+    // NOTE: XAException is double-wrapped in SystemException (probably unintentional)
+    assertThat(thrown)
+        .isInstanceOf(SystemException.class);
+    assertThat(thrown.getCause())
+        .isInstanceOf(SystemException.class)
+        .hasCauseInstanceOf(XAException.class)
+        .hasMessageContaining("No current connection");
+  }
+
+  @Test
+  public void testLoginTimeOut() throws Exception {
+    Context jndiContext = cache.getJNDIContext();
+    DataSource dataSource = (DataSource) jndiContext.lookup("java:/XAPooledDataSource");
+    for (int i = 0; i < DATA_SOURCE_POOL_SIZE; i++) {
+      dataSource.getConnection();
+    }
+
+    Throwable thrown = catchThrowable(() -> dataSource.getConnection());
+
+    assertThat(thrown)
+        .isInstanceOf(SQLException.class)
+        .hasMessageContaining("Login time-out exceeded");
+  }
+
+  @Test
+  public void testTransactionTimeOut() throws Exception {
+    Context jndiContext = cache.getJNDIContext();
+    DataSource dataSource = (DataSource) jndiContext.lookup("java:/XAPooledDataSource");
+    dataSource.getConnection();
+    UserTransaction utx = (UserTransaction) jndiContext.lookup("java:/UserTransaction");
+    utx.begin();
+    utx.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS);
+
+    // sleep longer than the transaction timeout (nothing exposed to await on)
+    Thread.sleep(Duration.ofSeconds(TRANSACTION_TIMEOUT_SECONDS * 2).toMillis());
+
+    Throwable thrown = catchThrowable(() -> utx.commit());
+
+    assertThat(thrown)
+        .isInstanceOf(IllegalStateException.class)
+        .hasMessageContaining("Transaction is null, cannot commit a null transaction");
+  }
+
+  private String modifyCacheJtaXml(String jtaConfig, String newDB) {
+    String begin = "<jndi-binding type=\"XAPooledDataSource\"";
+    String end = "</jndi-binding>";
+    String jndiBinding =
+        "<jndi-binding type=\"XAPooledDataSource\" " +
+            "jndi-name=\"XAPooledDataSource\" " +
+            "jdbc-driver-class=\"org.apache.derby.jdbc.EmbeddedDriver\" " +
+            "init-pool-size=\"" + DATA_SOURCE_POOL_SIZE + "\" " +
+            "max-pool-size=\"" + DATA_SOURCE_POOL_SIZE + "\" " +
+            "idle-timeout-seconds=\"" + IDLE_TIMEOUT_SECONDS + "\" " +
+            "blocking-timeout-seconds=\"" + BLOCKING_TIMEOUT_SECONDS + "\" " +
+            "login-timeout-seconds=\"" + LOGIN_TIMEOUT_SECONDS + "\" " +
+            "conn-pooled-datasource-class=\"org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource\" "
+            +
+            "xa-datasource-class=\"org.apache.derby.jdbc.EmbeddedXADataSource\" " +
+            "user-name=\"mitul\" " +
+            "password=\"83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a\" " +
+            "connection-url=\"jdbc:derby:" + newDB + ";create=true\" >";
+    String configProperty =
+        "<config-property>" +
+            "<config-property-name>description</config-property-name>" +
+            "<config-property-type>java.lang.String</config-property-type>" +
+            "<config-property-value>hi</config-property-value>" +
+            "</config-property>" +
+            "<config-property>" +
+            "<config-property-name>user</config-property-name>" +
+            "<config-property-type>java.lang.String</config-property-type>" +
+            "<config-property-value>jeeves</config-property-value>" +
+            "</config-property>" +
+            "<config-property>" +
+            "<config-property-name>password</config-property-name>" +
+            "<config-property-type>java.lang.String</config-property-type>" +
+            "<config-property-value>" +
+            "83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a" +
+            "</config-property-value>" +
+            "</config-property>" +
+            "<config-property>" +
+            "<config-property-name>databaseName</config-property-name>" +
+            "<config-property-type>java.lang.String</config-property-type>" +
+            "<config-property-value>" + newDB + "</config-property-value>" +
+            "</config-property>" +
+            System.lineSeparator();
+
+    String modifiedConfig = jndiBinding + configProperty;
+
+    int indexOfBegin = jtaConfig.indexOf(begin);
+    int indexOfEnd = jtaConfig.indexOf(end, indexOfBegin);
+
+    return new StringBuilder(jtaConfig).replace(indexOfBegin, indexOfEnd, modifiedConfig)
+        .toString();
+  }
+}
diff --git a/geode-core/src/integrationTest/resources/org/apache/geode/internal/jta/TransactionTimeoutExceptionIntegrationTest_cachejta.xml b/geode-core/src/integrationTest/resources/org/apache/geode/internal/jta/TransactionTimeoutExceptionIntegrationTest_cachejta.xml
new file mode 100644
index 0000000..fc26388
--- /dev/null
+++ b/geode-core/src/integrationTest/resources/org/apache/geode/internal/jta/TransactionTimeoutExceptionIntegrationTest_cachejta.xml
@@ -0,0 +1,250 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+  ~ agreements. See the NOTICE file distributed with this work for additional information regarding
+  ~ copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance with the License. You may obtain a
+  ~ copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software distributed under the License
+  ~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+  ~ or implied. See the License for the specific language governing permissions and limitations under
+  ~ the License.
+  -->
+<!DOCTYPE cache PUBLIC
+        "-//GemStone Systems, Inc.//GemFire Declarative Caching 7.0//EN"
+        "http://www.gemstone.com/dtd/cache7_0.dtd">
+<cache lock-lease="120" lock-timeout="60" search-timeout="300">
+    <vm-root-region name="root">
+        <region-attributes scope="distributed-no-ack" data-policy="normal" initial-capacity="16" load-factor="0.75" concurrency-level="16" statistics-enabled="true">
+            <region-time-to-live>
+                <expiration-attributes timeout="0" action="invalidate"/>
+            </region-time-to-live>
+            <region-idle-time>
+                <expiration-attributes timeout="0" action="invalidate"/>
+            </region-idle-time>
+            <entry-time-to-live>
+                <expiration-attributes timeout="0" action="invalidate"/>
+            </entry-time-to-live>
+            <entry-idle-time>
+                <expiration-attributes timeout="0" action="invalidate"/>
+            </entry-idle-time>
+        </region-attributes>
+        <entry>
+            <key>
+                <string>Application Version</string>
+            </key>
+            <value>
+                <string>1.0</string>
+            </value>
+        </entry>
+    </vm-root-region>
+
+    <jndi-bindings>
+        <jndi-binding type="SimpleDataSource" jndi-name="SimpleDataSource"
+                      jdbc-driver-class="org.apache.derby.jdbc.EmbeddedDriver"
+                      init-pool-size="2" max-pool-size="7"
+                      idle-timeout-seconds="40"
+                      blocking-timeout-seconds="40"
+                      login-timeout-seconds="60"
+                      conn-pooled-datasource-class="org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource"
+                      xa-datasource-class="org.apache.derby.jdbc.EmbeddedXADataSource"
+                      user-name="mitul"
+                      password="83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a"
+                      connection-url="jdbc:derby:newDB;create=true">
+            <config-property>
+                <config-property-name>description</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>hi</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>databaseName</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>newDB</config-property-value>
+            </config-property>
+        </jndi-binding>
+
+        <jndi-binding type="PooledDataSource" jndi-name="PooledDataSource"
+                      jdbc-driver-class="org.apache.derby.jdbc.EmbeddedDriver"
+                      init-pool-size="2" max-pool-size="7"
+                      idle-timeout-seconds="20"
+                      blocking-timeout-seconds="20"
+                      login-timeout-seconds="30"
+                      conn-pooled-datasource-class="org.apache.geode.internal.jta.CacheJTAPooledDataSourceFactory"
+                      xa-datasource-class="org.apache.derby.jdbc.EmbeddedXADataSource"
+                      user-name="mitul"
+                      password="83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a"
+                      connection-url="jdbc:derby:newDB;create=true">
+
+            <config-property>
+                <config-property-name>description</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>hi</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>user</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>mitul</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>password</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>databaseName</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>newDB</config-property-value>
+            </config-property>
+
+        </jndi-binding>
+
+        <jndi-binding type="XAPooledDataSource" jndi-name="XAPooledDataSource"
+                      jdbc-driver-class="org.apache.derby.jdbc.EmbeddedDriver"
+                      init-pool-size="2" max-pool-size="7"
+                      idle-timeout-seconds="20"
+                      blocking-timeout-seconds="20"
+                      login-timeout-seconds="30"
+                      conn-pooled-datasource-class="org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource"
+                      xa-datasource-class="org.apache.derby.jdbc.EmbeddedXADataSource"
+                      user-name="mitul"
+                      password="83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a"
+                      connection-url="jdbc:derby:newDB;create=true">
+            <config-property>
+                <config-property-name>description</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>hi</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>user</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>mitul</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>password</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>databaseName</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>newDB</config-property-value>
+            </config-property>
+
+        </jndi-binding>
+        <jndi-binding type="XAPooledDataSource" jndi-name="XAHydraPooledDataSource"
+                      jdbc-driver-class="org.apache.derby.jdbc.EmbeddedDriver"
+                      init-pool-size="2" max-pool-size="30"
+                      idle-timeout-seconds="300"
+                      blocking-timeout-seconds="300"
+                      login-timeout-seconds="50"
+                      conn-pooled-datasource-class="org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource"
+                      xa-datasource-class="org.apache.derby.jdbc.EmbeddedXADataSource"
+                      user-name="mitul"
+                      password="83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a"
+                      connection-url="jdbc:derby:newDB;create=true">
+            <config-property>
+                <config-property-name>description</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>hi</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>user</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>mitul</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>password</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>databaseName</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>newDB</config-property-value>
+            </config-property>
+
+        </jndi-binding>
+
+        <jndi-binding type="XAPooledDataSource" jndi-name="XAMultiThreadedDataSource"
+                      jdbc-driver-class="org.apache.derby.jdbc.EmbeddedDriver"
+                      init-pool-size="2" max-pool-size="5"
+                      idle-timeout-seconds="300"
+                      blocking-timeout-seconds="300"
+                      login-timeout-seconds="300"
+                      conn-pooled-datasource-class="org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource"
+                      xa-datasource-class="org.apache.derby.jdbc.EmbeddedXADataSource"
+                      user-name="mitul"
+                      password="83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a"
+                      connection-url="jdbc:derby:newDB;create=true">
+            <config-property>
+                <config-property-name>description</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>hi</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>user</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>mitul</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>password</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a</config-property-value>
+            </config-property>
+
+            <config-property>
+                <config-property-name>databaseName</config-property-name>
+                <config-property-type>java.lang.String</config-property-type>
+                <config-property-value>newDB</config-property-value>
+            </config-property>
+
+        </jndi-binding>
+    </jndi-bindings>
+</cache>
+<!--
+Binding TransactionManager
+Case 1: Use of GemFire JNDI Context
+GemFire TransactionManager will be bound to the GemFire JNDI tree.
+
+Case 2: Application Server JNDI Context
+    If a TransactionManager is associated with Application Server JNDI tree (if exists),
+    the GemFire system will make reference of that. Otherwise GemFire TransactionManager
+    will be bound to the Application Server JNDI tree.
+
+Binding UserTransaction
+    UserTransaction will be bound to same JNDI tree where GemFire TransactionManager is bound.
+  If an Application Server TransactionManager bound to Application Server JNDI tree
+  GemFire UserTransaction will not be bound at all.
+
+Lookup for UserTransaction
+
+Case 1: Use of Application Server JNDI tree and Application Server TransactionManager is available.
+    GemFire UserTransaction will not come into picture.
+    Should be referred as per Application Server specification.
+Case 2: In any other case (Includes use of GemFire JNDI tree, Application Server JNDI tree with
+GemFire TransactionManager)
+    UserTransaction will be looked up with java:/UserTransaction
+
+
+Binding and Lookup of DataSource
+ In all scenario, the GemFire DataSource will be bound to the available JNDI tree.
+ jndi-name attribute of jndi-binding element is key binding parameters.
+ if the value of jndi-name is aDataSource, it will be bound as java:/aDataSource.
+ The type attribute of jndi-binding element should be SimpleDataSource, PooledDataSource
+ or XAPooledDataSource.
+-->