[embjopr-commits] EMBJOPR SVN: r476 - in trunk/jsfunit: testdata/connfactories and 1 other directory.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Thu May 21 11:51:42 EDT 2009


Author: fjuma
Date: 2009-05-21 11:51:42 -0400 (Thu, 21 May 2009)
New Revision: 476

Added:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryConfigurationTest.java
   trunk/jsfunit/testdata/connfactories/ChangePropertiesExistingNoTxCF-ds.xml
   trunk/jsfunit/testdata/connfactories/ChangePropertiesExistingTxCF-ds.xml
   trunk/jsfunit/testdata/connfactories/UnsetPropertiesExistingNoTxCF-ds.xml
   trunk/jsfunit/testdata/connfactories/UnsetPropertiesExistingTxCF-ds.xml
Modified:
   trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryTest.java
Log:
Adding configuration tests for connection factories.


Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryConfigurationTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryConfigurationTest.java	                        (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryConfigurationTest.java	2009-05-21 15:51:42 UTC (rev 476)
@@ -0,0 +1,251 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jopr.jsfunit.as5.connfactories;
+
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.jopr.jsfunit.exceptions.*;
+import org.jboss.jopr.jsfunit.as5.ResourceTestBase;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import java.util.Map;
+import java.util.LinkedHashMap;
+
+
+/**
+ * This class contains tests for configuring Connection Factories with JBoss AS 5.
+ * 
+ * @author Farah Juma
+ *
+ */
+
+public class ConnFactoryConfigurationTest extends ConnFactoryTest {
+
+    /*
+     * CONFIGURATION TESTS
+     */
+
+    /**
+     * Test Name: testConfigureTxConnectionFactoryChangeProperties
+     * Assertion: Verify the ability to change Tx Connection Factory property 
+     * values.
+     */
+    public void testConfigureTxConnectionFactoryChangeProperties() throws Exception {
+        String jndiName = "ChangePropertiesTxCF";
+        
+        Map<String, MetaValue> propertiesMap = createTxConnFactory(jndiName);
+        
+        // Change some property values that are already set 
+        Map<String, MetaValue> propertiesMapChanges = new LinkedHashMap<String, MetaValue>();
+        propertiesMapChanges.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(60000)));
+        propertiesMapChanges.put("no-tx-separate-pools", SimpleValueSupport.wrap(Boolean.TRUE));
+
+        changeConnFactoryProperties(jndiName, CFType.LOCAL_TX_CF, LOCAL_TX_COMPONENT_TYPE,
+                                    propertiesMapChanges, propertiesMap);
+    }
+    
+    /**
+     * Test Name: testConfigureTxConnectionFactoryChangePropertiesUsingExistingDSFile
+     * Assertion: Verify the ability to change Tx Connection Factory property 
+     * values. Use an existing -ds.xml file.
+     */
+    public void testConfigureTxConnectionFactoryChangePropertiesUsingExistingDSFile() throws Exception {
+        String jndiName = "ChangePropertiesExistingTxCF";
+        Map<String, MetaValue> propertiesMap = getComponentProperties(jndiName, LOCAL_TX_COMPONENT_TYPE);
+        
+        // Change some property values that are already set 
+        Map<String, MetaValue> propertiesMapChanges = new LinkedHashMap<String, MetaValue>();
+        propertiesMapChanges.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(60000)));
+        propertiesMapChanges.put("prefill", SimpleValueSupport.wrap(Boolean.FALSE));
+        
+        expandNavTreeArrow(CF_NAV_LABEL);
+
+        changeConnFactoryProperties(jndiName, CFType.LOCAL_TX_CF, LOCAL_TX_COMPONENT_TYPE,
+                                    propertiesMapChanges, propertiesMap);
+    }
+    
+    /**
+     * Test Name: testConfigureNoTxConnectionFactoryChangeProperties
+     * Assertion: Verify the ability to change No Tx Connection Factory property 
+     * values.
+     */
+    public void testConfigureNoTxConnectionFactoryChangeProperties() throws Exception {
+        String jndiName = "ChangePropertiesNoTxCF";
+        
+        Map<String, MetaValue> propertiesMap = createNoTxConnFactoryWithPrefill(jndiName, Boolean.TRUE);
+        
+        // Change some property values that are already set 
+        Map<String, MetaValue> propertiesMapChanges = new LinkedHashMap<String, MetaValue>();
+        propertiesMapChanges.put("max-pool-size", SimpleValueSupport.wrap(new Integer(25)));
+        propertiesMapChanges.put("prefill", SimpleValueSupport.wrap(Boolean.FALSE));
+
+        changeConnFactoryProperties(jndiName, CFType.NO_TX_CF, NO_TX_COMPONENT_TYPE,
+                                    propertiesMapChanges, propertiesMap);
+    }
+    
+    /**
+     * Test Name: testConfigureNoTxConnectionFactoryChangePropertiesUsingExistingDSFile
+     * Assertion: Verify the ability to change No Tx Connection Factory property 
+     * values. Use an existing -ds.xml file.
+     */
+    public void testConfigureNoTxConnectionFactoryChangePropertiesUsingExistingDSFile() throws Exception {
+        String jndiName = "ChangePropertiesExistingNoTxCF";
+        Map<String, MetaValue> propertiesMap = getComponentProperties(jndiName, NO_TX_COMPONENT_TYPE);
+        
+        // Change some property values that are already set 
+        Map<String, MetaValue> propertiesMapChanges = new LinkedHashMap<String, MetaValue>();
+        propertiesMapChanges.put("idle-timeout-minutes", SimpleValueSupport.wrap(new Integer(35)));
+        propertiesMapChanges.put("prefill", SimpleValueSupport.wrap(Boolean.FALSE));
+        
+        expandNavTreeArrow(CF_NAV_LABEL);
+
+        changeConnFactoryProperties(jndiName, CFType.NO_TX_CF, NO_TX_COMPONENT_TYPE,
+                                    propertiesMapChanges, propertiesMap);
+    }
+    
+    
+    /**
+     * Common code for changing the property values of a connection factory.
+     */
+    private void changeConnFactoryProperties(String jndiName, 
+                                             CFType cfType,
+                                             ComponentType componentType,
+                                             Map<String, MetaValue> propertiesMapChanges,
+                                             Map<String, MetaValue> propertiesMap) throws Exception {
+        
+        // The success message we should see
+        String expectedMessage = UPDATE_MESSAGE + cfType.getName() + " '" 
+                                 + jndiName + "'";
+        
+        // Change some property values and check that the properties of
+        // the ManagedComponent were updated appropriately
+        configureResource(CF_NAV_LABEL, cfType.getLabel(), jndiName, 
+                          propertiesMap, propertiesMapChanges, componentType,
+                          expectedMessage);
+  
+        assertTrue("The connection factory is not deployed ",
+                   isDeployed(jndiName + "-ds.xml"));
+        
+        // Clean up
+        deleteConnFactory(cfType, jndiName); 
+    }
+    
+    /**
+     * Test Name: testConfigureTxConnectionFactoryUnsetProperties
+     * Assertion: Verify the ability to unset Tx Connection Factory property values. 
+     * 
+     * Strategy: Create a new Tx Connection Factory. Unset some property values for the 
+     * connection factory. Make sure other properties for the ManagedComponent 
+     * remain unchanged.
+     */
+    public void testConfigureTxConnectionFactoryUnsetProperties() throws Exception {
+        String jndiName = "UnsetPropertiesTxCF";
+        
+        // Create the connection factory first
+        createTxConnFactory(jndiName);
+        
+        unsetConnFactoryProperties(CFType.LOCAL_TX_CF, jndiName, LOCAL_TX_COMPONENT_TYPE);
+    }
+    
+    /**
+     * Test Name: testConfigureTxConnectionFactoryUnsetPropertiesUsingExistingDSFile
+     * Assertion: Verify the ability to unset Tx Connection Factory property values. 
+     * 
+     * Strategy: Unset some property values for an existing Tx Connection Factory. 
+     * Make sure other properties for the ManagedComponent remain unchanged.
+     */
+    public void testConfigureTxConnectionFactoryUnsetPropertiesUsingExistingDSFile() throws Exception {
+        String jndiName = "UnsetPropertiesExistingTxCF";
+         
+        expandNavTreeArrow(CF_NAV_LABEL);
+        unsetConnFactoryProperties(CFType.LOCAL_TX_CF, jndiName, LOCAL_TX_COMPONENT_TYPE);
+    }
+    
+    /**
+     * Test Name: testConfigureNoTxConnectionFactoryUnsetProperties
+     * Assertion: Verify the ability to unset No Tx Connection Factory property values. 
+     * 
+     * Strategy: Create a new No Tx Connection Factory. Unset some property values for the 
+     * connection factory. Make sure other properties for the ManagedComponent 
+     * remain unchanged.
+     */
+    public void testConfigureNoTxConnectionFactoryUnsetProperties() throws Exception {
+        String jndiName = "UnsetPropertiesNoTxCF";
+        
+        // Create the connection factory first
+        createNoTxConnFactory(jndiName);
+        
+        unsetConnFactoryProperties(CFType.NO_TX_CF, jndiName, NO_TX_COMPONENT_TYPE);
+    }
+    
+    /**
+     * Test Name: testConfigureNoTxConnectionFactoryUnsetPropertiesUsingExistingDSFile
+     * Assertion: Verify the ability to unset No Tx Connection Factory property values. 
+     * 
+     * Strategy: Unset some property values for an existing No Tx Connection Factory. 
+     * Make sure other properties for the ManagedComponent remain unchanged.
+     */
+    public void testConfigureNoTxConnectionFactoryUnsetPropertiesUsingExistingDSFile() throws Exception {
+        String jndiName = "UnsetPropertiesExistingNoTxCF";
+        
+        expandNavTreeArrow(CF_NAV_LABEL);
+        unsetConnFactoryProperties(CFType.NO_TX_CF, jndiName, NO_TX_COMPONENT_TYPE);
+    }
+    
+    /**
+     * Common code for the testConfigure*UnsetProperties* tests.
+     */
+    private void unsetConnFactoryProperties(CFType cfType,
+                                            String jndiName,
+                                            ComponentType componentType) throws Exception {
+        Map<String, MetaValue> propertiesMap = getSpecificComponentProperties(jndiName, componentType);
+        
+        String[] propertiesToUnset = new String[] { "min-pool-size" }; 
+        propertiesMap.remove("min-pool-size");
+        
+        // The success message we should see
+        String expectedMessage = UPDATE_MESSAGE + cfType.getName() + " '" 
+                                 + jndiName + "'";
+        
+        unsetResourceProperties(CF_NAV_LABEL, cfType.getLabel(), 
+                                jndiName, propertiesMap, propertiesToUnset, 
+                                componentType, expectedMessage);
+        
+        assertTrue("The connection factory is not deployed ",
+                   isDeployed(jndiName + "-ds.xml"));
+     
+        // Clean up
+        deleteConnFactory(cfType, jndiName);   
+    }
+    
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite() {
+        return new TestSuite(ConnFactoryConfigurationTest.class);
+    }
+}

Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryTest.java	2009-05-21 14:47:23 UTC (rev 475)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryTest.java	2009-05-21 15:51:42 UTC (rev 476)
@@ -336,4 +336,21 @@
     protected String getConnFactoryConfigFile(String jndiName) {
         return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName + "-ds.xml";
     }
+    
+    /**
+     * Create a map of property names to property values for a particular
+     * connection factory. The desired property names are given by specificProperties.
+     * (This is useful when we need to check the values of some specific properties
+     * only - eg. the configuration tests)
+     */
+    protected Map<String, MetaValue> getSpecificComponentProperties(String componentName,
+                                                                    ComponentType type) throws Exception {
+        
+        String[] specificProperties = new String[] {"jndi-name", "rar-name", "connection-definition", 
+                                                    "min-pool-size", "max-pool-size", 
+                                                    "prefill", "idle-timeout-minutes",
+                                                    "allocation-retry", "use-java-context", 
+                                                    "no-tx-separate-pools", "blocking-timeout-millis" };
+        return super.getSpecificComponentProperties(componentName, type, specificProperties);
+    }
 }

Added: trunk/jsfunit/testdata/connfactories/ChangePropertiesExistingNoTxCF-ds.xml
===================================================================
--- trunk/jsfunit/testdata/connfactories/ChangePropertiesExistingNoTxCF-ds.xml	                        (rev 0)
+++ trunk/jsfunit/testdata/connfactories/ChangePropertiesExistingNoTxCF-ds.xml	2009-05-21 15:51:42 UTC (rev 476)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<connection-factories>
+    <no-tx-connection-factory>
+        <jndi-name>ChangePropertiesExistingNoTxCF</jndi-name>
+        <rar-name>embjoprtestadapter.rar</rar-name>
+        <use-java-context>true</use-java-context>
+        <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+        <jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
+        <min-pool-size>5</min-pool-size>
+        <max-pool-size>20</max-pool-size>
+        <blocking-timeout-millis>30000</blocking-timeout-millis>
+        <idle-timeout-minutes>30</idle-timeout-minutes>
+        <prefill>true</prefill>
+        <background-validation>false</background-validation>
+        <background-validation-millis>0</background-validation-millis>
+        <validate-on-match>true</validate-on-match>
+        <statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
+        <isSameRM-override-value>false</isSameRM-override-value>
+        <interleaving/>
+        <allocation-retry>0</allocation-retry>
+        <allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
+        <application-managed-security xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+        <metadata/>
+    </no-tx-connection-factory>
+</connection-factories>

Added: trunk/jsfunit/testdata/connfactories/ChangePropertiesExistingTxCF-ds.xml
===================================================================
--- trunk/jsfunit/testdata/connfactories/ChangePropertiesExistingTxCF-ds.xml	                        (rev 0)
+++ trunk/jsfunit/testdata/connfactories/ChangePropertiesExistingTxCF-ds.xml	2009-05-21 15:51:42 UTC (rev 476)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<connection-factories>
+    <tx-connection-factory>
+        <jndi-name>ChangePropertiesExistingTxCF</jndi-name>
+        <rar-name>embjoprtestadapter.rar</rar-name>
+        <use-java-context>true</use-java-context>
+        <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+        <jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
+        <min-pool-size>5</min-pool-size>
+        <max-pool-size>20</max-pool-size>
+        <blocking-timeout-millis>30000</blocking-timeout-millis>
+        <idle-timeout-minutes>30</idle-timeout-minutes>
+        <prefill>true</prefill>
+        <background-validation>false</background-validation>
+        <background-validation-millis>0</background-validation-millis>
+        <validate-on-match>true</validate-on-match>
+        <statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
+        <isSameRM-override-value>false</isSameRM-override-value>
+        <allocation-retry>0</allocation-retry>
+        <allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
+        <application-managed-security xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+        <metadata/>
+        <xa-resource-timeout>0</xa-resource-timeout>
+    </tx-connection-factory>
+</connection-factories>

Added: trunk/jsfunit/testdata/connfactories/UnsetPropertiesExistingNoTxCF-ds.xml
===================================================================
--- trunk/jsfunit/testdata/connfactories/UnsetPropertiesExistingNoTxCF-ds.xml	                        (rev 0)
+++ trunk/jsfunit/testdata/connfactories/UnsetPropertiesExistingNoTxCF-ds.xml	2009-05-21 15:51:42 UTC (rev 476)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<connection-factories>
+    <no-tx-connection-factory>
+        <jndi-name>UnsetPropertiesExistingNoTxCF</jndi-name>
+        <rar-name>embjoprtestadapter.rar</rar-name>
+        <use-java-context>true</use-java-context>
+        <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+        <jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
+        <min-pool-size>5</min-pool-size>
+        <max-pool-size>20</max-pool-size>
+        <blocking-timeout-millis>30000</blocking-timeout-millis>
+        <idle-timeout-minutes>30</idle-timeout-minutes>
+        <prefill>true</prefill>
+        <background-validation>false</background-validation>
+        <background-validation-millis>0</background-validation-millis>
+        <validate-on-match>true</validate-on-match>
+        <statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
+        <isSameRM-override-value>false</isSameRM-override-value>
+        <interleaving/>
+        <allocation-retry>0</allocation-retry>
+        <allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
+        <application-managed-security xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+        <metadata/>
+    </no-tx-connection-factory>
+</connection-factories>

Added: trunk/jsfunit/testdata/connfactories/UnsetPropertiesExistingTxCF-ds.xml
===================================================================
--- trunk/jsfunit/testdata/connfactories/UnsetPropertiesExistingTxCF-ds.xml	                        (rev 0)
+++ trunk/jsfunit/testdata/connfactories/UnsetPropertiesExistingTxCF-ds.xml	2009-05-21 15:51:42 UTC (rev 476)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<connection-factories>
+    <tx-connection-factory>
+        <jndi-name>UnsetPropertiesExistingTxCF</jndi-name>
+        <rar-name>embjoprtestadapter.rar</rar-name>
+        <use-java-context>true</use-java-context>
+        <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+        <jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
+        <min-pool-size>5</min-pool-size>
+        <max-pool-size>20</max-pool-size>
+        <blocking-timeout-millis>30000</blocking-timeout-millis>
+        <idle-timeout-minutes>30</idle-timeout-minutes>
+        <prefill>true</prefill>
+        <background-validation>false</background-validation>
+        <background-validation-millis>0</background-validation-millis>
+        <validate-on-match>true</validate-on-match>
+        <statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
+        <isSameRM-override-value>false</isSameRM-override-value>
+        <allocation-retry>0</allocation-retry>
+        <allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
+        <application-managed-security xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
+        <metadata/>
+        <xa-resource-timeout>0</xa-resource-timeout>
+    </tx-connection-factory>
+</connection-factories>




More information about the embjopr-commits mailing list