EMBJOPR SVN: r126 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-01-28 16:50:27 -0500 (Wed, 28 Jan 2009)
New Revision: 126
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
Log:
- Added some logging - records go to JBoss AS log
- Changed signature of some test methods - they throw AssertException. More about that on mail / IRC
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-28 21:41:11 UTC (rev 125)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-28 21:50:27 UTC (rev 126)
@@ -39,7 +39,6 @@
import javax.naming.Context;
import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.logging.Level;
import javax.management.*;
/**
@@ -56,6 +55,7 @@
protected enum DatasourceType {
// Some of these values are specific for AS 5. TODO: Think up some way to split nicely.
+ // // label serviceName xml-element-name template <select>
LOCAL_TX_DATASOURCE("Local TX Datasources", "LocalTxCM", "local-tx-datasource", "default__Local TX Datasource"),
NO_TX_DATASOURCE( "No TX Datasources", "NoTxCM", "no-tx-datasource", "default__No TX Datasource"),
XA_DATASOURCE( "XA Datasources", "XATxCM", "xa-datasource", "default__XA Datasource");
@@ -70,6 +70,9 @@
protected final String xmlElementName;
public String getXmlElementName() { return xmlElementName; }
+ // Also server as value for HTML Radio for Datasource type selection.
+ public String getHtmlRadioValue() { return xmlElementName; }
+
protected final String templateHtmlSelectValue;
public String getTemplateHtmlSelectValue() { return templateHtmlSelectValue; }
@@ -152,7 +155,7 @@
/**
* Delete the datasource given by datasourceName.
*/
- protected abstract void deleteDatasource(String datasourceName) throws IOException;
+ protected abstract void deleteDatasource(String datasourceName) throws IOException, AssertException;
/**
* Use JMX to check if the datasource given by datasourceName is deployed.
@@ -186,12 +189,18 @@
// Get the first and only one MBean returned.
ObjectName deploymentMBean = (ObjectName)dsMBeans.iterator().next(); /**/
- ObjectName deploymentMBean = new ObjectName( this.getMBeanName(jndiName, dsMBeanServices[i]) );
+ String mBeanName = this.getMBeanName(jndiName, dsMBeanServices[i]);
+ log.info("Looking for MBean "+mBeanName+"...");
+ ObjectName deploymentMBean = new ObjectName( mBeanName );
///Object state = jmxServer.getAttribute(deploymentMBean, "State");
///if(!("DEPLOYED".equals(state.toString()))) return false;
- if( !this.isMBeanStateDeployed( deploymentMBean ) )
+ if( this.isMBeanStateDeployedImpl( deploymentMBean ) ){
+ log.info("Found, OK");
+ }else{
+ log.info("Not found.");
return false;
+ }
}
@@ -209,7 +218,8 @@
*/
protected boolean checkProperties(String jndiName,
DatasourceType datasourceType,
- Map<String, String> expectedValuesMap) {
+ Map<String, String> expectedValuesMap)
+ {
Map<String, String> actualValuesMap = new HashMap<String, String>();
@@ -218,7 +228,8 @@
// Parse the *-ds.xml file; create appropriate file name for AS 4 or 5.
File file = new File(this.getDatasourceConfigFile(jndiName));
-
+ log.info("Examining: "+file.getAbsolutePath());
+
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(file);
@@ -236,22 +247,25 @@
actualValuesMap.put(property.getName(), property.getValue());
}
- // Compare the actual values to the expected ones
- itr = expectedValuesMap.keySet().iterator();
- while(itr.hasNext()) {
- String key = (String)itr.next();
- if(actualValuesMap.containsKey(key)) {
- if(!expectedValuesMap.get(key).equals(actualValuesMap.get(key))) {
- return false; // incorrect value
- }
- } else {
- return false; // value was not set
- }
- }
+ // Compare the actual values to the expected ones.
+ for( String key : expectedValuesMap.keySet() ){
+ if(!actualValuesMap.containsKey(key)){
+ // Value was not set.
+ log.fatal("Property '"+key+"' is not found.");
+ return false;
+ }
+
+ if(!expectedValuesMap.get(key).equals(actualValuesMap.get(key))) {
+ // Incorrect value.
+ log.fatal("Property '"+key+"' has unexpected value: '"+actualValuesMap.get(key)+"'");
+ return false;
+ }
+ }
return true;
} catch (Exception e) {
+ log.fatal("Config file check failed: "+e.getMessage());
throw new RuntimeException(e);
}
}
@@ -298,7 +312,7 @@
* Create a new datasource. Leave some property values, that aren't
* required, unset.
*/
- public void testCreateDatasource() throws IOException {
+ public void testCreateDatasource() throws IOException, AssertException {
// The properties we want to configure
@@ -538,7 +552,7 @@
/**
* Check that the metrics are correct after creating a new datasource.
*/
- public void testMetricsAfterDatasourceCreation() throws IOException {
+ public void testMetricsAfterDatasourceCreation() throws IOException, AssertException {
// Min pool size will be 5, max pool size will be 20
Map<String, String> propertiesMap = createLocalTXDatasource("MetricsCreateDS");
@@ -807,6 +821,8 @@
protected abstract String getMBeanName( String jndiName, String serviceName );
+
+
/**
* This method is wrapper that handles JMX exceptions at Base level.
* Intended to keep AS-version-specific method, isMBeanStateDeployedImpl(), as small as possible.
@@ -823,16 +839,16 @@
// This super-exception includes JMX operation failures, including:
// AttributeNotFoundException, InstanceNotFoundException, MalformedObjectNameException, ServiceNotFoundException
catch (OperationsException ex) {
- log.log(Level.WARNING, "JMX operation error when retrieving MBean attribute.", ex);
+ log.warn("JMX operation error when retrieving MBean attribute.", ex);
return false;
}
// All other JMX failures...
catch (JMException ex) {
- log.log(Level.WARNING, "JMX error when retrieving MBean attribute.", ex);
+ log.warn("JMX error when retrieving MBean attribute.", ex);
return false;
}
catch (IOException ex) {
- log.log(Level.SEVERE, "I/O error when retrieving MBean attribute.", ex);
+ log.warn("I/O error when retrieving MBean attribute.", ex);
return false;
}
15 years, 11 months
EMBJOPR SVN: r125 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-01-28 16:41:11 -0500 (Wed, 28 Jan 2009)
New Revision: 125
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
- setFormInput() supports multi-radios (not only Yes / No )
- XPath helper methods changed - find... returns null, get... thows exception when no element found
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-01-28 15:03:55 UTC (rev 124)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-01-28 21:41:11 UTC (rev 125)
@@ -23,15 +23,12 @@
package org.jboss.jopr.jsfunit;
import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.*;
import java.io.IOException;
import java.util.*;
-import java.util.logging.Logger;
-import javax.naming.NamingException;
-import javax.naming.InitialContext;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.jboss.logging.*;
import org.apache.cactus.ServletTestCase;
import org.jboss.jsfunit.framework.WebClientSpec;
import org.jboss.jsfunit.jsfsession.JSFClientSession;
@@ -42,7 +39,7 @@
import org.jboss.mx.util.MBeanServerLocator;
//import org.jboss.jmx.adaptor.rmi.RMIAdaptor; // Needs dependency: jmx-adaptor-plugin
import java.util.regex.Pattern;
-import java.util.regex.Matcher;
+import javax.xml.xpath.XPathException;
@@ -256,19 +253,34 @@
* Set the given input box or "Yes/No" radio button to the given value.
*/
public void setFormInput(HtmlInput input, String propertyValue) {
+
boolean isRadioButton = input.getTypeAttribute().equals("radio");
- String id = input.getId();
-
if(isRadioButton) {
// Check the appropriate button
if(propertyValue.equals("false")) {
- // Get the "No" radio button
- input = (HtmlInput)client.getElement(id.substring(0,
- id.lastIndexOf(":"))
- + ":1");
+ // Get the "No" radio button.
+ String id = input.getId();
+ input = (HtmlInput)client.getElement(
+ id.substring(0, id.lastIndexOf(":")) + ":1");
}
+ else{
+
+ // Multiple choices - find the appropriate radio button.
+ String inputName = input.getNameAttribute();
+ DomNode node = input.getFirstByXPath(
+ "./ancestor::form//input[@name='"+inputName+"' and @value='"+propertyValue+"']");
+ //DomNode node = input.getOneHtmlElementByAttribute("input", "value", propertyValue);
+
+ if( null == node ){
+ throw new IllegalArgumentException(
+ "HTML Radio input of name '"+inputName+"' and value '"+propertyValue+"' not found.");
+ }
+
+ input = (HtmlInput)node;
+
+ }
input.setChecked(Boolean.TRUE);
} else {
@@ -284,13 +296,13 @@
String expectedServerMsg,
boolean isErrorMsg)
{
- assertTrue("Expected message not found on page.",
- client.getPageAsText().contains(expectedClientMsg));
-
- assertTrue("Expected message not found in faces messages.",
+
+ // In Faces
+
+ assertTrue("Expected message not found in faces messages (no messages in Faces).",
server.getFacesMessages().hasNext());
- FacesMessage message = server.getFacesMessages().next();
+ FacesMessage message = server.getFacesMessages().next();
if(isErrorMsg) {
assertTrue(FacesMessage.SEVERITY_ERROR.equals(message.getSeverity()));
} else {
@@ -299,9 +311,15 @@
assertTrue("Expected message: "+expectedServerMsg+" Actual: "+message.getDetail(),
message.getDetail().contains(expectedServerMsg));
- }
+ // On page
+
+ assertTrue("Expected message not found on page: "+expectedClientMsg,
+ client.getPageAsText().contains(expectedClientMsg));
+ }
+
+
/**
* Check that the given messages occur on the client side and server side.
* Given strings are treated as regular expressions to match.
@@ -310,9 +328,7 @@
String expectedServerMsgRE,
boolean isErrorMsg)
{
- String pageText = client.getPageAsText();
- assertTrue( Pattern.matches(expectedClientMsgRE, pageText) );
-
+ // In Faces
assertTrue(server.getFacesMessages().hasNext());
FacesMessage message = server.getFacesMessages().next();
@@ -323,6 +339,12 @@
}
assertTrue( Pattern.matches( expectedServerMsgRE, message.getDetail() ) );
+
+ // On page
+
+ String pageText = client.getPageAsText();
+ assertTrue( Pattern.matches(expectedClientMsgRE, pageText) );
+
}
@@ -405,31 +427,49 @@
public List<? extends HtmlElement> getElementsByXPath(
HtmlElement xPathContextElement, String sXPath )
throws AssertException
- {
+ {
if( null == xPathContextElement ){
throw new AssertException("Given XPath context element is null.");
}
return (List<? extends HtmlElement>) xPathContextElement.getByXPath(sXPath);
- }
+ }
/**
* Returns the first element in the list returned by getElementsByXPath(String sXPath ).
* @param sXPath
- * @return
+ * @returns The first of elements found, or null when XPath expr. found none.
*/
- public HtmlElement getFirstElementByXPath( HtmlElement xPathContext, String sXPath ) throws AssertException {
+ public HtmlElement findFirstElementByXPath( HtmlElement xPathContext, String sXPath ) throws AssertException {
List<? extends HtmlElement> elementsByXPath = getElementsByXPath(xPathContext, sXPath);
if( elementsByXPath.size() == 0 ){
- throw new RuntimeException("XPath expression found no elements: "+sXPath);
+ //
// Exception is better - will get the stack trace.
//fail("XPath expression found no elements: "+sXPath);
+ return null;
}
return elementsByXPath.get(0);
}
/**
+ * The same as findFirstElementByXPath(), only throws an exception when no element was found.
+ * Returns the first element in the list returned by getElementsByXPath(String sXPath ).
+ * @param sXPath
+ * @returns The first of elements found.
+ * @throws XPathException when the expression found no elements.
+ */
+ public HtmlElement getFirstElementByXPath( HtmlElement xPathContext, String sXPath )
+ throws AssertException
+ {
+ HtmlElement e = findFirstElementByXPath(xPathContext, sXPath);
+ if( null == e ){
+ throw new AssertException("XPath expression found no elements: "+sXPath);
+ }
+ return e;
+ }
+
+ /**
* Convenience method - calls getFirstElementByXPath() with content div as context.
* @param sXPath
* @return
@@ -462,6 +502,7 @@
}
}
+
/**
* Retrieves a named row of a table in the "right side of the page".
* Supposes that the table is in the "tabmenubox" or "notabmenubox" div.
@@ -471,16 +512,18 @@
* @throws org.jboss.jopr.jsfunit.AssertException
*/
public HtmlTableRow getRowByName(String sRowName) throws AssertException {
- HtmlTableRow row = (HtmlTableRow) getFirstElementByXPath(
- getTabMenuBoxElement(),
- ".//td[contains(text(),'"+sRowName+"')]/ancestor::tr"
- );
+
+ HtmlTableRow row = (HtmlTableRow) getFirstElementByXPath(
+ getTabMenuBoxElement(),
+ ".//td[contains(string(),'"+sRowName+"')]/ancestor::tr" );
+
if( null == row ){
- throw new AssertException("Row for value "+sRowName+" not found.");
+ throw new AssertException("Row with label "+sRowName+" not found.");
}
return row;
}
+
/**
* Returns the element which contains the "right side of the page".
* <div class="tabmenubox"> element exists on each page that shows resource's details.
@@ -492,6 +535,7 @@
return getFirstElementByXPath(".//div[@class='tabmenubox' or @class='notabmenubox']");
}
+
/**
* Returns an integer part of the beginning of the given string.
* @param s
@@ -517,6 +561,7 @@
}
}
+
}
15 years, 11 months
EMBJOPR SVN: r124 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5 and 1 other directory.
by embjopr-commits@lists.jboss.org
Author: fjuma
Date: 2009-01-28 10:03:55 -0500 (Wed, 28 Jan 2009)
New Revision: 124
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
Log:
Added datasource configuration tests for AS5.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-22 20:27:10 UTC (rev 123)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-28 15:03:55 UTC (rev 124)
@@ -42,13 +42,8 @@
import java.util.logging.Level;
import javax.management.*;
-
-
-
/**
- * When complete, this class will contain tests for creating,
- * configuring, and deleting various types of datasources. This
- * test class should be run against JBAS 5.x.
+ * This is the base test class for Embedded Jopr Datasource tests.
*
* @author Farah Juma
* @author Ondrej Zizka
@@ -162,7 +157,7 @@
/**
* Use JMX to check if the datasource given by datasourceName is deployed.
*/
- protected boolean isDatasourceDeployed(String jndiName, DatasourceType datasourceType) {
+ protected boolean isDatasourceDeployed(String jndiName, DatasourceType datasourceType) {
try {
String[] dsMBeanServices = {"DataSourceBinding",
@@ -174,7 +169,7 @@
MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
// Inspect these MBeans and make sure that the their state indicates successful deployment
- // (e.g. for AS 5, "State" attribute is "DEPLOYED"):
+ // (e.g. for AS 5, "State" attribute is "DEPLOYED"):
// 1) "jboss.jca:name=TestDS,service=DataSourceBinding",type=Component
// 2) "jboss.jca:name=TestDS,service=ManagedConnectionPool",type=Component
// 3) "jboss.jca:name=TestDS,service=ManagedConnectionFactory",type=Component
@@ -205,9 +200,7 @@
throw new RuntimeException(e);
}
}
-
-
-
+
/**
* checkProperties reads the *-ds.xml file corresponding to the datasource
* given by jndiName and compares the property values in this file to the
@@ -215,8 +208,8 @@
* properties are correctly set in the *-ds.xml file and false otherwise.
*/
protected boolean checkProperties(String jndiName,
- DatasourceType datasourceType,
- Map<String, String> expectedValuesMap) {
+ DatasourceType datasourceType,
+ Map<String, String> expectedValuesMap) {
Map<String, String> actualValuesMap = new HashMap<String, String>();
@@ -224,7 +217,7 @@
try {
// Parse the *-ds.xml file; create appropriate file name for AS 4 or 5.
- File file = new File( this.getDatasourceConfigFile( jndiName ));
+ File file = new File(this.getDatasourceConfigFile(jndiName));
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(file);
@@ -233,7 +226,7 @@
assertTrue(root.getName().equals("datasources"));
// Get the datasource element
- Element datasource = root.getChild( datasourceType.getXmlElementName() );
+ Element datasource = root.getChild(datasourceType.getXmlElementName());
// Create actualValuesMap by mapping property names to
// property values
@@ -298,11 +291,9 @@
/*
- * --- Some preliminary creation tests ---
+ * CREATION TESTS
*/
-
-
-
+
/**
* Create a new datasource. Leave some property values, that aren't
* required, unset.
@@ -334,17 +325,8 @@
// Clean up
deleteDatasource(propertiesMap.get("jndi-name"));
- expectedMessage = "Successfully deleted Local TX Datasource '"
- + propertiesMap.get("jndi-name") + "'";
- checkClientAndServerMessages(expectedMessage, expectedMessage, false);
}
-
-
-
-
-
-
/**
* Attempt to create a new datasource but leave at least one required
* value unset. An error should occur.
@@ -402,7 +384,6 @@
true);
}
-
/**
* Attempt to create a new datasource but set a property value
* to an invalid type. An error should occur.
@@ -432,9 +413,6 @@
true);
}
-
-
-
/**
* Attempt to create a new datasource but set a property value to a value
* that is the correct type but is not an allowed value for that
@@ -510,7 +488,7 @@
propertiesMap.get("jndi-name"),
DatasourceType.LOCAL_TX_DATASOURCE.getXmlElementName() )); //"local-tx-datasource"
}
-
+
/**
* Remove a No TX Datasource.
*/
@@ -729,26 +707,13 @@
propertiesMap.put("driver-class", "org.hsqldb.jdbcDriver");
propertiesMap.put("connection-url", "jdbc:hsqldb:."); // Store data current working dir.
propertiesMap.put("idle-timeout-minutes", "20");
- //propertiesMap.put("query-timeout", "180"); // AS 5 only - moved there
propertiesMap.put("prepared-statement-cache-size", "2");
- // Share Prepared Statements - AS 5
- //propertiesMap.put("share-prepared-statements", "false"); // AS 5
-
propertiesMap.put("valid-connection-checker-class-name",
"org.jboss.resource.adapter.jdbc.CheckValidConnectionSQL");
- //propertiesMap.put("stale-connection-checker-class-name",
- // "org.jboss.resource.adapter.jdbc.StaleConnectionChecker"); // AS 5
propertiesMap.put("exception-sorter-class-name",
"org.jboss.resource.adapter.jdbc.ExceptionSorter");
- //propertiesMap.put("allocation-retry", "10000"); // AS 5
- //propertiesMap.put("allocation-retry-wait-millis", "10000"); // AS 5
-
- //propertiesMap.put("background-validation-millis", "15000"); // AS 5
- //propertiesMap.put("prefill", "true"); // AS 5
- //propertiesMap.put("use-try-lock", "61000"); // AS 5
-
+
return propertiesMap;
-
}
@@ -819,6 +784,8 @@
propertiesMap.put("xa-resource-timeout", "36000");
propertiesMap.put("max-pool-size", "15");
propertiesMap.put("min-pool-size", "6");
+ propertiesMap.put("set-tx-query-timeout", "false");
+ propertiesMap.put("user-name", "testUser");
createDatasource(DatasourceType.XA_DATASOURCE,
DatasourceType.XA_DATASOURCE.getTemplateHtmlSelectValue(), //"default__XA Datasource",
@@ -876,13 +843,10 @@
/**
* containsElement returns whether or not the *-ds.xml file corresponding
* to the datasource given by jndiName contains the given element.
- * TODO: Refactor.
*/
protected boolean containsElement(String jndiName, String elementName) {
try {
- File file = new File(System.getProperty("jsfunit.deploy.dir")
- + "/" + jndiName + "-ds.xml");
-
+ File file = new File(this.getDatasourceConfigFile(jndiName));
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(file);
@@ -940,40 +904,6 @@
}
}
-
-
-
- /**
- * Perform the given operation on the given datasource.
- */
- protected void performDatasourceOperation(String datasourceName,
- String datasourceType,
- String operationName) throws IOException {
-
- refreshTreeNode("Datasources");
- ClickableElement datasourceTypeArrow = getNavTreeArrow(datasourceType);
- datasourceTypeArrow.click();
-
- HtmlAnchor datasourceLink = getNavTreeLink(datasourceName);
- datasourceLink.click();
-
- HtmlAnchor controlLink = (HtmlAnchor)client.getElement("controlTab");
- controlLink.click();
-
- HtmlForm form = (HtmlForm)client.getElement("operation_form");
- String xpath = ".//input[@value=\"" + operationName + "\"]";
-
- HtmlButtonInput operationButton = (HtmlButtonInput)form.getFirstByXPath(xpath);
- operationButton.click();
- }
-
-
-
-
-
-
-
-
/**
* This method should query the JMX server and decide whether the given MBean displays deployed resource.
* @param deploymentMBean Name of the MBean to examine. Differs between AS4 and 5.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-01-22 20:27:10 UTC (rev 123)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-01-28 15:03:55 UTC (rev 124)
@@ -42,27 +42,27 @@
*/
public class DatasourceTest extends DatasourceTestBase {
- private final String MAX_ITEMS_PER_PAGE="20";
+ private final String MAX_ITEMS_PER_PAGE="20";
-
- /**
+ /**
* Create a new datasource using the given type, template, and properties.
- *
- * AS 5 version differs in menu tree structure - one more step.
- * Thus, this test is overriden from the Base class.
+ *
+ * AS 5 version differs in menu tree structure - one more step.
+ * Thus, this method is overriden from the Base class.
*
- * @param datasourceType must be the a datasource type from DatasourceType enum.
- * It's label from the left nav (eg. "Local TX Datasources") is in getLabel() property.
- *
+ * @param datasourceType must be a datasource type from DatasourceType enum.
+ * It's label from the left nav (eg. "Local TX Datasources") is in getLabel() property.
+ *
*/
- @Override
+ @Override
protected void createDatasource(DatasourceType datasourceType,
- String datasourceTemplate,
- Map<String, String> propertiesMap) throws IOException {
-
+ String datasourceTemplate,
+ Map<String, String> propertiesMap) throws IOException {
+
// Expand the "Datasources" tree node
ClickableElement datasourcesArrow = getNavTreeArrow("Datasources");
datasourcesArrow.click();
+
HtmlAnchor datasourceLink = getNavTreeLink(datasourceType.getLabel());
datasourceLink.click();
@@ -77,37 +77,73 @@
}
- /**
- * Properties for the datasource for AS 5.
- * @returns the default properties from the base class overriden by properties for AS 5.
- */
- @Override
- protected Map<String, String> createDatasourceProperties()
- {
- Map<String, String> propertiesMap = super.createDatasourceProperties();
+ /**
+ * Properties needed for testCreateDatasource for AS 5.
+ * @returns the properties from the base class overriden by properties for AS 5.
+ */
+ @Override
+ protected Map<String, String> createDatasourceProperties()
+ {
+ Map<String, String> propertiesMap = super.createDatasourceProperties();
- // Additional or different properties for AS 5
- propertiesMap.put("query-timeout", "180");
- propertiesMap.put("share-prepared-statements", "false");
+ // Additional or different properties for AS 5
+ propertiesMap.put("query-timeout", "180");
+ propertiesMap.put("share-prepared-statements", "false");
propertiesMap.put("stale-connection-checker-class-name",
"org.jboss.resource.adapter.jdbc.StaleConnectionChecker");
propertiesMap.put("allocation-retry", "10000");
propertiesMap.put("allocation-retry-wait-millis", "10000");
-
- propertiesMap.put("allocation-retry", "10000");
- propertiesMap.put("allocation-retry-wait-millis", "10000");
-
propertiesMap.put("background-validation-millis", "15000");
propertiesMap.put("prefill", "true");
propertiesMap.put("use-try-lock", "61000");
- return propertiesMap;
+ return propertiesMap;
+ }
+
+ /**
+ * Perform the given operation on the given datasource.
+ *
+ * performDatasourceOperation() assumes that the "Datasources"
+ * tree node is already expanded when this method is called.
+ */
+ protected void performDatasourceOperation(String datasourceName,
+ DatasourceType datasourceType,
+ String operationName) throws IOException {
- }
+ navigateToPage(datasourceName, datasourceType, "controlTab");
+ HtmlForm form = (HtmlForm)client.getElement("operation_form");
+ String xpath = ".//input[@value=\"" + operationName + "\"]";
+ HtmlButtonInput operationButton = (HtmlButtonInput)form.getFirstByXPath(xpath);
+ operationButton.click();
+ }
+ /**
+ * Navigate to the given tab (eg. "configurationTab", "controlTab") for
+ * the given datasource.
+ *
+ * navigateToPage() assumes that the "Datasources" tree node is already
+ * expanded when this method is called.
+ */
+ private void navigateToPage(String datasourceName,
+ DatasourceType datasourceType,
+ String tabName) throws IOException {
+
+ refreshTreeNode("Datasources");
+ ClickableElement datasourceTypeArrow = getNavTreeArrow(datasourceType.getLabel());
+ datasourceTypeArrow.click();
+
+ HtmlAnchor datasource = getNavTreeLink(datasourceName);
+ datasource.click();
+
+ HtmlAnchor tabLink = (HtmlAnchor)client.getElement(tabName);
+ tabLink.click();
+ }
+ /**
+ * Delete the datasource given by datasourceName.
+ */
@Override
protected void deleteDatasource(String datasourceName) throws IOException {
HtmlAnchor datasourceLink = getNavTreeLink("Datasources");
@@ -118,76 +154,183 @@
menu.setSelectedAttribute(MAX_ITEMS_PER_PAGE, Boolean.TRUE);
}
- HtmlButtonInput deleteButton = getDeleteButton("categorySummaryForm", datasourceName);
+ HtmlButtonInput deleteButton = getDeleteButton("categorySummaryForm",
+ datasourceName);
deleteButton.click();
}
+ /**
+ * This method should query the JMX server and decide whether the given
+ * MBean displays deployed resource.
+ * @param deploymentMBean Name of the MBean to examine. Differs between AS4 and 5.
+ * @return true if the MBean indicates that the resource is deployed, false otherwise.
+ * @throws javax.management.JMException upon JMX related error, including invalid
+ * or non-existent MBean / attribute name.
+ * @throws java.io.IOException upon I/O error.
+ */
+ @Override
+ protected boolean isMBeanStateDeployedImpl(ObjectName deploymentMBean) throws JMException, IOException {
+ JMXUtils jmxUtils = JMXUtils.getInstanceForLocalJBoss();
+ Object state = jmxUtils.getMBeanAttribute(deploymentMBean, "State");
+ return !("DEPLOYED".equals( state.toString() ));
-
+ }
+ /**
+ * Return the location of the -ds.xml file that corresponds to the
+ * datasource given by jndiName.
+ */
+ @Override
+ protected String getDatasourceConfigFile( String jndiName ) {
+ return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName + "-ds.xml";
+ }
+ /**
+ * Return the name of the MBean that corresponds to the given
+ * JNDI name and service.
+ */
+ @Override
+ protected String getMBeanName( String jndiName, String serviceName ){
+ return "jboss.deployment:id=\"jboss.jca:name=" + jndiName + "," +
+ "service=" + serviceName + "\",type=Component";
+ }
- @Override
- protected boolean isMBeanStateDeployedImpl(ObjectName deploymentMBean) throws JMException, IOException {
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ return new TestSuite(DatasourceTest.class);
+ }
+
+ /*
+ * CONFIGURATION TESTS
+ */
+
+ /**
+ * Change the value of some already set properties.
+ */
+ public void testConfigureDatasourceChangeSetProperties() throws IOException {
+ Map<String, String> propertiesMap = createXADatasource("ChangeSetPropertiesDS");
+ assertTrue("Error creating datasource",
+ client.getPageAsText().contains("Successfully added"));
- JMXUtils jmxUtils = JMXUtils.getInstanceForLocalJBoss();
+ // Change some property values that are already set
+ Map<String, String> propertiesMapChanges = new HashMap<String, String>();
+ propertiesMapChanges.put("xa-resource-timeout", "60000");
+ propertiesMapChanges.put("set-tx-query-timeout", "true");
+ propertiesMapChanges.put("user-name", "newUser");
- Object state = jmxUtils.getMBeanAttribute(deploymentMBean, "State");
- return !("DEPLOYED".equals( state.toString() ));
+ navigateToPage(propertiesMap.get("jndi-name"),
+ DatasourceType.XA_DATASOURCE,
+ "configurationTab");
+ assertFalse("The configuration page could not be displayed",
+ client.getPageAsText().contains("There was an error retrieving the configuration for this resource"));
- }
+ fillOutForm(propertiesMapChanges);
+ client.click("resourceConfigurationForm:saveButton");
-
-
- @Override
- protected Map<String, String> createLocalTXDatasource(String datasourceName) throws IOException {
- return super.createLocalTXDatasource(datasourceName);
- }
+ // Update our expected property values
+ propertiesMap.putAll(propertiesMapChanges);
- @Override
- protected Map<String, String> createNoTXDatasource(String datasourceName) throws IOException {
- return super.createNoTXDatasource(datasourceName);
- }
+ // Check for the appropriate success messages
+ String expectedMessage = "Successfully updated XA Datasource '"
+ + propertiesMap.get("jndi-name") + "'";
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
- @Override
- protected Map<String, String> createXADatasource(String datasourceName) throws IOException {
- return super.createXADatasource(datasourceName);
+ assertTrue(isDatasourceDeployed(propertiesMap.get("jndi-name"),
+ DatasourceType.XA_DATASOURCE));
+ assertTrue(checkProperties(propertiesMap.get("jndi-name"),
+ DatasourceType.XA_DATASOURCE,
+ propertiesMap));
+
+ // Clean up
+ deleteDatasource(propertiesMap.get("jndi-name"));
}
+
+ /**
+ * Change the value of some previously unset properties.
+ */
+ public void testConfigureDatasourceChangeUnsetProperties() throws IOException {
+ Map<String, String> propertiesMap = createLocalTXDatasource("ChangeUnsetPropertiesDS");
+ assertTrue("Error creating datasource",
+ client.getPageAsText().contains("Successfully added"));
+ // Set some property values that were previously unset
+ Map<String, String> propertiesMapChanges = new HashMap<String, String>();
+ propertiesMapChanges.put("valid-connection-checker-class-name",
+ "org.jboss.resource.adapter.jdbc.CheckValidConnectionSQL");
+ propertiesMapChanges.put("set-tx-query-timeout", "true");
+ propertiesMapChanges.put("background-validation", "false");
+ propertiesMapChanges.put("allocation-retry", "10000");
+ navigateToPage(propertiesMap.get("jndi-name"),
+ DatasourceType.LOCAL_TX_DATASOURCE,
+ "configurationTab");
+ assertFalse("The configuration page could not be displayed",
+ client.getPageAsText().contains("There was an error retrieving the configuration for this resource"));
+ fillOutForm(propertiesMapChanges);
+ client.click("resourceConfigurationForm:saveButton");
+ // Update our expected property values
+ propertiesMap.putAll(propertiesMapChanges);
+ // Check for the appropriate success messages
+ String expectedMessage = "Successfully updated Local TX Datasource '"
+ + propertiesMap.get("jndi-name") + "'";
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+ assertTrue(isDatasourceDeployed(propertiesMap.get("jndi-name"),
+ DatasourceType.LOCAL_TX_DATASOURCE));
+ assertTrue(checkProperties(propertiesMap.get("jndi-name"),
+ DatasourceType.LOCAL_TX_DATASOURCE,
+ propertiesMap));
-
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite(DatasourceTest.class);
+ // Clean up
+ deleteDatasource(propertiesMap.get("jndi-name"));
}
-
- @Override
- protected String getDatasourceConfigFile( String jndiName ) {
- //String jndiName = this.getDatasourceProperties().get("jndi-name");
- return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName + "-ds.xml";
- }
+ /**
+ * Unset the value of some previously set properties.
+ */
+ public void testConfigureDatasourceUnsetProperties() throws IOException {
+ Map<String, String> propertiesMap = createNoTXDatasource("UnsetPropertiesDS");
+ assertTrue("Error creating datasource",
+ client.getPageAsText().contains("Successfully added"));
+ // Unset some property values
+ navigateToPage(propertiesMap.get("jndi-name"),
+ DatasourceType.NO_TX_DATASOURCE,
+ "configurationTab");
+ assertFalse("The configuration page could not be displayed",
+ client.getPageAsText().contains("There was an error retrieving the configuration for this resource"));
- @Override
- protected String getMBeanName( String jndiName, String serviceName ){
- return "jboss.deployment:id=\"jboss.jca:name=" + jndiName + "," +
- "service=" + serviceName + "\",type=Component";
- }
+ enableOrDisableFormInput("user-name", Boolean.FALSE);
+ enableOrDisableFormInput("idle-timeout-minutes", Boolean.FALSE);
+ enableOrDisableFormInput("prefill", Boolean.FALSE);
+ client.click("resourceConfigurationForm:saveButton");
+ // Update our expected property values
+ propertiesMap.remove("user-name");
+ propertiesMap.remove("idle-timeout-minutes");
+ propertiesMap.remove("prefill");
+ // Check for the appropriate success messages
+ String expectedMessage = "Successfully updated No TX Datasource '"
+ + propertiesMap.get("jndi-name") + "'";
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+ assertTrue(isDatasourceDeployed(propertiesMap.get("jndi-name"),
+ DatasourceType.NO_TX_DATASOURCE));
+ assertTrue(checkProperties(propertiesMap.get("jndi-name"),
+ DatasourceType.NO_TX_DATASOURCE,
+ propertiesMap));
-}// DatasourceTest.java for AS 5
+ // Clean up
+ deleteDatasource(propertiesMap.get("jndi-name"));
+ }
+}
15 years, 11 months
EMBJOPR SVN: r123 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-01-22 15:27:10 -0500 (Thu, 22 Jan 2009)
New Revision: 123
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JMXUtils.java
Log:
Added: JMXUtils::dumpInfo(), which lists MBeans registered on the server.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JMXUtils.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JMXUtils.java 2009-01-22 14:07:41 UTC (rev 122)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/JMXUtils.java 2009-01-22 20:27:10 UTC (rev 123)
@@ -1,7 +1,11 @@
package org.jboss.jopr.jsfunit;
import java.io.IOException;
+import java.util.Comparator;
import java.util.Hashtable;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import javax.management.*;
import javax.naming.*;
import org.jboss.mx.util.MBeanServerLocator;
@@ -71,4 +75,28 @@
return jmxServer.getAttribute( mBeanName, attribute );
}
+ public void dumpInfo(){
+
+ try{
+ System.out.println("Domains: ");
+ for( String domainName : this.jmxServer.getDomains() ){
+ System.out.println(" "+domainName);
+ }
+
+ System.out.println("MBeans count: " + this.jmxServer.getMBeanCount() );
+
+ System.out.println("MBeans: ");
+ Set<ObjectName> queryNames = this.jmxServer.queryNames(null, null);
+ SortedSet<ObjectName> sortedQueryNames = new TreeSet<ObjectName>(queryNames);
+
+ for( ObjectName objectName : sortedQueryNames ){
+ System.out.println(" "+objectName.getCanonicalName());
+ }
+ }
+ catch( IOException ex ){
+ System.out.println("Exception occured: "+ ex.getMessage());
+ }
+
+ }
+
}// class JMXUtils
15 years, 11 months
EMBJOPR SVN: r122 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-01-22 09:07:41 -0500 (Thu, 22 Jan 2009)
New Revision: 122
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
Log:
Added: checkClientAndServerMessagesRegExp() which checks the client and server messages against a regular expressions.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-01-21 21:56:52 UTC (rev 121)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-01-22 14:07:41 UTC (rev 122)
@@ -41,10 +41,11 @@
import javax.management.*;
import org.jboss.mx.util.MBeanServerLocator;
//import org.jboss.jmx.adaptor.rmi.RMIAdaptor; // Needs dependency: jmx-adaptor-plugin
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
-
/**
* This is the base test class for Embedded Jopr test cases.
* It supplies access to a JSFClientSession object and a JSFServerSession
@@ -275,13 +276,14 @@
}
}
+
/**
- * Check that the given messages occur on the client side
- * and server side.
+ * Check that the given messages occur on the client side and server side.
*/
public void checkClientAndServerMessages(String expectedClientMsg,
String expectedServerMsg,
- boolean isErrorMsg) {
+ boolean isErrorMsg)
+ {
assertTrue("Expected message not found on page.",
client.getPageAsText().contains(expectedClientMsg));
@@ -301,6 +303,30 @@
/**
+ * Check that the given messages occur on the client side and server side.
+ * Given strings are treated as regular expressions to match.
+ */
+ public void checkClientAndServerMessagesRegExp(String expectedClientMsgRE,
+ String expectedServerMsgRE,
+ boolean isErrorMsg)
+ {
+ String pageText = client.getPageAsText();
+ assertTrue( Pattern.matches(expectedClientMsgRE, pageText) );
+
+ assertTrue(server.getFacesMessages().hasNext());
+ FacesMessage message = server.getFacesMessages().next();
+
+ if(isErrorMsg) {
+ assertTrue(FacesMessage.SEVERITY_ERROR.equals(message.getSeverity()));
+ } else {
+ assertTrue(FacesMessage.SEVERITY_INFO.equals(message.getSeverity()));
+ }
+
+ assertTrue( Pattern.matches( expectedServerMsgRE, message.getDetail() ) );
+ }
+
+
+ /**
* Refresh the content under the given nav tree node.
*/
public void refreshTreeNode(String nodeName) throws IOException {
@@ -313,6 +339,7 @@
nodeArrow.click();
}
+
/**
* This just checks that the JSFServerSession object was created.
*/
@@ -320,6 +347,7 @@
assertTrue(server != null);
}
+
/**
* This just checks that the JSFClientSession object was created.
*/
15 years, 11 months
EMBJOPR SVN: r121 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: fjuma
Date: 2009-01-21 16:56:52 -0500 (Wed, 21 Jan 2009)
New Revision: 121
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
Log:
Reapplying my modifications to the datasource metrics tests from r112 that were lost after r118.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-21 17:26:27 UTC (rev 120)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-21 21:56:52 UTC (rev 121)
@@ -62,7 +62,7 @@
// Some of these values are specific for AS 5. TODO: Think up some way to split nicely.
LOCAL_TX_DATASOURCE("Local TX Datasources", "LocalTxCM", "local-tx-datasource", "default__Local TX Datasource"),
- NO_TX_DATASOURCE( "No TX Datasources", "NoTxCM", "no-tx-datasource", "default__No TX Datasource"), // TODO: Fill the value.
+ NO_TX_DATASOURCE( "No TX Datasources", "NoTxCM", "no-tx-datasource", "default__No TX Datasource"),
XA_DATASOURCE( "XA Datasources", "XATxCM", "xa-datasource", "default__XA Datasource");
protected String label;
@@ -554,7 +554,7 @@
}
/*
- * PRELIMINARY METRICS TESTS
+ * METRICS TESTS
*/
/**
@@ -592,7 +592,9 @@
Map<String, String> propertiesMap = createLocalTXDatasource("MetricsInitalConnectionDS");
// Create the first connection
- Connection con = connectDB(propertiesMap.get("jndi-name"), "sa", "");
+ Connection con = connectDB(propertiesMap.get("jndi-name"),
+ propertiesMap.get("user-name"),
+ propertiesMap.get("password"));
assertNotNull(con);
// Set up the expected values
@@ -625,7 +627,9 @@
// Establish multiple connections
ArrayList<Connection> connections = new ArrayList<Connection>();
for(int i = 0; i <= 5; i++) {
- Connection con = connectDB(propertiesMap.get("jndi-name"), "sa", "");
+ Connection con = connectDB(propertiesMap.get("jndi-name"),
+ propertiesMap.get("user-name"),
+ propertiesMap.get("password"));
assertNotNull(con);
connections.add(con);
}
@@ -651,8 +655,53 @@
deleteDatasource(propertiesMap.get("jndi-name"));
}
+ /**
+ * Make sure the metrics are updated appropriately after
+ * closing some connections.
+ */
+ public void testMetricsAfterClosingConnections() throws Exception {
+
+ // Min pool size will be 5, max pool size will be 20
+ Map<String, String> propertiesMap = createNoTXDatasource("MetricsCloseConnectionsDS");
+
+ // Establish some connections
+ ArrayList<Connection> connections = new ArrayList<Connection>();
+ for(int i = 0; i <= 4; i++) {
+ Connection con = connectDB(propertiesMap.get("jndi-name"),
+ propertiesMap.get("user-name"),
+ propertiesMap.get("password"));
+ assertNotNull(con);
+ connections.add(con);
+ }
+ // Close some connections
+ disconnectDB(connections.get(0));
+ disconnectDB(connections.get(1));
+ // Set up the expected values
+ Map<String, String> expectedMetrics = new HashMap<String, String>();
+ expectedMetrics.put("Available Connection Count", "17.0");
+ expectedMetrics.put("Connection Count", "3.0");
+ expectedMetrics.put("Connection Created Count", "5.0");
+ expectedMetrics.put("Connection Destroyed Count", "0.0");
+ expectedMetrics.put("In Use Connection Count", "3.0");
+ expectedMetrics.put("Max Connections In Use Count", "5.0");
+ expectedMetrics.put("Max Size", "20.0");
+ expectedMetrics.put("Min Size", "5.0");
+
+ checkMetrics(propertiesMap.get("jndi-name"), DatasourceType.NO_TX_DATASOURCE, expectedMetrics);
+
+ // Clean up
+ for(int i = 2; i <= 4; i++) {
+ disconnectDB(connections.get(i));
+ }
+
+ deleteDatasource(propertiesMap.get("jndi-name"));
+ }
+
+
+
+
@@ -854,8 +903,8 @@
* @param metricsMap maps metric names to the expected metric values.
*/
protected void checkMetrics(String datasourceName,
- DatasourceType datasourceType,
- Map<String, String> metricsMap) throws IOException {
+ DatasourceType datasourceType,
+ Map<String, String> metricsMap) throws IOException {
refreshTreeNode("Datasources");
ClickableElement datasourceTypeArrow = getNavTreeArrow(datasourceType.getLabel());
@@ -870,7 +919,8 @@
for(Iterator i = metricsMap.keySet().iterator(); i.hasNext();) {
String metricName = (String)i.next();
- assertEquals(metricsMap.get(metricName),
+ assertEquals("Incorrect metric value for: " + metricName,
+ metricsMap.get(metricName),
getMetricValueFromTable(metricName, "dataTable"));
}
@@ -878,10 +928,16 @@
HtmlAnchor summaryLink = (HtmlAnchor)client.getElement("summaryTab");
summaryLink.click();
- assertEquals(metricsMap.get("Available Connection Count"),
- getMetricValueFromTable("Available Connection Count", "dataTable"));
- assertEquals(metricsMap.get("Connection Count"),
- getMetricValueFromTable("Connection Count", "dataTable"));
+ ArrayList<String> summaryMetrics = new ArrayList<String>();
+ summaryMetrics.add("Available Connection Count");
+ summaryMetrics.add("Connection Count");
+
+ for(Iterator i = summaryMetrics.iterator(); i.hasNext();) {
+ String metricName = (String)i.next();
+ assertEquals("Incorrect metric value for: " + metricName,
+ metricsMap.get(metricName),
+ getMetricValueFromTable(metricName, "dataTable"));
+ }
}
15 years, 11 months
EMBJOPR SVN: r120 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as4 and 1 other directories.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-01-21 12:26:27 -0500 (Wed, 21 Jan 2009)
New Revision: 120
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
Log:
Fixed: removed toLowerCase getDatasourceConfigFile()
Fixed: NO_TX_DATASOURCE's htmlTemplateValue
Changed: added jndiName param to getDatasourceConfigFile( String jndiName )
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-21 17:18:00 UTC (rev 119)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-21 17:26:27 UTC (rev 120)
@@ -62,7 +62,7 @@
// Some of these values are specific for AS 5. TODO: Think up some way to split nicely.
LOCAL_TX_DATASOURCE("Local TX Datasources", "LocalTxCM", "local-tx-datasource", "default__Local TX Datasource"),
- NO_TX_DATASOURCE( "No TX Datasources", "NoTxCM", "no-tx-datasource", null), // TODO: Fill the value.
+ NO_TX_DATASOURCE( "No TX Datasources", "NoTxCM", "no-tx-datasource", "default__No TX Datasource"), // TODO: Fill the value.
XA_DATASOURCE( "XA Datasources", "XATxCM", "xa-datasource", "default__XA Datasource");
protected String label;
@@ -224,7 +224,7 @@
try {
// Parse the *-ds.xml file; create appropriate file name for AS 4 or 5.
- File file = new File( this.getDatasourceConfigFile());
+ File file = new File( this.getDatasourceConfigFile( jndiName ));
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(file);
@@ -787,7 +787,7 @@
*
* @returns a name of the Datasource's config file to check the properties in.
*/
- protected abstract String getDatasourceConfigFile();
+ protected abstract String getDatasourceConfigFile( String jndiName );
protected abstract String getMBeanName( String jndiName, String serviceName );
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-01-21 17:18:00 UTC (rev 119)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-01-21 17:26:27 UTC (rev 120)
@@ -282,20 +282,24 @@
public void checkClientAndServerMessages(String expectedClientMsg,
String expectedServerMsg,
boolean isErrorMsg) {
- assertTrue(client.getPageAsText().contains(expectedClientMsg));
+ assertTrue("Expected message not found on page.",
+ client.getPageAsText().contains(expectedClientMsg));
- assertTrue(server.getFacesMessages().hasNext());
+ assertTrue("Expected message not found in faces messages.",
+ server.getFacesMessages().hasNext());
+
FacesMessage message = server.getFacesMessages().next();
-
if(isErrorMsg) {
assertTrue(FacesMessage.SEVERITY_ERROR.equals(message.getSeverity()));
} else {
assertTrue(FacesMessage.SEVERITY_INFO.equals(message.getSeverity()));
}
-
- assertTrue(message.getDetail().contains(expectedServerMsg));
+ assertTrue("Expected message: "+expectedServerMsg+" Actual: "+message.getDetail(),
+ message.getDetail().contains(expectedServerMsg));
+
}
+
/**
* Refresh the content under the given nav tree node.
*/
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java 2009-01-21 17:18:00 UTC (rev 119)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java 2009-01-21 17:26:27 UTC (rev 120)
@@ -135,8 +135,8 @@
* @return
*/
@Override
- protected String getDatasourceConfigFile() {
- String jndiName = this.getDatasourceProperties().get("jndi-name");
+ protected String getDatasourceConfigFile( String jndiName ) {
+ //String jndiName = this.getDatasourceProperties().get("jndi-name");
return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName.toLowerCase() + "-ds.xml";
}
@@ -176,7 +176,8 @@
<option value="default__Datasource">default (Datasource)</option>
/**/
createDatasource(DatasourceType.LOCAL_TX_DATASOURCE, // unsued for AS 4
- "default__Datasource", // TODO: Differs! Split DatasourceType accordingly...
+ // TODO: Differs! Split DatasourceType accordingly...
+ DatasourceTemplate.DEFAULT.getTemplateHtmlSelectValue(),
propertiesMap);
client.click("resourceConfigurationForm:saveButton");
@@ -189,7 +190,7 @@
assertTrue(checkProperties(propertiesMap.get("jndi-name"),
DatasourceType.LOCAL_TX_DATASOURCE,
propertiesMap));
-
+
// TODO: need to verify that appropriate default values were
// set for properties that were not specified above
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-01-21 17:18:00 UTC (rev 119)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-01-21 17:26:27 UTC (rev 120)
@@ -174,8 +174,8 @@
@Override
- protected String getDatasourceConfigFile() {
- String jndiName = this.getDatasourceProperties().get("jndi-name");
+ protected String getDatasourceConfigFile( String jndiName ) {
+ //String jndiName = this.getDatasourceProperties().get("jndi-name");
return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName + "-ds.xml";
}
15 years, 11 months
EMBJOPR SVN: r119 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-01-21 12:18:00 -0500 (Wed, 21 Jan 2009)
New Revision: 119
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
Log:
Fixed - removed toLowerCase getDatasourceConfigFile()
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-01-20 23:02:22 UTC (rev 118)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-01-21 17:18:00 UTC (rev 119)
@@ -176,7 +176,7 @@
@Override
protected String getDatasourceConfigFile() {
String jndiName = this.getDatasourceProperties().get("jndi-name");
- return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName.toLowerCase() + "-ds.xml";
+ return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName + "-ds.xml";
}
15 years, 11 months
EMBJOPR SVN: r118 - in trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit: as5 and 1 other directory.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-01-20 18:02:22 -0500 (Tue, 20 Jan 2009)
New Revision: 118
Added:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
Log:
Changing DatasourceTest subclasses. Since now, they should cover differences between DatasourceTestBase and EmbJopr for AS 4 / 5.
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java (rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as4/DatasourceTest.java 2009-01-20 23:02:22 UTC (rev 118)
@@ -0,0 +1,244 @@
+/*
+ * 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.jopr.jsfunit.as4;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.jboss.jopr.jsfunit.*;
+import com.gargoylesoftware.htmlunit.html.*;
+import java.io.IOException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import javax.management.ObjectName;
+import java.util.Map;
+import javax.management.JMException;
+
+
+
+
+/**
+ * When complete, this class will contain tests for creating,
+ * configuring, and deleting various types of datasources. This
+ * test class should be run against JBAS 5.x.
+ *
+ * @author Farah Juma
+ *
+ */
+public class DatasourceTest extends org.jboss.jopr.jsfunit.DatasourceTestBase {
+
+
+ @Override
+ public void setUp() throws IOException {
+ super.setUp();
+ }
+
+
+
+ /**
+ * Create a new datasource using the given template and properties.
+ *
+ * @param datasourceType is not used.
+ * @param datasourceTemplate is the value of the HTML select option.
+ */
+ protected void createDatasource(DatasourceType datasourceType, // unused here, left for API compat.
+ String datasourceTemplate,
+ Map<String, String> propertiesMap) throws IOException {
+
+ // Expand the "Datasources" tree node
+ HtmlAnchor warLink = getNavTreeLink("Datasources");
+ warLink.click();
+
+ // Click on the "Add new resource" button
+ client.click("actionHeaderForm:addNewNotContent"); // 404 if setThrowExceptionOnFailingStatusCode(true) above
+
+ // Select the default datasource (other options: Oracle)
+ HtmlSelect menu = (HtmlSelect)client.getElement("resourceCreateForm:selectedTemplate");
+
+ menu.setSelectedAttribute(datasourceTemplate, true);
+
+ // Submit the form. [Continue]
+ //HtmlSubmitInput submit = (HtmlSubmitInput) util.getFirstElementByXPath(util.getTabMenuBoxElement(), ".//input[@type='submit']");
+ //if( null == submit ){ fail("\"Continue\" button not found."); }
+ //submit.click();
+
+ client.click("resourceCreateForm:addButton");
+
+ // Configure the properties associated with this datasource
+ fillOutForm(propertiesMap);
+ }
+
+
+ /**
+ * Properties for the datasource for AS4.
+ *
+ * AS 4 has Type selection as radio buttons ("Type")
+ *
+ * @returns the default properties from the base class overriden by properties for AS4.
+ */
+ @Override
+ protected Map<String, String> createDatasourceProperties()
+ {
+ Map<String, String> propertiesMap = super.createDatasourceProperties();
+
+ // Additional or different properties for AS 4
+
+
+ return propertiesMap;
+
+ }
+
+
+
+
+
+ /**
+ * Delete the datasource given by datasourceName.
+ */
+ protected void deleteDatasource(String datasourceName) throws IOException {
+ HtmlAnchor datasourceLink = getNavTreeLink("Datasources");
+ datasourceLink.click();
+ //HtmlButtonInput deleteButton = getDeleteButton("resourceSummaryForm", datasourceName); /*categorySummaryForm*/
+ //deleteButton.click();
+ try {
+ ((HtmlInput) getFirstElementByXPath(getRowByName(datasourceName), ".//input[text()='Delete']")).click();
+ } catch (AssertException ex) {
+ Logger.getLogger(DatasourceTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+
+
+
+
+ /**
+ * AS 4 lowercases the file name.
+ * @return
+ */
+ @Override
+ protected String getDatasourceConfigFile() {
+ String jndiName = this.getDatasourceProperties().get("jndi-name");
+ return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName.toLowerCase() + "-ds.xml";
+ }
+
+
+ /**
+ * AS 4 has it simplier than AS 5.
+ * @param jndiName
+ * @param serviceName
+ * @return
+ */
+ @Override
+ protected String getMBeanName( String jndiName, String serviceName ){
+ return "jboss.jca:name="+jndiName+",service="+serviceName;
+ }
+
+
+
+
+ /*
+ * Some preliminary creation tests
+ */
+
+
+
+ /**
+ * Create a new datasource. Leave some property values that aren't
+ * required unset.
+ */
+ public void testCreateDatasource() throws IOException {
+
+
+ Map<String, String> propertiesMap = getDatasourceProperties();
+
+ /* AS 4:
+ <option value="Oracle Local TX__Datasource">Oracle Local TX (Datasource)</option>
+ <option value="Oracle XA__Datasource">Oracle XA (Datasource)</option>
+ <option value="default__Datasource">default (Datasource)</option>
+ /**/
+ createDatasource(DatasourceType.LOCAL_TX_DATASOURCE, // unsued for AS 4
+ "default__Datasource", // TODO: Differs! Split DatasourceType accordingly...
+ propertiesMap);
+ client.click("resourceConfigurationForm:saveButton");
+
+ // Check for the appropriate success messages
+ String expectedMessage = "Successfully added new Local TX Datasource";
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+
+ assertTrue(isDatasourceDeployed(propertiesMap.get("jndi-name"),
+ DatasourceType.LOCAL_TX_DATASOURCE));
+ assertTrue(checkProperties(propertiesMap.get("jndi-name"),
+ DatasourceType.LOCAL_TX_DATASOURCE,
+ propertiesMap));
+
+ // TODO: need to verify that appropriate default values were
+ // set for properties that were not specified above
+
+ // Clean up
+ deleteDatasource(propertiesMap.get("jndi-name"));
+ expectedMessage = "Successfully deleted Local TX Datasource '"
+ + propertiesMap.get("jndi-name") + "'";
+ checkClientAndServerMessages(expectedMessage, expectedMessage, false);
+ }
+
+
+
+
+
+
+
+
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ return new TestSuite(DatasourceTest.class);
+ }
+
+
+
+
+
+
+ /**
+ * AS 4 uses State and StateString attributes.
+ * @param deploymentMBean
+ * @return
+ * @throws javax.management.JMException
+ * @throws java.io.IOException
+ */
+ @Override
+ protected boolean isMBeanStateDeployedImpl(ObjectName deploymentMBean) throws JMException, IOException {
+
+ JMXUtils jmxUtils = JMXUtils.getInstanceForLocalJBoss();
+
+ Object state = jmxUtils.getMBeanAttribute(deploymentMBean, "StateString");
+ //if(!("3".equals(state.toString()))) return false; // started state
+ return !( "Started".equals(state.toString()) );
+
+ }
+
+
+}// DatasourceTest.java for AS 4
+
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-01-20 22:51:51 UTC (rev 117)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/DatasourceTest.java 2009-01-20 23:02:22 UTC (rev 118)
@@ -22,35 +22,15 @@
package org.jboss.jopr.jsfunit.as5;
-import com.gargoylesoftware.htmlunit.html.ClickableElement;
import org.jboss.jopr.jsfunit.*;
-import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
-import com.gargoylesoftware.htmlunit.html.HtmlButtonInput;
-import com.gargoylesoftware.htmlunit.html.HtmlForm;
-import com.gargoylesoftware.htmlunit.html.HtmlImage;
-import com.gargoylesoftware.htmlunit.html.HtmlSelect;
-import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.*;
import java.io.IOException;
+import java.util.*;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.jboss.mx.util.MBeanServerLocator;
-import javax.management.MBeanServer;
import javax.management.ObjectName;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.ArrayList;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.input.SAXBuilder;
-import org.jdom.JDOMException;
-import java.io.File;
import java.util.Map;
-import java.util.HashMap;
-import javax.naming.InitialContext;
-import java.sql.Connection;
-import javax.sql.DataSource;
-import javax.naming.Context;
-import java.sql.SQLException;
+import javax.management.JMException;
/**
* When complete, this class will contain tests for creating,
@@ -60,29 +40,30 @@
* @author Farah Juma
*
*/
-public class DatasourceTest extends EmbjoprTestCase {
-
- // Datasource types, as they appear in the left nav
- private final String LOCAL_TX_DATASOURCE="Local TX Datasources";
- private final String NO_TX_DATASOURCE="No TX Datasources";
- private final String XA_DATASOURCE="XA Datasources";
-
- private final String MAX_ITEMS_PER_PAGE="20";
-
- /**
+public class DatasourceTest extends DatasourceTestBase {
+
+ private final String MAX_ITEMS_PER_PAGE="20";
+
+
+ /**
* Create a new datasource using the given type, template, and properties.
+ *
+ * AS 5 version differs in menu tree structure - one more step.
+ * Thus, this test is overriden from the Base class.
*
- * @param datasourceType must be the name of a datasource type, as it
- * appears in the left nav (eg. "Local TX Datasources")
+ * @param datasourceType must be the a datasource type from DatasourceType enum.
+ * It's label from the left nav (eg. "Local TX Datasources") is in getLabel() property.
+ *
*/
- private void createDatasource(String datasourceType,
+ @Override
+ protected void createDatasource(DatasourceType datasourceType,
String datasourceTemplate,
Map<String, String> propertiesMap) throws IOException {
// Expand the "Datasources" tree node
ClickableElement datasourcesArrow = getNavTreeArrow("Datasources");
datasourcesArrow.click();
- HtmlAnchor datasourceLink = getNavTreeLink(datasourceType);
+ HtmlAnchor datasourceLink = getNavTreeLink(datasourceType.getLabel());
datasourceLink.click();
// Add a new datasource
@@ -94,726 +75,119 @@
// Configure the properties associated with this datasource
fillOutForm(propertiesMap);
}
-
- /**
- * Delete the datasource given by datasourceName.
- */
- private void deleteDatasource(String datasourceName) throws IOException {
- HtmlAnchor datasourceLink = getNavTreeLink("Datasources");
- datasourceLink.click();
-
- HtmlSelect menu = (HtmlSelect)client.getElement("currentPageSize");
- if(menu != null) {
- menu.setSelectedAttribute(MAX_ITEMS_PER_PAGE, Boolean.TRUE);
- }
-
- HtmlButtonInput deleteButton = getDeleteButton("categorySummaryForm",
- datasourceName);
- deleteButton.click();
- }
-
- /**
- * Make sure that the metrics corresponding to the given datasource
- * are correct.
- *
- * @param metricsMap maps metric names to the expected metric values.
- */
- private void checkMetrics(String datasourceName,
- String datasourceType,
- Map<String, String> metricsMap) throws IOException {
- refreshTreeNode("Datasources");
- ClickableElement datasourceTypeArrow = getNavTreeArrow(datasourceType);
- datasourceTypeArrow.click();
- HtmlAnchor datasource = getNavTreeLink(datasourceName);
- datasource.click();
+ /**
+ * Properties for the datasource for AS 5.
+ * @returns the default properties from the base class overriden by properties for AS 5.
+ */
+ @Override
+ protected Map<String, String> createDatasourceProperties()
+ {
+ Map<String, String> propertiesMap = super.createDatasourceProperties();
- // Check values under the "Metrics" tab
- HtmlAnchor metricsLink = (HtmlAnchor)client.getElement("metricsTab");
- metricsLink.click();
+ // Additional or different properties for AS 5
+ propertiesMap.put("query-timeout", "180");
+ propertiesMap.put("share-prepared-statements", "false");
+ propertiesMap.put("stale-connection-checker-class-name",
+ "org.jboss.resource.adapter.jdbc.StaleConnectionChecker");
+ propertiesMap.put("allocation-retry", "10000");
+ propertiesMap.put("allocation-retry-wait-millis", "10000");
- for(Iterator i = metricsMap.keySet().iterator(); i.hasNext();) {
- String metricName = (String)i.next();
- assertEquals("Incorrect metric value for: " + metricName,
- metricsMap.get(metricName),
- getMetricValueFromTable(metricName, "dataTable"));
- }
+ propertiesMap.put("allocation-retry", "10000");
+ propertiesMap.put("allocation-retry-wait-millis", "10000");
- // Check values under the "Summary" tab
- HtmlAnchor summaryLink = (HtmlAnchor)client.getElement("summaryTab");
- summaryLink.click();
+ propertiesMap.put("background-validation-millis", "15000");
+ propertiesMap.put("prefill", "true");
+ propertiesMap.put("use-try-lock", "61000");
- ArrayList<String> summaryMetrics = new ArrayList<String>();
- summaryMetrics.add("Available Connection Count");
- summaryMetrics.add("Connection Count");
-
- for(Iterator i = summaryMetrics.iterator(); i.hasNext();) {
- String metricName = (String)i.next();
- assertEquals("Incorrect metric value for: " + metricName,
- metricsMap.get(metricName),
- getMetricValueFromTable(metricName, "dataTable"));
- }
- }
-
- /**
- * Use JMX to check if the datasource given by datasourceName is
- * deployed.
- */
- private boolean isDatasourceDeployed(String jndiName,
- String datasourceType) {
- try {
+ return propertiesMap;
- ObjectName deploymentMBean;
- ObjectName objName;
- Object state;
- Set dsMBeans;
- String service;
-
- // One of the MBeans we will need to inspect depends on
- // the type of datasource
- if(datasourceType.equals(LOCAL_TX_DATASOURCE)) {
- service="LocalTxCM";
- } else if(datasourceType.equals(NO_TX_DATASOURCE)) {
- service="NoTxCM";
- } else {
- service="XATxCM";
- }
-
- String[] dsMBeanServices = {"DataSourceBinding",
- "ManagedConnectionPool",
- "ManagedConnectionFactory",
- service};
-
- // Query the MBean server to check if the datasource is deployed
- MBeanServer jmxServer = MBeanServerLocator.locateJBoss();
+ }
- // Inspect the following MBeans and make sure that the "State" attribute
- // is "DEPLOYED":
- // 1) "jboss.jca:name=TestDS,service=DataSourceBinding",type=Component
- // 2) "jboss.jca:name=TestDS,service=ManagedConnectionPool",type=Component
- // 3) "jboss.jca:name=TestDS,service=ManagedConnectionFactory",type=Component
- // 4) The fourth MBean inspected depends on the type of datasource
- for(int i = 0; i < dsMBeanServices.length; i++) {
-
- objName = new ObjectName("jboss.deployment:id=\"jboss.jca:name="
- + jndiName + ",service="
- + dsMBeanServices[i] + "\",type=Component");
-
- dsMBeans = jmxServer.queryNames(objName, null);
- if (dsMBeans.size() != 1) return false;
-
- deploymentMBean = (ObjectName)dsMBeans.iterator().next();
- state = jmxServer.getAttribute(deploymentMBean, "State");
- if(!("DEPLOYED".equals(state.toString()))) return false;
- }
-
- return true;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-
- /**
- * checkProperties reads the *-ds.xml file corresponding to the datasource
- * given by jndiName and compares the property values in this file to the
- * given expected values. checkProperties returns true if all the given
- * properties are correctly set in the *-ds.xml file and false otherwise.
- */
- private boolean checkProperties(String jndiName,
- String datasourceType,
- Map<String, String> expectedValuesMap) {
-
- Map<String, String> actualValuesMap = new HashMap<String, String>();
- String datasourceElementName;
-
- try {
-
- // Parse the *-ds.xml file
- File file = new File(System.getProperty("jsfunit.deploy.dir")
- + "/" + jndiName + "-ds.xml");
-
- SAXBuilder builder = new SAXBuilder();
- Document doc = builder.build(file);
-
- Element root = doc.getRootElement();
- assertTrue(root.getName().equals("datasources"));
-
- // Get the datasource element
- if(datasourceType.equals(LOCAL_TX_DATASOURCE)) {
- datasourceElementName="local-tx-datasource";
- } else if(datasourceType.equals(NO_TX_DATASOURCE)) {
- datasourceElementName="no-tx-datasource";
- } else {
- datasourceElementName="xa-datasource";
- }
- Element datasource = root.getChild(datasourceElementName);
-
- // Create actualValuesMap by mapping property names to
- // property values
- Iterator itr = (datasource.getChildren()).iterator();
- while(itr.hasNext()) {
- Element property = (Element)itr.next();
- actualValuesMap.put(property.getName(), property.getValue());
- }
-
- // Compare the actual values to the expected ones
- itr = expectedValuesMap.keySet().iterator();
- while(itr.hasNext()) {
- String key = (String)itr.next();
- if(actualValuesMap.containsKey(key)) {
- if(!expectedValuesMap.get(key).equals(actualValuesMap.get(key))) {
- return false; // incorrect value
- }
- } else {
- return false; // value was not set
- }
- }
-
- return true;
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * containsElement returns whether or not the *-ds.xml file corresponding
- * to the datasource given by jndiName contains the given element.
- */
- private boolean containsElement(String jndiName, String elementName) {
- try {
- File file = new File(System.getProperty("jsfunit.deploy.dir")
- + "/" + jndiName + "-ds.xml");
- SAXBuilder builder = new SAXBuilder();
- Document doc = builder.build(file);
- Element root = doc.getRootElement();
- assertTrue(root.getName().equals("datasources"));
- return root.getChild(elementName) != null;
- } catch(Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Perform the given operation on the given datasource.
- */
- private void performDatasourceOperation(String datasourceName,
- String datasourceType,
- String operationName) throws IOException {
-
- refreshTreeNode("Datasources");
- ClickableElement datasourceTypeArrow = getNavTreeArrow(datasourceType);
- datasourceTypeArrow.click();
-
- HtmlAnchor datasourceLink = getNavTreeLink(datasourceName);
+
+ @Override
+ protected void deleteDatasource(String datasourceName) throws IOException {
+ HtmlAnchor datasourceLink = getNavTreeLink("Datasources");
datasourceLink.click();
- HtmlAnchor controlLink = (HtmlAnchor)client.getElement("controlTab");
- controlLink.click();
+ HtmlSelect menu = (HtmlSelect)client.getElement("currentPageSize");
+ if(menu != null) {
+ menu.setSelectedAttribute(MAX_ITEMS_PER_PAGE, Boolean.TRUE);
+ }
- HtmlForm form = (HtmlForm)client.getElement("operation_form");
- String xpath = ".//input[@value=\"" + operationName + "\"]";
-
- HtmlButtonInput operationButton = (HtmlButtonInput)form.getFirstByXPath(xpath);
- operationButton.click();
+ HtmlButtonInput deleteButton = getDeleteButton("categorySummaryForm", datasourceName);
+ deleteButton.click();
}
-
- /**
- * Connect to the database identified by the given JNDI name,
- * using the given username and password. Return the Connection
- * object.
- */
- public Connection connectDB(String jndiName, String username,
- String password) throws Exception{
- Context ctx = new InitialContext();
- DataSource ds = (DataSource)ctx.lookup(jndiName);
- return ds.getConnection(username, password);
- }
-
- /**
- * Disconnect from the database.
- */
- public void disconnectDB(Connection con) throws SQLException {
- if(con != null) {
- con.close();
- }
- }
-
- /**
- * Create a basic Local TX Datasource. Return the mapping of property
- * names to property values.
- */
- private Map<String, String> createLocalTXDatasource(String datasourceName) throws IOException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("jndi-name", datasourceName);
- propertiesMap.put("max-pool-size", "20");
- propertiesMap.put("min-pool-size", "5");
- propertiesMap.put("user-name", "sa");
- propertiesMap.put("password", "");
- propertiesMap.put("domain", "HsqlDbRealm");
- propertiesMap.put("blocking-timeout-millis", "35000");
- propertiesMap.put("idle-timeout-minutes", "20");
- propertiesMap.put("driver-class", "org.hsqldb.jdbcDriver");
- propertiesMap.put("connection-url", "jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB");
- createDatasource(LOCAL_TX_DATASOURCE, "default__Local TX Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
- return propertiesMap;
- }
- /**
- * Create a basic No TX Datasource. Return the mapping of property
- * names to property values.
- */
- private Map<String, String> createNoTXDatasource(String datasourceName) throws IOException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("jndi-name", datasourceName);
- propertiesMap.put("prefill", "true");
- propertiesMap.put("track-connection-by-tx", "false");
- propertiesMap.put("max-pool-size", "20");
- propertiesMap.put("min-pool-size", "5");
- propertiesMap.put("blocking-timeout-millis", "55000");
- propertiesMap.put("idle-timeout-minutes", "60");
- propertiesMap.put("noTxSeparatePools", "true");
- propertiesMap.put("user-name", "sa");
- propertiesMap.put("password", "");
- propertiesMap.put("domain", "HsqlDbRealm");
- propertiesMap.put("driver-class", "org.hsqldb.jdbcDriver");
- propertiesMap.put("connection-url", "jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB");
+
- createDatasource(NO_TX_DATASOURCE, "default__No TX Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
- return propertiesMap;
- }
- /**
- * Create a basic XA Datasource. Return the mapping of property
- * name to property values.
- */
- private Map<String, String> createXADatasource(String datasourceName) throws IOException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("jndi-name", datasourceName);
- propertiesMap.put("xa-datasource-class", "org.postgresql.xa.PGXADataSource");
- propertiesMap.put("xa-resource-timeout", "36000");
- propertiesMap.put("max-pool-size", "15");
- propertiesMap.put("min-pool-size", "6");
+ @Override
+ protected boolean isMBeanStateDeployedImpl(ObjectName deploymentMBean) throws JMException, IOException {
- createDatasource(XA_DATASOURCE, "default__XA Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
+ JMXUtils jmxUtils = JMXUtils.getInstanceForLocalJBoss();
- return propertiesMap;
- }
+ Object state = jmxUtils.getMBeanAttribute(deploymentMBean, "State");
+ return !("DEPLOYED".equals( state.toString() ));
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite(DatasourceTest.class);
- }
-
- /*
- * CREATION TESTS:
- */
-
- /**
- * Create a new datasource. Leave some property values that aren't
- * required unset.
- */
- public void testCreateDatasource() throws IOException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
-
- // The properties we want to configure
- propertiesMap.put("jndi-name", "CreationTestDS");
- propertiesMap.put("user-name", "testUser");
- propertiesMap.put("password", "password");
- propertiesMap.put("min-pool-size", "5");
- propertiesMap.put("driver-class", "org.hsqldb.jdbcDriver");
- propertiesMap.put("connection-url", "jdbc:hsqldb:.");
- propertiesMap.put("idle-timeout-minutes", "20");
- propertiesMap.put("query-timeout", "180");
- propertiesMap.put("prepared-statement-cache-size", "2");
- propertiesMap.put("valid-connection-checker-class-name",
- "org.jboss.resource.adapter.jdbc.CheckValidConnectionSQL");
- propertiesMap.put("stale-connection-checker-class-name",
- "org.jboss.resource.adapter.jdbc.StaleConnectionChecker");
- propertiesMap.put("exception-sorter-class-name",
- "org.jboss.resource.adapter.jdbc.ExceptionSorter");
- propertiesMap.put("allocation-retry", "10000");
- propertiesMap.put("allocation-retry-wait-millis", "10000");
- propertiesMap.put("background-validation-millis", "15000");
- propertiesMap.put("use-try-lock", "61000");
- propertiesMap.put("prefill", "true");
- propertiesMap.put("share-prepared-statements", "false");
+ }
- createDatasource(LOCAL_TX_DATASOURCE,
- "default__Local TX Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
-
- // Check for the appropriate success messages
- String expectedMessage = "Successfully added new Local TX Datasource";
- checkClientAndServerMessages(expectedMessage, expectedMessage, false);
-
- assertTrue(isDatasourceDeployed(propertiesMap.get("jndi-name"),
- LOCAL_TX_DATASOURCE));
- assertTrue(checkProperties(propertiesMap.get("jndi-name"),
- LOCAL_TX_DATASOURCE,
- propertiesMap));
-
- // TODO: need to verify that appropriate default values were
- // set for properties that were not specified above
-
- // Clean up
- deleteDatasource(propertiesMap.get("jndi-name"));
- }
- /**
- * Attempt to create a new datasource but leave at least one required
- * value unset. An error should occur.
- */
- public void testCreateDatasourceMissingRequiredValues() throws IOException {
-
- // Leave jndi-name and connection-url unset
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("user-name", "testUser");
- propertiesMap.put("max-pool-size", "10");
- propertiesMap.put("prefill", "true");
- propertiesMap.put("idle-timeout-minutes", "20");
- propertiesMap.put("set-tx-query-timeout", "true");
- propertiesMap.put("query-timeout", "1800");
-
- createDatasource(NO_TX_DATASOURCE, "default__No TX Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
-
- // Check for the appropriate error messages
- checkClientAndServerMessages("An invalid value was specified for one "
- + "or more properties",
- "Value is required",
- true);
- }
- /**
- * Attempt to create a new datasource but set a property value
- * beyond its expected range of values. An error should occur.
- */
- public void testCreateDatasourcePropertyOutOfRange() throws IOException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("jndi-name", "InvalidDS");
- propertiesMap.put("user-name", "testUser");
- propertiesMap.put("password", "password");
- propertiesMap.put("xa-datasource-class", "org.postgresql.xa.PGXADataSource");
- propertiesMap.put("xa-resource-timeout", "36000");
-
- // This number is too big
- propertiesMap.put("max-pool-size", "100000000000000");
-
- createDatasource(XA_DATASOURCE, "default__XA Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
-
- // Check for the appropriate error messages
- checkClientAndServerMessages("An invalid value was specified for one or more properties",
- "Specified attribute is not between the expected values",
- true);
+ @Override
+ protected Map<String, String> createLocalTXDatasource(String datasourceName) throws IOException {
+ return super.createLocalTXDatasource(datasourceName);
}
-
- /**
- * Attempt to create a new datasource but set a property value
- * to an invalid type. An error should occur.
- */
- public void testCreateDatasourceInvalidPropertyType() throws IOException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("jndi-name", "InvalidDS");
- propertiesMap.put("min-pool-size", "10");
- propertiesMap.put("max-pool-size", "20");
- propertiesMap.put("driver-class", "org.hsqldb.jdbcDriver");
- propertiesMap.put("connection-url", "jdbc:hsqldb:.");
- propertiesMap.put("share-prepared-statements", "false");
-
- // This property value is supposed to be an integer
- propertiesMap.put("background-validation-millis", "abcde");
-
- createDatasource(LOCAL_TX_DATASOURCE,
- "default__Local TX Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
-
- // Check for the appropriate error messages
- checkClientAndServerMessages("An invalid value was specified for one or more properties",
- "Value is not a valid integer",
- true);
- }
- /**
- * Attempt to create a new datasource but set a property value to a value
- * that is the correct type but is not an allowed value for that
- * property. An error should occur.
- */
- public void testCreateDatasourcePropertyNotAllowed() throws IOException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("jndi-name", "InvalidDS");
- propertiesMap.put("driver-class", "org.hsqldb.jdbcDriver");
- propertiesMap.put("connection-url", "jdbc:hsqldb:.");
-
- // This number is a valid integer but is below the
- // allowable minimum value
- propertiesMap.put("max-pool-size", "-25");
-
- createDatasource(NO_TX_DATASOURCE, "default__No TX Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
-
- // Check for the appropriate error messages
- checkClientAndServerMessages("An invalid value was specified for one "
- + "or more properties",
- "Value is less than allowable minimum",
- true);
+ @Override
+ protected Map<String, String> createNoTXDatasource(String datasourceName) throws IOException {
+ return super.createNoTXDatasource(datasourceName);
}
- /**
- * Attempt to create a new datasource using a JNDI name that already exists.
- * An error should occur.
- */
- public void testCreateDatasourceDuplicateJNDIName() throws IOException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
- propertiesMap.put("jndi-name", "DefaultDS");
- propertiesMap.put("driver-class", "org.hsqldb.jdbcDriver");
- propertiesMap.put("connection-url", "jdbc:hsqldb:.");
-
- createDatasource(LOCAL_TX_DATASOURCE, "default__Local TX Datasource",
- propertiesMap);
- client.click("resourceConfigurationForm:saveButton");
-
- // Check for the appropriate error messages
- String expectedMessage = "Failed to add Resource (see app server log for "
- + "additional details): A Local TX Datasource named "
- + "'DefaultDS' already exists";
- checkClientAndServerMessages(expectedMessage, expectedMessage, true);
- }
-
- /*
- * DELETION TESTS:
- */
-
- /**
- * Remove a Local TX Datasource.
- */
- public void testDeleteLocalTXDatasource() throws Exception {
- Map<String, String> propertiesMap = createLocalTXDatasource("DeleteLocalTXDS");
-
- deleteDatasource(propertiesMap.get("jndi-name"));
-
- // Check for the appropriate success messages
- String expectedMessage = "Successfully deleted Local TX Datasource '"
- + propertiesMap.get("jndi-name") + "'";
- checkClientAndServerMessages(expectedMessage, expectedMessage, false);
-
- assertFalse(isDatasourceDeployed(propertiesMap.get("jndi-name"),
- LOCAL_TX_DATASOURCE));
-
- // Make sure the entry was removed from the -ds.xml file
- assertFalse(containsElement(propertiesMap.get("jndi-name"),
- "local-tx-datasource"));
+ @Override
+ protected Map<String, String> createXADatasource(String datasourceName) throws IOException {
+ return super.createXADatasource(datasourceName);
}
- /**
- * Remove a No TX Datasource.
- */
- public void testDeleteNoTXDatasource() throws Exception {
- Map<String, String> propertiesMap = createNoTXDatasource("DeleteNoTXDS");
- deleteDatasource(propertiesMap.get("jndi-name"));
- // Check for the appropriate success messages
- String expectedMessage = "Successfully deleted No TX Datasource '"
- + propertiesMap.get("jndi-name") + "'";
- checkClientAndServerMessages(expectedMessage, expectedMessage, false);
- assertFalse(isDatasourceDeployed(propertiesMap.get("jndi-name"),
- NO_TX_DATASOURCE));
- // Make sure the entry was removed from the -ds.xml file
- assertFalse(containsElement(propertiesMap.get("jndi-name"),
- "no-tx-datasource"));
- }
- /**
- * Remove an XA Datasource.
- */
- public void testDeleteXADatasource() throws Exception {
- Map<String, String> propertiesMap = createXADatasource("DeleteXADS");
- deleteDatasource(propertiesMap.get("jndi-name"));
+
- // Check for the appropriate success messages
- String expectedMessage = "Successfully deleted XA Datasource '"
- + propertiesMap.get("jndi-name") + "'";
- checkClientAndServerMessages(expectedMessage, expectedMessage, false);
-
- assertFalse(isDatasourceDeployed(propertiesMap.get("jndi-name"),
- XA_DATASOURCE));
-
- // Make sure the entry was removed from the -ds.xml file
- assertFalse(containsElement(propertiesMap.get("jndi-name"),
- "xa-datasource"));
- }
-
- /*
- * METRICS TESTS
- */
-
/**
- * Check that the metrics are correct after creating a new datasource.
+ * @return the suite of tests being tested
*/
- public void testMetricsAfterDatasourceCreation() throws IOException {
-
- // Min pool size will be 5, max pool size will be 20
- Map<String, String> propertiesMap = createLocalTXDatasource("MetricsCreateDS");
-
- // Set up the expected values
- Map<String, String> expectedMetrics = new HashMap<String, String>();
- expectedMetrics.put("Available Connection Count", "20.0");
- expectedMetrics.put("Connection Count", "0.0");
- expectedMetrics.put("Connection Created Count", "0.0");
- expectedMetrics.put("Connection Destroyed Count", "0.0");
- expectedMetrics.put("In Use Connection Count", "0.0");
- expectedMetrics.put("Max Connections In Use Count", "0.0");
- expectedMetrics.put("Max Size", "20.0");
- expectedMetrics.put("Min Size", "5.0");
-
- checkMetrics(propertiesMap.get("jndi-name"), LOCAL_TX_DATASOURCE, expectedMetrics);
-
- // Clean up
- deleteDatasource(propertiesMap.get("jndi-name"));
+ public static Test suite()
+ {
+ return new TestSuite(DatasourceTest.class);
}
+
- /**
- * Make an initial request for a connection to a database. Make
- * sure the metrics are updated accordingly.
- */
- public void testMetricsAfterInitialDBConnection() throws Exception {
+ @Override
+ protected String getDatasourceConfigFile() {
+ String jndiName = this.getDatasourceProperties().get("jndi-name");
+ return System.getProperty("jsfunit.deploy.dir") + "/" + jndiName.toLowerCase() + "-ds.xml";
+ }
- // Min pool size will be 5, max pool size will be 20
- Map<String, String> propertiesMap = createLocalTXDatasource("MetricsInitalConnectionDS");
- // Create the first connection
- Connection con = connectDB(propertiesMap.get("jndi-name"),
- propertiesMap.get("user-name"),
- propertiesMap.get("password"));
- assertNotNull(con);
+ @Override
+ protected String getMBeanName( String jndiName, String serviceName ){
+ return "jboss.deployment:id=\"jboss.jca:name=" + jndiName + "," +
+ "service=" + serviceName + "\",type=Component";
+ }
- // Set up the expected values
- Map<String, String> expectedMetrics = new HashMap<String, String>();
- expectedMetrics.put("Available Connection Count", "19.0");
- expectedMetrics.put("Connection Count", "5.0");
- expectedMetrics.put("Connection Created Count", "5.0");
- expectedMetrics.put("Connection Destroyed Count", "0.0");
- expectedMetrics.put("In Use Connection Count", "1.0");
- expectedMetrics.put("Max Connections In Use Count", "1.0");
- expectedMetrics.put("Max Size", "20.0");
- expectedMetrics.put("Min Size", "5.0");
- checkMetrics(propertiesMap.get("jndi-name"), LOCAL_TX_DATASOURCE, expectedMetrics);
- // Clean up
- disconnectDB(con);
- deleteDatasource(propertiesMap.get("jndi-name"));
- }
- /**
- * Establish multiple connections to a database. Make sure
- * the metrics are updated accordingly.
- */
- public void testMetricsAfterMultipleDBConnections() throws Exception {
-
- // Min pool size will be 5, max pool size will be 20
- Map<String, String> propertiesMap = createNoTXDatasource("MetricsMultipleConnectionDS");
-
- // Establish multiple connections
- ArrayList<Connection> connections = new ArrayList<Connection>();
- for(int i = 0; i <= 5; i++) {
- Connection con = connectDB(propertiesMap.get("jndi-name"),
- propertiesMap.get("user-name"),
- propertiesMap.get("password"));
- assertNotNull(con);
- connections.add(con);
- }
+}// DatasourceTest.java for AS 5
- // Set up the expected values
- Map<String, String> expectedMetrics = new HashMap<String, String>();
- expectedMetrics.put("Available Connection Count", "14.0");
- expectedMetrics.put("Connection Count", "6.0");
- expectedMetrics.put("Connection Created Count", "6.0");
- expectedMetrics.put("Connection Destroyed Count", "0.0");
- expectedMetrics.put("In Use Connection Count", "6.0");
- expectedMetrics.put("Max Connections In Use Count", "6.0");
- expectedMetrics.put("Max Size", "20.0");
- expectedMetrics.put("Min Size", "5.0");
-
- checkMetrics(propertiesMap.get("jndi-name"), NO_TX_DATASOURCE, expectedMetrics);
-
- // Clean up
- for(int i = 0; i <= 5; i++) {
- disconnectDB(connections.get(i));
- }
-
- deleteDatasource(propertiesMap.get("jndi-name"));
- }
-
- /**
- * Make sure the metrics are updated appropriately after
- * closing some connections.
- */
- public void testMetricsAfterClosingConnections() throws Exception {
-
- // Min pool size will be 5, max pool size will be 20
- Map<String, String> propertiesMap = createNoTXDatasource("MetricsCloseConnectionsDS");
-
- // Establish some connections
- ArrayList<Connection> connections = new ArrayList<Connection>();
- for(int i = 0; i <= 4; i++) {
- Connection con = connectDB(propertiesMap.get("jndi-name"),
- propertiesMap.get("user-name"),
- propertiesMap.get("password"));
- assertNotNull(con);
- connections.add(con);
- }
-
- // Close some connections
- disconnectDB(connections.get(0));
- disconnectDB(connections.get(1));
-
- // Set up the expected values
- Map<String, String> expectedMetrics = new HashMap<String, String>();
- expectedMetrics.put("Available Connection Count", "17.0");
- expectedMetrics.put("Connection Count", "3.0");
- expectedMetrics.put("Connection Created Count", "5.0");
- expectedMetrics.put("Connection Destroyed Count", "0.0");
- expectedMetrics.put("In Use Connection Count", "3.0");
- expectedMetrics.put("Max Connections In Use Count", "5.0");
- expectedMetrics.put("Max Size", "20.0");
- expectedMetrics.put("Min Size", "5.0");
-
- checkMetrics(propertiesMap.get("jndi-name"), NO_TX_DATASOURCE, expectedMetrics);
-
- // Clean up
- for(int i = 2; i <= 4; i++) {
- disconnectDB(connections.get(i));
- }
-
- deleteDatasource(propertiesMap.get("jndi-name"));
- }
-}
-
15 years, 11 months
EMBJOPR SVN: r117 - trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit.
by embjopr-commits@lists.jboss.org
Author: ozizka(a)redhat.com
Date: 2009-01-20 17:51:51 -0500 (Tue, 20 Jan 2009)
New Revision: 117
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
Log:
Changing all private methods to protected... all are candidates for overriding.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-20 21:55:10 UTC (rev 116)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/DatasourceTestBase.java 2009-01-20 22:51:51 UTC (rev 117)
@@ -707,7 +707,7 @@
* Create a basic Local TX Datasource. Return the mapping of property
* names to property values.
*/
- private Map<String, String> createLocalTXDatasource(String datasourceName) throws IOException {
+ protected Map<String, String> createLocalTXDatasource(String datasourceName) throws IOException {
Map<String, String> propertiesMap = new HashMap<String, String>();
propertiesMap.put("jndi-name", datasourceName);
propertiesMap.put("max-pool-size", "20");
@@ -734,7 +734,7 @@
* Create a basic No TX Datasource. Return the mapping of property
* names to property values.
*/
- private Map<String, String> createNoTXDatasource(String datasourceName) throws IOException {
+ protected Map<String, String> createNoTXDatasource(String datasourceName) throws IOException {
Map<String, String> propertiesMap = new HashMap<String, String>();
propertiesMap.put("jndi-name", datasourceName);
propertiesMap.put("prefill", "true");
@@ -763,7 +763,7 @@
* Create a basic XA Datasource. Return the mapping of property
* name to property values.
*/
- private Map<String, String> createXADatasource(String datasourceName) throws IOException {
+ protected Map<String, String> createXADatasource(String datasourceName) throws IOException {
Map<String, String> propertiesMap = new HashMap<String, String>();
propertiesMap.put("jndi-name", datasourceName);
propertiesMap.put("xa-datasource-class", "org.postgresql.xa.PGXADataSource");
@@ -829,7 +829,7 @@
* to the datasource given by jndiName contains the given element.
* TODO: Refactor.
*/
- private boolean containsElement(String jndiName, String elementName) {
+ protected boolean containsElement(String jndiName, String elementName) {
try {
File file = new File(System.getProperty("jsfunit.deploy.dir")
+ "/" + jndiName + "-ds.xml");
@@ -853,7 +853,7 @@
*
* @param metricsMap maps metric names to the expected metric values.
*/
- private void checkMetrics(String datasourceName,
+ protected void checkMetrics(String datasourceName,
DatasourceType datasourceType,
Map<String, String> metricsMap) throws IOException {
@@ -890,7 +890,7 @@
/**
* Perform the given operation on the given datasource.
*/
- private void performDatasourceOperation(String datasourceName,
+ protected void performDatasourceOperation(String datasourceName,
String datasourceType,
String operationName) throws IOException {
15 years, 11 months